diff --git a/experimental/examples/chat-mpp/.gitignore b/examples/chat/.gitignore similarity index 100% rename from experimental/examples/chat-mpp/.gitignore rename to examples/chat/.gitignore diff --git a/experimental/examples/chat-mpp/.run/desktopApp.run.xml b/examples/chat/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/chat-mpp/.run/desktopApp.run.xml rename to examples/chat/.run/desktopApp.run.xml diff --git a/experimental/examples/chat-mpp/.run/jsApp.run.xml b/examples/chat/.run/jsApp.run.xml similarity index 100% rename from experimental/examples/chat-mpp/.run/jsApp.run.xml rename to examples/chat/.run/jsApp.run.xml diff --git a/experimental/examples/chat-mpp/README.md b/examples/chat/README.md similarity index 100% rename from experimental/examples/chat-mpp/README.md rename to examples/chat/README.md diff --git a/experimental/examples/chat-mpp/androidApp/build.gradle.kts b/examples/chat/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/chat-mpp/androidApp/build.gradle.kts rename to examples/chat/androidApp/build.gradle.kts diff --git a/experimental/examples/chat-mpp/androidApp/src/androidMain/AndroidManifest.xml b/examples/chat/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/chat-mpp/androidApp/src/androidMain/AndroidManifest.xml rename to examples/chat/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/chat-mpp/androidApp/src/androidMain/kotlin/MainActivity.kt b/examples/chat/androidApp/src/androidMain/kotlin/MainActivity.kt similarity index 100% rename from experimental/examples/chat-mpp/androidApp/src/androidMain/kotlin/MainActivity.kt rename to examples/chat/androidApp/src/androidMain/kotlin/MainActivity.kt diff --git a/experimental/examples/chat-mpp/androidApp/src/androidMain/res/values/strings.xml b/examples/chat/androidApp/src/androidMain/res/values/strings.xml similarity index 100% rename from experimental/examples/chat-mpp/androidApp/src/androidMain/res/values/strings.xml rename to examples/chat/androidApp/src/androidMain/res/values/strings.xml diff --git a/experimental/examples/chat-mpp/build.gradle.kts b/examples/chat/build.gradle.kts similarity index 100% rename from experimental/examples/chat-mpp/build.gradle.kts rename to examples/chat/build.gradle.kts diff --git a/experimental/examples/chat-mpp/desktopApp/build.gradle.kts b/examples/chat/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/chat-mpp/desktopApp/build.gradle.kts rename to examples/chat/desktopApp/build.gradle.kts diff --git a/experimental/examples/chat-mpp/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/chat/desktopApp/src/jvmMain/kotlin/Main.kt similarity index 100% rename from experimental/examples/chat-mpp/desktopApp/src/jvmMain/kotlin/Main.kt rename to examples/chat/desktopApp/src/jvmMain/kotlin/Main.kt diff --git a/experimental/examples/chat-mpp/gradle.properties b/examples/chat/gradle.properties similarity index 93% rename from experimental/examples/chat-mpp/gradle.properties rename to examples/chat/gradle.properties index 720f561017..9ff8815ad5 100644 --- a/experimental/examples/chat-mpp/gradle.properties +++ b/examples/chat/gradle.properties @@ -13,4 +13,4 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.8.0 agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 +compose.version=1.4.0-rc01 diff --git a/experimental/examples/chat-mpp/gradle/wrapper/gradle-wrapper.jar b/examples/chat/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from experimental/examples/chat-mpp/gradle/wrapper/gradle-wrapper.jar rename to examples/chat/gradle/wrapper/gradle-wrapper.jar diff --git a/experimental/examples/chat-mpp/gradle/wrapper/gradle-wrapper.properties b/examples/chat/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from experimental/examples/chat-mpp/gradle/wrapper/gradle-wrapper.properties rename to examples/chat/gradle/wrapper/gradle-wrapper.properties diff --git a/experimental/examples/chat-mpp/gradlew b/examples/chat/gradlew similarity index 100% rename from experimental/examples/chat-mpp/gradlew rename to examples/chat/gradlew diff --git a/experimental/examples/chat-mpp/iosApp/Configuration/Config.xcconfig b/examples/chat/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/chat-mpp/iosApp/Configuration/Config.xcconfig rename to examples/chat/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/chat-mpp/iosApp/Podfile b/examples/chat/iosApp/Podfile similarity index 100% rename from experimental/examples/chat-mpp/iosApp/Podfile rename to examples/chat/iosApp/Podfile diff --git a/experimental/examples/chat-mpp/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/chat/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift b/examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift rename to examples/chat/iosApp/iosApp/ComposeInsideSwiftUIScreen.swift diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift b/examples/chat/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift rename to examples/chat/iosApp/iosApp/ComposeViewControllerToSwiftUI.swift diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/GradientTemplate.swift b/examples/chat/iosApp/iosApp/GradientTemplate.swift similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/GradientTemplate.swift rename to examples/chat/iosApp/iosApp/GradientTemplate.swift diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/Info.plist b/examples/chat/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/Info.plist rename to examples/chat/iosApp/iosApp/Info.plist diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/KotlinToSwiftHelper.swift b/examples/chat/iosApp/iosApp/KotlinToSwiftHelper.swift similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/KotlinToSwiftHelper.swift rename to examples/chat/iosApp/iosApp/KotlinToSwiftHelper.swift diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/YetAnotherSwiftUIScreen.swift b/examples/chat/iosApp/iosApp/YetAnotherSwiftUIScreen.swift similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/YetAnotherSwiftUIScreen.swift rename to examples/chat/iosApp/iosApp/YetAnotherSwiftUIScreen.swift diff --git a/experimental/examples/chat-mpp/iosApp/iosApp/iosApp.swift b/examples/chat/iosApp/iosApp/iosApp.swift similarity index 100% rename from experimental/examples/chat-mpp/iosApp/iosApp/iosApp.swift rename to examples/chat/iosApp/iosApp/iosApp.swift diff --git a/experimental/examples/chat-mpp/jsApp/build.gradle.kts b/examples/chat/jsApp/build.gradle.kts similarity index 100% rename from experimental/examples/chat-mpp/jsApp/build.gradle.kts rename to examples/chat/jsApp/build.gradle.kts diff --git a/experimental/examples/chat-mpp/jsApp/src/jsMain/kotlin/main.js.kt b/examples/chat/jsApp/src/jsMain/kotlin/main.js.kt similarity index 100% rename from experimental/examples/chat-mpp/jsApp/src/jsMain/kotlin/main.js.kt rename to examples/chat/jsApp/src/jsMain/kotlin/main.js.kt diff --git a/experimental/examples/chat-mpp/jsApp/src/jsMain/resources/index.html b/examples/chat/jsApp/src/jsMain/resources/index.html similarity index 100% rename from experimental/examples/chat-mpp/jsApp/src/jsMain/resources/index.html rename to examples/chat/jsApp/src/jsMain/resources/index.html diff --git a/experimental/examples/chat-mpp/jsApp/src/jsMain/resources/styles.css b/examples/chat/jsApp/src/jsMain/resources/styles.css similarity index 100% rename from experimental/examples/chat-mpp/jsApp/src/jsMain/resources/styles.css rename to examples/chat/jsApp/src/jsMain/resources/styles.css diff --git a/experimental/examples/chat-mpp/run-configurations.png b/examples/chat/run-configurations.png similarity index 100% rename from experimental/examples/chat-mpp/run-configurations.png rename to examples/chat/run-configurations.png diff --git a/experimental/examples/chat-mpp/settings.gradle.kts b/examples/chat/settings.gradle.kts similarity index 100% rename from experimental/examples/chat-mpp/settings.gradle.kts rename to examples/chat/settings.gradle.kts diff --git a/experimental/examples/chat-mpp/shared/build.gradle.kts b/examples/chat/shared/build.gradle.kts similarity index 100% rename from experimental/examples/chat-mpp/shared/build.gradle.kts rename to examples/chat/shared/build.gradle.kts diff --git a/experimental/examples/chat-mpp/shared/src/androidMain/AndroidManifest.xml b/examples/chat/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/chat-mpp/shared/src/androidMain/AndroidManifest.xml rename to examples/chat/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/chat-mpp/shared/src/androidMain/kotlin/currentTime.android.kt b/examples/chat/shared/src/androidMain/kotlin/currentTime.android.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/androidMain/kotlin/currentTime.android.kt rename to examples/chat/shared/src/androidMain/kotlin/currentTime.android.kt diff --git a/experimental/examples/chat-mpp/shared/src/androidMain/kotlin/main.android.kt b/examples/chat/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/androidMain/kotlin/main.android.kt rename to examples/chat/shared/src/androidMain/kotlin/main.android.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/ChatApp.kt b/examples/chat/shared/src/commonMain/kotlin/ChatApp.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/ChatApp.kt rename to examples/chat/shared/src/commonMain/kotlin/ChatApp.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Colors.kt b/examples/chat/shared/src/commonMain/kotlin/Colors.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Colors.kt rename to examples/chat/shared/src/commonMain/kotlin/Colors.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Data.kt b/examples/chat/shared/src/commonMain/kotlin/Data.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Data.kt rename to examples/chat/shared/src/commonMain/kotlin/Data.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Messages.kt b/examples/chat/shared/src/commonMain/kotlin/Messages.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Messages.kt rename to examples/chat/shared/src/commonMain/kotlin/Messages.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Reducer.kt b/examples/chat/shared/src/commonMain/kotlin/Reducer.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Reducer.kt rename to examples/chat/shared/src/commonMain/kotlin/Reducer.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/SendMessage.kt b/examples/chat/shared/src/commonMain/kotlin/SendMessage.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/SendMessage.kt rename to examples/chat/shared/src/commonMain/kotlin/SendMessage.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Store.kt b/examples/chat/shared/src/commonMain/kotlin/Store.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/Store.kt rename to examples/chat/shared/src/commonMain/kotlin/Store.kt diff --git a/experimental/examples/chat-mpp/shared/src/commonMain/kotlin/currentTime.common.kt b/examples/chat/shared/src/commonMain/kotlin/currentTime.common.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/commonMain/kotlin/currentTime.common.kt rename to examples/chat/shared/src/commonMain/kotlin/currentTime.common.kt diff --git a/experimental/examples/chat-mpp/shared/src/desktopMain/kotlin/currentTime.desktop.kt b/examples/chat/shared/src/desktopMain/kotlin/currentTime.desktop.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/desktopMain/kotlin/currentTime.desktop.kt rename to examples/chat/shared/src/desktopMain/kotlin/currentTime.desktop.kt diff --git a/experimental/examples/chat-mpp/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/chat/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/chat/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/experimental/examples/chat-mpp/shared/src/iosMain/kotlin/currentTime.ios.kt b/examples/chat/shared/src/iosMain/kotlin/currentTime.ios.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/iosMain/kotlin/currentTime.ios.kt rename to examples/chat/shared/src/iosMain/kotlin/currentTime.ios.kt diff --git a/experimental/examples/chat-mpp/shared/src/iosMain/kotlin/main.ios.kt b/examples/chat/shared/src/iosMain/kotlin/main.ios.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/iosMain/kotlin/main.ios.kt rename to examples/chat/shared/src/iosMain/kotlin/main.ios.kt diff --git a/experimental/examples/chat-mpp/shared/src/jsMain/kotlin/currentTime.js.kt b/examples/chat/shared/src/jsMain/kotlin/currentTime.js.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/jsMain/kotlin/currentTime.js.kt rename to examples/chat/shared/src/jsMain/kotlin/currentTime.js.kt diff --git a/experimental/examples/chat-mpp/shared/src/jsMain/kotlin/main.js.kt b/examples/chat/shared/src/jsMain/kotlin/main.js.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/jsMain/kotlin/main.js.kt rename to examples/chat/shared/src/jsMain/kotlin/main.js.kt diff --git a/experimental/examples/chat-mpp/shared/src/macosMain/kotlin/currentTime.macos.kt b/examples/chat/shared/src/macosMain/kotlin/currentTime.macos.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/macosMain/kotlin/currentTime.macos.kt rename to examples/chat/shared/src/macosMain/kotlin/currentTime.macos.kt diff --git a/experimental/examples/chat-mpp/shared/src/macosMain/kotlin/main.macos.kt b/examples/chat/shared/src/macosMain/kotlin/main.macos.kt similarity index 100% rename from experimental/examples/chat-mpp/shared/src/macosMain/kotlin/main.macos.kt rename to examples/chat/shared/src/macosMain/kotlin/main.macos.kt diff --git a/examples/codeviewer/.gitignore b/examples/codeviewer/.gitignore index ba8435b9c5..6e5f30477c 100644 --- a/examples/codeviewer/.gitignore +++ b/examples/codeviewer/.gitignore @@ -2,14 +2,14 @@ .gradle /local.properties /.idea -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml .DS_Store build/ /captures .externalNativeBuild -.cxx \ No newline at end of file +.cxx +iosApp/Podfile.lock +iosApp/Pods/* +iosApp/iosApp.xcworkspace/* +iosApp/iosApp.xcodeproj/* +!iosApp/iosApp.xcodeproj/project.pbxproj +shared/shared.podspec diff --git a/examples/codeviewer/.run/desktop.run.xml b/examples/codeviewer/.run/desktop.run.xml deleted file mode 100644 index d9335c1be5..0000000000 --- a/examples/codeviewer/.run/desktop.run.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - true - - - \ No newline at end of file diff --git a/experimental/examples/codeviewer/.run/desktopApp.run.xml b/examples/codeviewer/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/codeviewer/.run/desktopApp.run.xml rename to examples/codeviewer/.run/desktopApp.run.xml diff --git a/examples/codeviewer/README.md b/examples/codeviewer/README.md index 172adda0ce..2489eae3dd 100644 --- a/examples/codeviewer/README.md +++ b/examples/codeviewer/README.md @@ -1,10 +1,21 @@ -MPP Code Viewer example for desktop/android written in Multiplatform Compose library. +# Code Viewer +MPP Code Viewer example for desktop/android/iOS written in Multiplatform Compose library. -### Running desktop application +## How to run -* To run, launch command: `./gradlew :desktop:run` -* Or choose **desktop** configuration in IDE and run it. - ![desktop-run-configuration.png](screenshots/desktop-run-configuration.png) +Choose a run configuration for an appropriate target in IDE and run it. + +![run-configurations.png](run-configurations.png) + +To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. +Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then +using "Signing & Capabilities" tab of `Codeviewer` target. + +Then choose **iosApp** configuration in IDE and run it. + +## Run on desktop via Gradle + +`./gradlew desktopApp:run` ### Building native desktop distribution ``` @@ -12,9 +23,4 @@ MPP Code Viewer example for desktop/android written in Multiplatform Compose lib # outputs are written to desktop/build/compose/binaries ``` -### Installing Android application on device/emulator -``` -./gradlew installDebug -``` - ![Desktop](screenshots/codeviewer.png) \ No newline at end of file diff --git a/examples/codeviewer/android/build.gradle.kts b/examples/codeviewer/android/build.gradle.kts deleted file mode 100644 index fed67b2b03..0000000000 --- a/examples/codeviewer/android/build.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -plugins { - id("com.android.application") - kotlin("android") - id("org.jetbrains.compose") -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } -} - -dependencies { - implementation(project(":common")) - implementation("androidx.activity:activity-compose:1.5.0") -} diff --git a/examples/codeviewer/android/src/main/java/org/jetbrains/codeviewer/MainActivity.kt b/examples/codeviewer/android/src/main/java/org/jetbrains/codeviewer/MainActivity.kt deleted file mode 100644 index 872c04c87a..0000000000 --- a/examples/codeviewer/android/src/main/java/org/jetbrains/codeviewer/MainActivity.kt +++ /dev/null @@ -1,32 +0,0 @@ -package org.jetbrains.codeviewer - -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity -import org.jetbrains.codeviewer.platform._HomeFolder -import org.jetbrains.codeviewer.ui.MainView -import java.io.File -import java.io.FileOutputStream - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - copyAssets() - _HomeFolder = filesDir - - setContent { - MainView() - } - } - - private fun copyAssets() { - for (filename in assets.list("data")!!) { - assets.open("data/$filename").use { assetStream -> - val file = File(filesDir, filename) - FileOutputStream(file).use { fileStream -> - assetStream.copyTo(fileStream) - } - } - } - } -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/build.gradle.kts b/examples/codeviewer/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/codeviewer/androidApp/build.gradle.kts rename to examples/codeviewer/androidApp/build.gradle.kts diff --git a/examples/codeviewer/android/src/main/AndroidManifest.xml b/examples/codeviewer/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/codeviewer/android/src/main/AndroidManifest.xml rename to examples/codeviewer/androidApp/src/androidMain/AndroidManifest.xml diff --git a/examples/codeviewer/android/src/main/assets/data/EditorView.kt b/examples/codeviewer/androidApp/src/androidMain/assets/data/EditorView.kt similarity index 100% rename from examples/codeviewer/android/src/main/assets/data/EditorView.kt rename to examples/codeviewer/androidApp/src/androidMain/assets/data/EditorView.kt diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/kotlin/org/jetbrains/codeviewer/MainActivity.kt b/examples/codeviewer/androidApp/src/androidMain/kotlin/org/jetbrains/codeviewer/MainActivity.kt similarity index 100% rename from experimental/examples/codeviewer/androidApp/src/androidMain/kotlin/org/jetbrains/codeviewer/MainActivity.kt rename to examples/codeviewer/androidApp/src/androidMain/kotlin/org/jetbrains/codeviewer/MainActivity.kt diff --git a/examples/codeviewer/android/src/main/res/drawable/ic_launcher_foreground.xml b/examples/codeviewer/androidApp/src/androidMain/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from examples/codeviewer/android/src/main/res/drawable/ic_launcher_foreground.xml rename to examples/codeviewer/androidApp/src/androidMain/res/drawable/ic_launcher_foreground.xml diff --git a/examples/codeviewer/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from examples/codeviewer/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/examples/codeviewer/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from examples/codeviewer/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/examples/codeviewer/android/src/main/res/values/ic_launcher_background.xml b/examples/codeviewer/androidApp/src/androidMain/res/values/ic_launcher_background.xml similarity index 100% rename from examples/codeviewer/android/src/main/res/values/ic_launcher_background.xml rename to examples/codeviewer/androidApp/src/androidMain/res/values/ic_launcher_background.xml diff --git a/examples/codeviewer/android/src/main/res/values/strings.xml b/examples/codeviewer/androidApp/src/androidMain/res/values/strings.xml similarity index 100% rename from examples/codeviewer/android/src/main/res/values/strings.xml rename to examples/codeviewer/androidApp/src/androidMain/res/values/strings.xml diff --git a/examples/codeviewer/common/build.gradle.kts b/examples/codeviewer/common/build.gradle.kts deleted file mode 100644 index 705a2269fe..0000000000 --- a/examples/codeviewer/common/build.gradle.kts +++ /dev/null @@ -1,50 +0,0 @@ -plugins { - id("com.android.library") - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - android() - jvm("desktop") - - sourceSets { - named("commonMain") { - dependencies { - api(compose.runtime) - api(compose.foundation) - api(compose.material) - api(compose.materialIconsExtended) - } - } - named("androidMain") { - kotlin.srcDirs("src/jvmMain/kotlin") - dependencies { - api("androidx.appcompat:appcompat:1.5.1") - api("androidx.core:core-ktx:1.8.0") - } - } - named("desktopMain") { - kotlin.srcDirs("src/jvmMain/kotlin") - dependencies { - api(compose.desktop.common) - } - } - } -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - } - - sourceSets { - named("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - res.srcDirs("src/androidMain/res", "src/commonMain/resources") - } - } -} diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt deleted file mode 100644 index d22698e61b..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.runtime.Composable -import androidx.compose.ui.text.font.Font -import androidx.compose.ui.text.font.FontStyle -import androidx.compose.ui.text.font.FontWeight - -@Composable -expect fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt deleted file mode 100644 index fd1f50c0d7..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt +++ /dev/null @@ -1,19 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.Dp - -@Composable -expect fun VerticalScrollbar( - modifier: Modifier, - scrollState: ScrollState -) - -@Composable -expect fun VerticalScrollbar( - modifier: Modifier, - scrollState: LazyListState -) \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt deleted file mode 100644 index cfc8ef796d..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt +++ /dev/null @@ -1,107 +0,0 @@ -package org.jetbrains.codeviewer.ui - -import androidx.compose.animation.core.Spring.StiffnessLow -import androidx.compose.animation.core.SpringSpec -import androidx.compose.animation.core.animateDpAsState -import androidx.compose.animation.core.animateFloatAsState -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentColor -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack -import androidx.compose.material.icons.filled.ArrowForward -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.graphicsLayer -import androidx.compose.ui.unit.dp -import org.jetbrains.codeviewer.ui.editor.EditorEmptyView -import org.jetbrains.codeviewer.ui.editor.EditorTabsView -import org.jetbrains.codeviewer.ui.editor.EditorView -import org.jetbrains.codeviewer.ui.filetree.FileTreeView -import org.jetbrains.codeviewer.ui.filetree.FileTreeViewTabView -import org.jetbrains.codeviewer.ui.statusbar.StatusBar -import org.jetbrains.codeviewer.util.SplitterState -import org.jetbrains.codeviewer.util.VerticalSplittable - -@Composable -fun CodeViewerView(model: CodeViewer) { - val panelState = remember { PanelState() } - - val animatedSize = if (panelState.splitter.isResizing) { - if (panelState.isExpanded) panelState.expandedSize else panelState.collapsedSize - } else { - animateDpAsState( - if (panelState.isExpanded) panelState.expandedSize else panelState.collapsedSize, - SpringSpec(stiffness = StiffnessLow) - ).value - } - - VerticalSplittable( - Modifier.fillMaxSize(), - panelState.splitter, - onResize = { - panelState.expandedSize = - (panelState.expandedSize + it).coerceAtLeast(panelState.expandedSizeMin) - } - ) { - ResizablePanel(Modifier.width(animatedSize).fillMaxHeight(), panelState) { - Column { - FileTreeViewTabView() - FileTreeView(model.fileTree) - } - } - - Box { - if (model.editors.active != null) { - Column(Modifier.fillMaxSize()) { - EditorTabsView(model.editors) - Box(Modifier.weight(1f)) { - EditorView(model.editors.active!!, model.settings) - } - StatusBar(model.settings) - } - } else { - EditorEmptyView() - } - } - } -} - -private class PanelState { - val collapsedSize = 24.dp - var expandedSize by mutableStateOf(300.dp) - val expandedSizeMin = 90.dp - var isExpanded by mutableStateOf(true) - val splitter = SplitterState() -} - -@Composable -private fun ResizablePanel( - modifier: Modifier, - state: PanelState, - content: @Composable () -> Unit, -) { - val alpha by animateFloatAsState(if (state.isExpanded) 1f else 0f, SpringSpec(stiffness = StiffnessLow)) - - Box(modifier) { - Box(Modifier.fillMaxSize().graphicsLayer(alpha = alpha)) { - content() - } - - Icon( - if (state.isExpanded) Icons.Default.ArrowBack else Icons.Default.ArrowForward, - contentDescription = if (state.isExpanded) "Collapse" else "Expand", - tint = LocalContentColor.current, - modifier = Modifier - .padding(top = 4.dp) - .width(24.dp) - .clickable { - state.isExpanded = !state.isExpanded - } - .padding(4.dp) - .align(Alignment.TopEnd) - ) - } -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt deleted file mode 100644 index 7648efd5c0..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt +++ /dev/null @@ -1,35 +0,0 @@ -package org.jetbrains.codeviewer.ui - -import androidx.compose.foundation.text.selection.DisableSelection -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import org.jetbrains.codeviewer.platform.HomeFolder -import org.jetbrains.codeviewer.ui.common.AppTheme -import org.jetbrains.codeviewer.ui.common.Settings -import org.jetbrains.codeviewer.ui.editor.Editors -import org.jetbrains.codeviewer.ui.filetree.FileTree - -@Composable -fun MainView() { - val codeViewer = remember { - val editors = Editors() - - CodeViewer( - editors = editors, - fileTree = FileTree(HomeFolder, editors), - settings = Settings() - ) - } - - DisableSelection { - MaterialTheme( - colors = AppTheme.colors.material - ) { - Surface { - CodeViewerView(codeViewer) - } - } - } -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt deleted file mode 100644 index 70461d77e5..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt +++ /dev/null @@ -1,64 +0,0 @@ -package org.jetbrains.codeviewer.ui.common - -import androidx.compose.runtime.Composable -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontStyle -import androidx.compose.ui.text.font.FontWeight -import org.jetbrains.codeviewer.platform.font - -object Fonts { - @Composable - fun jetbrainsMono() = FontFamily( - font( - "JetBrains Mono", - "jetbrainsmono_regular", - FontWeight.Normal, - FontStyle.Normal - ), - font( - "JetBrains Mono", - "jetbrainsmono_italic", - FontWeight.Normal, - FontStyle.Italic - ), - - font( - "JetBrains Mono", - "jetbrainsmono_bold", - FontWeight.Bold, - FontStyle.Normal - ), - font( - "JetBrains Mono", - "jetbrainsmono_bold_italic", - FontWeight.Bold, - FontStyle.Italic - ), - - font( - "JetBrains Mono", - "jetbrainsmono_extrabold", - FontWeight.ExtraBold, - FontStyle.Normal - ), - font( - "JetBrains Mono", - "jetbrainsmono_extrabold_italic", - FontWeight.ExtraBold, - FontStyle.Italic - ), - - font( - "JetBrains Mono", - "jetbrainsmono_medium", - FontWeight.Medium, - FontStyle.Normal - ), - font( - "JetBrains Mono", - "jetbrainsmono_medium_italic", - FontWeight.Medium, - FontStyle.Italic - ) - ) -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt deleted file mode 100644 index 6e62993275..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt +++ /dev/null @@ -1,35 +0,0 @@ -package org.jetbrains.codeviewer.ui.editor - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Code -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp - -@Composable -fun EditorEmptyView() = Box(Modifier.fillMaxSize()) { - Column(Modifier.align(Alignment.Center)) { - Icon( - Icons.Default.Code, - contentDescription = null, - tint = LocalContentColor.current.copy(alpha = 0.60f), - modifier = Modifier.align(Alignment.CenterHorizontally) - ) - - Text( - "To view file open it from the file tree", - color = LocalContentColor.current.copy(alpha = 0.60f), - fontSize = 20.sp, - modifier = Modifier.align(Alignment.CenterHorizontally).padding(16.dp) - ) - } -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt deleted file mode 100644 index 845c48a547..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt +++ /dev/null @@ -1,78 +0,0 @@ -package org.jetbrains.codeviewer.ui.editor - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.horizontalScroll -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.rememberScrollState -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Close -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import org.jetbrains.codeviewer.ui.common.AppTheme - -@Composable -fun EditorTabsView(model: Editors) = Row(Modifier.horizontalScroll(rememberScrollState())) { - for (editor in model.editors) { - EditorTabView(editor) - } -} - -@Composable -fun EditorTabView(model: Editor) = Surface( - color = if (model.isActive) { - AppTheme.colors.backgroundDark - } else { - Color.Transparent - } -) { - Row( - Modifier - .clickable(remember(::MutableInteractionSource), indication = null) { - model.activate() - } - .padding(4.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - model.fileName, - color = LocalContentColor.current, - fontSize = 12.sp, - modifier = Modifier.padding(horizontal = 4.dp) - ) - - val close = model.close - - if (close != null) { - Icon( - Icons.Default.Close, - tint = LocalContentColor.current, - contentDescription = "Close", - modifier = Modifier - .size(24.dp) - .padding(4.dp) - .clickable { - close() - } - ) - } else { - Box( - modifier = Modifier - .size(24.dp, 24.dp) - .padding(4.dp) - ) - } - } -} diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt deleted file mode 100644 index fbe74f8a2e..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt +++ /dev/null @@ -1,186 +0,0 @@ -package org.jetbrains.codeviewer.ui.editor - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.text.selection.DisableSelection -import androidx.compose.foundation.text.selection.SelectionContainer -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.key -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.text.AnnotatedString -import androidx.compose.ui.text.SpanStyle -import androidx.compose.ui.text.buildAnnotatedString -import androidx.compose.ui.text.withStyle -import androidx.compose.ui.unit.dp -import org.jetbrains.codeviewer.platform.VerticalScrollbar -import org.jetbrains.codeviewer.ui.common.AppTheme -import org.jetbrains.codeviewer.ui.common.Fonts -import org.jetbrains.codeviewer.ui.common.Settings -import org.jetbrains.codeviewer.util.loadableScoped -import org.jetbrains.codeviewer.util.withoutWidthConstraints -import kotlin.text.Regex.Companion.fromLiteral - -@Composable -fun EditorView(model: Editor, settings: Settings) = key(model) { - with (LocalDensity.current) { - SelectionContainer { - Surface( - Modifier.fillMaxSize(), - color = AppTheme.colors.backgroundDark, - ) { - val lines by loadableScoped(model.lines) - - if (lines != null) { - Box { - Lines(lines!!, settings) - Box( - Modifier - .offset( - x = settings.fontSize.toDp() * 0.5f * settings.maxLineSymbols - ) - .width(1.dp) - .fillMaxHeight() - .background(AppTheme.colors.backgroundLight) - ) - } - } else { - CircularProgressIndicator( - modifier = Modifier - .size(36.dp) - .padding(4.dp) - ) - } - } - } - } -} - -@Composable -private fun Lines(lines: Editor.Lines, settings: Settings) = with(LocalDensity.current) { - val maxNum = remember(lines.lineNumberDigitCount) { - (1..lines.lineNumberDigitCount).joinToString(separator = "") { "9" } - } - - Box(Modifier.fillMaxSize()) { - val scrollState = rememberLazyListState() - - LazyColumn( - modifier = Modifier.fillMaxSize(), - state = scrollState - ) { - items(lines.size) { index -> - Box(Modifier.height(settings.fontSize.toDp() * 1.6f)) { - Line(Modifier.align(Alignment.CenterStart), maxNum, lines[index], settings) - } - } - } - - VerticalScrollbar( - Modifier.align(Alignment.CenterEnd), - scrollState - ) - } -} - -// Поддержка русского языка -// دعم اللغة العربية -// 中文支持 -@Composable -private fun Line(modifier: Modifier, maxNum: String, line: Editor.Line, settings: Settings) { - Row(modifier = modifier) { - DisableSelection { - Box { - LineNumber(maxNum, Modifier.alpha(0f), settings) - LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings) - } - } - LineContent( - line.content, - modifier = Modifier - .weight(1f) - .withoutWidthConstraints() - .padding(start = 28.dp, end = 12.dp), - settings = settings - ) - } -} - -@Composable -private fun LineNumber(number: String, modifier: Modifier, settings: Settings) = Text( - text = number, - fontSize = settings.fontSize, - fontFamily = Fonts.jetbrainsMono(), - color = LocalContentColor.current.copy(alpha = 0.30f), - modifier = modifier.padding(start = 12.dp) -) - -@Composable -private fun LineContent(content: Editor.Content, modifier: Modifier, settings: Settings) = Text( - text = if (content.isCode) { - codeString(content.value.value) - } else { - buildAnnotatedString { - withStyle(AppTheme.code.simple) { - append(content.value.value) - } - } - }, - fontSize = settings.fontSize, - fontFamily = Fonts.jetbrainsMono(), - maxLines = 1, - modifier = modifier, - softWrap = false -) - -private fun codeString(str: String) = buildAnnotatedString { - withStyle(AppTheme.code.simple) { - val strFormatted = str.replace("\t", " ") - append(strFormatted) - addStyle(AppTheme.code.punctuation, strFormatted, ":") - addStyle(AppTheme.code.punctuation, strFormatted, "=") - addStyle(AppTheme.code.punctuation, strFormatted, "\"") - addStyle(AppTheme.code.punctuation, strFormatted, "[") - addStyle(AppTheme.code.punctuation, strFormatted, "]") - addStyle(AppTheme.code.punctuation, strFormatted, "{") - addStyle(AppTheme.code.punctuation, strFormatted, "}") - addStyle(AppTheme.code.punctuation, strFormatted, "(") - addStyle(AppTheme.code.punctuation, strFormatted, ")") - addStyle(AppTheme.code.punctuation, strFormatted, ",") - addStyle(AppTheme.code.keyword, strFormatted, "fun ") - addStyle(AppTheme.code.keyword, strFormatted, "val ") - addStyle(AppTheme.code.keyword, strFormatted, "var ") - addStyle(AppTheme.code.keyword, strFormatted, "private ") - addStyle(AppTheme.code.keyword, strFormatted, "internal ") - addStyle(AppTheme.code.keyword, strFormatted, "for ") - addStyle(AppTheme.code.keyword, strFormatted, "expect ") - addStyle(AppTheme.code.keyword, strFormatted, "actual ") - addStyle(AppTheme.code.keyword, strFormatted, "import ") - addStyle(AppTheme.code.keyword, strFormatted, "package ") - addStyle(AppTheme.code.value, strFormatted, "true") - addStyle(AppTheme.code.value, strFormatted, "false") - addStyle(AppTheme.code.value, strFormatted, Regex("[0-9]+")) - addStyle(AppTheme.code.annotation, strFormatted, Regex("^@[a-zA-Z_]*")) - addStyle(AppTheme.code.comment, strFormatted, Regex("^\\s*//.*")) - } -} - -private fun AnnotatedString.Builder.addStyle(style: SpanStyle, text: String, regexp: String) { - addStyle(style, text, fromLiteral(regexp)) -} - -private fun AnnotatedString.Builder.addStyle(style: SpanStyle, text: String, regexp: Regex) { - for (result in regexp.findAll(text)) { - addStyle(style, result.range.first, result.range.last + 1) - } -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt deleted file mode 100644 index 9bc690a7a5..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt +++ /dev/null @@ -1,125 +0,0 @@ -package org.jetbrains.codeviewer.ui.filetree - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.hoverable -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.interaction.collectIsHoveredAsState -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.* -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clipToBounds -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.TextUnit -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import org.jetbrains.codeviewer.platform.VerticalScrollbar -import org.jetbrains.codeviewer.util.withoutWidthConstraints - -@Composable -fun FileTreeViewTabView() = Surface { - Row( - Modifier.padding(8.dp), - verticalAlignment = Alignment.CenterVertically - ) { - Text( - "Files", - color = LocalContentColor.current.copy(alpha = 0.60f), - fontSize = 12.sp, - modifier = Modifier.padding(horizontal = 4.dp) - ) - } -} - -@Composable -fun FileTreeView(model: FileTree) = Surface( - modifier = Modifier.fillMaxSize() -) { - with(LocalDensity.current) { - Box { - val scrollState = rememberLazyListState() - - LazyColumn( - modifier = Modifier.fillMaxSize().withoutWidthConstraints(), - state = scrollState - ) { - items(model.items.size) { - FileTreeItemView(14.sp, 14.sp.toDp() * 1.5f, model.items[it]) - } - } - - VerticalScrollbar( - Modifier.align(Alignment.CenterEnd), - scrollState - ) - } - } -} - -@Composable -private fun FileTreeItemView(fontSize: TextUnit, height: Dp, model: FileTree.Item) = Row( - modifier = Modifier - .wrapContentHeight() - .clickable { model.open() } - .padding(start = 24.dp * model.level) - .height(height) - .fillMaxWidth() -) { - val interactionSource = remember { MutableInteractionSource() } - val active by interactionSource.collectIsHoveredAsState() - - FileItemIcon(Modifier.align(Alignment.CenterVertically), model) - Text( - text = model.name, - color = if (active) LocalContentColor.current.copy(alpha = 0.60f) else LocalContentColor.current, - modifier = Modifier - .align(Alignment.CenterVertically) - .clipToBounds() - .hoverable(interactionSource), - softWrap = true, - fontSize = fontSize, - overflow = TextOverflow.Ellipsis, - maxLines = 1 - ) -} - -@Composable -private fun FileItemIcon(modifier: Modifier, model: FileTree.Item) = Box(modifier.size(24.dp).padding(4.dp)) { - when (val type = model.type) { - is FileTree.ItemType.Folder -> when { - !type.canExpand -> Unit - type.isExpanded -> Icon( - Icons.Default.KeyboardArrowDown, contentDescription = null, tint = LocalContentColor.current - ) - else -> Icon( - Icons.Default.KeyboardArrowRight, contentDescription = null, tint = LocalContentColor.current - ) - } - is FileTree.ItemType.File -> when (type.ext) { - "kt" -> Icon(Icons.Default.Code, contentDescription = null, tint = Color(0xFF3E86A0)) - "xml" -> Icon(Icons.Default.Code, contentDescription = null, tint = Color(0xFFC19C5F)) - "txt" -> Icon(Icons.Default.Description, contentDescription = null, tint = Color(0xFF87939A)) - "md" -> Icon(Icons.Default.Description, contentDescription = null, tint = Color(0xFF87939A)) - "gitignore" -> Icon(Icons.Default.BrokenImage, contentDescription = null, tint = Color(0xFF87939A)) - "gradle" -> Icon(Icons.Default.Build, contentDescription = null, tint = Color(0xFF87939A)) - "kts" -> Icon(Icons.Default.Build, contentDescription = null, tint = Color(0xFF3E86A0)) - "properties" -> Icon(Icons.Default.Settings, contentDescription = null, tint = Color(0xFF62B543)) - "bat" -> Icon(Icons.Default.Launch, contentDescription = null, tint = Color(0xFF87939A)) - else -> Icon(Icons.Default.TextSnippet, contentDescription = null, tint = Color(0xFF87939A)) - } - } -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt deleted file mode 100644 index d2e29c8d81..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt +++ /dev/null @@ -1,47 +0,0 @@ -package org.jetbrains.codeviewer.ui.statusbar - -import androidx.compose.foundation.layout.* -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Slider -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.* -import org.jetbrains.codeviewer.ui.common.Settings - -private val MinFontSize = 6.sp -private val MaxFontSize = 40.sp - -@Composable -fun StatusBar(settings: Settings) = Box( - Modifier - .height(32.dp) - .fillMaxWidth() - .padding(4.dp) -) { - Row(Modifier.fillMaxHeight().align(Alignment.CenterEnd)) { - Text( - text = "Text size", - modifier = Modifier.align(Alignment.CenterVertically), - color = LocalContentColor.current.copy(alpha = 0.60f), - fontSize = 12.sp - ) - - Spacer(Modifier.width(8.dp)) - - CompositionLocalProvider(LocalDensity provides LocalDensity.current.scale(0.5f)) { - Slider( - (settings.fontSize - MinFontSize) / (MaxFontSize - MinFontSize), - onValueChange = { settings.fontSize = lerp(MinFontSize, MaxFontSize, it) }, - modifier = Modifier.width(240.dp).align(Alignment.CenterVertically) - ) - } - } -} - -private fun Density.scale(scale: Float) = Density(density * scale, fontScale * scale) -private operator fun TextUnit.minus(other: TextUnit) = (value - other.value).sp -private operator fun TextUnit.div(other: TextUnit) = value / other.value \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt deleted file mode 100644 index 58d8945726..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt +++ /dev/null @@ -1,27 +0,0 @@ -package org.jetbrains.codeviewer.util - -import androidx.compose.runtime.* -import kotlinx.coroutines.CancellationException -import kotlinx.coroutines.CoroutineScope - -@Composable -fun loadable(load: () -> T): MutableState { - return loadableScoped { load() } -} - -private val loadingKey = Any() - -@Composable -fun loadableScoped(load: CoroutineScope.() -> T): MutableState { - val state: MutableState = remember { mutableStateOf(null) } - LaunchedEffect(loadingKey) { - try { - state.value = load() - } catch (e: CancellationException) { - // ignore - } catch (e: Exception) { - e.printStackTrace() - } - } - return state -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt deleted file mode 100644 index d9b2e0f896..0000000000 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt +++ /dev/null @@ -1,95 +0,0 @@ -package org.jetbrains.codeviewer.util - -import androidx.compose.foundation.background -import androidx.compose.foundation.gestures.Orientation -import androidx.compose.foundation.gestures.draggable -import androidx.compose.foundation.gestures.rememberDraggableState -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.width -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.Layout -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.Constraints -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import org.jetbrains.codeviewer.platform.cursorForHorizontalResize -import org.jetbrains.codeviewer.ui.common.AppTheme - -@Composable -fun VerticalSplittable( - modifier: Modifier, - splitterState: SplitterState, - onResize: (delta: Dp) -> Unit, - children: @Composable () -> Unit -) = Layout({ - children() - VerticalSplitter(splitterState, onResize) -}, modifier, measurePolicy = { measurables, constraints -> - require(measurables.size == 3) - - val firstPlaceable = measurables[0].measure(constraints.copy(minWidth = 0)) - val secondWidth = constraints.maxWidth - firstPlaceable.width - val secondPlaceable = measurables[1].measure( - Constraints( - minWidth = secondWidth, - maxWidth = secondWidth, - minHeight = constraints.maxHeight, - maxHeight = constraints.maxHeight - ) - ) - val splitterPlaceable = measurables[2].measure(constraints) - layout(constraints.maxWidth, constraints.maxHeight) { - firstPlaceable.place(0, 0) - secondPlaceable.place(firstPlaceable.width, 0) - splitterPlaceable.place(firstPlaceable.width, 0) - } -}) - -class SplitterState { - var isResizing by mutableStateOf(false) - var isResizeEnabled by mutableStateOf(true) -} - -@Composable -fun VerticalSplitter( - splitterState: SplitterState, - onResize: (delta: Dp) -> Unit, - color: Color = AppTheme.colors.backgroundDark -) = Box { - val density = LocalDensity.current - Box( - Modifier - .width(8.dp) - .fillMaxHeight() - .run { - if (splitterState.isResizeEnabled) { - this.draggable( - state = rememberDraggableState { - with(density) { - onResize(it.toDp()) - } - }, - orientation = Orientation.Horizontal, - startDragImmediately = true, - onDragStarted = { splitterState.isResizing = true }, - onDragStopped = { splitterState.isResizing = false } - ).cursorForHorizontalResize() - } else { - this - } - } - ) - - Box( - Modifier - .width(1.dp) - .fillMaxHeight() - .background(color) - ) -} \ No newline at end of file diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt deleted file mode 100644 index 7726dbb3e7..0000000000 --- a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.input.pointer.PointerIcon -import androidx.compose.ui.input.pointer.pointerHoverIcon -import java.awt.Cursor - -actual fun Modifier.cursorForHorizontalResize(): Modifier = - this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR))) diff --git a/examples/codeviewer/common/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt b/examples/codeviewer/common/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt deleted file mode 100644 index 43a731f33f..0000000000 --- a/examples/codeviewer/common/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt +++ /dev/null @@ -1,177 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import kotlinx.coroutines.* -import org.jetbrains.codeviewer.util.TextLines -import java.io.FileInputStream -import java.io.FilenameFilter -import java.io.IOException -import java.io.RandomAccessFile -import java.nio.ByteBuffer -import java.nio.channels.FileChannel -import java.nio.charset.StandardCharsets - -fun java.io.File.toProjectFile(): File = object : File { - override val name: String - get() = this@toProjectFile.name - - override val isDirectory: Boolean - get() = this@toProjectFile.isDirectory - - override val children: List - get() = this@toProjectFile - .listFiles(FilenameFilter { _, name -> !name.startsWith(".")}) - .orEmpty() - .map { it.toProjectFile() } - - private val numberOfFiles - get() = listFiles()?.size ?: 0 - - override val hasChildren: Boolean - get() = isDirectory && numberOfFiles > 0 - - - override fun readLines(scope: CoroutineScope): TextLines { - var byteBufferSize: Int - val byteBuffer = RandomAccessFile(this@toProjectFile, "r").use { file -> - byteBufferSize = file.length().toInt() - file.channel.map(FileChannel.MapMode.READ_ONLY, 0, file.length()) - } - - val lineStartPositions = IntList() - var size by mutableStateOf(0) - - // In case of big files, update number of lines periodically - val refreshJob = scope.launch { - delay(100) - size = lineStartPositions.size - while (isActive) { - delay(1000) - size = lineStartPositions.size - } - } - - // Find indexes where lines starts in background - scope.launch(Dispatchers.IO) { - readLinePositions(lineStartPositions) - refreshJob.cancel() - size = lineStartPositions.size - } - - return object : TextLines { - override val size get() = size - - override fun get(index: Int): String { - val position = lineRange(index) - val slice = byteBuffer.slice(position.first, position.last - position.first) - return StandardCharsets.UTF_8.decode(slice).toString() - } - - private fun lineRange(index: Int): IntRange { - val startPosition = lineStartPositions[index] - val nextLineIndex = index + 1 - var endPosition = if (nextLineIndex < size) lineStartPositions[nextLineIndex] else byteBufferSize - - // Remove line endings from the range - while (endPosition > startPosition) { - val lastSymbol = byteBuffer[endPosition - 1] - when (lastSymbol.toInt().toChar()) { - '\n', '\r' -> endPosition-- - else -> break - } - } - return startPosition..endPosition - } - } - } -} - -// Backport slice from JDK 13 -private fun ByteBuffer.slice(index: Int, length: Int): ByteBuffer { - position(index) - return slice().limit(length) -} - -private fun java.io.File.readLinePositions(starts: IntList) { - require(length() <= Int.MAX_VALUE) { - "Files with size over ${Int.MAX_VALUE} aren't supported" - } - - val averageLineLength = 200 - starts.clear(length().toInt() / averageLineLength) - - try { - for (i in readLinePositions()) { - starts.add(i) - } - } catch (e: IOException) { - e.printStackTrace() - starts.clear(1) - starts.add(0) - } - - starts.compact() -} - -private fun java.io.File.readLinePositions() = sequence { - require(length() <= Int.MAX_VALUE) { - "Files with size over ${Int.MAX_VALUE} aren't supported" - } - readBuffer { - yield(position()) - while (hasRemaining()) { - val byte = get() - if (byte.isChar('\n')) { - yield(position()) - } - } - } -} - -private inline fun java.io.File.readBuffer(block: ByteBuffer.() -> Unit) { - FileInputStream(this).use { stream -> - stream.channel.use { channel -> - channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()).block() - } - } -} - -private fun Byte.isChar(char: Char) = toInt().toChar() == char - -/** - * Compact version of List (without unboxing Int and using IntArray under the hood) - */ -private class IntList(initialCapacity: Int = 16) { - @Volatile - private var array = IntArray(initialCapacity) - - @Volatile - var size: Int = 0 - private set - - fun clear(capacity: Int) { - array = IntArray(capacity) - size = 0 - } - - fun add(value: Int) { - if (size == array.size) { - doubleCapacity() - } - array[size++] = value - } - - operator fun get(index: Int) = array[index] - - private fun doubleCapacity() { - val newArray = IntArray(array.size * 2 + 1) - System.arraycopy(array, 0, newArray, 0, size) - array = newArray - } - - fun compact() { - array = array.copyOfRange(0, size) - } -} diff --git a/examples/codeviewer/desktop/build.gradle.kts b/examples/codeviewer/desktop/build.gradle.kts deleted file mode 100644 index e7263fd745..0000000000 --- a/examples/codeviewer/desktop/build.gradle.kts +++ /dev/null @@ -1,41 +0,0 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) - id("org.jetbrains.compose") -} - -kotlin { - jvm {} - sourceSets { - named("jvmMain") { - dependencies { - implementation(compose.desktop.currentOs) - implementation(project(":common")) - } - } - } -} - -compose.desktop { - application { - mainClass = "org.jetbrains.codeviewer.MainKt" - - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "ComposeCodeViewer" - packageVersion = "1.0.0" - - windows { - menu = true - // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html - upgradeUuid = "AF792DA6-2EA3-495A-95E5-C3C6CBCB9948" - } - - macOS { - // Use -Pcompose.desktop.mac.sign=true to sign and notarize. - bundleID = "com.jetbrains.compose.codeviewer" - } - } - } -} diff --git a/examples/codeviewer/desktop/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt b/examples/codeviewer/desktop/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt deleted file mode 100644 index b3e70a808f..0000000000 --- a/examples/codeviewer/desktop/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.jetbrains.codeviewer - -import androidx.compose.ui.graphics.painter.BitmapPainter -import androidx.compose.ui.res.loadImageBitmap -import androidx.compose.ui.res.useResource -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.window.singleWindowApplication -import org.jetbrains.codeviewer.ui.MainView - -fun main() = singleWindowApplication( - title = "Code Viewer", - state = WindowState(width = 1280.dp, height = 768.dp), - icon = BitmapPainter(useResource("ic_launcher.png", ::loadImageBitmap)), -) { - MainView() -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/desktopApp/build.gradle.kts b/examples/codeviewer/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/codeviewer/desktopApp/build.gradle.kts rename to examples/codeviewer/desktopApp/build.gradle.kts diff --git a/experimental/examples/codeviewer/desktopApp/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt b/examples/codeviewer/desktopApp/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt similarity index 100% rename from experimental/examples/codeviewer/desktopApp/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt rename to examples/codeviewer/desktopApp/src/jvmMain/kotlin/org/jetbrains/codeviewer/main.kt diff --git a/examples/codeviewer/desktop/src/jvmMain/resources/ic_launcher.png b/examples/codeviewer/desktopApp/src/jvmMain/resources/ic_launcher.png similarity index 100% rename from examples/codeviewer/desktop/src/jvmMain/resources/ic_launcher.png rename to examples/codeviewer/desktopApp/src/jvmMain/resources/ic_launcher.png diff --git a/examples/codeviewer/gradle.properties b/examples/codeviewer/gradle.properties index 5b6ab8f1b4..9ff8815ad5 100644 --- a/examples/codeviewer/gradle.properties +++ b/examples/codeviewer/gradle.properties @@ -1,24 +1,16 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -kotlin.version=1.8.10 +xcodeproj=./iosApp +kotlin.native.cocoapods.generate.wrapper=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3g +org.jetbrains.compose.experimental.jscanvas.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.uikit.enabled=true +kotlin.native.cacheKind=none +kotlin.native.useEmbeddableCompilerJar=true +kotlin.mpp.androidSourceSetLayoutVersion=2 +# Enable kotlin/native experimental memory model +kotlin.native.binary.memoryModel=experimental +kotlin.version=1.8.0 agp.version=7.1.3 -compose.version=1.3.1 +compose.version=1.4.0-rc01 diff --git a/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar b/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar index 62d4c05355..249e5832f0 100644 Binary files a/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar and b/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/codeviewer/gradlew b/examples/codeviewer/gradlew index 2fe81a7d95..a69d9cb6c2 100755 --- a/examples/codeviewer/gradlew +++ b/examples/codeviewer/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,79 +140,101 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/codeviewer/gradlew.bat b/examples/codeviewer/gradlew.bat index 9618d8d960..f127cfd49d 100644 --- a/examples/codeviewer/gradlew.bat +++ b/examples/codeviewer/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,13 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,38 +64,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/experimental/examples/codeviewer/iosApp/Configuration/Config.xcconfig b/examples/codeviewer/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/codeviewer/iosApp/Configuration/Config.xcconfig rename to examples/codeviewer/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/codeviewer/iosApp/Podfile b/examples/codeviewer/iosApp/Podfile similarity index 100% rename from experimental/examples/codeviewer/iosApp/Podfile rename to examples/codeviewer/iosApp/Podfile diff --git a/experimental/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/codeviewer/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/codeviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/codeviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/codeviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/codeviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/codeviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/codeviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/codeviewer/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/codeviewer/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/codeviewer/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/codeviewer/iosApp/iosApp/ContentView.swift b/examples/codeviewer/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/ContentView.swift rename to examples/codeviewer/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/codeviewer/iosApp/iosApp/Info.plist b/examples/codeviewer/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/Info.plist rename to examples/codeviewer/iosApp/iosApp/Info.plist diff --git a/experimental/examples/codeviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/codeviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/codeviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/codeviewer/iosApp/iosApp/iOSApp.swift b/examples/codeviewer/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/codeviewer/iosApp/iosApp/iOSApp.swift rename to examples/codeviewer/iosApp/iosApp/iOSApp.swift diff --git a/experimental/examples/codeviewer/run-configurations.png b/examples/codeviewer/run-configurations.png similarity index 100% rename from experimental/examples/codeviewer/run-configurations.png rename to examples/codeviewer/run-configurations.png diff --git a/examples/codeviewer/screenshots/desktop-run-configuration.png b/examples/codeviewer/screenshots/desktop-run-configuration.png deleted file mode 100644 index 3688407c6f..0000000000 Binary files a/examples/codeviewer/screenshots/desktop-run-configuration.png and /dev/null differ diff --git a/examples/codeviewer/settings.gradle.kts b/examples/codeviewer/settings.gradle.kts index c2ab465cc8..a1d0b79e3e 100644 --- a/examples/codeviewer/settings.gradle.kts +++ b/examples/codeviewer/settings.gradle.kts @@ -3,6 +3,7 @@ pluginManagement { gradlePluginPortal() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") google() + mavenLocal() } plugins { @@ -20,4 +21,8 @@ pluginManagement { } } -include(":common", ":android", ":desktop") +rootProject.name = "codeviewer" + +include(":androidApp") +include(":shared") +include(":desktopApp") diff --git a/experimental/examples/codeviewer/shared/build.gradle.kts b/examples/codeviewer/shared/build.gradle.kts similarity index 100% rename from experimental/examples/codeviewer/shared/build.gradle.kts rename to examples/codeviewer/shared/build.gradle.kts diff --git a/examples/codeviewer/common/src/androidMain/AndroidManifest.xml b/examples/codeviewer/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/codeviewer/common/src/androidMain/AndroidManifest.xml rename to examples/codeviewer/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/main.android.kt b/examples/codeviewer/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/androidMain/kotlin/main.android.kt rename to examples/codeviewer/shared/src/androidMain/kotlin/main.android.kt diff --git a/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt similarity index 100% rename from examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt rename to examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt diff --git a/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt similarity index 100% rename from examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt rename to examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt diff --git a/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt similarity index 100% rename from examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt rename to examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt diff --git a/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt similarity index 100% rename from examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt rename to examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorTabsView.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/statusbar/StatusBar.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt similarity index 100% rename from examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt b/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt rename to examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_bold.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_bold.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_italic.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_italic.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_italic.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_italic.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_medium.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_medium.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf diff --git a/examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_regular.ttf b/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_regular.ttf similarity index 100% rename from examples/codeviewer/common/src/commonMain/resources/font/jetbrainsmono_regular.ttf rename to examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_regular.ttf diff --git a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/codeviewer/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/codeviewer/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt similarity index 100% rename from examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt rename to examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt diff --git a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt rename to examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt similarity index 100% rename from examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt rename to examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt similarity index 100% rename from examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt rename to examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt diff --git a/experimental/examples/codeviewer/shared/src/iosMain/kotlin/main.ios.kt b/examples/codeviewer/shared/src/iosMain/kotlin/main.ios.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/iosMain/kotlin/main.ios.kt rename to examples/codeviewer/shared/src/iosMain/kotlin/main.ios.kt diff --git a/experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/File.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/File.kt rename to examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/File.kt diff --git a/experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt rename to examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt diff --git a/experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt rename to examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt diff --git a/experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt rename to examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt diff --git a/experimental/examples/codeviewer/shared/src/iosMain/resources/EditorView.kt b/examples/codeviewer/shared/src/iosMain/resources/EditorView.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/iosMain/resources/EditorView.kt rename to examples/codeviewer/shared/src/iosMain/resources/EditorView.kt diff --git a/experimental/examples/codeviewer/shared/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt b/examples/codeviewer/shared/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt similarity index 100% rename from experimental/examples/codeviewer/shared/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt rename to examples/codeviewer/shared/src/jvmMain/kotlin/org/jetbrains/codeviewer/platform/JvmFile.kt diff --git a/examples/falling-balls/.gitignore b/examples/falling-balls/.gitignore index ba8435b9c5..968bdd56ce 100644 --- a/examples/falling-balls/.gitignore +++ b/examples/falling-balls/.gitignore @@ -1,15 +1,7 @@ -*.iml -.gradle -/local.properties -/.idea -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -build/ -/captures -.externalNativeBuild -.cxx \ No newline at end of file +local.properties +iosApp/Podfile.lock +iosApp/Pods/* +iosApp/iosApp.xcworkspace/* +iosApp/iosApp.xcodeproj/* +!iosApp/iosApp.xcodeproj/project.pbxproj +shared/shared.podspec \ No newline at end of file diff --git a/examples/falling-balls/.run/desktop.run.xml b/examples/falling-balls/.run/desktop.run.xml deleted file mode 100644 index d4d6b92cb3..0000000000 --- a/examples/falling-balls/.run/desktop.run.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - true - true - false - - - \ No newline at end of file diff --git a/experimental/examples/falling-balls-mpp/.run/desktopApp.run.xml b/examples/falling-balls/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/falling-balls-mpp/.run/desktopApp.run.xml rename to examples/falling-balls/.run/desktopApp.run.xml diff --git a/experimental/examples/falling-balls-mpp/.run/jsApp.run.xml b/examples/falling-balls/.run/jsApp.run.xml similarity index 100% rename from experimental/examples/falling-balls-mpp/.run/jsApp.run.xml rename to examples/falling-balls/.run/jsApp.run.xml diff --git a/examples/falling-balls/README.md b/examples/falling-balls/README.md index f4eba98b85..a7d18ef15f 100644 --- a/examples/falling-balls/README.md +++ b/examples/falling-balls/README.md @@ -1,7 +1,52 @@ -Falling Balls game +# Falling Balls game + +Game can run on Android, iOS, desktop or in a browser. + +*Prerequisites*: to run on iOS and Android, you should have "Kotlin Multiplatform Mobile" plugin installed either + in Android Studio or in AppCode with [installed CocoaPods](https://kotlinlang.org/docs/native-cocoapods.html). + + +## How to run + +Choose a run configuration for an appropriate target in IDE and run it. + +![run-configurations.png](run-configurations.png) + +To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. +Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then +using "Signing & Capabilities" tab of `iosApp` target. See also how to prepare XCode section below. + +Then choose **iosApp** configuration in IDE and run it. + +## Run on desktop via Gradle + +`./gradlew desktopApp:run` + +## Run JS in browser with WebAssembly Skia via Gradle + +`./gradlew jsApp:jsBrowserDevelopmentRun` + +## Prepare Xcode to launch on iOS device + +1) **Add your Apple ID.** +Xcode -> Preferences... -> Accounts +![apple-id.png](apple-id.png) + +2) **Create certificates with XCode in temporary project.** +You can create a certificate in Xcode. Create a new iOS app in Xcode. +File -> New -> Project +Choose iOS, App: +![ios-app.png](ios-app.png) + +3) **In next dialog set any product name and choose your teamID.** + +4) **Run project on iOS Device.** +Xcode prompts you to install the certificate. Require password from login.keychain + +5) **Done** +After a successful launch on the device - you can delete this temporary project. +Certificates will remain in login.keychain + +## Run native on MacOS +Choose **shared[macosX64]** or **shared[macosArm64]** configuration in IDE and run it. -### Running desktop application - * To run, launch command: `./gradlew run` - * Or choose **desktop** configuration in IDE and run it. - ![desktop-run-configuration.png](screenshots/desktop-run-configuration.png) - diff --git a/experimental/examples/falling-balls-mpp/androidApp/build.gradle.kts b/examples/falling-balls/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/falling-balls-mpp/androidApp/build.gradle.kts rename to examples/falling-balls/androidApp/build.gradle.kts diff --git a/experimental/examples/falling-balls-mpp/androidApp/src/androidMain/AndroidManifest.xml b/examples/falling-balls/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/falling-balls-mpp/androidApp/src/androidMain/AndroidManifest.xml rename to examples/falling-balls/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/falling-balls-mpp/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt b/examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt rename to examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt diff --git a/experimental/examples/falling-balls-mpp/androidApp/src/androidMain/res/values/strings.xml b/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml similarity index 100% rename from experimental/examples/falling-balls-mpp/androidApp/src/androidMain/res/values/strings.xml rename to examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml diff --git a/experimental/examples/falling-balls-mpp/apple-id.png b/examples/falling-balls/apple-id.png similarity index 100% rename from experimental/examples/falling-balls-mpp/apple-id.png rename to examples/falling-balls/apple-id.png diff --git a/examples/falling-balls/build.gradle.kts b/examples/falling-balls/build.gradle.kts index afa3c552ef..0c00883af5 100644 --- a/examples/falling-balls/build.gradle.kts +++ b/examples/falling-balls/build.gradle.kts @@ -1,37 +1,18 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { - kotlin("jvm") - id("org.jetbrains.compose") -} - -group = "org.jetbrains.compose.demo.falling" -version = "1.0" - -repositories { - mavenCentral() - google() - maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") } -} - -dependencies { - implementation(compose.desktop.currentOs) -} - -tasks.withType() { - kotlinOptions.jvmTarget = "11" - kotlinOptions.allWarningsAsErrors = true - kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" + // this is necessary to avoid the plugins to be loaded multiple times + // in each subproject's classloader + kotlin("jvm") apply false + kotlin("multiplatform") apply false + kotlin("android") apply false + id("com.android.application") apply false + id("com.android.library") apply false + id("org.jetbrains.compose") apply false } -compose.desktop { - application { - mainClass = "org.jetbrains.compose.demo.falling.MainKt" - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "falling_balls" - packageVersion = "1.0.0" - } +allprojects { + repositories { + google() + mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") } } diff --git a/experimental/examples/falling-balls-mpp/desktopApp/build.gradle.kts b/examples/falling-balls/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/falling-balls-mpp/desktopApp/build.gradle.kts rename to examples/falling-balls/desktopApp/build.gradle.kts diff --git a/experimental/examples/falling-balls-mpp/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/desktopApp/src/jvmMain/kotlin/Main.kt rename to examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt diff --git a/examples/falling-balls/gradle.properties b/examples/falling-balls/gradle.properties index 130f9fa7ab..9ff8815ad5 100644 --- a/examples/falling-balls/gradle.properties +++ b/examples/falling-balls/gradle.properties @@ -1,3 +1,16 @@ kotlin.code.style=official -kotlin.version=1.8.10 -compose.version=1.3.1 +xcodeproj=./iosApp +kotlin.native.cocoapods.generate.wrapper=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3g +org.jetbrains.compose.experimental.jscanvas.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.uikit.enabled=true +kotlin.native.cacheKind=none +kotlin.native.useEmbeddableCompilerJar=true +kotlin.mpp.androidSourceSetLayoutVersion=2 +# Enable kotlin/native experimental memory model +kotlin.native.binary.memoryModel=experimental +kotlin.version=1.8.0 +agp.version=7.1.3 +compose.version=1.4.0-rc01 diff --git a/examples/falling-balls/gradle/wrapper/gradle-wrapper.jar b/examples/falling-balls/gradle/wrapper/gradle-wrapper.jar index e708b1c023..249e5832f0 100644 Binary files a/examples/falling-balls/gradle/wrapper/gradle-wrapper.jar and b/examples/falling-balls/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/falling-balls/gradlew b/examples/falling-balls/gradlew index 4f906e0c81..a69d9cb6c2 100755 --- a/examples/falling-balls/gradlew +++ b/examples/falling-balls/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,101 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/falling-balls/gradlew.bat b/examples/falling-balls/gradlew.bat index ac1b06f938..f127cfd49d 100644 --- a/examples/falling-balls/gradlew.bat +++ b/examples/falling-balls/gradlew.bat @@ -1,89 +1,91 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/experimental/examples/falling-balls-mpp/ios-app.png b/examples/falling-balls/ios-app.png similarity index 100% rename from experimental/examples/falling-balls-mpp/ios-app.png rename to examples/falling-balls/ios-app.png diff --git a/experimental/examples/falling-balls-mpp/iosApp/Configuration/Config.xcconfig b/examples/falling-balls/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/Configuration/Config.xcconfig rename to examples/falling-balls/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/falling-balls-mpp/iosApp/Podfile b/examples/falling-balls/iosApp/Podfile similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/Podfile rename to examples/falling-balls/iosApp/Podfile diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/falling-balls/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/falling-balls/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/falling-balls/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/falling-balls/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/falling-balls/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/falling-balls/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/ContentView.swift b/examples/falling-balls/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/ContentView.swift rename to examples/falling-balls/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/Info.plist b/examples/falling-balls/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/Info.plist rename to examples/falling-balls/iosApp/iosApp/Info.plist diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/falling-balls/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/falling-balls/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/falling-balls-mpp/iosApp/iosApp/iOSApp.swift b/examples/falling-balls/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/falling-balls-mpp/iosApp/iosApp/iOSApp.swift rename to examples/falling-balls/iosApp/iosApp/iOSApp.swift diff --git a/experimental/examples/falling-balls-mpp/jsApp/build.gradle.kts b/examples/falling-balls/jsApp/build.gradle.kts similarity index 100% rename from experimental/examples/falling-balls-mpp/jsApp/build.gradle.kts rename to examples/falling-balls/jsApp/build.gradle.kts diff --git a/experimental/examples/falling-balls-mpp/jsApp/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/jsApp/src/jsMain/kotlin/main.js.kt rename to examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt diff --git a/experimental/examples/falling-balls-mpp/jsApp/src/jsMain/resources/index.html b/examples/falling-balls/jsApp/src/jsMain/resources/index.html similarity index 100% rename from experimental/examples/falling-balls-mpp/jsApp/src/jsMain/resources/index.html rename to examples/falling-balls/jsApp/src/jsMain/resources/index.html diff --git a/experimental/examples/falling-balls-mpp/jsApp/src/jsMain/resources/styles.css b/examples/falling-balls/jsApp/src/jsMain/resources/styles.css similarity index 100% rename from experimental/examples/falling-balls-mpp/jsApp/src/jsMain/resources/styles.css rename to examples/falling-balls/jsApp/src/jsMain/resources/styles.css diff --git a/experimental/examples/falling-balls-mpp/run-configurations.png b/examples/falling-balls/run-configurations.png similarity index 100% rename from experimental/examples/falling-balls-mpp/run-configurations.png rename to examples/falling-balls/run-configurations.png diff --git a/examples/falling-balls/screenshots/desktop-run-configuration.png b/examples/falling-balls/screenshots/desktop-run-configuration.png deleted file mode 100644 index 3688407c6f..0000000000 Binary files a/examples/falling-balls/screenshots/desktop-run-configuration.png and /dev/null differ diff --git a/examples/falling-balls/settings.gradle.kts b/examples/falling-balls/settings.gradle.kts index 792529f337..95b7916058 100644 --- a/examples/falling-balls/settings.gradle.kts +++ b/examples/falling-balls/settings.gradle.kts @@ -1,8 +1,28 @@ pluginManagement { + repositories { + gradlePluginPortal() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + google() + } + plugins { - kotlin("jvm").version(extra["kotlin.version"] as String) - id("org.jetbrains.compose").version(extra["compose.version"] as String) + val kotlinVersion = extra["kotlin.version"] as String + val agpVersion = extra["agp.version"] as String + val composeVersion = extra["compose.version"] as String + + kotlin("jvm").version(kotlinVersion) + kotlin("multiplatform").version(kotlinVersion) + kotlin("android").version(kotlinVersion) + id("com.android.base").version(agpVersion) + id("com.android.application").version(agpVersion) + id("com.android.library").version(agpVersion) + id("org.jetbrains.compose").version(composeVersion) } } -rootProject.name = "falling_balls" +rootProject.name = "falling-balls-mpp" + +include(":androidApp") +include(":shared") +include(":desktopApp") +include(":jsApp") diff --git a/experimental/examples/falling-balls-mpp/shared/build.gradle.kts b/examples/falling-balls/shared/build.gradle.kts similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/build.gradle.kts rename to examples/falling-balls/shared/build.gradle.kts diff --git a/experimental/examples/falling-balls-mpp/shared/src/androidMain/AndroidManifest.xml b/examples/falling-balls/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/androidMain/AndroidManifest.xml rename to examples/falling-balls/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/falling-balls-mpp/shared/src/androidMain/kotlin/main.android.kt b/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/androidMain/kotlin/main.android.kt rename to examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt b/examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt rename to examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt b/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt rename to examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/fallingBalls/Game.kt b/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/fallingBalls/Game.kt rename to examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/fallingBalls/Piece.kt b/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/commonMain/kotlin/fallingBalls/Piece.kt rename to examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/iosMain/kotlin/main.ios.kt b/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/iosMain/kotlin/main.ios.kt rename to examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/jsMain/kotlin/main.js.kt rename to examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt diff --git a/experimental/examples/falling-balls-mpp/shared/src/macosMain/kotlin/main.macos.kt b/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt similarity index 100% rename from experimental/examples/falling-balls-mpp/shared/src/macosMain/kotlin/main.macos.kt rename to examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt diff --git a/examples/falling-balls/src/main/kotlin/Game.kt b/examples/falling-balls/src/main/kotlin/Game.kt deleted file mode 100644 index 0cd10d89d1..0000000000 --- a/examples/falling-balls/src/main/kotlin/Game.kt +++ /dev/null @@ -1,136 +0,0 @@ -package org.jetbrains.compose.demo.falling - -import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.foundation.layout.* -import androidx.compose.material.Button -import androidx.compose.material.Slider -import androidx.compose.material.Text -import androidx.compose.runtime.* -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.onSizeChanged -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.* -import kotlin.random.Random - -class Game { - private var previousTimeNanos: Long = Long.MAX_VALUE - private val colors = arrayOf( - Color.Red, Color.Blue, Color.Cyan, - Color.Magenta, Color.Yellow, Color.Black - ) - private var startTime = 0L - - var size by mutableStateOf(Pair(0.dp, 0.dp)) - - var pieces = mutableStateListOf() - private set - - var elapsed by mutableStateOf(0L) - var score by mutableStateOf(0) - private var clicked by mutableStateOf(0) - - var started by mutableStateOf(false) - var paused by mutableStateOf(false) - var finished by mutableStateOf(false) - - var numBlocks by mutableStateOf(5) - - fun start() { - previousTimeNanos = System.nanoTime() - startTime = previousTimeNanos - clicked = 0 - started = true - finished = false - paused = false - pieces.clear() - repeat(numBlocks) { index -> - pieces.add(PieceData(this, index * 1.5f + 5f, colors[index % colors.size]).also { piece -> - piece.position = Random.nextDouble(0.0, 100.0).toFloat() - }) - } - } - - fun togglePause() { - paused = !paused - previousTimeNanos = System.nanoTime() - } - - fun update(nanos: Long) { - val dt = (nanos - previousTimeNanos).coerceAtLeast(0) - previousTimeNanos = nanos - elapsed = nanos - startTime - pieces.forEach { it.update(dt) } - } - - fun clicked(piece: PieceData) { - score += piece.velocity.toInt() - clicked++ - if (clicked == numBlocks) { - finished = true - } - } -} - -@Composable -@Preview -fun FallingBallsGame() { - val game = remember { Game() } - val density = LocalDensity.current - Column { - Text( - "Catch balls!${if (game.finished) " Game over!" else ""}", - fontSize = 50.sp, - color = Color(218, 120, 91) - ) - Text("Score ${game.score} Time ${game.elapsed / 1_000_000} Blocks ${game.numBlocks}", fontSize = 35.sp) - Row { - if (!game.started) { - Slider( - value = game.numBlocks / 20f, - onValueChange = { game.numBlocks = (it * 20f).toInt().coerceAtLeast(1) }, - modifier = Modifier.width(100.dp) - ) - } - Button(onClick = { - game.started = !game.started - if (game.started) { - game.start() - } - }) { - Text(if (game.started) "Stop" else "Start", fontSize = 40.sp) - } - if (game.started) { - Spacer(Modifier.padding(5.dp)) - Button(onClick = { - game.togglePause() - }) { - Text(if (game.paused) "Resume" else "Pause", fontSize = 40.sp) - } - } - } - if (game.started) { - Box(modifier = Modifier - .fillMaxWidth() - .fillMaxHeight() - .onSizeChanged { - with(density) { - game.size = it.width.toDp() to it.height.toDp() - } - } - ) { - game.pieces.forEachIndexed { index, piece -> Piece(index, piece) } - } - } - - LaunchedEffect(Unit) { - while (true) { - withFrameNanos { - if (game.started && !game.paused && !game.finished) - game.update(it) - } - } - } - } -} - diff --git a/examples/falling-balls/src/main/kotlin/Piece.kt b/examples/falling-balls/src/main/kotlin/Piece.kt deleted file mode 100644 index 1ded6905b8..0000000000 --- a/examples/falling-balls/src/main/kotlin/Piece.kt +++ /dev/null @@ -1,54 +0,0 @@ -package org.jetbrains.compose.demo.falling - -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.draw.shadow -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp - -@Composable -fun Piece(index: Int, piece: PieceData) { - val boxSize = 40.dp - Box( - Modifier - .offset(boxSize * index * 5 / 3, piece.position.dp) - .shadow(30.dp) - .clip(CircleShape) - ) { - Box( - Modifier - .size(boxSize, boxSize) - .background(if (piece.clicked) Color.Gray else piece.color) - .clickable(onClick = { piece.click() }) - ) - } -} - -data class PieceData(val game: Game, val velocity: Float, val color: Color) { - var clicked by mutableStateOf(false) - var position by mutableStateOf(0f) - - fun update(dt: Long) { - if (clicked) return - val delta = (dt / 1E8 * velocity).toFloat() - position = if (position < game.size.second.value) position + delta else 0f - } - - fun click() { - if (!clicked && !game.paused) { - clicked = true - game.clicked(this) - } - } -} - diff --git a/examples/falling-balls/src/main/kotlin/main.kt b/examples/falling-balls/src/main/kotlin/main.kt deleted file mode 100644 index 0d9259f310..0000000000 --- a/examples/falling-balls/src/main/kotlin/main.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.compose.demo.falling - -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.window.singleWindowApplication - -@OptIn(ExperimentalComposeUiApi::class) -fun main() = singleWindowApplication( - title = "Falling Balls", state = WindowState(size = DpSize(800.dp, 800.dp)) -) { - FallingBallsGame() -} - diff --git a/examples/imageviewer/.gitignore b/examples/imageviewer/.gitignore index a32b16597b..d27dff7cb0 100644 --- a/examples/imageviewer/.gitignore +++ b/examples/imageviewer/.gitignore @@ -13,3 +13,9 @@ build/ /captures .externalNativeBuild .cxx +iosApp/Podfile.lock +iosApp/Pods/* +iosApp/iosApp.xcworkspace/* +iosApp/iosApp.xcodeproj/* +!iosApp/iosApp.xcodeproj/project.pbxproj +shared/shared.podspec diff --git a/examples/imageviewer/.idea/codeStyles/Project.xml b/examples/imageviewer/.idea/codeStyles/Project.xml deleted file mode 100755 index 88ea3aa1e5..0000000000 --- a/examples/imageviewer/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - -
- - - - xmlns:android - - ^$ - - - -
-
- - - - xmlns:.* - - ^$ - - - BY_NAME - -
-
- - - - .*:id - - http://schemas.android.com/apk/res/android - - - -
-
- - - - .*:name - - http://schemas.android.com/apk/res/android - - - -
-
- - - - name - - ^$ - - - -
-
- - - - style - - ^$ - - - -
-
- - - - .* - - ^$ - - - BY_NAME - -
-
- - - - .* - - http://schemas.android.com/apk/res/android - - - ANDROID_ATTRIBUTE_ORDER - -
-
- - - - .* - - .* - - - BY_NAME - -
-
-
-
- - -
-
\ No newline at end of file diff --git a/examples/imageviewer/.idea/codeStyles/codeStyleConfig.xml b/examples/imageviewer/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100755 index 79ee123c2b..0000000000 --- a/examples/imageviewer/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/examples/imageviewer/.idea/vcs.xml b/examples/imageviewer/.idea/vcs.xml deleted file mode 100755 index 8fe5bdbdc5..0000000000 --- a/examples/imageviewer/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/examples/imageviewer/.run/desktop.run.xml b/examples/imageviewer/.run/desktop.run.xml deleted file mode 100755 index d9335c1be5..0000000000 --- a/examples/imageviewer/.run/desktop.run.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - true - - - \ No newline at end of file diff --git a/experimental/examples/imageviewer/.run/desktopApp.run.xml b/examples/imageviewer/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/imageviewer/.run/desktopApp.run.xml rename to examples/imageviewer/.run/desktopApp.run.xml diff --git a/examples/imageviewer/README.md b/examples/imageviewer/README.md index 3d79c52613..72e6408ee5 100755 --- a/examples/imageviewer/README.md +++ b/examples/imageviewer/README.md @@ -1,11 +1,26 @@ -An example of image gallery for remote server image viewing, based on Jetpack Compose UI library (desktop and android). +# Imageviewer -### Running desktop application - * To run, launch command: `./gradlew :desktop:run` - * Or choose **desktop** configuration in IDE and run it. - ![desktop-run-configuration.png](screenshots/desktop-run-configuration.png) +An example of image gallery for remote server image viewing, +based on Compose Multiplatform UI library (desktop, android and iOS). + +## How to run + +Choose a run configuration for an appropriate target in IDE and run it. + +![run-configurations.png](screenshots/run-configurations.png) + +To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. +Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then +using "Signing & Capabilities" tab of `iosApp` target. + +Then choose **iosApp** configuration in IDE and run it. + +## Run on desktop via Gradle + +`./gradlew desktopApp:run` ### Building native desktop distribution + ``` ./gradlew :desktop:packageDistributionForCurrentOS # outputs are written to desktop/build/compose/binaries @@ -13,6 +28,8 @@ An example of image gallery for remote server image viewing, based on Jetpack Co ### Running Android application -Open project in IntelliJ IDEA or Android Studio and run "android" configuration. - -![Desktop](screenshots/imageviewer.png) +- Get a [Google Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key) +- Add to `local.properties` file located in the root directory (create if it doesn't exist): + - `MAPS_API_KEY=YOUR_KEY` where `YOUR_KEY` is your key from previous step; + - `sdk.dir=YOUR_SDK_PATH` where `YOUR_SDK_PATH` is a path to Android SDK in your system. +- Open project in IntelliJ IDEA or Android Studio and run `androidApp` configuration. diff --git a/examples/imageviewer/android/build.gradle.kts b/examples/imageviewer/android/build.gradle.kts deleted file mode 100755 index fed67b2b03..0000000000 --- a/examples/imageviewer/android/build.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -plugins { - id("com.android.application") - kotlin("android") - id("org.jetbrains.compose") -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } -} - -dependencies { - implementation(project(":common")) - implementation("androidx.activity:activity-compose:1.5.0") -} diff --git a/examples/imageviewer/android/src/main/AndroidManifest.xml b/examples/imageviewer/android/src/main/AndroidManifest.xml deleted file mode 100755 index 5b1501c058..0000000000 --- a/examples/imageviewer/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/imageviewer/android/src/main/java/example/imageviewer/MainActivity.kt b/examples/imageviewer/android/src/main/java/example/imageviewer/MainActivity.kt deleted file mode 100755 index 53bb8c6160..0000000000 --- a/examples/imageviewer/android/src/main/java/example/imageviewer/MainActivity.kt +++ /dev/null @@ -1,23 +0,0 @@ -package example.imageviewer - -import android.os.Bundle -import androidx.appcompat.app.AppCompatActivity -import androidx.activity.compose.setContent -import example.imageviewer.view.AppUI -import example.imageviewer.model.ContentState -import example.imageviewer.model.ImageRepository - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - val content = ContentState.applyContent( - this@MainActivity, - "https://raw.githubusercontent.com/JetBrains/compose-jb/master/artwork/imageviewerrepo/fetching.list" - ) - - setContent { - AppUI(content) - } - } -} \ No newline at end of file diff --git a/experimental/examples/imageviewer/androidApp/build.gradle.kts b/examples/imageviewer/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/imageviewer/androidApp/build.gradle.kts rename to examples/imageviewer/androidApp/build.gradle.kts diff --git a/experimental/examples/imageviewer/androidApp/src/androidMain/AndroidManifest.xml b/examples/imageviewer/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/imageviewer/androidApp/src/androidMain/AndroidManifest.xml rename to examples/imageviewer/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/imageviewer/androidApp/src/androidMain/kotlin/example/imageviewer/MainActivity.kt b/examples/imageviewer/androidApp/src/androidMain/kotlin/example/imageviewer/MainActivity.kt similarity index 100% rename from experimental/examples/imageviewer/androidApp/src/androidMain/kotlin/example/imageviewer/MainActivity.kt rename to examples/imageviewer/androidApp/src/androidMain/kotlin/example/imageviewer/MainActivity.kt diff --git a/experimental/examples/imageviewer/androidApp/src/androidMain/res/values/themes.xml b/examples/imageviewer/androidApp/src/androidMain/res/values/themes.xml similarity index 100% rename from experimental/examples/imageviewer/androidApp/src/androidMain/res/values/themes.xml rename to examples/imageviewer/androidApp/src/androidMain/res/values/themes.xml diff --git a/examples/imageviewer/build.gradle.kts b/examples/imageviewer/build.gradle.kts old mode 100755 new mode 100644 diff --git a/examples/imageviewer/common/build.gradle.kts b/examples/imageviewer/common/build.gradle.kts deleted file mode 100755 index 83b8d9cd89..0000000000 --- a/examples/imageviewer/common/build.gradle.kts +++ /dev/null @@ -1,54 +0,0 @@ -plugins { - id("com.android.library") - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - android() - jvm("desktop") - sourceSets { - named("commonMain") { - dependencies { - api(compose.runtime) - api(compose.foundation) - api(compose.material) - implementation("io.ktor:ktor-client-core:1.4.1") - } - } - named("androidMain") { - dependencies { - api("androidx.appcompat:appcompat:1.5.1") - api("androidx.core:core-ktx:1.8.0") - implementation("io.ktor:ktor-client-cio:1.4.1") - } - } - named("desktopMain") { - dependencies { - api(compose.desktop.common) - implementation("io.ktor:ktor-client-cio:1.4.1") - } - } - } -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - sourceSets { - named("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - res.srcDirs("src/androidMain/res") - } - } -} diff --git a/examples/imageviewer/common/src/androidMain/AndroidManifest.xml b/examples/imageviewer/common/src/androidMain/AndroidManifest.xml deleted file mode 100755 index 7a302a744c..0000000000 --- a/examples/imageviewer/common/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/core/BitmapFilter.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/core/BitmapFilter.kt deleted file mode 100755 index 1e14522811..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/core/BitmapFilter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package example.imageviewer.core - -import android.graphics.Bitmap - -interface BitmapFilter { - fun apply(bitmap: Bitmap) : Bitmap -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/AndroidContentState.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/AndroidContentState.kt deleted file mode 100644 index 00d4b026bc..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/AndroidContentState.kt +++ /dev/null @@ -1,383 +0,0 @@ -package example.imageviewer.model - -import android.content.Context -import android.graphics.* -import android.os.Handler -import android.os.Looper -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import example.imageviewer.common.R -import example.imageviewer.core.FilterType -import example.imageviewer.model.filtration.FiltersManager -import example.imageviewer.utils.clearCache -import example.imageviewer.utils.isInternetAvailable -import example.imageviewer.view.showPopUpMessage -import java.util.concurrent.ExecutorService -import java.util.concurrent.Executors - - -object ContentState { - - private lateinit var context: Context - private lateinit var repository: ImageRepository - private lateinit var uriRepository: String - - fun applyContent(context: Context, uriRepository: String): ContentState { - if (this::uriRepository.isInitialized && this.uriRepository == uriRepository) { - return this - } - - this.context = context - this.uriRepository = uriRepository - repository = ImageRepository(uriRepository) - appliedFilters = FiltersManager(context) - isContentReady.value = false - - initData() - - return this - } - - private val executor: ExecutorService by lazy { Executors.newFixedThreadPool(2) } - - private val handler: Handler by lazy { Handler(Looper.getMainLooper()) } - - fun getContext(): Context { - return context - } - - fun getOrientation(): Int { - return context.resources.configuration.orientation - } - - private val isAppReady = mutableStateOf(false) - fun isAppReady(): Boolean { - return isAppReady.value - } - - private val isContentReady = mutableStateOf(false) - fun isContentReady(): Boolean { - return isContentReady.value - } - - fun getString(id: Int): String { - return context.getString(id) - } - - // drawable content - private val mainImage = mutableStateOf(Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)) - private val currentImageIndex = mutableStateOf(0) - private val miniatures = Miniatures() - - fun getMiniatures(): List { - return miniatures.getMiniatures() - } - - fun getSelectedImage(): Bitmap { - return mainImage.value - } - - fun getSelectedImageName(): String { - return MainImageWrapper.getName() - } - - // filters managing - private lateinit var appliedFilters: FiltersManager - private val filterUIState: MutableMap> = LinkedHashMap() - - private fun toggleFilterState(filter: FilterType) { - - if (!filterUIState.containsKey(filter)) { - filterUIState[filter] = mutableStateOf(true) - } else { - val value = filterUIState[filter]!!.value - filterUIState[filter]!!.value = !value - } - } - - fun toggleFilter(filter: FilterType) { - - if (containsFilter(filter)) { - removeFilter(filter) - } else { - addFilter(filter) - } - - toggleFilterState(filter) - - var bitmap = MainImageWrapper.origin - - if (bitmap != null) { - bitmap = appliedFilters.applyFilters(bitmap) - MainImageWrapper.setImage(bitmap) - mainImage.value = bitmap - } - } - - private fun addFilter(filter: FilterType) { - appliedFilters.add(filter) - MainImageWrapper.addFilter(filter) - } - - private fun removeFilter(filter: FilterType) { - appliedFilters.remove(filter) - MainImageWrapper.removeFilter(filter) - } - - private fun containsFilter(type: FilterType): Boolean { - return appliedFilters.contains(type) - } - - fun isFilterEnabled(type: FilterType): Boolean { - if (!filterUIState.containsKey(type)) { - filterUIState[type] = mutableStateOf(false) - } - return filterUIState[type]!!.value - } - - private fun restoreFilters(): Bitmap { - filterUIState.clear() - appliedFilters.clear() - return MainImageWrapper.restore() - } - - fun restoreMainImage() { - mainImage.value = restoreFilters() - } - - // application content initialization - private fun initData() { - if (isContentReady.value) - return - - val directory = context.cacheDir.absolutePath - - executor.execute { - try { - if (isInternetAvailable()) { - val imageList = repository.get() - - if (imageList.isEmpty()) { - handler.post { - showPopUpMessage( - getString(R.string.repo_invalid), - context - ) - onContentReady() - } - return@execute - } - - val pictureList = loadImages(directory, imageList) - - if (pictureList.isEmpty()) { - handler.post { - showPopUpMessage( - getString(R.string.repo_empty), - context - ) - onContentReady() - } - } else { - val picture = loadFullImage(imageList[0]) - - handler.post { - miniatures.setMiniatures(pictureList) - - if (isMainImageEmpty()) { - wrapPictureIntoMainImage(picture) - } else { - appliedFilters.add(MainImageWrapper.getFilters()) - mainImage.value = MainImageWrapper.getImage() - currentImageIndex.value = MainImageWrapper.getId() - } - onContentReady() - } - } - } else { - handler.post { - showPopUpMessage( - getString(R.string.no_internet), - context - ) - onContentReady() - } - } - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - // preview/fullscreen image managing - fun isMainImageEmpty(): Boolean { - return MainImageWrapper.isEmpty() - } - - fun fullscreen(picture: Picture) { - isContentReady.value = false - AppState.screenState(ScreenType.FullscreenImage) - setMainImage(picture) - } - - fun setMainImage(picture: Picture) { - if (MainImageWrapper.getId() == picture.id) { - if (!isContentReady()) - onContentReady() - return - } - isContentReady.value = false - - executor.execute { - if (isInternetAvailable()) { - - val fullSizePicture = loadFullImage(picture.source) - fullSizePicture.id = picture.id - - handler.post { - wrapPictureIntoMainImage(fullSizePicture) - onContentReady() - } - } else { - handler.post { - showPopUpMessage( - "${getString(R.string.no_internet)}\n${getString(R.string.load_image_unavailable)}", - context - ) - wrapPictureIntoMainImage(picture) - } - } - } - } - - private fun onContentReady() { - isContentReady.value = true - isAppReady.value = true - } - - private fun wrapPictureIntoMainImage(picture: Picture) { - MainImageWrapper.wrapPicture(picture) - MainImageWrapper.saveOrigin() - mainImage.value = picture.image - currentImageIndex.value = picture.id - } - - fun swipeNext() { - if (currentImageIndex.value == miniatures.size() - 1) { - showPopUpMessage( - getString(R.string.last_image), - context - ) - return - } - - restoreFilters() - setMainImage(miniatures.get(++currentImageIndex.value)) - } - - fun swipePrevious() { - if (currentImageIndex.value == 0) { - showPopUpMessage( - getString(R.string.first_image), - context - ) - return - } - - restoreFilters() - setMainImage(miniatures.get(--currentImageIndex.value)) - } - - fun refresh() { - executor.execute { - if (isInternetAvailable()) { - handler.post { - clearCache(context) - MainImageWrapper.clear() - miniatures.clear() - isContentReady.value = false - initData() - } - } else { - handler.post { - showPopUpMessage( - "${getString(R.string.no_internet)}\n${getString(R.string.refresh_unavailable)}", - context - ) - } - } - } - } -} - -private object MainImageWrapper { - // origin image - var origin: Bitmap? = null - private set - - fun saveOrigin() { - origin = copy(picture.value.image) - } - - fun restore(): Bitmap { - - if (origin != null) { - filtersSet.clear() - picture.value.image = copy(origin!!) - } - - return copy(picture.value.image) - } - - // picture adapter - private var picture = mutableStateOf( - Picture(image = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)) - ) - - fun wrapPicture(picture: Picture) { - this.picture.value = picture - } - - fun setImage(bitmap: Bitmap) { - picture.value.image = bitmap - } - - fun isEmpty(): Boolean { - return (picture.value.name == "") - } - - fun clear() { - picture.value = Picture(image = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)) - } - - fun getName(): String { - return picture.value.name - } - - fun getImage(): Bitmap { - return picture.value.image - } - - fun getId(): Int { - return picture.value.id - } - - // applied filters - private var filtersSet: MutableSet = LinkedHashSet() - - fun addFilter(filter: FilterType) { - filtersSet.add(filter) - } - - fun removeFilter(filter: FilterType) { - filtersSet.remove(filter) - } - - fun getFilters(): Set { - return filtersSet - } - - private fun copy(bitmap: Bitmap): Bitmap { - return bitmap.copy(bitmap.config, false) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/ImageHandler.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/ImageHandler.kt deleted file mode 100755 index 627b36ac5a..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/ImageHandler.kt +++ /dev/null @@ -1,131 +0,0 @@ -package example.imageviewer.model - -import android.graphics.Bitmap -import android.graphics.BitmapFactory -import example.imageviewer.utils.cacheImage -import example.imageviewer.utils.cacheImagePostfix -import example.imageviewer.utils.scaleBitmapAspectRatio -import example.imageviewer.utils.toPx -import java.io.File -import java.io.FileInputStream -import java.io.InputStream -import java.io.InputStreamReader -import java.io.BufferedReader -import java.lang.Exception -import java.net.HttpURLConnection -import java.net.URL -import java.nio.charset.StandardCharsets - -fun loadFullImage(source: String): Picture { - try { - val url = URL(source) - val connection: HttpURLConnection = url.openConnection() as HttpURLConnection - connection.connectTimeout = 5000 - connection.connect() - - val input: InputStream = connection.inputStream - val bitmap: Bitmap? = BitmapFactory.decodeStream(input) - if (bitmap != null) { - return Picture( - source = source, - image = bitmap, - name = getNameURL(source), - width = bitmap.width, - height = bitmap.height - ) - } - } catch (e: Exception) { - e.printStackTrace() - } - - return Picture(image = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)) -} - -fun loadImages(cachePath: String, list: List): MutableList { - val result: MutableList = ArrayList() - - for (source in list) { - val name = getNameURL(source) - val path = cachePath + File.separator + name - - if (File(path + "info").exists()) { - addCachedMiniature(filePath = path, outList = result) - } else { - addFreshMiniature(source = source, outList = result, path = cachePath) - } - - result.last().id = result.size - 1 - } - - return result -} - -private fun addFreshMiniature( - source: String, - outList: MutableList, - path: String -) { - try { - val url = URL(source) - val connection: HttpURLConnection = url.openConnection() as HttpURLConnection - connection.connectTimeout = 5000 - connection.connect() - - val input: InputStream = connection.inputStream - val result: Bitmap? = BitmapFactory.decodeStream(input) - - if (result != null) { - val picture = Picture( - source, - getNameURL(source), - scaleBitmapAspectRatio(result, 200, 164), - result.width, - result.height - ) - - outList.add(picture) - cacheImage(path + getNameURL(source), picture) - } - } catch (e: Exception) { - e.printStackTrace() - } -} - -private fun addCachedMiniature( - filePath: String, - outList: MutableList -) { - try { - val read = BufferedReader( - InputStreamReader( - FileInputStream(filePath + cacheImagePostfix), - StandardCharsets.UTF_8 - ) - ) - - val source = read.readLine() - val width = read.readLine().toInt() - val height = read.readLine().toInt() - - read.close() - - val result: Bitmap? = BitmapFactory.decodeFile(filePath) - - if (result != null) { - val picture = Picture( - source, - getNameURL(source), - result, - width, - height - ) - outList.add(picture) - } - } catch (e: Exception) { - e.printStackTrace() - } -} - -private fun getNameURL(url: String): String { - return url.substring(url.lastIndexOf('/') + 1, url.length) -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/Picture.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/Picture.kt deleted file mode 100755 index 50a9f33b0d..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/Picture.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model - -import android.graphics.Bitmap - -actual data class Picture( - var source: String = "", - var name: String = "", - var image: Bitmap, - var width: Int = 0, - var height: Int = 0, - var id: Int = 0 -) \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/BlurFilter.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/BlurFilter.kt deleted file mode 100755 index 3e05416472..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/BlurFilter.kt +++ /dev/null @@ -1,13 +0,0 @@ -package example.imageviewer.model.filtration - -import android.content.Context -import android.graphics.Bitmap -import example.imageviewer.core.BitmapFilter -import example.imageviewer.utils.applyBlurFilter - -class BlurFilter(private val context: Context) : BitmapFilter { - - override fun apply(bitmap: Bitmap): Bitmap { - return applyBlurFilter(bitmap, context) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/EmptyFilter.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/EmptyFilter.kt deleted file mode 100755 index d353a55d00..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/EmptyFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - - -import android.graphics.Bitmap -import example.imageviewer.core.BitmapFilter - -class EmptyFilter : BitmapFilter { - - override fun apply(bitmap: Bitmap): Bitmap { - return bitmap - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/FiltersManager.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/FiltersManager.kt deleted file mode 100755 index 1ada647d21..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/FiltersManager.kt +++ /dev/null @@ -1,54 +0,0 @@ -package example.imageviewer.model.filtration - -import android.content.Context -import android.graphics.Bitmap -import example.imageviewer.core.BitmapFilter -import example.imageviewer.core.FilterType - -class FiltersManager(private val context: Context) { - - private var filtersMap: MutableMap = LinkedHashMap() - - fun clear() { - filtersMap = LinkedHashMap() - } - - fun add(filters: Collection) { - - for (filter in filters) - add(filter) - } - - fun add(filter: FilterType) { - - if (!filtersMap.containsKey(filter)) - filtersMap[filter] = getFilter(filter, context) - } - - fun remove(filter: FilterType) { - filtersMap.remove(filter) - } - - fun contains(filter: FilterType): Boolean { - return filtersMap.contains(filter) - } - - fun applyFilters(bitmap: Bitmap): Bitmap { - - var result: Bitmap = bitmap - for (filter in filtersMap) { - result = filter.value.apply(result) - } - - return result - } -} - -private fun getFilter(type: FilterType, context: Context): BitmapFilter { - - return when (type) { - FilterType.GrayScale -> GrayScaleFilter() - FilterType.Pixel -> PixelFilter() - FilterType.Blur -> BlurFilter(context) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/GrayScaleFilter.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/GrayScaleFilter.kt deleted file mode 100755 index 44ed1f1e3c..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/GrayScaleFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - -import android.graphics.Bitmap -import example.imageviewer.core.BitmapFilter -import example.imageviewer.utils.applyGrayScaleFilter - -class GrayScaleFilter : BitmapFilter { - - override fun apply(bitmap: Bitmap) : Bitmap { - return applyGrayScaleFilter(bitmap) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/PixelFilter.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/PixelFilter.kt deleted file mode 100755 index c9a265a7e2..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/model/filtration/PixelFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - -import android.graphics.Bitmap -import example.imageviewer.core.BitmapFilter -import example.imageviewer.utils.applyPixelFilter - -class PixelFilter : BitmapFilter { - - override fun apply(bitmap: Bitmap): Bitmap { - return applyPixelFilter(bitmap) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt deleted file mode 100755 index 77cea5c2be..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/style/Decoration.kt +++ /dev/null @@ -1,38 +0,0 @@ -package example.imageviewer.style - -import androidx.compose.runtime.Composable -import androidx.compose.ui.res.painterResource -import example.imageviewer.common.R - -@Composable -fun icEmpty() = painterResource(R.drawable.empty) - -@Composable -fun icBack() = painterResource(R.drawable.back) - -@Composable -fun icRefresh() = painterResource(R.drawable.refresh) - -@Composable -fun icDots() = painterResource(R.drawable.dots) - -@Composable -fun icFilterGrayscaleOn() = painterResource(R.drawable.grayscale_on) - -@Composable -fun icFilterGrayscaleOff() = painterResource(R.drawable.grayscale_off) - -@Composable -fun icFilterPixelOn() = painterResource(R.drawable.pixel_on) - -@Composable -fun icFilterPixelOff() = painterResource(R.drawable.pixel_off) - -@Composable -fun icFilterBlurOn() = painterResource(R.drawable.blur_on) - -@Composable -fun icFilterBlurOff() = painterResource(R.drawable.blur_off) - -@Composable -fun icFilterUnknown() = painterResource(R.drawable.filter_unknown) diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/Caching.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/Caching.kt deleted file mode 100755 index 7059938cb8..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/Caching.kt +++ /dev/null @@ -1,52 +0,0 @@ -package example.imageviewer.utils - -import android.content.Context -import android.graphics.* -import example.imageviewer.model.Picture -import java.io.File -import java.io.BufferedWriter -import java.io.OutputStreamWriter -import java.io.FileOutputStream -import java.io.IOException -import java.nio.charset.StandardCharsets - -val cacheImagePostfix = "info" - -fun cacheImage(path: String, picture: Picture) { - try { - FileOutputStream(path).use { out -> - picture.image.compress(Bitmap.CompressFormat.PNG, 100, out) - } - - val bw = - BufferedWriter( - OutputStreamWriter( - FileOutputStream(path + cacheImagePostfix), StandardCharsets.UTF_8 - ) - ) - - bw.write(picture.source) - bw.write("\r\n${picture.width}") - bw.write("\r\n${picture.height}") - bw.close() - - } catch (e: IOException) { - e.printStackTrace() - } -} - -fun clearCache(context: Context) { - - val directory = File(context.cacheDir.absolutePath) - - val files: Array? = directory.listFiles() - - if (files != null) { - for (file in files) { - if (file.isDirectory) - continue - - file.delete() - } - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/Coroutines.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/Coroutines.kt deleted file mode 100644 index ab006ef147..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/Coroutines.kt +++ /dev/null @@ -1,9 +0,0 @@ -package example.imageviewer.utils - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -actual fun runBlocking( - context: CoroutineContext, - block: suspend CoroutineScope.() -> T -): T = kotlinx.coroutines.runBlocking(context, block) \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/GraphicsMath.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/GraphicsMath.kt deleted file mode 100755 index 32e234da08..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/utils/GraphicsMath.kt +++ /dev/null @@ -1,195 +0,0 @@ -package example.imageviewer.utils - -import android.content.Context -import android.content.res.Resources -import android.graphics.* -import android.renderscript.Allocation -import android.renderscript.Element -import android.renderscript.RenderScript -import android.renderscript.ScriptIntrinsicBlur -import androidx.compose.ui.layout.ContentScale -import kotlin.math.pow -import kotlin.math.roundToInt -import example.imageviewer.view.DragHandler - -fun scaleBitmapAspectRatio( - bitmap: Bitmap, - width: Int, - height: Int, - filter: Boolean = false -): Bitmap { - val boundW: Float = width.toFloat() - val boundH: Float = height.toFloat() - - val ratioX: Float = boundW / bitmap.width - val ratioY: Float = boundH / bitmap.height - val ratio: Float = if (ratioX < ratioY) ratioX else ratioY - - val resultH = (bitmap.height * ratio).toInt() - val resultW = (bitmap.width * ratio).toInt() - - return Bitmap.createScaledBitmap(bitmap, resultW, resultH, filter) -} - -fun getDisplayBounds(bitmap: Bitmap): Rect { - - val boundW: Float = displayWidth().toFloat() - val boundH: Float = displayHeight().toFloat() - - val ratioX: Float = bitmap.width / boundW - val ratioY: Float = bitmap.height / boundH - val ratio: Float = if (ratioX > ratioY) ratioX else ratioY - val resultW = (boundW * ratio) - val resultH = (boundH * ratio) - - return Rect(0, 0, resultW.toInt(), resultH.toInt()) -} - -fun applyGrayScaleFilter(bitmap: Bitmap): Bitmap { - - val result: Bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true) - - val canvas = Canvas(result) - - val colorMatrix = ColorMatrix() - colorMatrix.setSaturation(0f) - - val paint = Paint() - paint.colorFilter = ColorMatrixColorFilter(colorMatrix) - - canvas.drawBitmap(result, 0f, 0f, paint) - - return result -} - -fun applyPixelFilter(bitmap: Bitmap): Bitmap { - - var result: Bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true) - val w: Int = bitmap.width - val h: Int = bitmap.height - result = scaleBitmapAspectRatio(result, w / 20, h / 20) - result = scaleBitmapAspectRatio(result, w, h) - - return result -} - -fun applyBlurFilter(bitmap: Bitmap, context: Context): Bitmap { - - val result: Bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true) - - val renderScript: RenderScript = RenderScript.create(context) - - val tmpIn: Allocation = Allocation.createFromBitmap(renderScript, bitmap) - val tmpOut: Allocation = Allocation.createFromBitmap(renderScript, result) - - val theIntrinsic: ScriptIntrinsicBlur = - ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript)) - - theIntrinsic.setRadius(25f) - theIntrinsic.setInput(tmpIn) - theIntrinsic.forEach(tmpOut) - - tmpOut.copyTo(result) - - return result -} - -fun adjustImageScale(bitmap: Bitmap): ContentScale { - val bitmapRatio = (10 * bitmap.width.toFloat() / bitmap.height).toInt() - val displayRatio = (10 * displayWidth().toFloat() / displayHeight()).toInt() - - if (displayRatio > bitmapRatio) { - return ContentScale.FillHeight - } - return ContentScale.FillWidth -} - -fun toPx(dp: Int): Int { - return (dp * Resources.getSystem().displayMetrics.density).toInt() -} - -fun toDp(px: Int): Int { - return (px / Resources.getSystem().displayMetrics.density).toInt() -} - -fun displayWidth(): Int { - return Resources.getSystem().displayMetrics.widthPixels -} - -fun displayHeight(): Int { - return Resources.getSystem().displayMetrics.heightPixels -} - -fun cropBitmapByScale(bitmap: Bitmap, scale: Float, drag: DragHandler): Bitmap { - val crop = cropBitmapByBounds( - bitmap, - getDisplayBounds(bitmap), - scale, - drag - ) - return Bitmap.createBitmap( - bitmap, - crop.left, - crop.top, - crop.right - crop.left, - crop.bottom - crop.top - ) -} - -fun cropBitmapByBounds( - bitmap: Bitmap, - bounds: Rect, - scaleFactor: Float, - drag: DragHandler -): Rect { - if (scaleFactor <= 1f) - return Rect(0, 0, bitmap.width, bitmap.height) - - var scale = scaleFactor.toDouble().pow(1.4) - - var boundW = (bounds.width() / scale).roundToInt() - var boundH = (bounds.height() / scale).roundToInt() - - scale *= displayWidth() / bounds.width().toDouble() - - val offsetX = drag.getAmount().x / scale - val offsetY = drag.getAmount().y / scale - - if (boundW > bitmap.width) { - boundW = bitmap.width - } - if (boundH > bitmap.height) { - boundH = bitmap.height - } - - val invisibleW = bitmap.width - boundW - var leftOffset = (invisibleW / 2.0 - offsetX).roundToInt().toFloat() - - if (leftOffset > invisibleW) { - leftOffset = invisibleW.toFloat() - drag.getAmount().x = -((invisibleW / 2.0) * scale).roundToInt().toFloat() - } - if (leftOffset < 0) { - drag.getAmount().x = ((invisibleW / 2.0) * scale).roundToInt().toFloat() - leftOffset = 0f - } - - val invisibleH = bitmap.height - boundH - var topOffset = (invisibleH / 2 - offsetY).roundToInt().toFloat() - - if (topOffset > invisibleH) { - topOffset = invisibleH.toFloat() - drag.getAmount().y = -((invisibleH / 2.0) * scale).roundToInt().toFloat() - } - if (topOffset < 0) { - drag.getAmount().y = ((invisibleH / 2.0) * scale).roundToInt().toFloat() - topOffset = 0f - } - - return Rect( - leftOffset.toInt(), - topOffset.toInt(), - (leftOffset + boundW).toInt(), - (topOffset + boundH).toInt() - ) -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AppUI.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AppUI.kt deleted file mode 100755 index dacce3b7c3..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AppUI.kt +++ /dev/null @@ -1,40 +0,0 @@ -package example.imageviewer.view - -import android.content.Context -import android.widget.Toast -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.Surface -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import example.imageviewer.model.AppState -import example.imageviewer.model.ScreenType -import example.imageviewer.model.ContentState -import example.imageviewer.style.Gray - -@Composable -fun AppUI(content: ContentState) { - - Surface( - modifier = Modifier.fillMaxSize(), - color = Gray - ) { - when (AppState.screenState()) { - ScreenType.MainScreen -> { - MainScreen(content) - } - ScreenType.FullscreenImage -> { - FullscreenImage(content) - } - } - } -} - -fun showPopUpMessage(text: String, context: Context) { - Toast.makeText( - context, - text, - Toast.LENGTH_SHORT - ).show() -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullscreenImage.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullscreenImage.kt deleted file mode 100644 index 1c0e7d73b4..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/FullscreenImage.kt +++ /dev/null @@ -1,197 +0,0 @@ -package example.imageviewer.view - -import android.graphics.Bitmap -import android.graphics.Rect -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.horizontalScroll -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.unit.dp -import example.imageviewer.core.FilterType -import example.imageviewer.model.AppState -import example.imageviewer.model.ContentState -import example.imageviewer.model.ScreenType -import example.imageviewer.style.DarkGray -import example.imageviewer.style.DarkGreen -import example.imageviewer.style.Foreground -import example.imageviewer.style.MiniatureColor -import example.imageviewer.style.Transparent -import example.imageviewer.style.icBack -import example.imageviewer.style.icFilterBlurOff -import example.imageviewer.style.icFilterBlurOn -import example.imageviewer.style.icFilterGrayscaleOff -import example.imageviewer.style.icFilterGrayscaleOn -import example.imageviewer.style.icFilterPixelOff -import example.imageviewer.style.icFilterPixelOn -import example.imageviewer.utils.adjustImageScale -import example.imageviewer.utils.cropBitmapByScale -import example.imageviewer.utils.displayWidth -import example.imageviewer.utils.getDisplayBounds -import kotlin.math.abs -import kotlin.math.pow -import kotlin.math.roundToInt - -@Composable -fun FullscreenImage( - content: ContentState -) { - Column { - ToolBar(content.getSelectedImageName(), content) - Image(content) - } - if (!content.isContentReady()) { - LoadingScreen() - } -} - -@Composable -fun ToolBar( - text: String, - content: ContentState -) { - val scrollState = rememberScrollState() - Surface(color = MiniatureColor, modifier = Modifier.height(44.dp)) { - Row(modifier = Modifier.padding(end = 30.dp)) { - Surface( - color = Transparent, - modifier = Modifier.padding(start = 20.dp).align(Alignment.CenterVertically), - shape = CircleShape - ) { - Clickable( - onClick = { - if (content.isContentReady()) { - content.restoreMainImage() - AppState.screenState(ScreenType.MainScreen) - } - }) { - Image( - icBack(), - contentDescription = null, - modifier = Modifier.size(38.dp) - ) - } - } - Text( - text, - color = Foreground, - maxLines = 1, - modifier = Modifier.padding(start = 30.dp).weight(1f) - .align(Alignment.CenterVertically), - style = MaterialTheme.typography.body1 - ) - - Surface( - color = Color(255, 255, 255, 40), - modifier = Modifier.size(154.dp, 38.dp) - .align(Alignment.CenterVertically), - shape = CircleShape - ) { - Row(Modifier.horizontalScroll(scrollState)) { - for (type in FilterType.values()) { - FilterButton(content, type) - } - } - } - } - } -} - -@Composable -fun FilterButton( - content: ContentState, - type: FilterType, - modifier: Modifier = Modifier.size(38.dp) -) { - Box( - modifier = Modifier.background(color = Transparent).clip(CircleShape) - ) { - Clickable( - onClick = { content.toggleFilter(type) } - ) { - Image( - getFilterImage(type = type, content = content), - contentDescription = null, - modifier - ) - } - } - - Spacer(Modifier.width(20.dp)) -} - -@Composable -fun getFilterImage(type: FilterType, content: ContentState): Painter { - return when (type) { - FilterType.GrayScale -> if (content.isFilterEnabled(type)) icFilterGrayscaleOn() else icFilterGrayscaleOff() - FilterType.Pixel -> if (content.isFilterEnabled(type)) icFilterPixelOn() else icFilterPixelOff() - FilterType.Blur -> if (content.isFilterEnabled(type)) icFilterBlurOn() else icFilterBlurOff() - } -} - -@Composable -fun Image(content: ContentState) { - val drag = remember { DragHandler() } - val scale = remember { ScaleHandler() } - - Surface( - color = DarkGray, - modifier = Modifier.fillMaxSize() - ) { - Draggable(dragHandler = drag, modifier = Modifier.fillMaxSize()) { - Scalable(onScale = scale, modifier = Modifier.fillMaxSize()) { - val bitmap = imageByGesture(content, scale, drag) - Image( - bitmap = bitmap.asImageBitmap(), - contentDescription = null, - contentScale = adjustImageScale(bitmap) - ) - } - } - } -} - -@Composable -fun imageByGesture( - content: ContentState, - scale: ScaleHandler, - drag: DragHandler -): Bitmap { - val bitmap = cropBitmapByScale(content.getSelectedImage(), scale.factor.value, drag) - - if (scale.factor.value > 1f) - return bitmap - - if (abs(drag.getDistance().x) > displayWidth() / 10) { - if (drag.getDistance().x < 0) { - content.swipeNext() - } else { - content.swipePrevious() - } - drag.cancel() - } - - return bitmap -} diff --git a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt b/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt deleted file mode 100755 index 5509e28050..0000000000 --- a/examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/MainScreen.kt +++ /dev/null @@ -1,218 +0,0 @@ -package example.imageviewer.view - -import android.content.res.Configuration -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.foundation.Image -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Card -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.RectangleShape -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.graphics.painter.BitmapPainter -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.unit.dp -import example.imageviewer.common.R -import example.imageviewer.model.AppState -import example.imageviewer.model.ContentState -import example.imageviewer.model.Picture -import example.imageviewer.model.ScreenType -import example.imageviewer.style.DarkGray -import example.imageviewer.style.DarkGreen -import example.imageviewer.style.Foreground -import example.imageviewer.style.LightGray -import example.imageviewer.style.MiniatureColor -import example.imageviewer.style.Transparent -import example.imageviewer.style.icDots -import example.imageviewer.style.icEmpty -import example.imageviewer.style.icRefresh - -@Composable -fun MainScreen(content: ContentState) { - Column { - TopContent(content) - ScrollableArea(content) - } - if (!content.isContentReady()) { - LoadingScreen(content.getString(R.string.loading)) - } -} - -@Composable -fun TopContent(content: ContentState) { - TitleBar(text = content.getString(R.string.app_name), content = content) - if (content.getOrientation() == Configuration.ORIENTATION_PORTRAIT) { - PreviewImage(content) - Spacer(modifier = Modifier.height(10.dp)) - Divider() - } - Spacer(modifier = Modifier.height(5.dp)) -} - -@Composable -fun TitleBar(text: String, content: ContentState) { - TopAppBar( - backgroundColor = DarkGreen, - title = { - Row(Modifier.height(50.dp)) { - Text( - text, - color = Foreground, - modifier = Modifier.weight(1f).align(Alignment.CenterVertically) - ) - Surface( - color = Transparent, - modifier = Modifier.padding(end = 20.dp).align(Alignment.CenterVertically), - shape = CircleShape - ) { - Clickable( - onClick = { - if (content.isContentReady()) { - content.refresh() - } - } - ) { - Image( - icRefresh(), - contentDescription = null, - modifier = Modifier.size(35.dp) - ) - } - } - } - }) -} - -@Composable -fun PreviewImage(content: ContentState) { - Clickable(onClick = { - AppState.screenState(ScreenType.FullscreenImage) - }) { - Card( - backgroundColor = DarkGray, - modifier = Modifier.height(250.dp), - shape = RectangleShape, - elevation = 1.dp - ) { - Image( - if (content.isMainImageEmpty()) { - icEmpty() - } else { - BitmapPainter(content.getSelectedImage().asImageBitmap()) - }, - contentDescription = null, - modifier = Modifier - .fillMaxWidth().padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 5.dp), - contentScale = ContentScale.Fit - ) - } - } -} - -@Composable -fun Miniature( - picture: Picture, - content: ContentState -) { - Card( - backgroundColor = MiniatureColor, - modifier = Modifier.padding(start = 10.dp, end = 10.dp).height(70.dp) - .fillMaxWidth() - .clickable { - content.setMainImage(picture) - }, - shape = RectangleShape, - elevation = 2.dp - ) { - Row(modifier = Modifier.padding(end = 30.dp)) { - Clickable( - onClick = { - content.fullscreen(picture) - } - ) { - Image( - picture.image.asImageBitmap(), - contentDescription = null, - modifier = Modifier.height(70.dp) - .width(90.dp) - .padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 1.dp), - contentScale = ContentScale.Crop - ) - } - Text( - text = picture.name, - color = Foreground, - modifier = Modifier.weight(1f).align(Alignment.CenterVertically).padding(start = 16.dp), - style = MaterialTheme.typography.body1 - ) - - Clickable( - modifier = Modifier.height(70.dp) - .width(30.dp), - onClick = { - showPopUpMessage( - "${content.getString(R.string.picture)} " + - "${picture.name} \n" + - "${content.getString(R.string.size)} " + - "${picture.width}x${picture.height} " + - "${content.getString(R.string.pixels)}", - content.getContext() - ) - } - ) { - Image( - icDots(), - contentDescription = null, - modifier = Modifier.height(70.dp) - .width(30.dp) - .padding(start = 1.dp, top = 25.dp, end = 1.dp, bottom = 25.dp), - contentScale = ContentScale.FillHeight - ) - } - } - } -} - -@Composable -fun ScrollableArea(content: ContentState) { - var index = 1 - val scrollState = rememberScrollState() - Column(Modifier.verticalScroll(scrollState)) { - for (picture in content.getMiniatures()) { - Miniature( - picture = picture, - content = content - ) - Spacer(modifier = Modifier.height(5.dp)) - index++ - } - } -} - -@Composable -fun Divider() { - Divider( - color = LightGray, - modifier = Modifier.padding(start = 10.dp, end = 10.dp) - ) -} diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/back.png b/examples/imageviewer/common/src/androidMain/res/drawable/back.png deleted file mode 100755 index 206b8d4678..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/back.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/blur_off.png b/examples/imageviewer/common/src/androidMain/res/drawable/blur_off.png deleted file mode 100755 index e632616157..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/blur_off.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/blur_on.png b/examples/imageviewer/common/src/androidMain/res/drawable/blur_on.png deleted file mode 100755 index 7f5ad81bd6..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/blur_on.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/empty.png b/examples/imageviewer/common/src/androidMain/res/drawable/empty.png deleted file mode 100755 index 54e9007671..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/empty.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/filter_unknown.png b/examples/imageviewer/common/src/androidMain/res/drawable/filter_unknown.png deleted file mode 100755 index 9193c3f33e..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/filter_unknown.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/grayscale_off.png b/examples/imageviewer/common/src/androidMain/res/drawable/grayscale_off.png deleted file mode 100755 index 57fbe7891c..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/grayscale_off.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/grayscale_on.png b/examples/imageviewer/common/src/androidMain/res/drawable/grayscale_on.png deleted file mode 100755 index ffe1f6102b..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/grayscale_on.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/pixel_off.png b/examples/imageviewer/common/src/androidMain/res/drawable/pixel_off.png deleted file mode 100755 index a41ebfe04e..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/pixel_off.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/pixel_on.png b/examples/imageviewer/common/src/androidMain/res/drawable/pixel_on.png deleted file mode 100755 index 1482ff8583..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/pixel_on.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/refresh.png b/examples/imageviewer/common/src/androidMain/res/drawable/refresh.png deleted file mode 100755 index 3be99c1944..0000000000 Binary files a/examples/imageviewer/common/src/androidMain/res/drawable/refresh.png and /dev/null differ diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml b/examples/imageviewer/common/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml deleted file mode 100755 index 706b9a150c..0000000000 --- a/examples/imageviewer/common/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml b/examples/imageviewer/common/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml deleted file mode 100755 index 706b9a150c..0000000000 --- a/examples/imageviewer/common/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/res/values-ru/strings.xml b/examples/imageviewer/common/src/androidMain/res/values-ru/strings.xml deleted file mode 100755 index 1f3b09a7d3..0000000000 --- a/examples/imageviewer/common/src/androidMain/res/values-ru/strings.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - ImageViewer - Загружаем изображения... - Репозиторий пуст. - Нет доступа в интернет. - Список изображений в репозитории пуст или имеет неверный формат. - Невозможно обновить изображения. - Невозможно загузить полное изображение. - Это последнее изображение. - Это первое изображение. - Изображение: - Размеры: - пикселей. - \ No newline at end of file diff --git a/examples/imageviewer/common/src/androidMain/res/values/strings.xml b/examples/imageviewer/common/src/androidMain/res/values/strings.xml deleted file mode 100755 index e2ae85b003..0000000000 --- a/examples/imageviewer/common/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,14 +0,0 @@ - - ImageViewer - Loading images... - Repository is empty. - No internet access. - List of images in current repository is invalid or empty. - Cannot refresh images. - Cannot load full size image. - This is last image. - This is first image. - Picture: - Size: - pixels. - \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/EventLocker.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/EventLocker.kt deleted file mode 100755 index f31ab9ca61..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/EventLocker.kt +++ /dev/null @@ -1,18 +0,0 @@ -package example.imageviewer.core - -class EventLocker { - - private var value: Boolean = false - - fun lock() { - value = false - } - - fun unlock() { - value = true - } - - fun isLocked(): Boolean { - return value - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/FilterType.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/FilterType.kt deleted file mode 100755 index 53ad4ee60f..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/FilterType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package example.imageviewer.core - -enum class FilterType { - GrayScale, Pixel, Blur -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/Repository.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/Repository.kt deleted file mode 100755 index df6cd11ff0..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/core/Repository.kt +++ /dev/null @@ -1,5 +0,0 @@ -package example.imageviewer.core - -interface Repository { - fun get() : T -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/ImageRepository.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/ImageRepository.kt deleted file mode 100755 index 14178fa238..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/ImageRepository.kt +++ /dev/null @@ -1,33 +0,0 @@ -// READ ME FIRST! -// -// Code in this file is shared between the Android and Desktop JVM targets. -// Kotlin's hierarchical multiplatform projects currently -// don't support sharing code depending on JVM declarations. -// -// You can follow the progress for HMPP JVM & Android intermediate source sets here: -// https://youtrack.jetbrains.com/issue/KT-42466 -// -// The workaround used here to access JVM libraries causes IntelliJ IDEA to not -// resolve symbols in this file properly. -// -// Resolution errors in your IDE do not indicate a problem with your setup. - - -package example.imageviewer.model - -import example.imageviewer.core.Repository -import example.imageviewer.utils.ktorHttpClient -import example.imageviewer.utils.runBlocking -import io.ktor.client.request.* - -class ImageRepository( - private val httpsURL: String -) : Repository> { - - override fun get(): MutableList { - return runBlocking { - val content = ktorHttpClient.get(httpsURL) - content.lines().toMutableList() - } - } -} diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/Miniatures.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/Miniatures.kt deleted file mode 100755 index 4daaca3940..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/Miniatures.kt +++ /dev/null @@ -1,41 +0,0 @@ -// READ ME FIRST! -// -// Code in this file is shared between the Android and Desktop JVM targets. -// Kotlin's hierarchical multiplatform projects currently -// don't support sharing code depending on JVM declarations. -// -// You can follow the progress for HMPP JVM & Android intermediate source sets here: -// https://youtrack.jetbrains.com/issue/KT-42466 -// -// The workaround used here to access JVM libraries causes IntelliJ IDEA to not -// resolve symbols in this file properly. -// -// Resolution errors in your IDE do not indicate a problem with your setup. - -package example.imageviewer.model - -expect class Picture - -class Miniatures( - private var list: List = emptyList() -) { - fun get(index: Int): Picture { - return list[index] - } - - fun getMiniatures(): List { - return list.toList() - } - - fun setMiniatures(list: List) { - this.list = list.toList() - } - - fun size(): Int { - return list.size - } - - fun clear() { - list = emptyList() - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/ScreenType.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/ScreenType.kt deleted file mode 100755 index 8e38a79e52..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/model/ScreenType.kt +++ /dev/null @@ -1,23 +0,0 @@ -package example.imageviewer.model - -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf - -enum class ScreenType { - MainScreen, FullscreenImage -} - -object AppState { - private var screen: MutableState - init { - screen = mutableStateOf(ScreenType.MainScreen) - } - - fun screenState() : ScreenType { - return screen.value - } - - fun screenState(state: ScreenType) { - screen.value = state - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/style/Palette.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/style/Palette.kt deleted file mode 100755 index ca4b822fe4..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/style/Palette.kt +++ /dev/null @@ -1,16 +0,0 @@ -package example.imageviewer.style - -import androidx.compose.ui.graphics.Color - -val DarkGreen = Color(16, 139, 102) -val Gray = Color.DarkGray -val LightGray = Color(100, 100, 100) -val DarkGray = Color(32, 32, 32) -val PreviewImageAreaHoverColor = Color(45, 45, 45) -val ToastBackground = Color(23, 23, 23) -val MiniatureColor = Color(50, 50, 50) -val MiniatureHoverColor = Color(55, 55, 55) -val Foreground = Color(210, 210, 210) -val TranslucentBlack = Color(0, 0, 0, 60) -val TranslucentWhite = Color(255, 255, 255, 20) -val Transparent = Color.Transparent \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/utils/Coroutines.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/utils/Coroutines.kt deleted file mode 100644 index d35b09543e..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/utils/Coroutines.kt +++ /dev/null @@ -1,7 +0,0 @@ -package example.imageviewer.utils - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext - -expect fun runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/utils/Network.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/utils/Network.kt deleted file mode 100755 index c2d5a23bfa..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/utils/Network.kt +++ /dev/null @@ -1,37 +0,0 @@ -// READ ME FIRST! -// -// Code in this file is shared between the Android and Desktop JVM targets. -// Kotlin's hierarchical multiplatform projects currently -// don't support sharing code depending on JVM declarations. -// -// You can follow the progress for HMPP JVM & Android intermediate source sets here: -// https://youtrack.jetbrains.com/issue/KT-42466 -// -// The workaround used here to access JVM libraries causes IntelliJ IDEA to not -// resolve symbols in this file properly. -// -// Resolution errors in your IDE do not indicate a problem with your setup. - -package example.imageviewer.utils - -import io.ktor.client.* -import io.ktor.client.request.* -import kotlinx.coroutines.Deferred -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.async - -//import java.net.InetAddress - -fun isInternetAvailable(): Boolean { - return runBlocking { - try { - ktorHttpClient.head("http://google.com") - true - } catch (e: Exception) { - println(e.message) - false - } - } -} - -val ktorHttpClient = HttpClient {} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt deleted file mode 100755 index 8eae0782da..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Clickable.kt +++ /dev/null @@ -1,21 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.runtime.Composable -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.ui.Modifier - -@Composable -fun Clickable( - modifier: Modifier = Modifier, - onClick: (() -> Unit)? = null, - children: @Composable () -> Unit = { } -) { - Box( - modifier = modifier.clickable { - onClick?.invoke() - } - ) { - children() - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt deleted file mode 100755 index eabbadc4ef..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt +++ /dev/null @@ -1,88 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.gestures.detectDragGestures -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.ui.input.pointer.pointerInput -import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset -import example.imageviewer.core.EventLocker -import example.imageviewer.style.Transparent - -@Composable -fun Draggable( - dragHandler: DragHandler, - modifier: Modifier = Modifier, - onUpdate: (() -> Unit)? = null, - children: @Composable() () -> Unit -) { - Surface( - color = Transparent, - modifier = modifier.pointerInput(Unit) { - detectDragGestures( - onDragStart = { dragHandler.reset() }, - onDragEnd = { dragHandler.reset() }, - onDragCancel = { dragHandler.cancel() }, - ) { change, dragAmount -> - dragHandler.drag(dragAmount) - onUpdate?.invoke() - change.consume() - } - } - ) { - children() - } -} - -class DragHandler { - - private val amount = mutableStateOf(Point(0f, 0f)) - private val distance = mutableStateOf(Point(0f, 0f)) - private val locker: EventLocker = EventLocker() - - fun getAmount(): Point { - return amount.value - } - - fun getDistance(): Point { - return distance.value - } - - fun reset() { - distance.value = Point(Offset.Zero) - locker.unlock() - } - - fun cancel() { - distance.value = Point(Offset.Zero) - locker.lock() - } - - fun drag(dragDistance: Offset) { - if (locker.isLocked()) { - val dx = dragDistance.x - val dy = dragDistance.y - - distance.value = Point(distance.value.x + dx, distance.value.y + dy) - amount.value = Point(amount.value.x + dx, amount.value.y + dy) - } - } -} - -class Point { - var x: Float = 0f - var y: Float = 0f - constructor(x: Float, y: Float) { - this.x = x - this.y = y - } - constructor(point: Offset) { - this.x = point.x - this.y = point.y - } - fun setAttr(x: Float, y: Float) { - this.x = x - this.y = y - } -} diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/LoadingScreen.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/LoadingScreen.kt deleted file mode 100644 index 8a6a4191f6..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/LoadingScreen.kt +++ /dev/null @@ -1,43 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import example.imageviewer.style.DarkGray -import example.imageviewer.style.DarkGreen -import example.imageviewer.style.Foreground -import example.imageviewer.style.TranslucentBlack - -@Composable -fun LoadingScreen(text: String = "") { - Box( - modifier = Modifier.fillMaxSize().background(color = TranslucentBlack) - ) { - Box(modifier = Modifier.align(Alignment.Center)) { - Surface(color = DarkGray, elevation = 4.dp, shape = CircleShape) { - CircularProgressIndicator( - modifier = Modifier.size(50.dp).padding(3.dp, 3.dp, 4.dp, 4.dp), - color = DarkGreen - ) - } - } - Text( - text = text, - modifier = Modifier.align(Alignment.Center).offset(0.dp, 70.dp), - style = MaterialTheme.typography.body1, - color = Foreground - ) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Scalable.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Scalable.kt deleted file mode 100755 index ef9887c4f6..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Scalable.kt +++ /dev/null @@ -1,47 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.gestures.detectTapGestures -import androidx.compose.foundation.gestures.detectTransformGestures -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.ui.Modifier -import androidx.compose.ui.input.pointer.pointerInput -import example.imageviewer.style.Transparent - -@Composable -fun Scalable( - onScale: ScaleHandler, - modifier: Modifier = Modifier, - children: @Composable() () -> Unit -) { - Surface( - color = Transparent, - modifier = modifier.pointerInput(Unit) { - detectTapGestures(onDoubleTap = { onScale.reset() }) - detectTransformGestures { _, _, zoom, _ -> - onScale.onScale(zoom) - } - }, - ) { - children() - } -} - -class ScaleHandler(private val maxFactor: Float = 5f, private val minFactor: Float = 1f) { - val factor = mutableStateOf(1f) - - fun reset() { - if (factor.value > minFactor) - factor.value = minFactor - } - - fun onScale(scaleFactor: Float): Float { - factor.value += scaleFactor - 1f - - if (maxFactor < factor.value) factor.value = maxFactor - if (minFactor > factor.value) factor.value = minFactor - - return scaleFactor - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/SplashUI.kt b/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/SplashUI.kt deleted file mode 100644 index 544121d2d2..0000000000 --- a/examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/SplashUI.kt +++ /dev/null @@ -1,27 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.sp -import example.imageviewer.style.DarkGray - -@Composable -fun SplashUI() { - Box(Modifier.fillMaxSize().background(DarkGray)) { - Text( - // TODO implement common resources - "Image Viewer", - Modifier.align(Alignment.Center), - color = Color.White, - fontWeight = FontWeight.Bold, - fontSize = 100.sp - ) - } -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/R.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/R.kt deleted file mode 100755 index ef361ecc84..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/R.kt +++ /dev/null @@ -1,53 +0,0 @@ -package example.imageviewer - -object ResString { - - val appName: String - val loading: String - val repoEmpty: String - val noInternet: String - val repoInvalid: String - val refreshUnavailable: String - val loadImageUnavailable: String - val lastImage: String - val firstImage: String - val picture: String - val size: String - val pixels: String - val back: String - val refresh: String - - init { - if (System.getProperty("user.language").equals("ru")) { - appName = "ImageViewer" - loading = "Загружаем изображения..." - repoEmpty = "Репозиторий пуст." - noInternet = "Нет доступа в интернет." - repoInvalid = "Список изображений в репозитории пуст или имеет неверный формат." - refreshUnavailable = "Невозможно обновить изображения." - loadImageUnavailable = "Невозможно загузить полное изображение." - lastImage = "Это последнее изображение." - firstImage = "Это первое изображение." - picture = "Изображение:" - size = "Размеры:" - pixels = "пикселей." - back = "Назад" - refresh = "Обновить" - } else { - appName = "ImageViewer" - loading = "Loading images..." - repoEmpty = "Repository is empty." - noInternet = "No internet access." - repoInvalid = "List of images in current repository is invalid or empty." - refreshUnavailable = "Cannot refresh images." - loadImageUnavailable = "Cannot load full size image." - lastImage = "This is last image." - firstImage = "This is first image." - picture = "Picture:" - size = "Size:" - pixels = "pixels." - back = "Back" - refresh = "Refresh" - } - } -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/core/BitmapFilter.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/core/BitmapFilter.kt deleted file mode 100755 index b8dcdbae47..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/core/BitmapFilter.kt +++ /dev/null @@ -1,7 +0,0 @@ -package example.imageviewer.core - -import java.awt.image.BufferedImage - -interface BitmapFilter { - fun apply(bitmap: BufferedImage) : BufferedImage -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt deleted file mode 100644 index 36e0983da8..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt +++ /dev/null @@ -1,362 +0,0 @@ -package example.imageviewer.model - -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.graphics.toComposeImageBitmap -import example.imageviewer.ResString -import example.imageviewer.core.FilterType -import example.imageviewer.model.filtration.FiltersManager -import example.imageviewer.utils.cacheImagePath -import example.imageviewer.utils.clearCache -import example.imageviewer.utils.isInternetAvailable -import example.imageviewer.view.showPopUpMessage -import example.imageviewer.view.DragHandler -import example.imageviewer.view.ScaleHandler -import example.imageviewer.utils.cropBitmapByScale -import example.imageviewer.utils.toByteArray -import java.awt.image.BufferedImage -import java.io.File -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.CoroutineScope -import org.jetbrains.skia.Image - -object ContentState { - val drag = DragHandler() - val scale = ScaleHandler() - lateinit var windowState: WindowState - private lateinit var repository: ImageRepository - private lateinit var uriRepository: String - val scope = CoroutineScope(Dispatchers.IO) - - fun applyContent(state: WindowState, uriRepository: String): ContentState { - windowState = state - if (this::uriRepository.isInitialized && this.uriRepository == uriRepository) { - return this - } - this.uriRepository = uriRepository - repository = ImageRepository(uriRepository) - isContentReady.value = false - - initData() - - return this - } - - private val isAppReady = mutableStateOf(false) - fun isAppReady(): Boolean { - return isAppReady.value - } - - private val isContentReady = mutableStateOf(false) - fun isContentReady(): Boolean { - return isContentReady.value - } - - // drawable content - private val mainImage = mutableStateOf(BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) - private val currentImageIndex = mutableStateOf(0) - private val miniatures = Miniatures() - - fun getMiniatures(): List { - return miniatures.getMiniatures() - } - - fun getSelectedImage(): ImageBitmap { - return MainImageWrapper.mainImageAsImageBitmap.value - } - - fun getSelectedImageName(): String { - return MainImageWrapper.getName() - } - - // filters managing - private val appliedFilters = FiltersManager() - private val filterUIState: MutableMap> = LinkedHashMap() - - private fun toggleFilterState(filter: FilterType) { - if (!filterUIState.containsKey(filter)) { - filterUIState[filter] = mutableStateOf(true) - } else { - val value = filterUIState[filter]!!.value - filterUIState[filter]!!.value = !value - } - } - - fun toggleFilter(filter: FilterType) { - if (containsFilter(filter)) { - removeFilter(filter) - } else { - addFilter(filter) - } - - toggleFilterState(filter) - - var bitmap = MainImageWrapper.origin - - if (bitmap != null) { - bitmap = appliedFilters.applyFilters(bitmap) - MainImageWrapper.setImage(bitmap) - mainImage.value = bitmap - updateMainImage() - } - } - - private fun addFilter(filter: FilterType) { - appliedFilters.add(filter) - MainImageWrapper.addFilter(filter) - } - - private fun removeFilter(filter: FilterType) { - appliedFilters.remove(filter) - MainImageWrapper.removeFilter(filter) - } - - private fun containsFilter(type: FilterType): Boolean { - return appliedFilters.contains(type) - } - - fun isFilterEnabled(type: FilterType): Boolean { - if (!filterUIState.containsKey(type)) { - filterUIState[type] = mutableStateOf(false) - } - return filterUIState[type]!!.value - } - - private fun restoreFilters(): BufferedImage { - filterUIState.clear() - appliedFilters.clear() - return MainImageWrapper.restore() - } - - fun restoreMainImage() { - mainImage.value = restoreFilters() - } - - // application content initialization - private fun initData() { - if (isContentReady.value) - return - - val directory = File(cacheImagePath) - if (!directory.exists()) { - directory.mkdir() - } - - scope.launch(Dispatchers.IO) { - try { - if (isInternetAvailable()) { - val imageList = repository.get() - - if (imageList.isEmpty()) { - showPopUpMessage( - ResString.repoInvalid - ) - onContentReady() - } else { - val pictureList = loadImages(cacheImagePath, imageList) - - if (pictureList.isEmpty()) { - showPopUpMessage( - ResString.repoEmpty - ) - onContentReady() - } else { - val picture = loadFullImage(imageList[0]) - miniatures.setMiniatures(pictureList) - if (isMainImageEmpty()) { - wrapPictureIntoMainImage(picture) - } else { - appliedFilters.add(MainImageWrapper.getFilters()) - currentImageIndex.value = MainImageWrapper.getId() - } - onContentReady() - } - } - } else { - showPopUpMessage( - ResString.noInternet - ) - onContentReady() - } - } catch (e: Exception) { - e.printStackTrace() - } - } - } - - // preview/fullscreen image managing - fun isMainImageEmpty(): Boolean { - return MainImageWrapper.isEmpty() - } - - fun fullscreen(picture: Picture) { - isContentReady.value = false - AppState.screenState(ScreenType.FullscreenImage) - setMainImage(picture) - } - - fun setMainImage(picture: Picture) { - if (MainImageWrapper.getId() == picture.id) { - if (!isContentReady()) { - onContentReady() - } - return - } - isContentReady.value = false - - scope.launch(Dispatchers.IO) { - scale.reset() - if (isInternetAvailable()) { - val fullSizePicture = loadFullImage(picture.source) - fullSizePicture.id = picture.id - wrapPictureIntoMainImage(fullSizePicture) - } else { - showPopUpMessage( - "${ResString.noInternet}\n${ResString.loadImageUnavailable}" - ) - wrapPictureIntoMainImage(picture) - } - onContentReady() - } - } - - private fun onContentReady() { - isContentReady.value = true - isAppReady.value = true - } - - private fun wrapPictureIntoMainImage(picture: Picture) { - MainImageWrapper.wrapPicture(picture) - MainImageWrapper.saveOrigin() - mainImage.value = picture.image - currentImageIndex.value = picture.id - updateMainImage() - } - - fun updateMainImage() { - MainImageWrapper.mainImageAsImageBitmap.value = Image.makeFromEncoded( - toByteArray( - cropBitmapByScale( - mainImage.value, - windowState.size, - scale.factor.value, - drag - ) - ) - ).toComposeImageBitmap() - } - - fun swipeNext() { - if (currentImageIndex.value == miniatures.size() - 1) { - showPopUpMessage(ResString.lastImage) - return - } - - restoreFilters() - setMainImage(miniatures.get(++currentImageIndex.value)) - } - - fun swipePrevious() { - if (currentImageIndex.value == 0) { - showPopUpMessage(ResString.firstImage) - return - } - - restoreFilters() - setMainImage(miniatures.get(--currentImageIndex.value)) - } - - fun refresh() { - scope.launch(Dispatchers.IO) { - if (isInternetAvailable()) { - clearCache() - MainImageWrapper.clear() - miniatures.clear() - isContentReady.value = false - initData() - } else { - showPopUpMessage( - "${ResString.noInternet}\n${ResString.refreshUnavailable}" - ) - } - } - } -} - -private object MainImageWrapper { - // origin image - var origin: BufferedImage? = null - private set - - fun saveOrigin() { - origin = copy(picture.value.image) - } - - fun restore(): BufferedImage { - if (origin != null) { - picture.value.image = copy(origin!!) - filtersSet.clear() - } - return copy(picture.value.image) - } - - var mainImageAsImageBitmap = mutableStateOf(ImageBitmap(1, 1)) - - // picture adapter - private var picture = mutableStateOf( - Picture(image = BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) - ) - - fun wrapPicture(picture: Picture) { - this.picture.value = picture - } - - fun setImage(bitmap: BufferedImage) { - picture.value.image = bitmap - } - - fun isEmpty(): Boolean { - return (picture.value.name == "") - } - - fun clear() { - picture.value = Picture(image = BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) - } - - fun getName(): String { - return picture.value.name - } - - fun getImage(): BufferedImage { - return picture.value.image - } - - fun getId(): Int { - return picture.value.id - } - - // applied filters - private var filtersSet: MutableSet = LinkedHashSet() - - fun addFilter(filter: FilterType) { - filtersSet.add(filter) - } - - fun removeFilter(filter: FilterType) { - filtersSet.remove(filter) - } - - fun getFilters(): Set { - return filtersSet - } - - private fun copy(bitmap: BufferedImage) : BufferedImage { - val result = BufferedImage(bitmap.width, bitmap.height, bitmap.type) - val graphics = result.createGraphics() - graphics.drawImage(bitmap, 0, 0, result.width, result.height, null) - return result - } -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/ImageHandler.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/ImageHandler.kt deleted file mode 100755 index 5b02b75527..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/ImageHandler.kt +++ /dev/null @@ -1,130 +0,0 @@ -package example.imageviewer.model - -import java.awt.image.BufferedImage -import example.imageviewer.utils.cacheImage -import example.imageviewer.utils.cacheImagePostfix -import example.imageviewer.utils.scaleBitmapAspectRatio -import java.io.File -import java.io.FileInputStream -import java.io.InputStream -import java.io.InputStreamReader -import java.io.BufferedReader -import javax.imageio.ImageIO -import java.lang.Exception -import java.net.HttpURLConnection -import java.net.URL -import java.nio.charset.StandardCharsets - -fun loadFullImage(source: String): Picture { - try { - val url = URL(source) - val connection: HttpURLConnection = url.openConnection() as HttpURLConnection - connection.connectTimeout = 5000 - connection.connect() - - val input: InputStream = connection.inputStream - val bitmap: BufferedImage? = ImageIO.read(input) - if (bitmap != null) { - return Picture( - source = source, - image = bitmap, - name = getNameURL(source), - width = bitmap.width, - height = bitmap.height - ) - } - } catch (e: Exception) { - e.printStackTrace() - } - - return Picture(image = BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) -} - -fun loadImages(cachePath: String, list: List): MutableList { - val result: MutableList = ArrayList() - - for (source in list) { - val name = getNameURL(source) - val path = cachePath + File.separator + name - - if (File(path + "info").exists()) { - addCachedMiniature(filePath = path, outList = result) - } else { - addFreshMiniature(source = source, outList = result, path = cachePath) - } - - result.last().id = result.size - 1 - } - - return result -} - -private fun addFreshMiniature( - source: String, - outList: MutableList, - path: String -) { - try { - val url = URL(source) - val connection: HttpURLConnection = url.openConnection() as HttpURLConnection - connection.connectTimeout = 5000 - connection.connect() - - val input: InputStream = connection.inputStream - val result: BufferedImage? = ImageIO.read(input) - - if (result != null) { - val picture = Picture( - source, - getNameURL(source), - scaleBitmapAspectRatio(result, 200, 164), - result.width, - result.height - ) - - outList.add(picture) - cacheImage(path + getNameURL(source), picture) - } - } catch (e: Exception) { - e.printStackTrace() - } -} - -private fun addCachedMiniature( - filePath: String, - outList: MutableList -) { - try { - val read = BufferedReader( - InputStreamReader( - FileInputStream(filePath + cacheImagePostfix), - StandardCharsets.UTF_8 - ) - ) - - val source = read.readLine() - val width = read.readLine().toInt() - val height = read.readLine().toInt() - - read.close() - - val result: BufferedImage? = ImageIO.read(File(filePath)) - - if (result != null) { - val picture = Picture( - source, - getNameURL(source), - result, - width, - height - ) - outList.add(picture) - } - } catch (e: Exception) { - e.printStackTrace() - } -} - -private fun getNameURL(url: String): String { - return url.substring(url.lastIndexOf('/') + 1, url.length) -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/Picture.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/Picture.kt deleted file mode 100755 index 1113afb440..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/Picture.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model - -import java.awt.image.BufferedImage - -actual data class Picture( - var source: String = "", - var name: String = "", - var image: BufferedImage, - var width: Int = 0, - var height: Int = 0, - var id: Int = 0 -) \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/BlurFilter.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/BlurFilter.kt deleted file mode 100755 index 7ae798b3ec..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/BlurFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - -import java.awt.image.BufferedImage -import example.imageviewer.core.BitmapFilter -import example.imageviewer.utils.applyBlurFilter - -class BlurFilter : BitmapFilter { - - override fun apply(bitmap: BufferedImage): BufferedImage { - return applyBlurFilter(bitmap) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/EmptyFilter.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/EmptyFilter.kt deleted file mode 100755 index 1174489ac8..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/EmptyFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - - -import java.awt.image.BufferedImage -import example.imageviewer.core.BitmapFilter - -class EmptyFilter : BitmapFilter { - - override fun apply(bitmap: BufferedImage): BufferedImage { - return bitmap - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/FiltersManager.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/FiltersManager.kt deleted file mode 100755 index 37fc441888..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/FiltersManager.kt +++ /dev/null @@ -1,53 +0,0 @@ -package example.imageviewer.model.filtration - -import java.awt.image.BufferedImage -import example.imageviewer.core.BitmapFilter -import example.imageviewer.core.FilterType - -class FiltersManager { - - private var filtersMap: MutableMap = LinkedHashMap() - - fun clear() { - filtersMap = LinkedHashMap() - } - - fun add(filters: Collection) { - - for (filter in filters) - add(filter) - } - - fun add(filter: FilterType) { - - if (!filtersMap.containsKey(filter)) - filtersMap[filter] = getFilter(filter) - } - - fun remove(filter: FilterType) { - filtersMap.remove(filter) - } - - fun contains(filter: FilterType): Boolean { - return filtersMap.contains(filter) - } - - fun applyFilters(bitmap: BufferedImage): BufferedImage { - - var result: BufferedImage = bitmap - for (filter in filtersMap) { - result = filter.value.apply(result) - } - - return result - } -} - -private fun getFilter(type: FilterType): BitmapFilter { - - return when (type) { - FilterType.GrayScale -> GrayScaleFilter() - FilterType.Pixel -> PixelFilter() - FilterType.Blur -> BlurFilter() - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/GrayScaleFilter.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/GrayScaleFilter.kt deleted file mode 100755 index 6b10bbf3b0..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/GrayScaleFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - -import java.awt.image.BufferedImage -import example.imageviewer.core.BitmapFilter -import example.imageviewer.utils.applyGrayScaleFilter - -class GrayScaleFilter : BitmapFilter { - - override fun apply(bitmap: BufferedImage) : BufferedImage { - return applyGrayScaleFilter(bitmap) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/PixelFilter.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/PixelFilter.kt deleted file mode 100755 index 5b3a2cf9c2..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/filtration/PixelFilter.kt +++ /dev/null @@ -1,12 +0,0 @@ -package example.imageviewer.model.filtration - -import java.awt.image.BufferedImage -import example.imageviewer.core.BitmapFilter -import example.imageviewer.utils.applyPixelFilter - -class PixelFilter : BitmapFilter { - - override fun apply(bitmap: BufferedImage): BufferedImage { - return applyPixelFilter(bitmap) - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/style/Decoration.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/style/Decoration.kt deleted file mode 100755 index 7c06d90124..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/style/Decoration.kt +++ /dev/null @@ -1,42 +0,0 @@ -package example.imageviewer.style - -import androidx.compose.runtime.Composable -import androidx.compose.ui.res.painterResource -import java.awt.image.BufferedImage -import javax.imageio.ImageIO - -@Composable -fun icEmpty() = painterResource("images/empty.png") - -@Composable -fun icBack() = painterResource("images/back.png") - -@Composable -fun icRefresh() = painterResource("images/refresh.png") - -@Composable -fun icDots() = painterResource("images/dots.png") - -@Composable -fun icFilterGrayscaleOn() = painterResource("images/grayscale_on.png") - -@Composable -fun icFilterGrayscaleOff() = painterResource("images/grayscale_off.png") - -@Composable -fun icFilterPixelOn() = painterResource("images/pixel_on.png") - -@Composable -fun icFilterPixelOff() = painterResource("images/pixel_off.png") - -@Composable -fun icFilterBlurOn() = painterResource("images/blur_on.png") - -@Composable -fun icFilterBlurOff() = painterResource("images/blur_off.png") - -@Composable -fun icFilterUnknown() = painterResource("images/filter_unknown.png") - -@Composable -fun icAppRounded() = painterResource("images/ic_imageviewer_round.png") diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Caching.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Caching.kt deleted file mode 100755 index 192289f20b..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Caching.kt +++ /dev/null @@ -1,53 +0,0 @@ -package example.imageviewer.utils - -import java.awt.image.BufferedImage -import example.imageviewer.model.Picture -import javax.imageio.ImageIO -import java.io.File -import java.io.BufferedWriter -import java.io.OutputStreamWriter -import java.io.FileOutputStream -import java.io.IOException -import java.nio.charset.StandardCharsets - -val cacheImagePostfix = "info" -val cacheImagePath = System.getProperty("user.home")!! + - File.separator + "Pictures/imageviewer" + File.separator - -fun cacheImage(path: String, picture: Picture) { - try { - ImageIO.write(picture.image, "png", File(path)) - - val bw = - BufferedWriter( - OutputStreamWriter( - FileOutputStream(path + cacheImagePostfix), - StandardCharsets.UTF_8 - ) - ) - - bw.write(picture.source) - bw.write("\r\n${picture.width}") - bw.write("\r\n${picture.height}") - bw.close() - - } catch (e: IOException) { - e.printStackTrace() - } -} - -fun clearCache() { - - val directory = File(cacheImagePath) - - val files: Array? = directory.listFiles() - - if (files != null) { - for (file in files) { - if (file.isDirectory) - continue - - file.delete() - } - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Coroutines.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Coroutines.kt deleted file mode 100644 index ab006ef147..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/Coroutines.kt +++ /dev/null @@ -1,9 +0,0 @@ -package example.imageviewer.utils - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -actual fun runBlocking( - context: CoroutineContext, - block: suspend CoroutineScope.() -> T -): T = kotlinx.coroutines.runBlocking(context, block) \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/GraphicsMath.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/GraphicsMath.kt deleted file mode 100755 index 711a629426..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/utils/GraphicsMath.kt +++ /dev/null @@ -1,206 +0,0 @@ -package example.imageviewer.utils - -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import java.awt.Dimension -import java.awt.Graphics2D -import java.awt.Rectangle -import java.awt.Toolkit -import java.awt.image.BufferedImage -import java.io.ByteArrayOutputStream -import java.io.File -import java.io.IOException -import javax.imageio.ImageIO -import java.awt.image.BufferedImageOp -import java.awt.image.ConvolveOp -import java.awt.image.Kernel -import kotlin.math.pow -import kotlin.math.roundToInt -import example.imageviewer.view.DragHandler - -fun scaleBitmapAspectRatio( - bitmap: BufferedImage, - width: Int, - height: Int -): BufferedImage { - val boundW: Float = width.toFloat() - val boundH: Float = height.toFloat() - - val ratioX: Float = boundW / bitmap.width - val ratioY: Float = boundH / bitmap.height - val ratio: Float = if (ratioX < ratioY) ratioX else ratioY - - val resultH = (bitmap.height * ratio).toInt() - val resultW = (bitmap.width * ratio).toInt() - - val result = BufferedImage(resultW, resultH, BufferedImage.TYPE_INT_ARGB) - val graphics = result.createGraphics() - graphics.drawImage(bitmap, 0, 0, resultW, resultH, null) - graphics.dispose() - - return result -} - -fun getDisplayBounds(bitmap: BufferedImage, windowSize: DpSize): Rectangle { - - val boundW: Float = windowSize.width.value.toFloat() - val boundH: Float = windowSize.height.value.toFloat() - - val ratioX: Float = bitmap.width / boundW - val ratioY: Float = bitmap.height / boundH - - val ratio: Float = if (ratioX > ratioY) ratioX else ratioY - - val resultW = (boundW * ratio) - val resultH = (boundH * ratio) - - return Rectangle(0, 0, resultW.toInt(), resultH.toInt()) -} - -fun applyGrayScaleFilter(bitmap: BufferedImage): BufferedImage { - - val result = BufferedImage( - bitmap.getWidth(), - bitmap.getHeight(), - BufferedImage.TYPE_BYTE_GRAY) - - val graphics = result.getGraphics() - graphics.drawImage(bitmap, 0, 0, null) - graphics.dispose() - - return result -} - -fun applyPixelFilter(bitmap: BufferedImage): BufferedImage { - - val w: Int = bitmap.width - val h: Int = bitmap.height - - var result = scaleBitmapAspectRatio(bitmap, w / 20, h / 20) - result = scaleBitmapAspectRatio(result, w, h) - - return result -} - -fun applyBlurFilter(bitmap: BufferedImage): BufferedImage { - - var result = BufferedImage(bitmap.getWidth(), bitmap.getHeight(), bitmap.type) - - val graphics = result.getGraphics() - graphics.drawImage(bitmap, 0, 0, null) - graphics.dispose() - - val radius = 11 - val size = 11 - val weight: Float = 1.0f / (size * size) - val matrix = FloatArray(size * size) - - for (i in 0..matrix.size - 1) { - matrix[i] = weight - } - - val kernel = Kernel(radius, size, matrix) - val op = ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null) - result = op.filter(result, null) - - return result.getSubimage( - radius, - radius, - result.width - radius * 2, - result.height - radius * 2 - ) -} - -fun toByteArray(bitmap: BufferedImage) : ByteArray { - val baos = ByteArrayOutputStream() - ImageIO.write(bitmap, "png", baos) - return baos.toByteArray() -} - -fun cropImage(bitmap: BufferedImage, crop: Rectangle) : BufferedImage { - return bitmap.getSubimage(crop.x, crop.y, crop.width, crop.height) -} - -fun cropBitmapByScale( - bitmap: BufferedImage, - size: DpSize, - scale: Float, - drag: DragHandler -): BufferedImage { - val crop = cropBitmapByBounds( - bitmap, - getDisplayBounds(bitmap, size), - size, - scale, - drag - ) - return cropImage( - bitmap, - Rectangle(crop.x, crop.y, crop.width - crop.x, crop.height - crop.y) - ) -} - -fun cropBitmapByBounds( - bitmap: BufferedImage, - bounds: Rectangle, - size: DpSize, - scaleFactor: Float, - drag: DragHandler -): Rectangle { - - if (scaleFactor <= 1f) { - return Rectangle(0, 0, bitmap.width, bitmap.height) - } - - var scale = scaleFactor.toDouble().pow(1.4) - - var boundW = (bounds.width / scale).roundToInt() - var boundH = (bounds.height / scale).roundToInt() - - scale *= size.width.value / bounds.width.toDouble() - - val offsetX = drag.getAmount().x / scale - val offsetY = drag.getAmount().y / scale - - if (boundW > bitmap.width) { - boundW = bitmap.width - } - if (boundH > bitmap.height) { - boundH = bitmap.height - } - - val invisibleW = bitmap.width - boundW - var leftOffset = (invisibleW / 2.0 - offsetX).roundToInt() - - if (leftOffset > invisibleW) { - leftOffset = invisibleW - drag.getAmount().x = -((invisibleW / 2.0) * scale).roundToInt().toFloat() - } - if (leftOffset < 0) { - drag.getAmount().x = ((invisibleW / 2.0) * scale).roundToInt().toFloat() - leftOffset = 0 - } - - val invisibleH = bitmap.height - boundH - var topOffset = (invisibleH / 2 - offsetY).roundToInt() - - if (topOffset > invisibleH) { - topOffset = invisibleH - drag.getAmount().y = -((invisibleH / 2.0) * scale).roundToInt().toFloat() - } - if (topOffset < 0) { - drag.getAmount().y = ((invisibleH / 2.0) * scale).roundToInt().toFloat() - topOffset = 0 - } - - return Rectangle(leftOffset, topOffset, leftOffset + boundW, topOffset + boundH) -} - -fun getPreferredWindowSize(desiredWidth: Int, desiredHeight: Int): DpSize { - val screenSize: Dimension = Toolkit.getDefaultToolkit().screenSize - val preferredWidth: Int = (screenSize.width * 0.8f).toInt() - val preferredHeight: Int = (screenSize.height * 0.8f).toInt() - val width: Int = if (desiredWidth < preferredWidth) desiredWidth else preferredWidth - val height: Int = if (desiredHeight < preferredHeight) desiredHeight else preferredHeight - return DpSize(width.dp, height.dp) -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/AppUI.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/AppUI.kt deleted file mode 100755 index ef002711bf..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/AppUI.kt +++ /dev/null @@ -1,40 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.Surface -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import example.imageviewer.model.AppState -import example.imageviewer.model.ScreenType -import example.imageviewer.model.ContentState -import example.imageviewer.style.Gray - -private val message: MutableState = mutableStateOf("") -private val state: MutableState = mutableStateOf(false) - -@Composable -fun AppUI(content: ContentState) { - - Surface( - modifier = Modifier.fillMaxSize(), - color = Gray - ) { - when (AppState.screenState()) { - ScreenType.MainScreen -> { - MainScreen(content) - } - ScreenType.FullscreenImage -> { - FullscreenImage(content) - } - } - } - - Toast(message.value, state) -} - -fun showPopUpMessage(text: String) { - message.value = text - state.value = true -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt deleted file mode 100644 index e8e91e4930..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt +++ /dev/null @@ -1,207 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.* -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.interaction.collectIsHoveredAsState -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.input.key.Key -import androidx.compose.ui.input.key.key -import androidx.compose.ui.input.key.type -import androidx.compose.ui.input.key.KeyEventType -import androidx.compose.ui.input.key.onPreviewKeyEvent -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.unit.dp -import example.imageviewer.core.FilterType -import example.imageviewer.model.AppState -import example.imageviewer.model.ContentState -import example.imageviewer.model.ScreenType -import example.imageviewer.ResString -import example.imageviewer.style.DarkGray -import example.imageviewer.style.Foreground -import example.imageviewer.style.MiniatureColor -import example.imageviewer.style.TranslucentBlack -import example.imageviewer.style.Transparent -import example.imageviewer.style.icBack -import example.imageviewer.style.icFilterBlurOff -import example.imageviewer.style.icFilterBlurOn -import example.imageviewer.style.icFilterGrayscaleOff -import example.imageviewer.style.icFilterGrayscaleOn -import example.imageviewer.style.icFilterPixelOff -import example.imageviewer.style.icFilterPixelOn - -@Composable -fun FullscreenImage( - content: ContentState -) { - Column { - ToolBar(content.getSelectedImageName(), content) - Image(content) - } - if (!content.isContentReady()) { - LoadingScreen() - } -} - -@Composable -fun ToolBar( - text: String, - content: ContentState -) { - val backButtonInteractionSource = remember { MutableInteractionSource() } - val backButtonHover by backButtonInteractionSource.collectIsHoveredAsState() - Surface( - color = MiniatureColor, - modifier = Modifier.height(44.dp) - ) { - Row(modifier = Modifier.padding(end = 30.dp)) { - Surface( - color = Transparent, - modifier = Modifier.padding(start = 20.dp).align(Alignment.CenterVertically), - shape = CircleShape - ) { - Tooltip(ResString.back) { - Clickable( - modifier = Modifier - .hoverable(backButtonInteractionSource) - .background(color = if (backButtonHover) TranslucentBlack else Transparent), - onClick = { - if (content.isContentReady()) { - content.restoreMainImage() - AppState.screenState(ScreenType.MainScreen) - } - }) { - Image( - icBack(), - contentDescription = null, - modifier = Modifier.size(38.dp) - ) - } - } - } - Text( - text, - color = Foreground, - maxLines = 1, - modifier = Modifier.padding(start = 30.dp).weight(1f) - .align(Alignment.CenterVertically), - style = MaterialTheme.typography.body1 - ) - - Surface( - color = Color(255, 255, 255, 40), - modifier = Modifier.size(154.dp, 38.dp) - .align(Alignment.CenterVertically), - shape = CircleShape - ) { - val state = rememberScrollState(0) - Row(modifier = Modifier.horizontalScroll(state)) { - Row { - for (type in FilterType.values()) { - FilterButton(content, type) - } - } - } - } - } - } -} - -@Composable -fun FilterButton( - content: ContentState, - type: FilterType, - modifier: Modifier = Modifier.size(38.dp) -) { - val interactionSource = remember { MutableInteractionSource() } - val filterButtonHover by interactionSource.collectIsHoveredAsState() - Box( - modifier = Modifier.background(color = Transparent).clip(CircleShape) - ) { - Tooltip("$type") { - Clickable( - modifier = Modifier - .hoverable(interactionSource) - .background(color = if (filterButtonHover) TranslucentBlack else Transparent), - onClick = { content.toggleFilter(type)} - ) { - Image( - getFilterImage(type = type, content = content), - contentDescription = null, - modifier - ) - } - } - } - Spacer(Modifier.width(20.dp)) -} - -@Composable -fun getFilterImage(type: FilterType, content: ContentState): Painter { - return when (type) { - FilterType.GrayScale -> if (content.isFilterEnabled(type)) icFilterGrayscaleOn() else icFilterGrayscaleOff() - FilterType.Pixel -> if (content.isFilterEnabled(type)) icFilterPixelOn() else icFilterPixelOff() - FilterType.Blur -> if (content.isFilterEnabled(type)) icFilterBlurOn() else icFilterBlurOff() - } -} - -@OptIn(ExperimentalComposeUiApi::class) -@Composable -fun Image(content: ContentState) { - val onUpdate = remember { { content.updateMainImage() } } - Surface( - color = DarkGray, - modifier = Modifier.fillMaxSize() - ) { - Draggable( - onUpdate = onUpdate, - dragHandler = content.drag, - modifier = Modifier.fillMaxSize() - ) { - Zoomable( - onUpdate = onUpdate, - scaleHandler = content.scale, - modifier = Modifier.fillMaxSize() - .onPreviewKeyEvent { - if (it.type == KeyEventType.KeyUp) { - when (it.key) { - Key.DirectionLeft -> { - content.swipePrevious() - } - Key.DirectionRight -> { - content.swipeNext() - } - } - } - false - } - ) { - Image( - bitmap = content.getSelectedImage(), - contentDescription = null, - contentScale = ContentScale.Fit - ) - } - } - } -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt deleted file mode 100755 index edf1f4b27b..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt +++ /dev/null @@ -1,250 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.* -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.interaction.collectIsHoveredAsState -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Card -import androidx.compose.material.Divider -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.painter.BitmapPainter -import androidx.compose.ui.graphics.RectangleShape -import androidx.compose.ui.graphics.toComposeImageBitmap -import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.unit.dp -import example.imageviewer.ResString -import example.imageviewer.model.AppState -import example.imageviewer.model.ContentState -import example.imageviewer.model.Picture -import example.imageviewer.model.ScreenType -import example.imageviewer.style.DarkGray -import example.imageviewer.style.DarkGreen -import example.imageviewer.style.Foreground -import example.imageviewer.style.LightGray -import example.imageviewer.style.MiniatureColor -import example.imageviewer.style.MiniatureHoverColor -import example.imageviewer.style.TranslucentBlack -import example.imageviewer.style.TranslucentWhite -import example.imageviewer.style.Transparent -import example.imageviewer.style.icDots -import example.imageviewer.style.icEmpty -import example.imageviewer.style.icRefresh -import example.imageviewer.utils.toByteArray - -@Composable -fun MainScreen(content: ContentState) { - Column { - TopContent(content) - ScrollableArea(content) - } - if (!content.isContentReady()) { - LoadingScreen(ResString.loading) - } -} - -@Composable -fun TopContent(content: ContentState) { - TitleBar(text = ResString.appName, content = content) - PreviewImage(content) - Spacer(modifier = Modifier.height(10.dp)) - Divider() - Spacer(modifier = Modifier.height(5.dp)) -} - -@Composable -fun TitleBar(text: String, content: ContentState) { - val interactionSource = remember { MutableInteractionSource() } - val refreshButtonHover by interactionSource.collectIsHoveredAsState() - TopAppBar( - backgroundColor = DarkGreen, - title = { - Row(Modifier.height(50.dp)) { - Text( - text, - color = Foreground, - modifier = Modifier.weight(1f).align(Alignment.CenterVertically) - ) - Surface( - color = Transparent, - modifier = Modifier.padding(end = 20.dp).align(Alignment.CenterVertically), - shape = CircleShape - ) { - Tooltip(ResString.refresh) { - Clickable( - modifier = Modifier - .hoverable(interactionSource) - .background(color = if (refreshButtonHover) TranslucentBlack else Transparent), - onClick = { - if (content.isContentReady()) { - content.refresh() - } - } - ) { - Image( - icRefresh(), - contentDescription = null, - modifier = Modifier.size(35.dp) - ) - } - } - } - } - }) -} - -@Composable -fun PreviewImage(content: ContentState) { - Clickable( - modifier = Modifier.background(color = DarkGray), - onClick = { - AppState.screenState(ScreenType.FullscreenImage) - } - ) { - Card( - backgroundColor = Transparent, - modifier = Modifier.height(250.dp), - shape = RectangleShape, - elevation = 1.dp - ) { - Image( - if (content.isMainImageEmpty()) - icEmpty() - else - BitmapPainter(content.getSelectedImage()), - contentDescription = null, - modifier = Modifier - .fillMaxWidth().padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 5.dp), - contentScale = ContentScale.Fit - ) - } - } -} - -@Composable -fun Miniature( - picture: Picture, - content: ContentState -) { - val cardHoverInteractionSource = remember { MutableInteractionSource() } - val cardHover by cardHoverInteractionSource.collectIsHoveredAsState() - val infoButtonInteractionSource = remember { MutableInteractionSource() } - val infoButtonHover by infoButtonInteractionSource.collectIsHoveredAsState() - Card( - backgroundColor = if (cardHover) MiniatureHoverColor else MiniatureColor, - modifier = Modifier.padding(start = 10.dp, end = 18.dp).height(70.dp) - .fillMaxWidth() - .hoverable(cardHoverInteractionSource) - .clickable { - content.setMainImage(picture) - }, - shape = RectangleShape - ) { - Row(modifier = Modifier.padding(end = 30.dp)) { - Clickable( - onClick = { - content.fullscreen(picture) - } - ) { - Image( - org.jetbrains.skia.Image.makeFromEncoded( - toByteArray(picture.image) - ).toComposeImageBitmap(), - contentDescription = null, - modifier = Modifier.height(70.dp) - .width(90.dp) - .padding(start = 1.dp, top = 1.dp, end = 1.dp, bottom = 1.dp), - contentScale = ContentScale.Crop - ) - } - Text( - text = picture.name, - color = Foreground, - modifier = Modifier - .weight(1f) - .align(Alignment.CenterVertically) - .padding(start = 16.dp), - style = MaterialTheme.typography.body1 - ) - - Clickable( - modifier = Modifier.height(70.dp) - .width(30.dp) - .hoverable(infoButtonInteractionSource) - .background(color = if (infoButtonHover) TranslucentWhite else Transparent), - onClick = { - showPopUpMessage( - "${ResString.picture} " + - "${picture.name} \n" + - "${ResString.size} " + - "${picture.width}x${picture.height} " + - "${ResString.pixels}" - ) - } - ) { - Image( - icDots(), - contentDescription = null, - modifier = Modifier.height(70.dp) - .width(30.dp) - .padding(start = 1.dp, top = 25.dp, end = 1.dp, bottom = 25.dp), - contentScale = ContentScale.FillHeight - ) - } - } - } -} - -@Composable -fun ScrollableArea(content: ContentState) { - Box( - modifier = Modifier.fillMaxSize() - .padding(end = 8.dp) - ) { - val stateVertical = rememberScrollState(0) - Column(modifier = Modifier.verticalScroll(stateVertical)) { - var index = 1 - Column { - for (picture in content.getMiniatures()) { - Miniature( - picture = picture, - content = content - ) - Spacer(modifier = Modifier.height(5.dp)) - index++ - } - } - } - VerticalScrollbar( - adapter = rememberScrollbarAdapter(stateVertical), - modifier = Modifier.align(Alignment.CenterEnd) - .fillMaxHeight() - ) - } -} - -@Composable -fun Divider() { - Divider( - color = LightGray, - modifier = Modifier.padding(start = 10.dp, end = 10.dp) - ) -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Toast.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Toast.kt deleted file mode 100755 index d214552818..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Toast.kt +++ /dev/null @@ -1,59 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import example.imageviewer.style.Foreground -import example.imageviewer.style.ToastBackground -import kotlinx.coroutines.delay - -enum class ToastDuration(val value: Int) { - Short(1000), Long(3000) -} - -private var isShown: Boolean = false - -@Composable -fun Toast( - text: String, - visibility: MutableState = mutableStateOf(false), - duration: ToastDuration = ToastDuration.Long -) { - if (isShown) { - return - } - - if (visibility.value) { - isShown = true - Box( - modifier = Modifier.fillMaxSize().padding(bottom = 20.dp), - contentAlignment = Alignment.BottomCenter - ) { - Surface( - modifier = Modifier.size(300.dp, 70.dp), - color = ToastBackground, - shape = RoundedCornerShape(4.dp) - ) { - Box(contentAlignment = Alignment.Center) { - Text( - text = text, - color = Foreground - ) - } - LaunchedEffect(Unit) { - delay(duration.value.toLong()) - isShown = false - visibility.value = false - } - } - } - } -} \ No newline at end of file diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt deleted file mode 100644 index 4cee5684fc..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.kt +++ /dev/null @@ -1,38 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.BoxWithTooltip -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.TooltipArea -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -@OptIn(ExperimentalFoundationApi::class) -@Composable -fun Tooltip( - text: String = "Tooltip", - content: @Composable () -> Unit -) { - TooltipArea( - tooltip = { - Surface( - color = Color(210, 210, 210), - shape = RoundedCornerShape(4.dp) - ) { - Text( - text = text, - modifier = Modifier.padding(10.dp), - style = MaterialTheme.typography.caption - ) - } - } - ) { - content() - } -} diff --git a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Zoomable.kt b/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Zoomable.kt deleted file mode 100644 index e9f6321be0..0000000000 --- a/examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Zoomable.kt +++ /dev/null @@ -1,67 +0,0 @@ -package example.imageviewer.view - -import androidx.compose.foundation.focusable -import androidx.compose.foundation.gestures.detectTapGestures -import androidx.compose.material.Surface -import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester -import androidx.compose.ui.input.key.Key -import androidx.compose.ui.input.key.key -import androidx.compose.ui.input.key.type -import androidx.compose.ui.input.key.KeyEventType -import androidx.compose.ui.input.key.onPreviewKeyEvent -import androidx.compose.ui.input.pointer.pointerInput -import androidx.compose.ui.ExperimentalComposeUiApi -import example.imageviewer.style.Transparent - -@OptIn(ExperimentalComposeUiApi::class) -@Composable -fun Zoomable( - scaleHandler: ScaleHandler, - modifier: Modifier = Modifier, - onUpdate: (() -> Unit)? = null, - children: @Composable() () -> Unit -) { - val focusRequester = FocusRequester() - - Surface( - color = Transparent, - modifier = modifier.onPreviewKeyEvent { - if (it.type == KeyEventType.KeyUp) { - when (it.key) { - Key.I -> { - scaleHandler.onScale(1.2f) - onUpdate?.invoke() - } - Key.O -> { - scaleHandler.onScale(0.8f) - onUpdate?.invoke() - } - Key.R -> { - scaleHandler.reset() - onUpdate?.invoke() - } - } - } - false - } - .focusRequester(focusRequester) - .focusable() - .pointerInput(Unit) { - detectTapGestures(onDoubleTap = { scaleHandler.reset() }) { - focusRequester.requestFocus() - } - } - ) { - children() - } - - DisposableEffect(Unit) { - focusRequester.requestFocus() - onDispose { } - } -} diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/back.png b/examples/imageviewer/common/src/desktopMain/resources/images/back.png deleted file mode 100755 index 206b8d4678..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/back.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/blur_off.png b/examples/imageviewer/common/src/desktopMain/resources/images/blur_off.png deleted file mode 100755 index e632616157..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/blur_off.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/blur_on.png b/examples/imageviewer/common/src/desktopMain/resources/images/blur_on.png deleted file mode 100755 index 7f5ad81bd6..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/blur_on.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/dots.png b/examples/imageviewer/common/src/desktopMain/resources/images/dots.png deleted file mode 100755 index 4eb0c9f1e4..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/dots.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/empty.png b/examples/imageviewer/common/src/desktopMain/resources/images/empty.png deleted file mode 100755 index 54e9007671..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/empty.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/filter_unknown.png b/examples/imageviewer/common/src/desktopMain/resources/images/filter_unknown.png deleted file mode 100755 index 9193c3f33e..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/filter_unknown.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/grayscale_off.png b/examples/imageviewer/common/src/desktopMain/resources/images/grayscale_off.png deleted file mode 100755 index 57fbe7891c..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/grayscale_off.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/grayscale_on.png b/examples/imageviewer/common/src/desktopMain/resources/images/grayscale_on.png deleted file mode 100755 index ffe1f6102b..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/grayscale_on.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/pixel_off.png b/examples/imageviewer/common/src/desktopMain/resources/images/pixel_off.png deleted file mode 100755 index a41ebfe04e..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/pixel_off.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/pixel_on.png b/examples/imageviewer/common/src/desktopMain/resources/images/pixel_on.png deleted file mode 100755 index 1482ff8583..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/pixel_on.png and /dev/null differ diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/refresh.png b/examples/imageviewer/common/src/desktopMain/resources/images/refresh.png deleted file mode 100755 index 3be99c1944..0000000000 Binary files a/examples/imageviewer/common/src/desktopMain/resources/images/refresh.png and /dev/null differ diff --git a/experimental/examples/imageviewer/default.local.properties b/examples/imageviewer/default.local.properties similarity index 100% rename from experimental/examples/imageviewer/default.local.properties rename to examples/imageviewer/default.local.properties diff --git a/examples/imageviewer/desktop/build.gradle.kts b/examples/imageviewer/desktop/build.gradle.kts deleted file mode 100755 index 2116a0481a..0000000000 --- a/examples/imageviewer/desktop/build.gradle.kts +++ /dev/null @@ -1,46 +0,0 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) - id("org.jetbrains.compose") -} - -kotlin { - jvm { - withJava() - } - sourceSets { - named("jvmMain") { - dependencies { - implementation(compose.desktop.currentOs) - implementation(project(":common")) - } - } - } -} - -compose.desktop { - application { - mainClass = "example.imageviewer.MainKt" - - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "ImageViewer" - packageVersion = "1.0.0" - - val iconsRoot = project.file("../common/src/desktopMain/resources/images") - macOS { - iconFile.set(iconsRoot.resolve("icon-mac.icns")) - } - windows { - iconFile.set(iconsRoot.resolve("icon-windows.ico")) - menuGroup = "Compose Examples" - // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html - upgradeUuid = "18159995-d967-4CD2-8885-77BFA97CFA9F" - } - linux { - iconFile.set(iconsRoot.resolve("icon-linux.png")) - } - } - } -} diff --git a/examples/imageviewer/desktop/src/jvmMain/kotlin/example/imageviewer/Main.kt b/examples/imageviewer/desktop/src/jvmMain/kotlin/example/imageviewer/Main.kt deleted file mode 100644 index c17682c405..0000000000 --- a/examples/imageviewer/desktop/src/jvmMain/kotlin/example/imageviewer/Main.kt +++ /dev/null @@ -1,59 +0,0 @@ -package example.imageviewer - -import androidx.compose.material.MaterialTheme -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.window.Window -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.window.WindowPosition -import androidx.compose.ui.window.application -import androidx.compose.ui.window.rememberWindowState -import example.imageviewer.model.ContentState -import example.imageviewer.style.icAppRounded -import example.imageviewer.utils.getPreferredWindowSize -import example.imageviewer.view.AppUI -import example.imageviewer.view.SplashUI - -fun main() = application { - val state = rememberWindowState() - val content = remember { - ContentState.applyContent( - state, - "https://raw.githubusercontent.com/JetBrains/compose-jb/master/artwork/imageviewerrepo/fetching.list" - ) - } - - val icon = icAppRounded() - - if (content.isAppReady()) { - Window( - onCloseRequest = ::exitApplication, - title = "Image Viewer", - state = WindowState( - position = WindowPosition.Aligned(Alignment.Center), - size = getPreferredWindowSize(800, 1000) - ), - icon = icon - ) { - MaterialTheme { - AppUI(content) - } - } - } else { - Window( - onCloseRequest = ::exitApplication, - title = "Image Viewer", - state = WindowState( - position = WindowPosition.Aligned(Alignment.Center), - size = getPreferredWindowSize(800, 300) - ), - undecorated = true, - icon = icon, - ) { - MaterialTheme { - SplashUI() - } - } - } -} \ No newline at end of file diff --git a/experimental/examples/imageviewer/desktopApp/build.gradle.kts b/examples/imageviewer/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/imageviewer/desktopApp/build.gradle.kts rename to examples/imageviewer/desktopApp/build.gradle.kts diff --git a/examples/imageviewer/desktop/rules.pro b/examples/imageviewer/desktopApp/rules.pro similarity index 100% rename from examples/imageviewer/desktop/rules.pro rename to examples/imageviewer/desktopApp/rules.pro diff --git a/experimental/examples/imageviewer/desktopApp/src/jvmMain/kotlin/example/imageviewer/Main.kt b/examples/imageviewer/desktopApp/src/jvmMain/kotlin/example/imageviewer/Main.kt similarity index 100% rename from experimental/examples/imageviewer/desktopApp/src/jvmMain/kotlin/example/imageviewer/Main.kt rename to examples/imageviewer/desktopApp/src/jvmMain/kotlin/example/imageviewer/Main.kt diff --git a/examples/imageviewer/gradle.properties b/examples/imageviewer/gradle.properties old mode 100755 new mode 100644 index 5b6ab8f1b4..f3376fef36 --- a/examples/imageviewer/gradle.properties +++ b/examples/imageviewer/gradle.properties @@ -1,24 +1,16 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official +xcodeproj=iosApp +kotlin.native.cocoapods.generate.wrapper=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3g +org.jetbrains.compose.experimental.jscanvas.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.uikit.enabled=true +kotlin.native.cacheKind=none +kotlin.mpp.androidSourceSetLayoutVersion=2 +kotlin.native.useEmbeddableCompilerJar=true +# Enable kotlin/native experimental memory model +kotlin.native.binary.memoryModel=experimental kotlin.version=1.8.10 agp.version=7.1.3 -compose.version=1.3.1 +compose.version=1.4.0-rc01 diff --git a/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar b/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar index f3d88b1c2f..943f0cbfa7 100644 Binary files a/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar and b/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties b/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties index ae04661ee7..f398c33c4b 100755 --- a/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties +++ b/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/examples/imageviewer/gradlew b/examples/imageviewer/gradlew index fbd7c51583..65dcd68d65 100755 --- a/examples/imageviewer/gradlew +++ b/examples/imageviewer/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,105 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/imageviewer/gradlew.bat b/examples/imageviewer/gradlew.bat index a9f778a7a9..93e3f59f13 100755 --- a/examples/imageviewer/gradlew.bat +++ b/examples/imageviewer/gradlew.bat @@ -1,104 +1,92 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/experimental/examples/imageviewer/iosApp/Configuration/Config.xcconfig b/examples/imageviewer/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/imageviewer/iosApp/Configuration/Config.xcconfig rename to examples/imageviewer/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/imageviewer/iosApp/Podfile b/examples/imageviewer/iosApp/Podfile similarity index 100% rename from experimental/examples/imageviewer/iosApp/Podfile rename to examples/imageviewer/iosApp/Podfile diff --git a/experimental/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/imageviewer/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/imageviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/imageviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/imageviewer/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/imageviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/imageviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/imageviewer/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/imageviewer/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/imageviewer/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/imageviewer/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/imageviewer/iosApp/iosApp/ContentView.swift b/examples/imageviewer/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/ContentView.swift rename to examples/imageviewer/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/imageviewer/iosApp/iosApp/Info.plist b/examples/imageviewer/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/Info.plist rename to examples/imageviewer/iosApp/iosApp/Info.plist diff --git a/experimental/examples/imageviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/imageviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/imageviewer/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/imageviewer/iosApp/iosApp/iOSApp.swift b/examples/imageviewer/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/imageviewer/iosApp/iosApp/iOSApp.swift rename to examples/imageviewer/iosApp/iosApp/iOSApp.swift diff --git a/examples/imageviewer/screenshots/desktop-run-configuration.png b/examples/imageviewer/screenshots/desktop-run-configuration.png deleted file mode 100644 index 3688407c6f..0000000000 Binary files a/examples/imageviewer/screenshots/desktop-run-configuration.png and /dev/null differ diff --git a/examples/imageviewer/screenshots/imageviewer.png b/examples/imageviewer/screenshots/imageviewer.png deleted file mode 100755 index 55ce953839..0000000000 Binary files a/examples/imageviewer/screenshots/imageviewer.png and /dev/null differ diff --git a/experimental/examples/imageviewer/screenshots/run-configurations.png b/examples/imageviewer/screenshots/run-configurations.png similarity index 100% rename from experimental/examples/imageviewer/screenshots/run-configurations.png rename to examples/imageviewer/screenshots/run-configurations.png diff --git a/examples/imageviewer/settings.gradle.kts b/examples/imageviewer/settings.gradle.kts old mode 100755 new mode 100644 index f4ac8d1ff7..a2c5064a25 --- a/examples/imageviewer/settings.gradle.kts +++ b/examples/imageviewer/settings.gradle.kts @@ -12,11 +12,17 @@ pluginManagement { kotlin("jvm").version(kotlinVersion) kotlin("multiplatform").version(kotlinVersion) + kotlin("plugin.serialization").version(kotlinVersion) kotlin("android").version(kotlinVersion) + id("com.android.base").version(agpVersion) id("com.android.application").version(agpVersion) id("com.android.library").version(agpVersion) id("org.jetbrains.compose").version(composeVersion) } } -include(":common", ":android", ":desktop") +rootProject.name = "imageviewer" + +include(":androidApp") +include(":shared") +include(":desktopApp") diff --git a/experimental/examples/imageviewer/shared/build.gradle.kts b/examples/imageviewer/shared/build.gradle.kts similarity index 100% rename from experimental/examples/imageviewer/shared/build.gradle.kts rename to examples/imageviewer/shared/build.gradle.kts diff --git a/experimental/examples/imageviewer/shared/src/androidMain/AndroidManifest.xml b/examples/imageviewer/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/AndroidManifest.xml rename to examples/imageviewer/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageBitmap.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageBitmap.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageBitmap.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageBitmap.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageViewerFileProvider.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageViewerFileProvider.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageViewerFileProvider.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/ImageViewerFileProvider.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/Localization.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/Localization.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/Localization.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/Localization.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/filter/BitmapFilter.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/filter/BitmapFilter.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/filter/BitmapFilter.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/filter/BitmapFilter.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/platform.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/EditMemoryDialog.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/EditMemoryDialog.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/EditMemoryDialog.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/EditMemoryDialog.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ImageViewer.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ImageViewer.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ImageViewer.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ImageViewer.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/LocationVisualizer.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ScrollableColumn.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ScrollableColumn.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ScrollableColumn.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ScrollableColumn.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/Tooltip.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/Tooltip.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/Tooltip.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/Tooltip.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ZoomControllerView.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ZoomControllerView.android.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ZoomControllerView.android.kt rename to examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/ZoomControllerView.android.kt diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml b/examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml rename to examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer.xml diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml b/examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml rename to examples/imageviewer/shared/src/androidMain/res/mipmap-anydpi-v26/ic_imageviewer_round.xml diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png diff --git a/examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png b/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png rename to examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/values-de/strings.xml b/examples/imageviewer/shared/src/androidMain/res/values-de/strings.xml similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/res/values-de/strings.xml rename to examples/imageviewer/shared/src/androidMain/res/values-de/strings.xml diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/values/strings.xml b/examples/imageviewer/shared/src/androidMain/res/values/strings.xml similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/res/values/strings.xml rename to examples/imageviewer/shared/src/androidMain/res/values/strings.xml diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/xml/file_paths.xml b/examples/imageviewer/shared/src/androidMain/res/xml/file_paths.xml similarity index 100% rename from experimental/examples/imageviewer/shared/src/androidMain/res/xml/file_paths.xml rename to examples/imageviewer/shared/src/androidMain/res/xml/file_paths.xml diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageBitmap.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageBitmap.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageBitmap.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageBitmap.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageViewer.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageViewer.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageViewer.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ImageViewer.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Localization.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Localization.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Localization.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Localization.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/NameAndDescription.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/NameAndDescription.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/NameAndDescription.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/NameAndDescription.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ResourcePictures.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ResourcePictures.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ResourcePictures.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/ResourcePictures.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/BitmapFilter.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/BitmapFilter.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/BitmapFilter.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/BitmapFilter.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/FilterType.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/FilterType.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/FilterType.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/filter/FilterType.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Config.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Config.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Config.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Config.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Page.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Page.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Page.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/Page.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/PictureData.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/PictureData.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/PictureData.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/PictureData.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/ScalableState.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/ScalableState.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/ScalableState.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/model/ScalableState.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/platform.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/style/Palette.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/style/Palette.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/style/Palette.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/style/Palette.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/utils/EventUtils.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/utils/EventUtils.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/utils/EventUtils.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/utils/EventUtils.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraScreen.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraScreen.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraScreen.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraScreen.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraView.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraView.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraView.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CameraView.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CircularButton.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CircularButton.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CircularButton.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/CircularButton.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/EditMemoryDialog.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/EditMemoryDialog.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/EditMemoryDialog.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/EditMemoryDialog.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/FullscreenImageScreen.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/FullscreenImageScreen.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/FullscreenImageScreen.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/FullscreenImageScreen.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/GalleryScreen.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/LocationVisualizer.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/MemoryScreen.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/NavigationStack.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/NavigationStack.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/NavigationStack.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/NavigationStack.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/PreviewImage.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/PreviewImage.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/PreviewImage.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/PreviewImage.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScalableImage.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScalableImage.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScalableImage.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScalableImage.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Thumbnail.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Thumbnail.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Thumbnail.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Thumbnail.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ThumbnailImage.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ThumbnailImage.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ThumbnailImage.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ThumbnailImage.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Toast.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Toast.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Toast.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Toast.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Tooltip.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Tooltip.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Tooltip.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/Tooltip.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/TopLayout.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ZoomControllerView.common.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ZoomControllerView.common.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ZoomControllerView.common.kt rename to examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ZoomControllerView.common.kt diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/1-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/1-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/1-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/1-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/1.jpg b/examples/imageviewer/shared/src/commonMain/resources/1.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/1.jpg rename to examples/imageviewer/shared/src/commonMain/resources/1.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/10-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/10-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/10-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/10-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/10.jpg b/examples/imageviewer/shared/src/commonMain/resources/10.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/10.jpg rename to examples/imageviewer/shared/src/commonMain/resources/10.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/11-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/11-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/11-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/11-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/11.jpg b/examples/imageviewer/shared/src/commonMain/resources/11.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/11.jpg rename to examples/imageviewer/shared/src/commonMain/resources/11.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/12-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/12-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/12-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/12-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/12.jpg b/examples/imageviewer/shared/src/commonMain/resources/12.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/12.jpg rename to examples/imageviewer/shared/src/commonMain/resources/12.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/13-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/13-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/13-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/13-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/13.jpg b/examples/imageviewer/shared/src/commonMain/resources/13.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/13.jpg rename to examples/imageviewer/shared/src/commonMain/resources/13.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/14-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/14-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/14-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/14-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/14.jpg b/examples/imageviewer/shared/src/commonMain/resources/14.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/14.jpg rename to examples/imageviewer/shared/src/commonMain/resources/14.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/15-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/15-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/15-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/15-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/15.jpg b/examples/imageviewer/shared/src/commonMain/resources/15.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/15.jpg rename to examples/imageviewer/shared/src/commonMain/resources/15.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/16-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/16-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/16-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/16-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/16.jpg b/examples/imageviewer/shared/src/commonMain/resources/16.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/16.jpg rename to examples/imageviewer/shared/src/commonMain/resources/16.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/17-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/17-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/17-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/17-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/17.jpg b/examples/imageviewer/shared/src/commonMain/resources/17.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/17.jpg rename to examples/imageviewer/shared/src/commonMain/resources/17.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/2-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/2-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/2-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/2-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/2.jpg b/examples/imageviewer/shared/src/commonMain/resources/2.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/2.jpg rename to examples/imageviewer/shared/src/commonMain/resources/2.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/3-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/3-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/3-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/3-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/3.jpg b/examples/imageviewer/shared/src/commonMain/resources/3.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/3.jpg rename to examples/imageviewer/shared/src/commonMain/resources/3.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/4-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/4-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/4-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/4-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/4.jpg b/examples/imageviewer/shared/src/commonMain/resources/4.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/4.jpg rename to examples/imageviewer/shared/src/commonMain/resources/4.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/5-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/5-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/5-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/5-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/5.jpg b/examples/imageviewer/shared/src/commonMain/resources/5.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/5.jpg rename to examples/imageviewer/shared/src/commonMain/resources/5.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/6-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/6-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/6-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/6-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/6.jpg b/examples/imageviewer/shared/src/commonMain/resources/6.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/6.jpg rename to examples/imageviewer/shared/src/commonMain/resources/6.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/7-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/7-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/7-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/7-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/7.jpg b/examples/imageviewer/shared/src/commonMain/resources/7.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/7.jpg rename to examples/imageviewer/shared/src/commonMain/resources/7.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/8-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/8-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/8-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/8-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/8.jpg b/examples/imageviewer/shared/src/commonMain/resources/8.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/8.jpg rename to examples/imageviewer/shared/src/commonMain/resources/8.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/9-thumbnail.jpg b/examples/imageviewer/shared/src/commonMain/resources/9-thumbnail.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/9-thumbnail.jpg rename to examples/imageviewer/shared/src/commonMain/resources/9-thumbnail.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/9.jpg b/examples/imageviewer/shared/src/commonMain/resources/9.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/9.jpg rename to examples/imageviewer/shared/src/commonMain/resources/9.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/android-emulator-photo.jpg b/examples/imageviewer/shared/src/commonMain/resources/android-emulator-photo.jpg similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/android-emulator-photo.jpg rename to examples/imageviewer/shared/src/commonMain/resources/android-emulator-photo.jpg diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/arrowleft.png b/examples/imageviewer/shared/src/commonMain/resources/arrowleft.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/arrowleft.png rename to examples/imageviewer/shared/src/commonMain/resources/arrowleft.png diff --git a/examples/imageviewer/common/src/androidMain/res/drawable/dots.png b/examples/imageviewer/shared/src/commonMain/resources/dots.png similarity index 100% rename from examples/imageviewer/common/src/androidMain/res/drawable/dots.png rename to examples/imageviewer/shared/src/commonMain/resources/dots.png diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/dummy_map.png b/examples/imageviewer/shared/src/commonMain/resources/dummy_map.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/dummy_map.png rename to examples/imageviewer/shared/src/commonMain/resources/dummy_map.png diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/eye.png b/examples/imageviewer/shared/src/commonMain/resources/eye.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/eye.png rename to examples/imageviewer/shared/src/commonMain/resources/eye.png diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/ic_imageviewer_round.png b/examples/imageviewer/shared/src/commonMain/resources/ic_imageviewer_round.png similarity index 100% rename from examples/imageviewer/common/src/desktopMain/resources/images/ic_imageviewer_round.png rename to examples/imageviewer/shared/src/commonMain/resources/ic_imageviewer_round.png diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/icon-linux.png b/examples/imageviewer/shared/src/commonMain/resources/icon-linux.png similarity index 100% rename from examples/imageviewer/common/src/desktopMain/resources/images/icon-linux.png rename to examples/imageviewer/shared/src/commonMain/resources/icon-linux.png diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/icon-mac.icns b/examples/imageviewer/shared/src/commonMain/resources/icon-mac.icns similarity index 100% rename from examples/imageviewer/common/src/desktopMain/resources/images/icon-mac.icns rename to examples/imageviewer/shared/src/commonMain/resources/icon-mac.icns diff --git a/examples/imageviewer/common/src/desktopMain/resources/images/icon-windows.ico b/examples/imageviewer/shared/src/commonMain/resources/icon-windows.ico similarity index 100% rename from examples/imageviewer/common/src/desktopMain/resources/images/icon-windows.ico rename to examples/imageviewer/shared/src/commonMain/resources/icon-windows.ico diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/list_view.png b/examples/imageviewer/shared/src/commonMain/resources/list_view.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/list_view.png rename to examples/imageviewer/shared/src/commonMain/resources/list_view.png diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/magic.png b/examples/imageviewer/shared/src/commonMain/resources/magic.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/magic.png rename to examples/imageviewer/shared/src/commonMain/resources/magic.png diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/plus.png b/examples/imageviewer/shared/src/commonMain/resources/plus.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/plus.png rename to examples/imageviewer/shared/src/commonMain/resources/plus.png diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/trash.png b/examples/imageviewer/shared/src/commonMain/resources/trash.png similarity index 100% rename from experimental/examples/imageviewer/shared/src/commonMain/resources/trash.png rename to examples/imageviewer/shared/src/commonMain/resources/trash.png diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/DesktopImageStorage.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/DesktopImageStorage.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/DesktopImageStorage.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/DesktopImageStorage.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/ImageBitmap.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/ImageBitmap.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/ImageBitmap.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/ImageBitmap.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/Localization.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/Localization.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/Localization.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/Localization.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/filter/BitmapFilter.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/filter/BitmapFilter.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/filter/BitmapFilter.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/filter/BitmapFilter.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/platform.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/EditMemoryDialog.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/EditMemoryDialog.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/EditMemoryDialog.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/EditMemoryDialog.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ImageViewer.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ImageViewer.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ImageViewer.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ImageViewer.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/LocationVisualizer.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ScrollableColumn.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ScrollableColumn.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ScrollableColumn.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ScrollableColumn.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/Tooltip.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ZoomControllerView.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ZoomControllerView.desktop.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ZoomControllerView.desktop.kt rename to examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/ZoomControllerView.desktop.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageBitmap.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageBitmap.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageBitmap.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageBitmap.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/IosShareIcon.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/IosShareIcon.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/IosShareIcon.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/IosShareIcon.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/Localization.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/Localization.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/Localization.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/Localization.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/filter/BitmapFilter.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/filter/BitmapFilter.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/filter/BitmapFilter.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/filter/BitmapFilter.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/main.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/main.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/main.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/main.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/platform.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/FileExtensions.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/CameraView.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/EditMemoryDialog.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/EditMemoryDialog.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/EditMemoryDialog.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/EditMemoryDialog.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/Tooltip.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/Tooltip.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/Tooltip.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/Tooltip.ios.kt diff --git a/experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ZoomControllerView.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ZoomControllerView.ios.kt similarity index 100% rename from experimental/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ZoomControllerView.ios.kt rename to examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ZoomControllerView.ios.kt diff --git a/experimental/examples/minesweeper/.gitignore b/examples/minesweeper/.gitignore similarity index 100% rename from experimental/examples/minesweeper/.gitignore rename to examples/minesweeper/.gitignore diff --git a/experimental/examples/minesweeper/.run/desktopApp.run.xml b/examples/minesweeper/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/minesweeper/.run/desktopApp.run.xml rename to examples/minesweeper/.run/desktopApp.run.xml diff --git a/experimental/examples/minesweeper/.run/jsApp.run.xml b/examples/minesweeper/.run/jsApp.run.xml similarity index 100% rename from experimental/examples/minesweeper/.run/jsApp.run.xml rename to examples/minesweeper/.run/jsApp.run.xml diff --git a/experimental/examples/minesweeper/README.md b/examples/minesweeper/README.md similarity index 100% rename from experimental/examples/minesweeper/README.md rename to examples/minesweeper/README.md diff --git a/experimental/examples/minesweeper/androidApp/build.gradle.kts b/examples/minesweeper/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/minesweeper/androidApp/build.gradle.kts rename to examples/minesweeper/androidApp/build.gradle.kts diff --git a/experimental/examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml b/examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml rename to examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt b/examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt similarity index 100% rename from experimental/examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt rename to examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt diff --git a/experimental/examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml b/examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml similarity index 100% rename from experimental/examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml rename to examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml diff --git a/experimental/examples/falling-balls-mpp/build.gradle.kts b/examples/minesweeper/build.gradle.kts similarity index 100% rename from experimental/examples/falling-balls-mpp/build.gradle.kts rename to examples/minesweeper/build.gradle.kts diff --git a/experimental/examples/minesweeper/desktopApp/build.gradle.kts b/examples/minesweeper/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/minesweeper/desktopApp/build.gradle.kts rename to examples/minesweeper/desktopApp/build.gradle.kts diff --git a/experimental/examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt similarity index 100% rename from experimental/examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt rename to examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt diff --git a/experimental/examples/codeviewer/gradle.properties b/examples/minesweeper/gradle.properties similarity index 93% rename from experimental/examples/codeviewer/gradle.properties rename to examples/minesweeper/gradle.properties index 720f561017..9ff8815ad5 100644 --- a/experimental/examples/codeviewer/gradle.properties +++ b/examples/minesweeper/gradle.properties @@ -13,4 +13,4 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.8.0 agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 +compose.version=1.4.0-rc01 diff --git a/experimental/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar b/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from experimental/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar rename to examples/minesweeper/gradle/wrapper/gradle-wrapper.jar diff --git a/experimental/examples/codeviewer/gradle/wrapper/gradle-wrapper.properties b/examples/minesweeper/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from experimental/examples/codeviewer/gradle/wrapper/gradle-wrapper.properties rename to examples/minesweeper/gradle/wrapper/gradle-wrapper.properties diff --git a/experimental/examples/minesweeper/gradlew b/examples/minesweeper/gradlew similarity index 100% rename from experimental/examples/minesweeper/gradlew rename to examples/minesweeper/gradlew diff --git a/experimental/examples/minesweeper/gradlew.bat b/examples/minesweeper/gradlew.bat similarity index 100% rename from experimental/examples/minesweeper/gradlew.bat rename to examples/minesweeper/gradlew.bat diff --git a/experimental/examples/minesweeper/iosApp/Configuration/Config.xcconfig b/examples/minesweeper/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/minesweeper/iosApp/Configuration/Config.xcconfig rename to examples/minesweeper/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/minesweeper/iosApp/Podfile b/examples/minesweeper/iosApp/Podfile similarity index 100% rename from experimental/examples/minesweeper/iosApp/Podfile rename to examples/minesweeper/iosApp/Podfile diff --git a/experimental/examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/minesweeper/iosApp/iosApp/ContentView.swift b/examples/minesweeper/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/ContentView.swift rename to examples/minesweeper/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/minesweeper/iosApp/iosApp/Info.plist b/examples/minesweeper/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/Info.plist rename to examples/minesweeper/iosApp/iosApp/Info.plist diff --git a/experimental/examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/minesweeper/iosApp/iosApp/iOSApp.swift b/examples/minesweeper/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/minesweeper/iosApp/iosApp/iOSApp.swift rename to examples/minesweeper/iosApp/iosApp/iOSApp.swift diff --git a/experimental/examples/minesweeper/jsApp/build.gradle.kts b/examples/minesweeper/jsApp/build.gradle.kts similarity index 100% rename from experimental/examples/minesweeper/jsApp/build.gradle.kts rename to examples/minesweeper/jsApp/build.gradle.kts diff --git a/experimental/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt b/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt similarity index 100% rename from experimental/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt rename to examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt diff --git a/experimental/examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png b/examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png similarity index 100% rename from experimental/examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png rename to examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png diff --git a/experimental/examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png b/examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png similarity index 100% rename from experimental/examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png rename to examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png diff --git a/experimental/examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png b/examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png similarity index 100% rename from experimental/examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png rename to examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png diff --git a/experimental/examples/minesweeper/jsApp/src/jsMain/resources/index.html b/examples/minesweeper/jsApp/src/jsMain/resources/index.html similarity index 100% rename from experimental/examples/minesweeper/jsApp/src/jsMain/resources/index.html rename to examples/minesweeper/jsApp/src/jsMain/resources/index.html diff --git a/experimental/examples/minesweeper/run-configurations.png b/examples/minesweeper/run-configurations.png similarity index 100% rename from experimental/examples/minesweeper/run-configurations.png rename to examples/minesweeper/run-configurations.png diff --git a/experimental/examples/minesweeper/settings.gradle.kts b/examples/minesweeper/settings.gradle.kts similarity index 100% rename from experimental/examples/minesweeper/settings.gradle.kts rename to examples/minesweeper/settings.gradle.kts diff --git a/experimental/examples/minesweeper/shared/build.gradle.kts b/examples/minesweeper/shared/build.gradle.kts similarity index 100% rename from experimental/examples/minesweeper/shared/build.gradle.kts rename to examples/minesweeper/shared/build.gradle.kts diff --git a/experimental/examples/minesweeper/shared/src/androidMain/AndroidManifest.xml b/examples/minesweeper/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/minesweeper/shared/src/androidMain/AndroidManifest.xml rename to examples/minesweeper/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt b/examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt rename to examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt diff --git a/experimental/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt b/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt rename to examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt diff --git a/experimental/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt b/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt rename to examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt diff --git a/experimental/examples/minesweeper/shared/src/commonMain/kotlin/game.kt b/examples/minesweeper/shared/src/commonMain/kotlin/game.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/kotlin/game.kt rename to examples/minesweeper/shared/src/commonMain/kotlin/game.kt diff --git a/experimental/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt b/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt rename to examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt diff --git a/experimental/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt b/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt rename to examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt diff --git a/experimental/examples/minesweeper/shared/src/commonMain/resources/assets/clock.png b/examples/minesweeper/shared/src/commonMain/resources/assets/clock.png similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/resources/assets/clock.png rename to examples/minesweeper/shared/src/commonMain/resources/assets/clock.png diff --git a/experimental/examples/minesweeper/shared/src/commonMain/resources/assets/flag.png b/examples/minesweeper/shared/src/commonMain/resources/assets/flag.png similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/resources/assets/flag.png rename to examples/minesweeper/shared/src/commonMain/resources/assets/flag.png diff --git a/experimental/examples/minesweeper/shared/src/commonMain/resources/assets/mine.png b/examples/minesweeper/shared/src/commonMain/resources/assets/mine.png similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonMain/resources/assets/mine.png rename to examples/minesweeper/shared/src/commonMain/resources/assets/mine.png diff --git a/experimental/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt b/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt rename to examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt diff --git a/experimental/examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/experimental/examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt b/examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt rename to examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt diff --git a/experimental/examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt b/examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt rename to examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt diff --git a/experimental/examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt b/examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt similarity index 100% rename from experimental/examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt rename to examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt diff --git a/examples/todoapp-lite/.gitignore b/examples/todoapp-lite/.gitignore index a32b16597b..e6c9b61384 100644 --- a/examples/todoapp-lite/.gitignore +++ b/examples/todoapp-lite/.gitignore @@ -1,15 +1,15 @@ *.iml .gradle /local.properties -/.idea -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml +/.idea/ .DS_Store build/ /captures .externalNativeBuild .cxx +iosApp/Podfile.lock +iosApp/Pods/* +iosApp/iosApp.xcworkspace/* +iosApp/iosApp.xcodeproj/* +!iosApp/iosApp.xcodeproj/project.pbxproj +shared/shared.podspec \ No newline at end of file diff --git a/examples/todoapp-lite/.run/desktop.run.xml b/examples/todoapp-lite/.run/desktop.run.xml deleted file mode 100644 index c10d50877a..0000000000 --- a/examples/todoapp-lite/.run/desktop.run.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - true - true - false - - - \ No newline at end of file diff --git a/experimental/examples/todoapp-lite/.run/desktopApp.run.xml b/examples/todoapp-lite/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/todoapp-lite/.run/desktopApp.run.xml rename to examples/todoapp-lite/.run/desktopApp.run.xml diff --git a/examples/todoapp-lite/README.md b/examples/todoapp-lite/README.md index e0526a0209..b072b23540 100755 --- a/examples/todoapp-lite/README.md +++ b/examples/todoapp-lite/README.md @@ -1,20 +1,29 @@ +# TodoApp (lite version) + A simplified version of the [TodoApp example](https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp), fully based on Jetpack Compose and without using any third-party libraries. -Supported targets: Android and Desktop. +Supported targets: Android, Desktop and iOS. -### Running desktop application - * To run, launch command: `./gradlew :desktop:run` - * Or choose **desktop** configuration in IDE and run it. - ![desktop-run-configuration.png](screenshots/desktop-run-configuration.png) +## How to run -### Building native desktop distribution -``` -./gradlew :desktop:packageDistributionForCurrentOS -# outputs are written to desktop/build/compose/binaries -``` +Choose a run configuration for an appropriate target in IDE and run it. + +![run-configurations.png](run-configurations.png) + +To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. +Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then +using "Signing & Capabilities" tab of `iosApp` target. -### Running Android application +Then choose **iosApp** configuration in IDE and run it. -Open project in IntelliJ IDEA or Android Studio and run "android" configuration. +## Run on desktop via Gradle + +`./gradlew desktopApp:run` + +## Building native desktop distribution +``` +./gradlew :desktopApp:packageDistributionForCurrentOS +# outputs are written to desktopApp/build/compose/binaries +``` ![Desktop](screenshots/todoapplite.png) diff --git a/examples/todoapp-lite/android/build.gradle.kts b/examples/todoapp-lite/android/build.gradle.kts deleted file mode 100755 index b3b4020d85..0000000000 --- a/examples/todoapp-lite/android/build.gradle.kts +++ /dev/null @@ -1,29 +0,0 @@ -plugins { - id("com.android.application") - kotlin("android") - id("org.jetbrains.compose") -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } -} - -dependencies { - implementation(project(":common")) - implementation(compose.material) - implementation("androidx.appcompat:appcompat:1.5.1") - implementation("androidx.activity:activity-compose:1.5.0") -} - diff --git a/examples/todoapp-lite/android/src/main/java/example/todoapp/lite/MainActivity.kt b/examples/todoapp-lite/android/src/main/java/example/todoapp/lite/MainActivity.kt deleted file mode 100755 index 0635d7d922..0000000000 --- a/examples/todoapp-lite/android/src/main/java/example/todoapp/lite/MainActivity.kt +++ /dev/null @@ -1,26 +0,0 @@ -package example.todoapp.lite - -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.ui.Modifier -import example.todoapp.lite.common.RootContent - -class MainActivity : AppCompatActivity() { - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - - setContent { - MaterialTheme { - Surface(color = MaterialTheme.colors.background) { - RootContent(modifier = Modifier.fillMaxSize()) - } - } - } - } -} - diff --git a/experimental/examples/todoapp-lite/androidApp/build.gradle.kts b/examples/todoapp-lite/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/todoapp-lite/androidApp/build.gradle.kts rename to examples/todoapp-lite/androidApp/build.gradle.kts diff --git a/examples/todoapp-lite/android/src/main/AndroidManifest.xml b/examples/todoapp-lite/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/todoapp-lite/android/src/main/AndroidManifest.xml rename to examples/todoapp-lite/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/todoapp-lite/androidApp/src/androidMain/kotlin/example/todoapp/lite/MainActivity.kt b/examples/todoapp-lite/androidApp/src/androidMain/kotlin/example/todoapp/lite/MainActivity.kt similarity index 100% rename from experimental/examples/todoapp-lite/androidApp/src/androidMain/kotlin/example/todoapp/lite/MainActivity.kt rename to examples/todoapp-lite/androidApp/src/androidMain/kotlin/example/todoapp/lite/MainActivity.kt diff --git a/examples/todoapp-lite/common/build.gradle.kts b/examples/todoapp-lite/common/build.gradle.kts deleted file mode 100755 index da02ce524f..0000000000 --- a/examples/todoapp-lite/common/build.gradle.kts +++ /dev/null @@ -1,42 +0,0 @@ -plugins { - id("com.android.library") - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - android() - jvm("desktop") - sourceSets { - named("commonMain") { - dependencies { - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material) - implementation(compose.ui) - } - } - } -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - sourceSets { - named("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - res.srcDirs("src/androidMain/res") - } - } -} - diff --git a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt b/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt deleted file mode 100644 index 84fa449e36..0000000000 --- a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt +++ /dev/null @@ -1,38 +0,0 @@ -package example.todoapp.lite.common - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import example.todoapp.lite.common.RootStore.RootState - -@Composable -fun RootContent(modifier: Modifier = Modifier) { - val model = remember { RootStore() } - val state = model.state - - MainContent( - modifier = modifier, - items = state.items, - inputText = state.inputText, - onItemClicked = model::onItemClicked, - onItemDoneChanged = model::onItemDoneChanged, - onItemDeleteClicked = model::onItemDeleteClicked, - onAddItemClicked = model::onAddItemClicked, - onInputTextChanged = model::onInputTextChanged, - ) - - state.editingItem?.also { item -> - EditDialog( - item = item, - onCloseClicked = model::onEditorCloseClicked, - onTextChanged = model::onEditorTextChanged, - onDoneChanged = model::onEditorDoneChanged, - ) - } -} - -private val RootState.editingItem: TodoItem? - get() = editingItemId?.let(items::firstById) - -private fun List.firstById(id: Long): TodoItem = - first { it.id == id } diff --git a/examples/todoapp-lite/common/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt b/examples/todoapp-lite/common/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt deleted file mode 100644 index 1e36024aa1..0000000000 --- a/examples/todoapp-lite/common/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt +++ /dev/null @@ -1,55 +0,0 @@ -@file:JvmName("Utils") - -package example.todoapp.lite.common - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp - -internal actual val MARGIN_SCROLLBAR: Dp = 8.dp - -@Suppress("ACTUAL_WITHOUT_EXPECT") // Workaround https://youtrack.jetbrains.com/issue/KT-37316 -internal actual typealias ScrollbarAdapter = androidx.compose.foundation.ScrollbarAdapter - -@Composable -internal actual fun rememberScrollbarAdapter(scrollState: LazyListState): ScrollbarAdapter = - androidx.compose.foundation.rememberScrollbarAdapter(scrollState) - -@Composable -internal actual fun VerticalScrollbar( - modifier: Modifier, - adapter: ScrollbarAdapter -) { - androidx.compose.foundation.VerticalScrollbar( - modifier = modifier, - adapter = adapter - ) -} - -@Composable -internal actual fun Dialog( - title: String, - onCloseRequest: () -> Unit, - content: @Composable () -> Unit -) { - androidx.compose.ui.window.Dialog( - onCloseRequest = onCloseRequest, - focusable = true, - title = title, - ) { - Box( - modifier = Modifier - .fillMaxSize() - .padding(8.dp), - contentAlignment = Alignment.Center, - ) { - content() - } - } -} diff --git a/examples/todoapp-lite/desktop/build.gradle.kts b/examples/todoapp-lite/desktop/build.gradle.kts deleted file mode 100755 index 81678409de..0000000000 --- a/examples/todoapp-lite/desktop/build.gradle.kts +++ /dev/null @@ -1,39 +0,0 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) - id("org.jetbrains.compose") -} - -kotlin { - jvm { - withJava() - } - sourceSets { - named("jvmMain") { - dependencies { - implementation(compose.desktop.currentOs) - implementation(project(":common")) - } - } - } -} - -compose.desktop { - application { - mainClass = "example.todoapp.lite.MainKt" - - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "TodoApp Lite" - packageVersion = "1.0.0" - - windows { - menuGroup = "Compose Examples" - // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html - upgradeUuid = "5ac63736-d8c7-4a65-a66b-6870df88ddfe" - } - } - } -} - diff --git a/examples/todoapp-lite/desktop/src/jvmMain/kotlin/example/todoapp/lite/Main.kt b/examples/todoapp-lite/desktop/src/jvmMain/kotlin/example/todoapp/lite/Main.kt deleted file mode 100644 index 835c00b79b..0000000000 --- a/examples/todoapp-lite/desktop/src/jvmMain/kotlin/example/todoapp/lite/Main.kt +++ /dev/null @@ -1,29 +0,0 @@ -package example.todoapp.lite - -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.material.MaterialTheme -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.window.Window -import androidx.compose.ui.window.WindowPosition -import androidx.compose.ui.window.application -import androidx.compose.ui.window.rememberWindowState -import example.todoapp.lite.common.RootContent - -fun main() { - application { - Window( - onCloseRequest = ::exitApplication, - title = "TodoApp Lite", - state = rememberWindowState( - position = WindowPosition(alignment = Alignment.Center), - ), - ) { - MaterialTheme { - RootContent( - modifier = Modifier.fillMaxSize() - ) - } - } - } -} diff --git a/experimental/examples/todoapp-lite/desktopApp/build.gradle.kts b/examples/todoapp-lite/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/todoapp-lite/desktopApp/build.gradle.kts rename to examples/todoapp-lite/desktopApp/build.gradle.kts diff --git a/experimental/examples/todoapp-lite/desktopApp/src/jvmMain/kotlin/example/todoapp/lite/Main.kt b/examples/todoapp-lite/desktopApp/src/jvmMain/kotlin/example/todoapp/lite/Main.kt similarity index 100% rename from experimental/examples/todoapp-lite/desktopApp/src/jvmMain/kotlin/example/todoapp/lite/Main.kt rename to examples/todoapp-lite/desktopApp/src/jvmMain/kotlin/example/todoapp/lite/Main.kt diff --git a/examples/todoapp-lite/gradle.properties b/examples/todoapp-lite/gradle.properties index 5b6ab8f1b4..9ff8815ad5 100755 --- a/examples/todoapp-lite/gradle.properties +++ b/examples/todoapp-lite/gradle.properties @@ -1,24 +1,16 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -kotlin.version=1.8.10 +xcodeproj=./iosApp +kotlin.native.cocoapods.generate.wrapper=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3g +org.jetbrains.compose.experimental.jscanvas.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.uikit.enabled=true +kotlin.native.cacheKind=none +kotlin.native.useEmbeddableCompilerJar=true +kotlin.mpp.androidSourceSetLayoutVersion=2 +# Enable kotlin/native experimental memory model +kotlin.native.binary.memoryModel=experimental +kotlin.version=1.8.0 agp.version=7.1.3 -compose.version=1.3.1 +compose.version=1.4.0-rc01 diff --git a/experimental/examples/todoapp-lite/iosApp/Configuration/Config.xcconfig b/examples/todoapp-lite/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/Configuration/Config.xcconfig rename to examples/todoapp-lite/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/todoapp-lite/iosApp/Podfile b/examples/todoapp-lite/iosApp/Podfile similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/Podfile rename to examples/todoapp-lite/iosApp/Podfile diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/todoapp-lite/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/todoapp-lite/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/ContentView.swift b/examples/todoapp-lite/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/ContentView.swift rename to examples/todoapp-lite/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/Info.plist b/examples/todoapp-lite/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/Info.plist rename to examples/todoapp-lite/iosApp/iosApp/Info.plist diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/todoapp-lite/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/todoapp-lite/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift b/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/todoapp-lite/iosApp/iosApp/iOSApp.swift rename to examples/todoapp-lite/iosApp/iosApp/iOSApp.swift diff --git a/experimental/examples/todoapp-lite/run-configurations.png b/examples/todoapp-lite/run-configurations.png similarity index 100% rename from experimental/examples/todoapp-lite/run-configurations.png rename to examples/todoapp-lite/run-configurations.png diff --git a/examples/todoapp-lite/screenshots/desktop-run-configuration.png b/examples/todoapp-lite/screenshots/desktop-run-configuration.png deleted file mode 100644 index 3688407c6f..0000000000 Binary files a/examples/todoapp-lite/screenshots/desktop-run-configuration.png and /dev/null differ diff --git a/examples/todoapp-lite/settings.gradle.kts b/examples/todoapp-lite/settings.gradle.kts index f4ac8d1ff7..279b5471e7 100755 --- a/examples/todoapp-lite/settings.gradle.kts +++ b/examples/todoapp-lite/settings.gradle.kts @@ -19,4 +19,8 @@ pluginManagement { } } -include(":common", ":android", ":desktop") +rootProject.name = "todoapp-lite" + +include(":androidApp") +include(":shared") +include(":desktopApp") diff --git a/experimental/examples/todoapp-lite/shared/build.gradle.kts b/examples/todoapp-lite/shared/build.gradle.kts similarity index 100% rename from experimental/examples/todoapp-lite/shared/build.gradle.kts rename to examples/todoapp-lite/shared/build.gradle.kts diff --git a/examples/todoapp-lite/common/src/androidMain/AndroidManifest.xml b/examples/todoapp-lite/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/AndroidManifest.xml rename to examples/todoapp-lite/shared/src/androidMain/AndroidManifest.xml diff --git a/examples/todoapp-lite/common/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt b/examples/todoapp-lite/shared/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt rename to examples/todoapp-lite/shared/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/kotlin/main.android.kt b/examples/todoapp-lite/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/todoapp-lite/shared/src/androidMain/kotlin/main.android.kt rename to examples/todoapp-lite/shared/src/androidMain/kotlin/main.android.kt diff --git a/examples/todoapp-lite/common/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/examples/todoapp-lite/shared/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml rename to examples/todoapp-lite/shared/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml diff --git a/examples/todoapp-lite/common/src/androidMain/res/drawable/ic_launcher_background.xml b/examples/todoapp-lite/shared/src/androidMain/res/drawable/ic_launcher_background.xml similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/drawable/ic_launcher_background.xml rename to examples/todoapp-lite/shared/src/androidMain/res/drawable/ic_launcher_background.xml diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-hdpi/ic_launcher.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-hdpi/ic_launcher.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-mdpi/ic_launcher.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-mdpi/ic_launcher.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-xhdpi/ic_launcher.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-xhdpi/ic_launcher.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png b/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png rename to examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/examples/todoapp-lite/common/src/androidMain/res/values/strings.xml b/examples/todoapp-lite/shared/src/androidMain/res/values/strings.xml similarity index 100% rename from examples/todoapp-lite/common/src/androidMain/res/values/strings.xml rename to examples/todoapp-lite/shared/src/androidMain/res/values/strings.xml diff --git a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt b/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt similarity index 100% rename from examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt rename to examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt diff --git a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt b/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt similarity index 100% rename from examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt rename to examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt diff --git a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt b/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt similarity index 100% rename from experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt rename to examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootContent.kt diff --git a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt b/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt similarity index 100% rename from examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt rename to examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt diff --git a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt b/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt similarity index 100% rename from examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt rename to examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt diff --git a/examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt b/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt similarity index 100% rename from examples/todoapp-lite/common/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt rename to examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt diff --git a/experimental/examples/todoapp-lite/shared/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt b/examples/todoapp-lite/shared/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt similarity index 100% rename from experimental/examples/todoapp-lite/shared/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt rename to examples/todoapp-lite/shared/src/desktopMain/kotlin/example/todoapp/lite/common/Utils.kt diff --git a/experimental/examples/todoapp-lite/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/todoapp-lite/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/todoapp-lite/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/todoapp-lite/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/experimental/examples/todoapp-lite/shared/src/iosMain/kotlin/example/todoapp/lite/common/Utils.kt b/examples/todoapp-lite/shared/src/iosMain/kotlin/example/todoapp/lite/common/Utils.kt similarity index 100% rename from experimental/examples/todoapp-lite/shared/src/iosMain/kotlin/example/todoapp/lite/common/Utils.kt rename to examples/todoapp-lite/shared/src/iosMain/kotlin/example/todoapp/lite/common/Utils.kt diff --git a/experimental/examples/todoapp-lite/shared/src/iosMain/kotlin/main.ios.kt b/examples/todoapp-lite/shared/src/iosMain/kotlin/main.ios.kt similarity index 100% rename from experimental/examples/todoapp-lite/shared/src/iosMain/kotlin/main.ios.kt rename to examples/todoapp-lite/shared/src/iosMain/kotlin/main.ios.kt diff --git a/examples/validateExamples.sh b/examples/validateExamples.sh index 8188a3cbe4..874184f8d6 100755 --- a/examples/validateExamples.sh +++ b/examples/validateExamples.sh @@ -19,10 +19,12 @@ runGradle() { popd } +runGradle chat-mpp packageDistributionForCurrentOS runGradle codeviewer packageDistributionForCurrentOS runGradle imageviewer packageDistributionForCurrentOS runGradle issues packageDistributionForCurrentOS runGradle notepad packageDistributionForCurrentOS -# runGradle todoapp-lite packageDistributionForCurrentOS # Disabled due to scrollbars until upgrade to compose 1.4.0 +runGradle todoapp-lite packageDistributionForCurrentOS # Disabled due to scrollbars until upgrade to compose 1.4.0 +runGradle minesweeper packageDistributionForCurrentOS runGradle visual-effects packageDistributionForCurrentOS runGradle widgets-gallery packageDistributionForCurrentOS diff --git a/examples/validateExamplesAndroid.sh b/examples/validateExamplesAndroid.sh index cceb247830..24d077f496 100644 --- a/examples/validateExamplesAndroid.sh +++ b/examples/validateExamplesAndroid.sh @@ -20,9 +20,11 @@ runGradle() { } # requires an emulator running or an Android device to be connected +runGradle chat installDebug runGradle codeviewer installDebug runGradle imageviewer installDebug runGradle issues installDebug +runGradle minesweeper installDebug runGradle todoapp-lite installDebug runGradle widgets-gallery installDebug runGradle todoapp installDebug diff --git a/experimental/examples/validateExamplesIos.sh b/examples/validateExamplesIos.sh similarity index 94% rename from experimental/examples/validateExamplesIos.sh rename to examples/validateExamplesIos.sh index a7b0bfcbce..6da14bb210 100755 --- a/experimental/examples/validateExamplesIos.sh +++ b/examples/validateExamplesIos.sh @@ -31,9 +31,9 @@ runGradle() { popd } -runGradle chat-mpp +runGradle chat runGradle codeviewer -runGradle falling-balls-mpp +runGradle falling-balls runGradle imageviewer runGradle todoapp-lite runGradle visual-effects diff --git a/examples/visual-effects/.gitignore b/examples/visual-effects/.gitignore index ba8435b9c5..180e034383 100644 --- a/examples/visual-effects/.gitignore +++ b/examples/visual-effects/.gitignore @@ -12,4 +12,10 @@ build/ /captures .externalNativeBuild -.cxx \ No newline at end of file +.cxx +iosApp/Podfile.lock +iosApp/Pods/* +iosApp/iosApp.xcworkspace/* +iosApp/iosApp.xcodeproj/* +!iosApp/iosApp.xcodeproj/project.pbxproj +shared/shared.podspec \ No newline at end of file diff --git a/examples/visual-effects/.run/desktop.run.xml b/examples/visual-effects/.run/desktop.run.xml deleted file mode 100644 index 29d5ed2ecd..0000000000 --- a/examples/visual-effects/.run/desktop.run.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - true - true - false - - - \ No newline at end of file diff --git a/experimental/examples/visual-effects/.run/desktopApp.run.xml b/examples/visual-effects/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/visual-effects/.run/desktopApp.run.xml rename to examples/visual-effects/.run/desktopApp.run.xml diff --git a/examples/visual-effects/README.md b/examples/visual-effects/README.md index 0943c31b12..ba75334da2 100644 --- a/examples/visual-effects/README.md +++ b/examples/visual-effects/README.md @@ -1,7 +1,24 @@ -Several visual effects implmented with Compose Multiplatform, used in 1.0 release announce video. +# Visual Effects -### Running desktop application -* To run, launch command: `./gradlew run` -* Or choose **desktop** configuration in IDE and run it. - ![desktop-run-configuration.png](screenshots/desktop-run-configuration.png) +Several visual effects implemented with Compose Multiplatform, used in 1.0 release announce video. + +*Prerequisites*: to run on iOS and Android, you should have "Kotlin Multiplatform Mobile" plugin installed either +in Android Studio or in AppCode with [installed CocoaPods](https://kotlinlang.org/docs/native-cocoapods.html). + + +## How to run + +Choose a run configuration for an appropriate target in IDE and run it. + +![run-configurations.png](run-configurations.png) + +To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. +Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then +using "Signing & Capabilities" tab of `iosApp` target. + +Then choose **iosApp** configuration in IDE and run it. + +## Run on desktop via Gradle + +`./gradlew desktopApp:run` diff --git a/experimental/examples/visual-effects/androidApp/build.gradle.kts b/examples/visual-effects/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/visual-effects/androidApp/build.gradle.kts rename to examples/visual-effects/androidApp/build.gradle.kts diff --git a/experimental/examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml b/examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml rename to examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt b/examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt similarity index 100% rename from experimental/examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt rename to examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt diff --git a/experimental/examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml b/examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml similarity index 100% rename from experimental/examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml rename to examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml diff --git a/examples/visual-effects/build.gradle.kts b/examples/visual-effects/build.gradle.kts index 8fabdf370a..8d0c1f3d7c 100644 --- a/examples/visual-effects/build.gradle.kts +++ b/examples/visual-effects/build.gradle.kts @@ -1,62 +1,19 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { - kotlin("jvm") - id("org.jetbrains.compose") + // this is necessary to avoid the plugins to be loaded multiple times + // in each subproject's classloader + kotlin("jvm") apply false + kotlin("multiplatform") apply false + kotlin("android") apply false + id("com.android.application") apply false + id("com.android.library") apply false + id("org.jetbrains.compose") apply false } -group = "me.user" -version = "1.0" - -repositories { - mavenCentral() - google() - maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") } -} - -dependencies { - implementation(compose.desktop.currentOs) -} - -tasks.withType { - kotlinOptions.jvmTarget = "11" - kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn" -} - -compose.desktop { - application { - mainClass = "org.jetbrains.compose.demo.visuals.MainKt" - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "compose-demo" - packageVersion = "1.0.0" - } +allprojects { + repositories { + google() + mavenCentral() + maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + mavenLocal() } } - -afterEvaluate { - val additionalArguments = mutableListOf() - - val runTask = tasks.named("run") { - this.args = additionalArguments - } - - tasks.register("runWords") { - additionalArguments.add("words") - group = "compose desktop" - dependsOn(runTask) - } - - tasks.register("runWave") { - additionalArguments.add("wave") - group = "compose desktop" - dependsOn(runTask) - } - - tasks.register("runNewYear") { - additionalArguments.add("NY") - group = "compose desktop" - dependsOn(runTask) - } -} \ No newline at end of file diff --git a/experimental/examples/visual-effects/desktopApp/build.gradle.kts b/examples/visual-effects/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/visual-effects/desktopApp/build.gradle.kts rename to examples/visual-effects/desktopApp/build.gradle.kts diff --git a/experimental/examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt b/examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt similarity index 100% rename from experimental/examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt rename to examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt diff --git a/examples/visual-effects/gradle.properties b/examples/visual-effects/gradle.properties index 130f9fa7ab..8bddc51e54 100644 --- a/examples/visual-effects/gradle.properties +++ b/examples/visual-effects/gradle.properties @@ -1,3 +1,16 @@ kotlin.code.style=official -kotlin.version=1.8.10 -compose.version=1.3.1 +xcodeproj=./iosApp +kotlin.native.cocoapods.generate.wrapper=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3g +org.jetbrains.compose.experimental.jscanvas.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.uikit.enabled=true +kotlin.mpp.androidSourceSetLayoutVersion=2 +kotlin.native.cacheKind=none +kotlin.native.useEmbeddableCompilerJar=true +# Enable kotlin/native experimental memory model +kotlin.native.binary.memoryModel=experimental +kotlin.version=1.8.0 +agp.version=7.1.3 +compose.version=1.4.0-rc01 diff --git a/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar b/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar index e708b1c023..249e5832f0 100644 Binary files a/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar and b/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/visual-effects/gradlew b/examples/visual-effects/gradlew index 4f906e0c81..a69d9cb6c2 100755 --- a/examples/visual-effects/gradlew +++ b/examples/visual-effects/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,67 +17,101 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -106,80 +140,101 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/visual-effects/gradlew.bat b/examples/visual-effects/gradlew.bat index ac1b06f938..f127cfd49d 100644 --- a/examples/visual-effects/gradlew.bat +++ b/examples/visual-effects/gradlew.bat @@ -1,89 +1,91 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/experimental/examples/visual-effects/iosApp/Configuration/Config.xcconfig b/examples/visual-effects/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/visual-effects/iosApp/Configuration/Config.xcconfig rename to examples/visual-effects/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/visual-effects/iosApp/Podfile b/examples/visual-effects/iosApp/Podfile similarity index 100% rename from experimental/examples/visual-effects/iosApp/Podfile rename to examples/visual-effects/iosApp/Podfile diff --git a/experimental/examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/visual-effects/iosApp/iosApp/ContentView.swift b/examples/visual-effects/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/ContentView.swift rename to examples/visual-effects/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/visual-effects/iosApp/iosApp/Info.plist b/examples/visual-effects/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/Info.plist rename to examples/visual-effects/iosApp/iosApp/Info.plist diff --git a/experimental/examples/visual-effects/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/visual-effects/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/visual-effects/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/visual-effects/iosApp/iosApp/iOSApp.swift b/examples/visual-effects/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/visual-effects/iosApp/iosApp/iOSApp.swift rename to examples/visual-effects/iosApp/iosApp/iOSApp.swift diff --git a/experimental/examples/visual-effects/run-configurations.png b/examples/visual-effects/run-configurations.png similarity index 100% rename from experimental/examples/visual-effects/run-configurations.png rename to examples/visual-effects/run-configurations.png diff --git a/examples/visual-effects/screenshots/desktop-run-configuration.png b/examples/visual-effects/screenshots/desktop-run-configuration.png deleted file mode 100644 index 3688407c6f..0000000000 Binary files a/examples/visual-effects/screenshots/desktop-run-configuration.png and /dev/null differ diff --git a/examples/visual-effects/settings.gradle.kts b/examples/visual-effects/settings.gradle.kts index 69d08df2c6..665c2f3deb 100644 --- a/examples/visual-effects/settings.gradle.kts +++ b/examples/visual-effects/settings.gradle.kts @@ -2,12 +2,26 @@ pluginManagement { repositories { gradlePluginPortal() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + google() } plugins { - kotlin("jvm").version(extra["kotlin.version"] as String) - id("org.jetbrains.compose").version(extra["compose.version"] as String) + val kotlinVersion = extra["kotlin.version"] as String + val agpVersion = extra["agp.version"] as String + val composeVersion = extra["compose.version"] as String + + kotlin("jvm").version(kotlinVersion) + kotlin("multiplatform").version(kotlinVersion) + kotlin("android").version(kotlinVersion) + id("com.android.base").version(agpVersion) + id("com.android.application").version(agpVersion) + id("com.android.library").version(agpVersion) + id("org.jetbrains.compose").version(composeVersion) } } rootProject.name = "visual-effects" + +include(":androidApp") +include(":shared") +include(":desktopApp") diff --git a/experimental/examples/visual-effects/shared/build.gradle.kts b/examples/visual-effects/shared/build.gradle.kts similarity index 100% rename from experimental/examples/visual-effects/shared/build.gradle.kts rename to examples/visual-effects/shared/build.gradle.kts diff --git a/experimental/examples/visual-effects/shared/src/androidMain/AndroidManifest.xml b/examples/visual-effects/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from experimental/examples/visual-effects/shared/src/androidMain/AndroidManifest.xml rename to examples/visual-effects/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt b/examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt rename to examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt diff --git a/experimental/examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt rename to examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt diff --git a/experimental/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt b/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt rename to examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt diff --git a/experimental/examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt b/examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt rename to examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt diff --git a/experimental/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt b/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt rename to examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt diff --git a/experimental/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt b/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt rename to examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt diff --git a/experimental/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt b/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt rename to examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt diff --git a/experimental/examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt rename to examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt diff --git a/experimental/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt b/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt rename to examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt diff --git a/examples/visual-effects/src/main/resources/compose-community-primary.png b/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png similarity index 100% rename from examples/visual-effects/src/main/resources/compose-community-primary.png rename to examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png diff --git a/examples/visual-effects/src/main/resources/compose-community-primary.svg b/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg similarity index 100% rename from examples/visual-effects/src/main/resources/compose-community-primary.svg rename to examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg diff --git a/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml b/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml similarity index 100% rename from experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml rename to examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml diff --git a/experimental/examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt rename to examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt diff --git a/experimental/examples/visual-effects/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/visual-effects/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/experimental/examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt rename to examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt diff --git a/experimental/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt rename to examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt diff --git a/experimental/examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt b/examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt rename to examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt diff --git a/experimental/examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt rename to examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt diff --git a/experimental/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt b/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt similarity index 100% rename from experimental/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt rename to examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt diff --git a/examples/visual-effects/src/main/kotlin/HappyNY.kt b/examples/visual-effects/src/main/kotlin/HappyNY.kt deleted file mode 100644 index ca1d797055..0000000000 --- a/examples/visual-effects/src/main/kotlin/HappyNY.kt +++ /dev/null @@ -1,430 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.* -import androidx.compose.runtime.snapshots.SnapshotStateList -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.* -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.input.pointer.pointerMoveFilter -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.* -import java.lang.Math.random -import kotlin.math.* -import kotlin.random.Random - -const val width = 1200 -const val height = 800 -const val snowCount = 80 -const val starCount = 60 -const val rocketPartsCount = 30 - -data class SnowFlake( - var x: Dp, - var y: Dp, - val scale: Float, - var v: Double, - var alpha: Float, - var angle: Float, - var rotate: Int, - var phase: Double -) - -data class Star(val x: Dp, val y: Dp, val color: Color, val size: Dp) - -const val HNYString = "Happy New Year!" - -class DoubleRocket(val particle: Particle) { - private val STATE_ROCKET = 0 - private val STATE_SMALL_ROCKETS = 1 - var state = STATE_ROCKET - var rockets: Array = emptyArray() - private fun checkState(time: Long) { - if (particle.vy > -3.0 && state == STATE_ROCKET) { - explode(time) - } - if (state == STATE_SMALL_ROCKETS) { - var done = true - rockets.forEach { - if (!it.exploded) { - it.checkExplode(time) - } - if (!it.checkDone()) { - done = false - } - } - if (done) { - reset() - } - } - } - - private fun reset() { - if (particle.vx < 0) return //to stop drawing after the second rocket. This could be commented out - state = STATE_ROCKET - particle.x = if (particle.vx > 0) width - 0.0 else 0.0 - particle.y = 1000.0 - particle.vx = -1 * particle.vx - particle.vy = -12.5 - } - - private fun explode(time: Long) { - val colors = arrayOf(Color(0xff, 0, 0), Color(192, 255, 192), Color(192, 212, 255)) - rockets = Array(7) { - val v = 1.2f + 1.0 * random() - val angle = 2 * PI * random() - Rocket( - Particle( - particle.x, - particle.y, - v * sin(angle) + particle.vx, - v * cos(angle) + particle.vy - 0.5f, - colors[it % colors.size] - ), colors[it % colors.size], time - ) - } - state = STATE_SMALL_ROCKETS - } - - fun move(time: Long, prevTime: Long) { - if (rocket.state == rocket.STATE_ROCKET) { - rocket.particle.move(time, prevTime) - rocket.particle.gravity(time, prevTime) - } else { - rocket.rockets.forEach { - it.move(time, prevTime) - } - } - rocket.checkState(time) - } - - @Composable - fun draw() { - if (state == rocket.STATE_ROCKET) { - particle.draw() - } else { - rockets.forEach { - it.draw() - } - } - } - -} - -class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0) { - var exploded = false - var parts: Array = emptyArray() - - fun checkExplode(time: Long) { - if (time - startTime > 1200000000) { - explode() - } - } - - private fun explode() { - parts = Array(rocketPartsCount) { - val v = 0.5f + 1.5 * random() - val angle = 2 * PI * random() - Particle(particle.x, particle.y, v * sin(angle) + particle.vx, v * cos(angle) + particle.vy, color, 1) - } - exploded = true - } - - fun checkDone(): Boolean { - if (!exploded) return false - parts.forEach { - if (it.y < 800) return false - } - return true - } - - fun move(time: Long, prevTime: Long) { - if (!exploded) { - particle.move(time, prevTime) - particle.gravity(time, prevTime) - checkExplode(time) - } else { - parts.forEach { - it.move(time, prevTime) - it.gravity(time, prevTime) - } - } - } - - @Composable - fun draw() { - if (!exploded) { - particle.draw() - } else { - parts.forEach { - it.draw() - } - } - } -} - -class Particle(var x: Double, var y: Double, var vx: Double, var vy: Double, val color: Color, val type: Int = 0) { - fun move(time: Long, prevTime: Long) { - x = (x + vx * (time - prevTime) / 30000000) - y = (y + vy * (time - prevTime) / 30000000) - } - - fun gravity(time: Long, prevTime: Long) { - vy = vy + 1.0f * (time - prevTime) / 300000000 - } - - @Composable - fun draw() { - val alphaFactor = if (type == 0) 1.0f else 1 / (1 + abs(vy / 5)).toFloat() - Box(Modifier.size(5.dp).offset(x.dp, y.dp).alpha(alphaFactor).clip(CircleShape).background(color)) - for (i in 1..5) { - Box( - Modifier.size(4.dp).offset((x - vx / 2 * i).dp, (y - vy / 2 * i).dp) - .alpha(alphaFactor * (1 - 0.18f * i)).clip(CircleShape).background(color) - ) - } - } -} - -val rocket = DoubleRocket(Particle(0.0, 1000.0, 2.1, -12.5, Color.White)) - - -@Composable -fun NYWindow(onCloseRequest: () -> Unit) { - val windowState = remember { WindowState(width = width.dp, height = height.dp) } - Window(onCloseRequest = onCloseRequest, undecorated = true, transparent = true, state = windowState) { - NYContent() - } -} - -fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: SnapshotStateList) { - for (i in 0..snowCount) { - snowFlakes.add( - SnowFlake( - (50 + (width - 50) * random()).dp, - (height * random()).dp, - 0.1f + 0.2f * random().toFloat(), - 1.5 + 3 * random(), - (0.4f + 0.4 * random()).toFloat(), - 60 * random().toFloat(), - Random.nextInt(1, 5) - 3, - random() * 2 * PI - ) - ) - } - val colors = arrayOf(Color.Red, Color.Yellow, Color.Green, Color.Yellow, Color.Cyan, Color.Magenta, Color.White) - for (i in 0..starCount) { - stars.add( - Star( - (width * random()).dp, - (height * random()).dp, - colors[Random.nextInt(colors.size)], - (3 + 5 * random()).dp - ) - ) - } -} - -@OptIn(ExperimentalComposeUiApi::class) -@Composable -@Preview -fun NYContent() { - var time by remember { mutableStateOf(System.nanoTime()) } - var started by remember { mutableStateOf(false) } - var startTime = remember { System.nanoTime() } - var prevTime by remember { mutableStateOf(System.nanoTime()) } - val snowFlakes = remember { mutableStateListOf() } - val stars = remember { mutableStateListOf() } - var flickering2 by remember { mutableStateOf(true) } - remember { prepareStarsAndSnowFlakes(stars, snowFlakes) } - - Surface( - modifier = Modifier.fillMaxSize().padding(5.dp).shadow(3.dp, RoundedCornerShape(20.dp)), - color = Color.Black, - shape = RoundedCornerShape(20.dp) - ) { - - LaunchedEffect(Unit) { - while (true) { - withFrameNanos { - prevTime = time - time = it - } - } - } - - if (!started) { //animation starts with delay, so there is some time to start recording - if (time - startTime in 7000000001..7099999999) println("ready!") - if (time - startTime > 10000000000) { - startTime = time //restarting timer - started = true - } - } - - if (flickering2) { - if (time - startTime > 15500000000) { //note, that startTime has been updated above - flickering2 = false - } - } - if (started) { - rocket.move(time, prevTime) - } - - with(LocalDensity.current) { - Box(Modifier.fillMaxSize()) { - - snow(time, prevTime, snowFlakes, startTime) - - starrySky(stars) - - Text( - "202", - Modifier.scale(10f).align(Alignment.Center).offset(-2.dp, 15.dp) - .alpha(if (flickering2) 0.8f else 1.0f), - color = Color.White - ) - - val alpha = if (flickering2) flickeringAlpha(time) else 1.0f - Text( - "2", - Modifier.scale(10f).align(Alignment.Center).offset(14.dp, 15.dp).alpha(alpha), - color = Color.White - ) - - if (started) { //delay to be able to start recording - //HNY - var i = 0 - val angle = (HNYString.length / 2 * 5) * -1.0f - val color = colorHNY(time, startTime) - HNYString.forEach { - val alpha = alphaHNY(i, time, startTime) - Text( - it.toString(), - color = color, - modifier = Modifier.scale(5f).align(Alignment.Center).offset(0.dp, 85.dp) - .rotate((angle + 5.0f * i)).offset(0.dp, -90.dp).alpha(alpha) - ) - i++ - } - - rocket.draw() - } - - Text( - "Powered by Compose Multiplatform", - modifier = Modifier.align(Alignment.BottomEnd).offset(-20.dp, 0.dp), - color = Color.White - ) - } - } - } -} - -fun colorHNY(time: Long, startTime: Long): Color { - val periodLength = 60 - val offset = ((time - startTime) / 80000000).toFloat() / periodLength - val color1 = Color.Red - val color2 = Color.Yellow - val color3 = Color.Magenta - if (offset < 1) return blend(color1, color2, offset) - if (offset < 2) return blend(color2, color3, offset - 1) - if (offset < 3) return blend(color3, color1, offset - 2) - return color1 -} - -fun blend(color1: Color, color2: Color, fraction: Float): Color { - if (fraction < 0) return color1 - if (fraction > 1) return color2 - return Color( - color2.red * fraction + color1.red * (1 - fraction), - color2.green * fraction + color1.green * (1 - fraction), - color2.blue * fraction + color1.blue * (1 - fraction) - ) -} - -fun alphaHNY(i: Int, time: Long, startTime: Long): Float { - val period = period(time, startTime, 200) - i - if (period < 0) return 0.0f - if (period > 10) return 1.0f - return 0.1f * period -} - -fun period(time: Long, startTime: Long, periodLength: Int, speed: Int = 1): Int { - val period = 200000000 / speed - return (((time - startTime) / period) % periodLength).toInt() -} - -fun flickeringAlpha(time: Long): Float { - val time = (time / 10000000) % 100 - var result = 0.2f - if (time > 75) { - result += 0.6f * ((time - 75) % 3) / 3 - } - return result -} - - -@Composable -fun starrySky(stars: SnapshotStateList) { - stars.forEach { - star(it.x, it.y, it.color, size = it.size) - } -} - -@Composable -fun star(x: Dp, y: Dp, color: Color = Color.White, size: Dp) { - Box(Modifier.offset(x, y).scale(1.0f, 0.2f).rotate(45f).size(size).background(color)) - Box(Modifier.offset(x, y).scale(0.2f, 1.0f).rotate(45f).size(size).background(color)) -} - -@Composable -fun snow(time: Long, prevTime: Long, snowFlakes: SnapshotStateList, startTime: Long) { - val deltaAngle = (time - startTime) / 100000000 - with(LocalDensity.current) { - snowFlakes.forEach { - var y = it.y + ((it.v * (time - prevTime)) / 300000000).dp - if (y > (height + 20).dp) { - y = -20.dp - } - it.y = y - val x = it.x + (15 * sin(time.toDouble() / 3000000000 + it.phase)).dp - snowFlake(Modifier.offset(x, y).scale(it.scale).rotate(it.angle + deltaAngle * it.rotate), it.alpha) - } - } -} - -@Composable -fun snowFlake(modifier: Modifier, alpha: Float = 0.8f) { - Box(modifier) { - snowFlakeInt(0, 0f, 30.dp, 0.dp, alpha) - snowFlakeInt(0, 60f, 15.dp, 25.dp, alpha) - snowFlakeInt(0, 120f, -15.dp, 25.dp, alpha) - snowFlakeInt(0, 180f, -30.dp, 0.dp, alpha) - snowFlakeInt(0, 240f, -15.dp, -25.dp, alpha) - snowFlakeInt(0, 300f, 15.dp, -25.dp, alpha) - } - -} - -@Composable -fun snowFlakeInt(level: Int, angle: Float, shiftX: Dp, shiftY: Dp, alpha: Float) { - if (level > 3) return - Box( - Modifier.offset(shiftX, shiftY).rotate(angle).width(100.dp).height(10.dp).scale(0.6f).alpha(1f) - .background(Color.White.copy(alpha = alpha)) - ) { - snowFlakeInt(level + 1, 30f, 12.dp, 20.dp, alpha * 0.8f) - snowFlakeInt(level + 1, -30f, 12.dp, -20.dp, alpha * 0.8f) - } -} - diff --git a/examples/visual-effects/src/main/kotlin/RotatingWords.kt b/examples/visual-effects/src/main/kotlin/RotatingWords.kt deleted file mode 100644 index 2ccd610b5a..0000000000 --- a/examples/visual-effects/src/main/kotlin/RotatingWords.kt +++ /dev/null @@ -1,162 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import androidx.compose.animation.ExperimentalAnimationApi -import androidx.compose.animation.core.* -import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.foundation.Image -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.draw.clip -import androidx.compose.ui.draw.rotate -import androidx.compose.ui.draw.scale -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.res.loadSvgPainter -import androidx.compose.ui.res.useResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.DpOffset -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.IntOffset -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.window.singleWindowApplication - -@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterialApi::class) -@Preview -@Composable -fun Words() { - val density = LocalDensity.current - val duration = 5000 - - val infiniteTransition = rememberInfiniteTransition() - val angle by infiniteTransition.animateFloat( - initialValue = -50f, - targetValue = 30f, - animationSpec = infiniteRepeatable( - animation = tween(duration, easing = FastOutSlowInEasing), - repeatMode = RepeatMode.Reverse - ) - ) - val scale by infiniteTransition.animateFloat( - initialValue = 1f, - targetValue = 7f, - animationSpec = infiniteRepeatable( - animation = tween(duration, easing = FastOutSlowInEasing), - repeatMode = RepeatMode.Reverse - ) - ) - - val logoSvg = remember { - useResource("compose-community-primary.svg") { loadSvgPainter(it, density) } - } - - val baseLogo = DpOffset(350.dp, 270.dp) - - val baseText = DpOffset(350.dp, 270.dp) - - val baseRu = DpOffset(100.dp, 100.dp) - val baseEn = DpOffset(100.dp, 600.dp) - val baseCh = DpOffset(600.dp, 100.dp) - val baseJa = DpOffset(600.dp, 600.dp) - - val color1 = Color(0x6B, 0x57, 0xFF) - val color2 = Color(0xFE, 0x28, 0x57) - val color3 = Color(0xFD, 0xB6, 0x0D) - val color4 = Color(0xFC, 0xF8, 0x4A) - - Column(modifier = Modifier - .fillMaxSize() - .padding(16.dp) - ) { - Word(position = baseRu, angle = angle, scale = scale, text = "Ваш", color = color1) - Word(position = baseEn, angle = angle, scale = scale, text = "Your", color = color2) - Word(position = baseCh, angle = angle, scale = scale, text = "您的", color = color3) - Word(position = baseJa, angle = angle, scale = scale, text = "あなたの", color = color4) - Word(position = baseText, angle = 0f, scale = 6f, text = " Compose\nMultiplatform", color = Color(52, 67, 235), - alpha = 0.4f) - - val size = 80.dp * scale - Image(logoSvg, contentDescription = "Logo", - modifier = Modifier - .offset(baseLogo.x - size / 2, baseLogo.y - size / 2) - .size(size) - .rotate(angle * 2f) - ) - } -} - -@Composable -fun Word(position: DpOffset, angle: Float, scale: Float, text: String, - color: Color, alpha: Float = 0.8f) { - Text( - modifier = Modifier - .offset(position.x, position.y) - .rotate(angle) - .scale(scale) - .alpha(alpha), - color = color, - fontWeight = FontWeight.Bold, - text = text, - ) -} - -@Composable -@Preview -fun FallingSnow() { - BoxWithConstraints(Modifier.fillMaxSize()) { - repeat(50) { - val size = remember { 20.dp + 10.dp * Math.random().toFloat() } - val alpha = remember { 0.10f + 0.15f * Math.random().toFloat() } - val sizePx = with(LocalDensity.current) { size.toPx() } - val x = remember { (constraints.maxWidth * Math.random()).toInt() } - - val infiniteTransition = rememberInfiniteTransition() - val t by infiniteTransition.animateFloat( - initialValue = 0f, - targetValue = 1f, - animationSpec = infiniteRepeatable( - animation = tween(16000 + (16000 * Math.random()).toInt(), easing = LinearEasing), - repeatMode = RepeatMode.Restart - ) - ) - val initialT = remember { Math.random().toFloat() } - val actualT = (initialT + t) % 1f - val y = (-sizePx + (constraints.maxHeight + sizePx) * actualT).toInt() - - Box( - Modifier - .offset { IntOffset(x, y) } - .clip(CircleShape) - .alpha(alpha) - .background(Color.White) - .size(size) - ) - - } - } -} - -@Composable -@Preview -fun Background() = Box( - Modifier - .fillMaxSize() - .background(Color(0xFF6F97FF)) -) - -@Composable -@Preview -fun RotatingWords() { - Background() - FallingSnow() - Words() -} diff --git a/examples/visual-effects/src/main/kotlin/WaveEffect.kt b/examples/visual-effects/src/main/kotlin/WaveEffect.kt deleted file mode 100644 index 1f09d139e9..0000000000 --- a/examples/visual-effects/src/main/kotlin/WaveEffect.kt +++ /dev/null @@ -1,265 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.runtime.* -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.* -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.input.pointer.PointerEventType -import androidx.compose.ui.input.pointer.onPointerEvent -import androidx.compose.ui.input.pointer.pointerMoveFilter -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Window -import androidx.compose.ui.window.WindowPosition -import androidx.compose.ui.window.WindowState -import kotlin.math.* - -@Composable -fun WaveEffect(onCloseRequest: () -> Unit, showControls: Boolean) { - val windowState = remember { WindowState(width = 1200.dp, height = 800.dp) } - Window(onCloseRequest = {}, undecorated = true, transparent = true, state = windowState) { - Grid() - } - - if (showControls) { - Window( - onCloseRequest = onCloseRequest, - state = WindowState(width = 200.dp, height = 400.dp, position = WindowPosition(1400.dp, 200.dp)) - ) { - Column { - SettingsPanel(State.red, "Red") - SettingsPanel(State.green, "Green") - SettingsPanel(State.blue, "Blue") - } - } - } -} - -@OptIn(ExperimentalComposeUiApi::class) -@Composable -@Preview -fun Grid() { - var mouseX by remember { mutableStateOf(0) } - var mouseY by remember { mutableStateOf(0) } - var centerX by remember { mutableStateOf(1200) } - var centerY by remember { mutableStateOf(900) } - var vX by remember { mutableStateOf(0) } - var vY by remember { mutableStateOf(0) } - - var time by remember { mutableStateOf(System.nanoTime()) } - var prevTime by remember { mutableStateOf(System.nanoTime()) } - - if (State.mouseUsed) { - centerX = (centerX + vX * (time - prevTime) / 1000000000).toInt() - if (centerX < -100) centerX = -100 - if (centerX > 2600) centerX = 2600 - vX = - (vX * (1 - (time - prevTime).toDouble() / 500000000) + 10 * (mouseX - centerX) * (time - prevTime) / 1000000000).toInt() - centerY = (centerY + vY * (time - prevTime) / 1000000000).toInt() - if (centerY < -100) centerY = -100 - if (centerY > 1800) centerY = 1800 - vY = - (vY * (1 - (time - prevTime).toDouble() / 500000000) + 5 * (mouseY - centerY) * (time - prevTime) / 1000000000).toInt() - - prevTime = time - } - - Surface( - modifier = Modifier.fillMaxSize().padding(5.dp).shadow(3.dp, RoundedCornerShape(20.dp)) - .onPointerEvent(PointerEventType.Move) { - mouseX = it.changes.first().position.x.toInt() - mouseY = it.changes.first().position.y.toInt() - } - .onPointerEvent(PointerEventType.Enter) { - State.mouseUsed = true - } - .onPointerEvent(PointerEventType.Exit) { - State.mouseUsed = false - }, - color = Color(0, 0, 0), - shape = RoundedCornerShape(20.dp) - ) { - Box(Modifier.fillMaxSize()) { - var x = 10 // initial position - var y = 10 // initial position - val shift = 25 - var evenRow = false - val pointerOffsetX = (centerX / 2) - val pointerOffsety = (centerY / 2) - while (y < 790) { - x = if (evenRow) 10 + shift else 10 - while (x < 1190) { - val size: Int = size(x, y, pointerOffsetX, pointerOffsety) - val color = boxColor(x, y, time, pointerOffsetX, pointerOffsety) - Dot(size, Modifier.offset(x.dp, y.dp), color, time) - x += shift * 2 - } - y += shift - evenRow = !evenRow - } - HighPanel(pointerOffsetX, pointerOffsety) - } - - LaunchedEffect(Unit) { - while (true) { - withFrameNanos { - time = it - } - } - } - - } -} - -@Composable -fun HighPanel(mouseX: Int, mouseY: Int) { - Text( - "Compose", - Modifier.offset(270.dp, 600.dp).scale(7.0f).alpha(alpha(mouseX, mouseY, 270, 700)), - color = colorMouse(mouseX, mouseY, 270, 700), - fontWeight = FontWeight.Bold - ) - Text( - "Multiplatform", - Modifier.offset(350.dp, 700.dp).scale(7.0f).alpha(alpha(mouseX, mouseY, 550, 800)), - color = colorMouse(mouseX, mouseY, 550, 800), - fontWeight = FontWeight.Bold - ) - Text( - "1.0", - Modifier.offset(800.dp, 700.dp).scale(7.0f).alpha(alpha(mouseX, mouseY, 800, 800)), - color = colorMouse(mouseX, mouseY, 800, 800), - fontWeight = FontWeight.Bold - ) -} - -private fun alpha(mouseX: Int, mouseY: Int, x: Int, y: Int): Float { - var d = distance(mouseX, mouseY, x, y) - if (d > 450) return 0.0f - d = d / 450 - 0.1 - return (1 - d * d).toFloat() -} - -private fun colorMouse(mouseX: Int, mouseY: Int, x: Int, y: Int): Color { - val d = distance(mouseX, mouseY, x, y) / 450 - val color1 = Color(0x6B, 0x57, 0xFF) - val color2 = Color(0xFE, 0x28, 0x57) - val color3 = Color(0xFD, 0xB6, 0x0D) - val color4 = Color(0xFC, 0xF8, 0x4A) - if (d > 1) return color1 - if (d > 0.66) return balancedColor(3 * d - 2, color1, color2) - if (d > 0.33) return balancedColor(3 * d - 1, color2, color3) - return balancedColor(3 * d, color3, color4) -} - -private fun balancedColor(d: Double, color1: Color, color2: Color): Color { - if (d > 1) return color1 - if (d < 0) return color2 - val red = ((color1.red * d + color2.red * (1 - d)) * 255).toInt() - val green = ((color1.green * d + color2.green * (1 - d)) * 255).toInt() - val blue = ((color1.blue * d + color2.blue * (1 - d)) * 255).toInt() - return Color(red, green, blue) -} - - -private fun distance(x1: Int, y1: Int, x2: Int, y2: Int): Double { - return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2).toDouble()) -} - -@Composable -fun Dot(size: Int, modifier: Modifier, color: Color, time: Long) { - Box( - modifier.rotate(time.toFloat() / (15 * 10000000)).clip(RoundedCornerShape((3 + size / 20).dp)) - .size(width = size.dp, height = size.dp) - ) { - Box(modifier = Modifier.fillMaxSize().background(color)) { - } - } -} - -private fun size(x: Int, y: Int, mouseX: Int, mouseY: Int): Int { - val addSize = 3 - var result = 5 - if (y > 550 && x < 550) return result - if (y > 650 && x < 900) return result - val distance2 = sqrt((x - mouseX) * (x - mouseX) + (y - mouseY) * (y - mouseY).toDouble()) / 200 - val scale: Double = (if (distance2 < 1) { - addSize * (1 - distance2) - } else 0.toDouble()) - result += (if (State.mouseUsed) round(7.5 * scale).toInt() else 0) - return result -} - -private fun boxColor(x: Int, y: Int, time: Long, mouseX: Int, mouseY: Int): Color { - if (!State.mouseUsed) return Color.White - - val color1 = Color(0x6B, 0x57, 0xFF) - val color2 = Color(0xFE, 0x28, 0x57) - val color3 = Color(0xFC, 0xF8, 0x4A) - - val distance = sqrt(((x - mouseX) * (x - mouseX) + (y - mouseY) * (y - mouseY)).toDouble()) - val fade = exp(-1 * distance * distance / 150000) - - var c1 = sin(12 * distance / 450 - (time.toDouble() / (5 * 100000000))) - if (c1 < 0) c1 = 0.0 - var c2 = sin(2 + 12 * distance / 450 - (time.toDouble() / (5 * 100000000))) - if (c2 < 0) c2 = 0.0 - var c3 = sin(4 + 12 * distance / 450 - (time.toDouble() / (5 * 100000000))) - if (c3 < 0) c3 = 0.0 - var color = Color.White - - if (c1 <= 0) { - val d = c2 / (c2 + c3) - color = balancedColor(d, color2, color3) - } else if (c2 <= 0) { - val d = c3 / (c1 + c3) - color = balancedColor(d, color3, color1) - } else if (c3 <= 0) { - val d = c1 / (c1 + c2) - color = balancedColor(d, color1, color2) - } - - return balancedColor(fade, color, Color.White) -} - -internal class ColorSettings { - var enabled by mutableStateOf(true) - var waveLength by mutableStateOf(30.0) - var simple by mutableStateOf(true) - var period by mutableStateOf(80.0) -} - -private class State { - companion object { - var red by mutableStateOf(ColorSettings()) - var green by mutableStateOf(ColorSettings()) - var blue by mutableStateOf(ColorSettings()) - var mouseUsed by mutableStateOf(false) - } -} - -@Composable -internal fun SettingsPanel(settings: ColorSettings, name: String) { - Row { - Text(name) - Checkbox(settings.enabled, onCheckedChange = { settings.enabled = it }) - Checkbox(settings.simple, onCheckedChange = { settings.simple = it }) - Slider( - (settings.waveLength.toFloat() - 10) / 90, - { settings.waveLength = 10 + 90 * it.toDouble() }, - Modifier.width(100.dp) - ) - Slider( - (settings.period.toFloat() - 10) / 90, - { settings.period = 10 + 90 * it.toDouble() }, - Modifier.width(100.dp) - ) - } -} - diff --git a/examples/visual-effects/src/main/kotlin/main.kt b/examples/visual-effects/src/main/kotlin/main.kt deleted file mode 100644 index 98d7d5c582..0000000000 --- a/examples/visual-effects/src/main/kotlin/main.kt +++ /dev/null @@ -1,32 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.window.application -import androidx.compose.ui.window.singleWindowApplication - -fun mainWords() = singleWindowApplication( - title = "Compose Demo", state = WindowState(size = DpSize(830.dp, 830.dp)) -) { - RotatingWords() -} - -fun mainWave(controls: Boolean) = application { - WaveEffect(::exitApplication, controls) -} - -fun mainNY() = application { - NYWindow(::exitApplication) -} - -fun main(args: Array) { - if (args.isEmpty()) return mainWords() - when (val effect = args[0]) { - "words" -> mainWords() - "wave" -> mainWave(false) - "wave-controls" -> mainWave(true) - "NY" -> mainNY() - else -> throw Error("Unknown effect: $effect") - } -} diff --git a/examples/widgets-gallery/.gitignore b/examples/widgets-gallery/.gitignore index 88816f6122..e6c9b61384 100644 --- a/examples/widgets-gallery/.gitignore +++ b/examples/widgets-gallery/.gitignore @@ -2,9 +2,14 @@ .gradle /local.properties /.idea/ -/.run .DS_Store build/ /captures .externalNativeBuild -.cxx \ No newline at end of file +.cxx +iosApp/Podfile.lock +iosApp/Pods/* +iosApp/iosApp.xcworkspace/* +iosApp/iosApp.xcodeproj/* +!iosApp/iosApp.xcodeproj/project.pbxproj +shared/shared.podspec \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/.run/desktopApp.run.xml b/examples/widgets-gallery/.run/desktopApp.run.xml similarity index 100% rename from experimental/examples/widgets-gallery/.run/desktopApp.run.xml rename to examples/widgets-gallery/.run/desktopApp.run.xml diff --git a/examples/widgets-gallery/README.md b/examples/widgets-gallery/README.md index 262f9759d0..0121f321d1 100644 --- a/examples/widgets-gallery/README.md +++ b/examples/widgets-gallery/README.md @@ -1,25 +1,31 @@ -# Widget gallery +# Widgets gallery This example is derived from [ComposeCookBook](https://github.com/Gurupreet/ComposeCookBook) project by Gurupreet Singh ([@Gurupreet](https://github.com/Gurupreet)) published under [MIT license](third_party/ComposeCookBook_LICENSE.txt). -An example of Compose application for Desktop and Android platforms, +An example of Compose application for Desktop, Android and iOS platforms, demonstrating how to use various Material widgets. -### Running desktop application - * To run, launch command: `./gradlew :desktop:run` - * Or choose **desktop** configuration in IDE and run it. - ![desktop-run-configuration.png](screenshots/desktop-run-configuration.png) +## How to run + +Choose a run configuration for an appropriate target in IDE and run it. + +![run-configurations.png](run-configurations.png) + +To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. +Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then +using "Signing & Capabilities" tab of `iosApp` target. + +Then choose **iosApp** configuration in IDE and run it. + +## Run on desktop via Gradle + +`./gradlew desktopApp:run` ### Building native desktop distribution ``` ./gradlew :desktop:packageDistributionForCurrentOS # outputs are written to desktop/build/compose/binaries ``` - -### Installing Android application on device/emulator -``` -./gradlew installDebug -``` diff --git a/examples/widgets-gallery/android/build.gradle.kts b/examples/widgets-gallery/android/build.gradle.kts deleted file mode 100644 index fed67b2b03..0000000000 --- a/examples/widgets-gallery/android/build.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -plugins { - id("com.android.application") - kotlin("android") - id("org.jetbrains.compose") -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } -} - -dependencies { - implementation(project(":common")) - implementation("androidx.activity:activity-compose:1.5.0") -} diff --git a/examples/widgets-gallery/android/src/main/java/org/jetbrains/compose/demo/widgets/MainActivity.kt b/examples/widgets-gallery/android/src/main/java/org/jetbrains/compose/demo/widgets/MainActivity.kt deleted file mode 100644 index 7f1ad35382..0000000000 --- a/examples/widgets-gallery/android/src/main/java/org/jetbrains/compose/demo/widgets/MainActivity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.compose.demo.widgets - -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity -import org.jetbrains.compose.demo.widgets.ui.MainView - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - MainView() - } - } -} \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/build.gradle.kts b/examples/widgets-gallery/androidApp/build.gradle.kts similarity index 100% rename from experimental/examples/widgets-gallery/androidApp/build.gradle.kts rename to examples/widgets-gallery/androidApp/build.gradle.kts diff --git a/examples/widgets-gallery/android/src/main/AndroidManifest.xml b/examples/widgets-gallery/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/AndroidManifest.xml rename to examples/widgets-gallery/androidApp/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/MainActivity.kt b/examples/widgets-gallery/androidApp/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/MainActivity.kt similarity index 100% rename from experimental/examples/widgets-gallery/androidApp/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/MainActivity.kt rename to examples/widgets-gallery/androidApp/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/MainActivity.kt diff --git a/examples/widgets-gallery/android/src/main/res/drawable-v24/ic_launcher_background.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_background.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/drawable-v24/ic_launcher_background.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_background.xml diff --git a/examples/widgets-gallery/android/src/main/res/drawable-v24/ic_launcher_foreground.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-hdpi/ic_launcher.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-hdpi/ic_launcher_round.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-hdpi/ic_launcher_round.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-mdpi/ic_launcher.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-mdpi/ic_launcher_round.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-mdpi/ic_launcher_round.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-xhdpi/ic_launcher.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-xhdpi/ic_launcher_round.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-xxxhdpi/ic_launcher.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/examples/widgets-gallery/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png similarity index 100% rename from examples/widgets-gallery/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png rename to examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png diff --git a/examples/widgets-gallery/android/src/main/res/values-night/themes.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/values-night/themes.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/values-night/themes.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/values-night/themes.xml diff --git a/examples/widgets-gallery/android/src/main/res/values/colors.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/values/colors.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/values/colors.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/values/colors.xml diff --git a/examples/widgets-gallery/android/src/main/res/values/strings.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/values/strings.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/values/strings.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/values/strings.xml diff --git a/examples/widgets-gallery/android/src/main/res/values/themes.xml b/examples/widgets-gallery/androidApp/src/androidMain/res/values/themes.xml similarity index 100% rename from examples/widgets-gallery/android/src/main/res/values/themes.xml rename to examples/widgets-gallery/androidApp/src/androidMain/res/values/themes.xml diff --git a/examples/widgets-gallery/build.gradle.kts b/examples/widgets-gallery/build.gradle.kts index 0c00883af5..8d0c1f3d7c 100644 --- a/examples/widgets-gallery/build.gradle.kts +++ b/examples/widgets-gallery/build.gradle.kts @@ -14,5 +14,6 @@ allprojects { google() mavenCentral() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") + mavenLocal() } } diff --git a/examples/widgets-gallery/common/build.gradle.kts b/examples/widgets-gallery/common/build.gradle.kts deleted file mode 100644 index 0a8338b2d3..0000000000 --- a/examples/widgets-gallery/common/build.gradle.kts +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id("com.android.library") - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - android() - jvm("desktop") - - sourceSets { - named("commonMain") { - dependencies { - api(compose.runtime) - api(compose.foundation) - api(compose.material) - api(compose.materialIconsExtended) - } - } - named("androidMain") { - dependencies { - api("androidx.appcompat:appcompat:1.5.1") - api("androidx.core:core-ktx:1.8.0") - } - } - named("desktopMain") { - dependencies { - api(compose.desktop.common) - } - } - } -} - -android { - compileSdk = 33 - - defaultConfig { - minSdk = 26 - targetSdk = 33 - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - - sourceSets { - named("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - res.srcDirs("src/androidMain/res", "src/commonMain/resources") - } - } -} diff --git a/examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt b/examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt deleted file mode 100644 index 552d284f9a..0000000000 --- a/examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.painter.Painter - -@Composable -actual fun painterResource(res: String): Painter { - val id = drawableId(res) - return androidx.compose.ui.res.painterResource(id) -} - -// TODO: improve resource loading -private fun drawableId(res: String): Int { - val imageName = res.substringAfterLast("/").substringBeforeLast(".") - val drawableClass = R.drawable::class.java - val field = drawableClass.getDeclaredField(imageName) - return field.get(drawableClass) as Int -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt deleted file mode 100644 index 74369433cc..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt +++ /dev/null @@ -1,14 +0,0 @@ -package org.jetbrains.compose.demo.widgets.data - -import org.jetbrains.compose.demo.widgets.data.model.Item -import org.jetbrains.compose.demo.widgets.data.model.Tweet -import org.jetbrains.compose.demo.widgets.platform.Res - -object DemoDataProvider { - val item = Item( - 1, - "Awesome List Item", - "Very awesome list item has very awesome subtitle. This is bit long", - Res.drawable.food6 - ) -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt deleted file mode 100644 index bb879b4ac4..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.compose.demo.widgets.data.model - -data class Item( - val id: Int, - val title: String, - val subtitle: String, - val imageId: String, - val source: String = "demo source" -) \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt deleted file mode 100644 index 404e83a410..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -object Res { - object drawable { - val food6 = "drawable-nodpi/food6.jpg" - val p1 = "drawable-nodpi/p1.jpeg" - val p2 = "drawable-nodpi/p2.jpeg" - val p3 = "drawable-nodpi/p3.jpeg" - val p6 = "drawable-nodpi/p6.jpeg" - - val ic_instagram = "drawable/ic_instagram.xml" - val ic_send = "drawable/ic_send.xml" - val ic_twitter = "drawable/ic_twitter.xml" - } - - object string { - val spotify_nav_home = "Home" - val spotify_nav_search = "Search" - val spotify_nav_library = "Your Library" - } -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt deleted file mode 100644 index 690e9ea06d..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.painter.Painter - -@Composable -expect fun painterResource(res: String): Painter diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt deleted file mode 100644 index d7adfa7349..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.Dp - -@Composable -expect fun VerticalScrollbar( - modifier: Modifier, - scrollState: ScrollState -) - -@Composable -expect fun VerticalScrollbar( - modifier: Modifier, - scrollState: LazyListState, - itemCount: Int, - averageItemSize: Dp -) \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt deleted file mode 100644 index 3050d9f245..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -expect fun isSystemInDarkTheme(): Boolean \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt deleted file mode 100644 index 64ec9f8344..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt +++ /dev/null @@ -1,136 +0,0 @@ -package org.jetbrains.compose.demo.widgets.theme - -import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import org.jetbrains.compose.demo.widgets.platform.isSystemInDarkTheme -import org.jetbrains.compose.demo.widgets.theme.ColorPallet.* - -// dark palettes -private val DarkGreenColorPalette = darkColors( - primary = green200, - primaryVariant = green700, - secondary = teal200, - background = Color.Black, - surface = Color.Black, - onPrimary = Color.Black, - onSecondary = Color.White, - onBackground = Color.White, - onSurface = Color.White, - error = Color.Red, -) - -private val DarkPurpleColorPalette = darkColors( - primary = purple200, - primaryVariant = purple700, - secondary = teal200, - background = Color.Black, - surface = Color.Black, - onPrimary = Color.Black, - onSecondary = Color.White, - onBackground = Color.White, - onSurface = Color.White, - error = Color.Red, -) - -private val DarkBlueColorPalette = darkColors( - primary = blue200, - primaryVariant = blue700, - secondary = teal200, - background = Color.Black, - surface = Color.Black, - onPrimary = Color.Black, - onSecondary = Color.White, - onBackground = Color.White, - onSurface = Color.White, - error = Color.Red, -) - -private val DarkOrangeColorPalette = darkColors( - primary = orange200, - primaryVariant = orange700, - secondary = teal200, - background = Color.Black, - surface = Color.Black, - onPrimary = Color.Black, - onSecondary = Color.White, - onBackground = Color.White, - onSurface = Color.White, - error = Color.Red, -) - -// Light pallets -private val LightGreenColorPalette = lightColors( - primary = green500, - primaryVariant = green700, - secondary = teal200, - background = Color.White, - surface = Color.White, - onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black -) - -private val LightPurpleColorPalette = lightColors( - primary = purple, - primaryVariant = purple700, - secondary = teal200, - background = Color.White, - surface = Color.White, - onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black -) - -private val LightBlueColorPalette = lightColors( - primary = blue500, - primaryVariant = blue700, - secondary = teal200, - background = Color.White, - surface = Color.White, - onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black -) - -private val LightOrangeColorPalette = lightColors( - primary = orange500, - primaryVariant = orange700, - secondary = teal200, - background = Color.White, - surface = Color.White, - onPrimary = Color.White, - onSecondary = Color.Black, - onBackground = Color.Black, - onSurface = Color.Black -) - -enum class ColorPallet { - PURPLE, GREEN, ORANGE, BLUE -} - -@Composable -fun WidgetGalleryTheme( - darkTheme: Boolean = isSystemInDarkTheme(), - colorPallet: ColorPallet = GREEN, - content: @Composable() () -> Unit, -) { - val colors = when (colorPallet) { - GREEN -> if (darkTheme) DarkGreenColorPalette else LightGreenColorPalette - PURPLE -> if (darkTheme) DarkPurpleColorPalette else LightPurpleColorPalette - ORANGE -> if (darkTheme) DarkOrangeColorPalette else LightOrangeColorPalette - BLUE -> if (darkTheme) DarkBlueColorPalette else LightBlueColorPalette - } - - MaterialTheme( - colors = colors, - typography = typography, - shapes = shapes, - content = content - ) -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt deleted file mode 100644 index 5049b3dbb4..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt +++ /dev/null @@ -1,160 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui - -import androidx.compose.animation.core.Spring -import androidx.compose.animation.core.SpringSpec -import androidx.compose.animation.core.animateDpAsState -import androidx.compose.foundation.clickable -import androidx.compose.foundation.hoverable -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.interaction.collectIsHoveredAsState -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.* -import androidx.compose.runtime.saveable.rememberSaveable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clipToBounds -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.SemanticsProperties -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.TextUnit -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import org.jetbrains.compose.demo.widgets.platform.VerticalScrollbar -import org.jetbrains.compose.demo.widgets.theme.WidgetGalleryTheme -import org.jetbrains.compose.demo.widgets.ui.utils.PanelState -import org.jetbrains.compose.demo.widgets.ui.utils.ResizablePanel -import org.jetbrains.compose.demo.widgets.ui.utils.VerticalSplittable -import org.jetbrains.compose.demo.widgets.ui.utils.withoutWidthConstraints - -@Composable -fun MainView() { - WidgetGalleryTheme { - Surface { - WidgetsPanel() - } - } -} - -@Composable -fun WidgetsPanel() { - val widgetsTypeState = rememberSaveable { mutableStateOf(WidgetsType.sortedValues.first()) } - val panelState = remember { PanelState() } - - val animatedSize = if (panelState.splitter.isResizing) { - if (panelState.isExpanded) panelState.expandedSize else panelState.collapsedSize - } else { - animateDpAsState( - if (panelState.isExpanded) panelState.expandedSize else panelState.collapsedSize, - SpringSpec(stiffness = Spring.StiffnessLow) - ).value - } - - VerticalSplittable( - Modifier.fillMaxSize(), - panelState.splitter, - onResize = { - panelState.expandedSize = - (panelState.expandedSize + it).coerceAtLeast(panelState.expandedSizeMin) - } - ) { - ResizablePanel( - Modifier.width(animatedSize).fillMaxHeight(), - title = "Widgets", - state = panelState - ) { - WidgetsListView(widgetsTypeState) - } - - Box { - Column { - WidgetsView( - widgetsTypeState, - modifier = Modifier.weight(1f) - ) - } - } - } -} - -@Composable -private fun WidgetsListView(widgetsTypeState: MutableState) { - Box { - with(LocalDensity.current) { - val scrollState = rememberLazyListState() - - val fontSize = 14.sp - val lineHeight = fontSize.toDp() * 1.5f - - val sortedItems = WidgetsType.sortedValues - LazyColumn( - modifier = Modifier.fillMaxSize().withoutWidthConstraints(), - state = scrollState - ) { - items(sortedItems) { - WidgetsListItemViewImpl(it, widgetsTypeState, fontSize, lineHeight) - } - } - - VerticalScrollbar( - Modifier.align(Alignment.CenterEnd), - scrollState, - sortedItems.size, - lineHeight - ) - } - } - -} - -@Composable -private fun WidgetsListItemViewImpl( - widgetsType: WidgetsType, - widgetsTypeState: MutableState, - fontSize: TextUnit, - height: Dp -) { - val isCurrent = widgetsTypeState.value == widgetsType - - Row( - modifier = Modifier - .wrapContentHeight() - .clickable { widgetsTypeState.value = widgetsType } - .semantics { - set(SemanticsProperties.Role, Role.Button) - } - .height(height) - .padding(start = 16.dp) - ) { - val inFocusInteractionSource = remember { MutableInteractionSource() } - val inFocus by inFocusInteractionSource.collectIsHoveredAsState() - val textColor = LocalContentColor.current.let { - when { - isCurrent -> it - inFocus -> it.copy(alpha = 0.6f) - else -> it.copy(alpha = 0.4f) - } - } - - Text( - text = widgetsType.readableName, - color = textColor, - modifier = Modifier - .align(Alignment.CenterVertically) - .clipToBounds() - .hoverable(inFocusInteractionSource), - softWrap = true, - fontSize = fontSize, - overflow = TextOverflow.Ellipsis, - maxLines = 1 - ) - } -} diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt deleted file mode 100644 index c624bff519..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt +++ /dev/null @@ -1,30 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import androidx.compose.ui.Modifier -import org.jetbrains.compose.demo.widgets.ui.screens.* - -@Composable -fun WidgetsView( - widgetsTypeState: MutableState, - modifier: Modifier -) { - Column(modifier = modifier.verticalScroll(state = rememberScrollState())) { - @Suppress("UNUSED_VARIABLE") - val exhaustive = when (widgetsTypeState.value) { - WidgetsType.APP_BARS -> AppBars() - WidgetsType.BUTTONS -> Buttons() - WidgetsType.CHIPS -> Chips() - WidgetsType.LOADERS -> Loaders() - WidgetsType.SNACK_BARS -> SnackBars() - WidgetsType.TEXT_VIEWS -> TextViews() - WidgetsType.TEXT_INPUTS -> TextInputs() - WidgetsType.TOGGLES -> Toggles() - WidgetsType.UI_CARDS -> UICards() - } - } -} diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt deleted file mode 100644 index cdbc0b08e1..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt +++ /dev/null @@ -1,34 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui - -import java.util.Locale - -enum class WidgetsType(private val customTitle: String? = null) { - APP_BARS, - BUTTONS, - CHIPS, - LOADERS, - SNACK_BARS, - TEXT_VIEWS, - TEXT_INPUTS, - TOGGLES, - UI_CARDS("UI Cards"); - - val readableName: String by lazy { - name.split("_") - .map { it.lowercase(Locale.getDefault()) } - .mapIndexed { i, it -> - if (i == 0) it.replaceFirstChar { - if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() - } else it - }.joinToString(" ") - } - - val title: String - get() = customTitle ?: readableName - - companion object { - val sortedValues: List by lazy { - values().sortedBy { it.name } - } - } -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt deleted file mode 100644 index b0344477d6..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt +++ /dev/null @@ -1,161 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack -import androidx.compose.material.icons.filled.MoreHoriz -import androidx.compose.material.icons.filled.StarBorder -import androidx.compose.material.icons.outlined.* -import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.platform.Res -import org.jetbrains.compose.demo.widgets.platform.painterResource -import org.jetbrains.compose.demo.widgets.theme.twitterColor -import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText -import org.jetbrains.compose.demo.widgets.ui.utils.TitleText - -@Composable -fun AppBars() { - TopAppBarsDemo() - BottomAppBarDemo() - NavigationBarDemo() -} - -@Composable -private fun TopAppBarsDemo() { - SubtitleText(subtitle = "Top App bar") - - TopAppBar( - title = { Text(text = "Home") }, - elevation = 8.dp, - navigationIcon = { - IconButton(onClick = {}) { - Icon(Icons.Default.ArrowBack, contentDescription = "ArrowBack") - } - } - ) - - Spacer(modifier = Modifier.height(8.dp)) - - TopAppBar( - title = { Text(text = "Instagram") }, - backgroundColor = MaterialTheme.colors.surface, - contentColor = MaterialTheme.colors.onSurface, - elevation = 8.dp, - navigationIcon = { - IconButton(onClick = {}) { - Icon(painterResource(Res.drawable.ic_instagram), contentDescription = "Instagram") - } - }, - actions = { - IconButton(onClick = {}) { - Icon(painterResource(Res.drawable.ic_send), contentDescription = "Send") - } - } - ) - - Spacer(modifier = Modifier.height(8.dp)) - - TopAppBar( - title = { - Icon( - painterResource(Res.drawable.ic_twitter), - contentDescription = "Twitter", - tint = twitterColor, - modifier = Modifier.fillMaxWidth() - ) - }, - backgroundColor = MaterialTheme.colors.surface, - contentColor = MaterialTheme.colors.onSurface, - elevation = 8.dp, - navigationIcon = { - Image( - painterResource(Res.drawable.p6), - contentDescription = "", - modifier = Modifier.padding(vertical = 4.dp, horizontal = 8.dp) - .requiredSize(32.dp).clip(CircleShape) - ) - }, - actions = { - Icon( - Icons.Default.StarBorder, - contentDescription = "", - modifier = Modifier.padding(horizontal = 8.dp) - ) - } - ) - Spacer(modifier = Modifier.height(8.dp)) -} - -@Composable -private fun BottomAppBarDemo() { - Spacer(modifier = Modifier.height(16.dp)) - SubtitleText("Bottom app bars: Note bottom app bar support FAB cutouts when used with scafolds see demoUI crypto app") - - BottomAppBar( - cutoutShape = CircleShape - ) { - IconButton(onClick = {}) { - Icon(Icons.Default.MoreHoriz, contentDescription = "") - } - TitleText(title = "Bottom App Bar") - } -} - -@Composable -private fun NavigationBarDemo() { - Spacer(modifier = Modifier.height(16.dp)) - SubtitleText(subtitle = "Bottom Navigation Bars") - val navItemState = remember { mutableStateOf(NavType.HOME) } - BottomNavigation(backgroundColor = MaterialTheme.colors.surface) { - BottomNavigationItem( - icon = { Icon(Icons.Outlined.Home, contentDescription = "Home") }, - selected = navItemState.value == NavType.HOME, - onClick = { navItemState.value = NavType.HOME }, - label = { Text(text = Res.string.spotify_nav_home) }, - ) - BottomNavigationItem( - icon = { Icon(Icons.Outlined.Search, contentDescription = "Search") }, - selected = navItemState.value == NavType.SEARCH, - onClick = { navItemState.value = NavType.SEARCH }, - label = { Text(text = Res.string.spotify_nav_search) } - ) - BottomNavigationItem( - icon = { Icon(Icons.Outlined.LibraryMusic, contentDescription = "LibraryMusic") }, - selected = navItemState.value == NavType.LIBRARY, - onClick = { navItemState.value = NavType.LIBRARY }, - label = { Text(text = Res.string.spotify_nav_library) } - ) - } - - Spacer(modifier = Modifier.height(16.dp)) - - BottomNavigation { - BottomNavigationItem( - icon = { Icon(Icons.Outlined.ReadMore, contentDescription = "ReadMore") }, - selected = navItemState.value == NavType.HOME, - onClick = { navItemState.value = NavType.HOME }, - ) - BottomNavigationItem( - icon = { Icon(Icons.Outlined.Search, contentDescription = "Search") }, - selected = navItemState.value == NavType.SEARCH, - onClick = { navItemState.value = NavType.SEARCH }, - ) - BottomNavigationItem( - icon = { Icon(Icons.Outlined.CleanHands, contentDescription = "CleanHands") }, - selected = navItemState.value == NavType.LIBRARY, - onClick = { navItemState.value = NavType.LIBRARY }, - ) - } -} - -private enum class NavType { - HOME, SEARCH, LIBRARY -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt deleted file mode 100644 index a7e5e295b5..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt +++ /dev/null @@ -1,108 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.FavoriteBorder -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Brush -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.theme.purple -import org.jetbrains.compose.demo.widgets.theme.purple200 -import org.jetbrains.compose.demo.widgets.theme.typography - -@Composable -fun Buttons() { - Column { - Button(onClick = {}, modifier = Modifier.padding(8.dp)) { - Text(text = "Main Button") - } - TextButton(onClick = {}, modifier = Modifier.padding(8.dp)) { - Text(text = "Text Button") - } - TextButton(onClick = {}, modifier = Modifier.padding(8.dp), enabled = false) { - Text(text = "Text Disabled") - } - Button(onClick = {}, modifier = Modifier.padding(8.dp), enabled = false) { - Text(text = "Disabled") - } - Button( - onClick = {}, - modifier = Modifier.padding(8.dp), - elevation = ButtonDefaults.elevation() - ) { - Text(text = "Flat") - } - Button( - onClick = {}, - modifier = Modifier.padding(8.dp), - shape = RoundedCornerShape(12.dp) - ) { - Text(text = "Rounded") - } - OutlinedButton(onClick = {}, modifier = Modifier.padding(8.dp)) { - Text(text = "Outline") - } - Button(onClick = {}, modifier = Modifier.padding(8.dp)) { - Row { - Icon(Icons.Default.FavoriteBorder, contentDescription = null, modifier = Modifier.padding(end = 4.dp)) - Text(text = "Icon Button") - } - } - Button(onClick = {}, modifier = Modifier.padding(8.dp)) { - Text(text = "Icon Button") - Icon(Icons.Default.FavoriteBorder, contentDescription = null, modifier = Modifier.padding(start = 4.dp)) - } - //custom background buttons - val outlineButtonColor = ButtonDefaults.outlinedButtonColors( - contentColor = purple200, - ) - val mainButtonColor = ButtonDefaults.buttonColors( - backgroundColor = purple, - contentColor = MaterialTheme.colors.surface - ) - OutlinedButton( - colors = outlineButtonColor, - onClick = {}, - modifier = Modifier.padding(8.dp) - ) { - Text(text = "Outline colors") - } - Button(colors = mainButtonColor, onClick = {}, modifier = Modifier.padding(8.dp)) { - Text(text = "Custom colors") - } - - val horizontalGradient = Brush.horizontalGradient( - colors = listOf(MaterialTheme.colors.primary, MaterialTheme.colors.primaryVariant), - 0f, - 250f - ) - val verticalGradient = Brush.verticalGradient( - colors = listOf(MaterialTheme.colors.primary, MaterialTheme.colors.primaryVariant), - startY = 0f, - endY = 100f - ) - Text( - text = "Horizontal gradient", - style = typography.body2.copy(color = Color.White), - modifier = Modifier.padding(12.dp).clickable(onClick = {}) - .clip(RoundedCornerShape(4.dp)) - .background(brush = horizontalGradient).padding(12.dp) - ) - Text( - text = "Vertical gradient", - style = typography.body1.copy(color = Color.White), - modifier = Modifier.padding(12.dp).clickable(onClick = {}) - .clip(RoundedCornerShape(4.dp)) - .background(brush = verticalGradient).padding(12.dp) - ) - } -} diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt deleted file mode 100644 index 95f5d6088d..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt +++ /dev/null @@ -1,130 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.platform.Res -import org.jetbrains.compose.demo.widgets.platform.painterResource -import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText - -@Composable -fun Chips() { - // There is no in-built chips but you can make yours like below - SubtitleText(subtitle = "Custom chips with surface") - Column(modifier = Modifier.padding(8.dp)) { - YoutubeChip(selected = true, text = "Chip", modifier = Modifier.padding(horizontal = 8.dp)) - Spacer(modifier = Modifier.padding(8.dp)) - YoutubeChip( - selected = false, - text = "Inactive", - modifier = Modifier.padding(horizontal = 8.dp) - ) - Spacer(modifier = Modifier.padding(8.dp)) - CustomImageChip(text = "custom", imageId = Res.drawable.p2, selected = true) - Spacer(modifier = Modifier.padding(8.dp)) - CustomImageChip(text = "custom2", imageId = Res.drawable.p6, selected = false) - } - SubtitleText(subtitle = "Buttons with circle clipping.") - Column(modifier = Modifier.padding(8.dp)) { - Button( - onClick = {}, - modifier = Modifier.padding(8.dp).clip(CircleShape) - ) { - Text(text = "Chip button") - } - Button( - onClick = {}, - enabled = false, - modifier = Modifier.padding(8.dp).clip(CircleShape) - ) { - Text(text = "Disabled chip") - } - } -} - - -//Inspired from jetcaster sample. I hope compose can add simple Chip UI element that can -// support images or icons with multiple states. -@Composable -private fun CustomImageChip( - text: String, - imageId: String, - selected: Boolean, - modifier: Modifier = Modifier -) { - Surface( - color = when { - selected -> MaterialTheme.colors.primary - else -> Color.Transparent - }, - contentColor = when { - selected -> MaterialTheme.colors.onPrimary - else -> Color.LightGray - }, - shape = RoundedCornerShape(16.dp), - border = BorderStroke( - width = 1.dp, - color = when { - selected -> MaterialTheme.colors.primary - else -> Color.LightGray - } - ), - modifier = modifier - ) { - Row(modifier = Modifier) { - Image( - painterResource(imageId), - contentDescription = null, - modifier = Modifier.padding(8.dp).requiredSize(20.dp).clip(CircleShape) - ) - Text( - text = text, - style = MaterialTheme.typography.body2, - modifier = Modifier.padding(end = 8.dp, top = 8.dp, bottom = 8.dp) - ) - } - } -} - -@Composable -private fun YoutubeChip(selected: Boolean, text: String, modifier: Modifier = Modifier) { - Surface( - color = when { - selected -> MaterialTheme.colors.onSurface - else -> Color.Transparent - }, - contentColor = when { - selected -> MaterialTheme.colors.onPrimary - else -> Color.LightGray - }, - shape = CircleShape, - border = BorderStroke( - width = 1.dp, - color = when { - selected -> MaterialTheme.colors.primary - else -> Color.LightGray - } - ), - modifier = modifier - ) { - Text( - text = text, - textAlign = TextAlign.Center, - style = MaterialTheme.typography.body2, - modifier = Modifier.padding(8.dp) - ) - - } -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt deleted file mode 100644 index df19865d62..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.LinearProgressIndicator -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -@Composable -fun Loaders() { - AlignedColumn { - CircularProgressIndicator() - } - - AlignedColumn { - CircularProgressIndicator(strokeWidth = 8.dp) - } - - AlignedColumn { - LinearProgressIndicator() - } - - AlignedColumn { - LinearProgressIndicator() - Text(text = "Loading with text...", modifier = Modifier.padding(8.dp)) - } -} -@Composable -private fun AlignedColumn(content: @Composable () -> Unit) { - Column( - modifier = Modifier.fillMaxWidth().padding(16.dp) - ) { - content() - } -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt deleted file mode 100644 index 78946984a7..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Snackbar -import androidx.compose.material.Text -import androidx.compose.material.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.theme.typography - -@Composable -fun SnackBars() { - Snackbar(modifier = Modifier.padding(4.dp)) { - Text(text = "This is a basic snackbar") - } - Snackbar( - modifier = Modifier.padding(4.dp), - action = { - TextButton(onClick = {}) { - Text(text = "Remove") - } - } - ) { - Text(text = "This is a basic Snackbar with action item") - } - Snackbar( - modifier = Modifier.padding(4.dp), - actionOnNewLine = true, - action = { - TextButton(onClick = {}) { - Text(text = "Remove") - } - } - ) { - Text(text = "Snackbar with action item below text") - } -} diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt deleted file mode 100644 index 41634eceb4..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt +++ /dev/null @@ -1,86 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - - -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material.Icon -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text -import androidx.compose.material.TextField -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Edit -import androidx.compose.material.icons.filled.Email -import androidx.compose.runtime.* -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.input.KeyboardType -import androidx.compose.ui.text.input.PasswordVisualTransformation -import androidx.compose.ui.text.input.TextFieldValue -import androidx.compose.ui.unit.dp - -@Composable -fun TextInputs() { - var text by remember { mutableStateOf(TextFieldValue("")) } - - // TODO Explore CoreTextField -// CoreTextField( -// value = text, -// onValueChange = { newValue -> text = newValue }, -// modifier = Modifier.padding(8.dp).preferredSize(0.dp), -// cursorColor = Color.Magenta -// ) - TextField( - value = text, - onValueChange = { newValue -> text = newValue }, - modifier = Modifier.padding(8.dp).fillMaxWidth(), - label = { Text("label") }, - placeholder = { Text("placeholder") } - ) - - OutlinedTextField( - value = text, - modifier = Modifier.padding(8.dp).fillMaxWidth(), - label = { Text(text = "Password") }, - placeholder = { Text(text = "12334444") }, - visualTransformation = PasswordVisualTransformation(), - onValueChange = { - text = it - }, - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password) - ) - - OutlinedTextField( - value = text, - leadingIcon = { Icon(Icons.Default.Email, contentDescription = "Email") }, - modifier = Modifier.padding(8.dp).fillMaxWidth(), - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), - label = { Text(text = "Email address") }, - placeholder = { Text(text = "Your email") }, - onValueChange = { - text = it - } - ) - OutlinedTextField( - value = text, - leadingIcon = { Icon(Icons.Default.Email, contentDescription = "Email") }, - trailingIcon = { Icon(Icons.Default.Edit, contentDescription = "Edit") }, - modifier = Modifier.padding(8.dp).fillMaxWidth(), - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text), - label = { Text(text = "Email address") }, - placeholder = { Text(text = "Your email") }, - onValueChange = { - text = it - } - ) - - var numberText by remember { mutableStateOf(TextFieldValue("")) } - OutlinedTextField(value = numberText, - modifier = Modifier.padding(8.dp).fillMaxWidth(), - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), - label = { Text(text = "Phone number") }, - placeholder = { Text(text = "88888888") }, - onValueChange = { - numberText = it - } - ) -} diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt deleted file mode 100644 index c14f8f9545..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt +++ /dev/null @@ -1,97 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.text.style.TextDecoration -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.theme.typography -import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText - -@Composable -fun TextViews() { - Column { - val textModifier = Modifier.padding(horizontal = 8.dp) - - SubtitleText(subtitle = "Font weights") - Text(text = "Plain", modifier = textModifier) - Text( - text = "Medium Bold", - style = typography.body1.copy(fontWeight = FontWeight.Medium), - modifier = textModifier - ) - Text( - text = "Bold", - style = typography.body1.copy(fontWeight = FontWeight.Bold), - modifier = textModifier - ) - Text( - text = "Extra Bold", - style = typography.body1.copy(fontWeight = FontWeight.Bold), - modifier = textModifier - ) - - SubtitleText(subtitle = "Text decorations") - Text(text = "Default", modifier = textModifier) - Text( - text = "Underline", - textDecoration = TextDecoration.Underline, - modifier = textModifier - ) - Text( - text = "LineThrough", - textDecoration = TextDecoration.LineThrough, - modifier = textModifier - ) - Text( - text = "UnderlineLineThrough", - textDecoration = TextDecoration.combine( - listOf( - TextDecoration.Underline, - TextDecoration.LineThrough - ) - ), - modifier = textModifier - ) - - SubtitleText(subtitle = "Overflow") - Text( - text = "Ellipsis: This text is supposed to ellipsis with max 1 line allowed for this", - overflow = TextOverflow.Ellipsis, - modifier = textModifier, - maxLines = 1 - ) - Text( - text = "Clip: This text is supposed to clip with max 1 line allowed for this", - overflow = TextOverflow.Clip, - modifier = textModifier, - maxLines = 1 - ) - } - - /* TODO: https://github.com/JetBrains/compose-jb/issues/106 - SubtitleText(subtitle = "font family dynamic") - Row { - Text(text = "Default", modifier = textModifier) - Text( - text = "Cursive", - style = typography.body1.copy(fontFamily = FontFamily.Cursive), - modifier = textModifier - ) - Text( - text = "SansSerif", - style = typography.body1.copy(fontFamily = FontFamily.SansSerif), - modifier = textModifier - ) - Text( - text = "Monospace", - style = typography.body1.copy(fontFamily = FontFamily.Monospace), - modifier = textModifier - ) - } */ -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt deleted file mode 100644 index ce3ac76ee2..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt +++ /dev/null @@ -1,71 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding -import androidx.compose.material.* -import androidx.compose.runtime.* -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -@Composable -fun Toggles() { - Column { - var checked by remember { mutableStateOf(true) } - Checkbox( - checked = checked, - modifier = Modifier.padding(8.dp), - onCheckedChange = { checked = !checked } - ) - - var switched by remember { mutableStateOf(true) } - Switch( - checked = switched, - colors = SwitchDefaults.colors(checkedThumbColor = MaterialTheme.colors.primary), - modifier = Modifier.padding(8.dp), - onCheckedChange = { switched = it } - ) - - AlignedColumn { - var selected by remember { mutableStateOf("Kotlin") } - for (lang in arrayOf("Kotlin", "Java", "Swift")) { - Row(verticalAlignment = Alignment.CenterVertically) { - RadioButton(selected = selected == lang, onClick = { selected = lang }) - Text( - text = lang, - modifier = Modifier.clickable(onClick = { selected = lang }).padding(start = 4.dp) - ) - } - } - } - - var sliderState by remember { mutableStateOf(0f) } - Slider(value = sliderState, modifier = Modifier.fillMaxWidth().padding(8.dp), - onValueChange = { newValue -> - sliderState = newValue - } - ) - - var sliderState2 by remember { mutableStateOf(20f) } - Slider(value = sliderState2, modifier = Modifier.fillMaxWidth().padding(8.dp), - valueRange = 0f..100f, - steps = 5, - colors = SliderDefaults.colors(thumbColor = MaterialTheme.colors.secondary), - onValueChange = { newValue -> - sliderState2 = newValue - } - ) - } -} - -@Composable -private fun AlignedColumn(content: @Composable () -> Unit) { - Column( - modifier = Modifier.fillMaxWidth().padding(16.dp) - ) { - content() - } -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt deleted file mode 100644 index 204a90fc09..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt +++ /dev/null @@ -1,103 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.screens - -import androidx.compose.foundation.Image -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ShoppingCart -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.data.DemoDataProvider -import org.jetbrains.compose.demo.widgets.platform.Res -import org.jetbrains.compose.demo.widgets.platform.painterResource -import org.jetbrains.compose.demo.widgets.theme.typography - -@OptIn(ExperimentalMaterialApi::class) -@Composable -fun UICards() { - val item = remember { DemoDataProvider.item } - - Text( - text = "Inbuilt box as container for any Clipping/Alignment controls", - style = typography.subtitle1, - modifier = Modifier.padding(8.dp) - ) - Card( - modifier = Modifier.padding(8.dp).fillMaxWidth(), - backgroundColor = MaterialTheme.colors.primary, - shape = RoundedCornerShape(topStart = 16.dp, bottomEnd = 16.dp) - ) { - Column { - Text( - text = item.title, - modifier = Modifier.padding(8.dp), - color = MaterialTheme.colors.onPrimary - ) - Text( - text = item.subtitle, - modifier = Modifier.padding(8.dp), - color = MaterialTheme.colors.onPrimary - ) - } - } - Divider() - - Text(text = "Inbuilt Card", style = typography.subtitle1, modifier = Modifier.padding(8.dp)) - Card( - modifier = Modifier.padding(16.dp).fillMaxWidth(), - shape = RoundedCornerShape(4.dp), - elevation = 4.dp - ) { - Row { - Image( - painterResource(Res.drawable.p3), - contentDescription = null, - modifier = Modifier.requiredSize(60.dp) - ) - Text(text = item.title, modifier = Modifier.padding(16.dp)) - } - } - Divider() - - Text( - text = "In-built ListItems", - style = typography.subtitle1, - modifier = Modifier.padding(8.dp) - ) - ListItem(text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }) - Divider(modifier = Modifier.padding(4.dp)) - ListItem( - text = { Text(item.title) }, - secondaryText = { Text(item.subtitle) }, - singleLineSecondaryText = false - ) - Divider(modifier = Modifier.padding(4.dp)) - ListItem(text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, icon = { - Image( - painterResource(Res.drawable.p3), - contentDescription = null - ) - }) - Divider(modifier = Modifier.padding(4.dp)) - //I am not sure why this is not going multiline for secondaryText... - ListItem( - text = { Text(item.title) }, - secondaryText = { Text(item.subtitle) }, - icon = { Image(painterResource(Res.drawable.p1), contentDescription = null) }, - overlineText = { Text("Overline text") }, - singleLineSecondaryText = false - ) - Divider() - ListItem( - text = { Text(item.title) }, - secondaryText = { Text(item.subtitle) }, - icon = { Image(painterResource(Res.drawable.p2), contentDescription = null) }, - trailing = { Icon(Icons.Default.ShoppingCart, contentDescription = null) }, - singleLineSecondaryText = false - ) - Divider() - -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt deleted file mode 100644 index 4fe446c26f..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt +++ /dev/null @@ -1,91 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.utils - -import androidx.compose.animation.core.* -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* -import androidx.compose.material.Icon -import androidx.compose.material.LocalContentColor -import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack -import androidx.compose.material.icons.filled.ArrowForward -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clipToBounds -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.graphicsLayer -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.SemanticsProperties -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.AnnotatedString -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp - -class PanelState { - val collapsedSize = 40.dp - var expandedSize by mutableStateOf(110.dp) - val expandedSizeMin = 120.dp - var isExpanded by mutableStateOf(true) - val splitter = SplitterState() -} - -@Composable -fun ResizablePanel( - modifier: Modifier, - state: PanelState, - title: String, - content: @Composable () -> Unit, -) { - val alpha = animateFloatAsState( - if (state.isExpanded) 1f else 0f, - SpringSpec(stiffness = Spring.StiffnessLow), - ).value - - Box(modifier) { - Column { - Row(Modifier - .height(32.dp) - .padding(6.dp) - .semantics(mergeDescendants = false) { - val text = if (state.isExpanded) "Collapse" else "Expand" - set(SemanticsProperties.Text, listOf( - AnnotatedString("$text $title panel") - )) - set(SemanticsProperties.Role, Role.Button) - } - .clickable { state.isExpanded = !state.isExpanded } - ) { - Icon( - if (state.isExpanded) Icons.Default.ArrowBack else Icons.Default.ArrowForward, - contentDescription = if (state.isExpanded) "Collapse" else "Expand", - tint = LocalContentColor.current, - modifier = Modifier - .size(24.dp) - .padding(start = 2.dp, end = 2.dp, bottom = 2.dp) - ) - Text( - text = if (state.isExpanded) title else "", - modifier = Modifier.fillMaxWidth().clipToBounds(), - fontSize = 14.sp - ) - } - - if (state.isExpanded) { - Box( - Modifier - .fillMaxWidth() - .height(1.dp) - .background(Color.Gray) - ) - - Column(Modifier.fillMaxSize().padding(top = 4.dp).graphicsLayer(alpha = alpha)) { - content() - } - } - } - } -} diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt deleted file mode 100644 index 083e8165cb..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt +++ /dev/null @@ -1,23 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.utils - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import org.jetbrains.compose.demo.widgets.theme.typography - -@Composable -fun SubtitleText(subtitle: String, modifier: Modifier = Modifier) { - Text(text = subtitle, style = typography.subtitle2, modifier = modifier.padding(8.dp)) -} - -@Composable -fun TitleText(title: String) { - Text( - text = title, - style = typography.h6.copy(fontSize = 14.sp), - modifier = Modifier.padding(8.dp) - ) -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt b/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt deleted file mode 100644 index 450fa865ea..0000000000 --- a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt +++ /dev/null @@ -1,96 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.utils - -import androidx.compose.foundation.background -import androidx.compose.foundation.gestures.draggable -import androidx.compose.foundation.gestures.Orientation -import androidx.compose.foundation.gestures.rememberDraggableState -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.width -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.layout.Layout -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.Constraints -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.platform.cursorForHorizontalResize - -class SplitterState { - var isResizing by mutableStateOf(false) - var isResizeEnabled by mutableStateOf(true) -} - -@Composable -fun VerticalSplittable( - modifier: Modifier, - splitterState: SplitterState, - onResize: (delta: Dp) -> Unit, - children: @Composable () -> Unit -) = Layout({ - children() - VerticalSplitter(splitterState, onResize) -}, modifier, measurePolicy = { measurables, constraints -> - require(measurables.size == 3) - - val firstPlaceable = measurables[0].measure(constraints.copy(minWidth = 0)) - val secondWidth = constraints.maxWidth - firstPlaceable.width - val secondPlaceable = measurables[1].measure( - Constraints( - minWidth = secondWidth, - maxWidth = secondWidth, - minHeight = constraints.maxHeight, - maxHeight = constraints.maxHeight - ) - ) - val splitterPlaceable = measurables[2].measure(constraints) - layout(constraints.maxWidth, constraints.maxHeight) { - firstPlaceable.place(0, 0) - secondPlaceable.place(firstPlaceable.width, 0) - splitterPlaceable.place(firstPlaceable.width, 0) - } -}) - - - -@Composable -fun VerticalSplitter( - splitterState: SplitterState, - onResize: (delta: Dp) -> Unit, - color: Color = Color.DarkGray -) = Box { - val density = LocalDensity.current - Box( - Modifier - .width(8.dp) - .fillMaxHeight() - .run { - if (splitterState.isResizeEnabled) { - this.draggable( - state = rememberDraggableState { - with(density) { - onResize(it.toDp()) - } - }, - orientation = Orientation.Horizontal, - startDragImmediately = true, - onDragStarted = { splitterState.isResizing = true }, - onDragStopped = { splitterState.isResizing = false } - ).cursorForHorizontalResize() - } else { - this - } - } - ) - - Box( - Modifier - .width(1.dp) - .fillMaxHeight() - .background(color) - ) -} \ No newline at end of file diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/food6.jpg b/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/food6.jpg deleted file mode 100644 index 2fdf68f5e1..0000000000 Binary files a/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/food6.jpg and /dev/null differ diff --git a/examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt b/examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt deleted file mode 100644 index ea49a5a059..0000000000 --- a/examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Resources.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.painter.Painter - -@Composable -actual fun painterResource(res: String): Painter = androidx.compose.ui.res.painterResource(res) diff --git a/examples/widgets-gallery/desktop/build.gradle.kts b/examples/widgets-gallery/desktop/build.gradle.kts deleted file mode 100644 index aeaf89a327..0000000000 --- a/examples/widgets-gallery/desktop/build.gradle.kts +++ /dev/null @@ -1,43 +0,0 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - kotlin("multiplatform") // kotlin("jvm") doesn't work well in IDEA/AndroidStudio (https://github.com/JetBrains/compose-jb/issues/22) - id("org.jetbrains.compose") -} - -kotlin { - jvm { - withJava() - } - - sourceSets { - named("jvmMain") { - dependencies { - implementation(compose.desktop.currentOs) - implementation(project(":common")) - } - } - } -} - -compose.desktop { - application { - mainClass = "org.jetbrains.compose.demo.widgets.MainKt" - - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "ComposeWidgetsGallery" - packageVersion = "1.0.0" - - windows { - menu = true - // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html - upgradeUuid = "a61b72be-1b0c-4de5-9607-791c17687428" - } - - macOS { - bundleID = "org.jetbrains.compose.demo.widgets" - } - } - } -} diff --git a/examples/widgets-gallery/desktop/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt b/examples/widgets-gallery/desktop/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt deleted file mode 100644 index 5497905568..0000000000 --- a/examples/widgets-gallery/desktop/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.compose.demo.widgets - -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.WindowState -import androidx.compose.ui.window.singleWindowApplication -import org.jetbrains.compose.demo.widgets.ui.MainView - -fun main() = singleWindowApplication( - title = "Widgets Gallery", state = WindowState(size = DpSize(800.dp, 800.dp)) -) { - MainView() -} \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/desktopApp/build.gradle.kts b/examples/widgets-gallery/desktopApp/build.gradle.kts similarity index 100% rename from experimental/examples/widgets-gallery/desktopApp/build.gradle.kts rename to examples/widgets-gallery/desktopApp/build.gradle.kts diff --git a/experimental/examples/widgets-gallery/desktopApp/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt b/examples/widgets-gallery/desktopApp/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt similarity index 100% rename from experimental/examples/widgets-gallery/desktopApp/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt rename to examples/widgets-gallery/desktopApp/src/jvmMain/kotlin/org/jetbrains/compose/demo/widgets/main.kt diff --git a/examples/widgets-gallery/gradle.properties b/examples/widgets-gallery/gradle.properties index bb4113d2b7..9ff8815ad5 100644 --- a/examples/widgets-gallery/gradle.properties +++ b/examples/widgets-gallery/gradle.properties @@ -1,24 +1,16 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -kotlin.version=1.8.10 -compose.version=1.3.1 +xcodeproj=./iosApp +kotlin.native.cocoapods.generate.wrapper=true +android.useAndroidX=true +org.gradle.jvmargs=-Xmx3g +org.jetbrains.compose.experimental.jscanvas.enabled=true +org.jetbrains.compose.experimental.macos.enabled=true +org.jetbrains.compose.experimental.uikit.enabled=true +kotlin.native.cacheKind=none +kotlin.native.useEmbeddableCompilerJar=true +kotlin.mpp.androidSourceSetLayoutVersion=2 +# Enable kotlin/native experimental memory model +kotlin.native.binary.memoryModel=experimental +kotlin.version=1.8.0 agp.version=7.1.3 +compose.version=1.4.0-rc01 diff --git a/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar b/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar index 62d4c05355..249e5832f0 100644 Binary files a/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar and b/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar differ diff --git a/examples/widgets-gallery/gradlew b/examples/widgets-gallery/gradlew index 2fe81a7d95..a69d9cb6c2 100755 --- a/examples/widgets-gallery/gradlew +++ b/examples/widgets-gallery/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,113 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -105,79 +140,101 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/examples/widgets-gallery/gradlew.bat b/examples/widgets-gallery/gradlew.bat index 9618d8d960..f127cfd49d 100644 --- a/examples/widgets-gallery/gradlew.bat +++ b/examples/widgets-gallery/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,13 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,38 +64,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/experimental/examples/widgets-gallery/iosApp/Configuration/Config.xcconfig b/examples/widgets-gallery/iosApp/Configuration/Config.xcconfig similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/Configuration/Config.xcconfig rename to examples/widgets-gallery/iosApp/Configuration/Config.xcconfig diff --git a/experimental/examples/widgets-gallery/iosApp/Podfile b/examples/widgets-gallery/iosApp/Podfile similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/Podfile rename to examples/widgets-gallery/iosApp/Podfile diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/widgets-gallery/iosApp/iosApp.xcodeproj/project.pbxproj diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/widgets-gallery/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/ContentView.swift b/examples/widgets-gallery/iosApp/iosApp/ContentView.swift similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/ContentView.swift rename to examples/widgets-gallery/iosApp/iosApp/ContentView.swift diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/Info.plist b/examples/widgets-gallery/iosApp/iosApp/Info.plist similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/Info.plist rename to examples/widgets-gallery/iosApp/iosApp/Info.plist diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/widgets-gallery/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/widgets-gallery/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/experimental/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift b/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift similarity index 100% rename from experimental/examples/widgets-gallery/iosApp/iosApp/iOSApp.swift rename to examples/widgets-gallery/iosApp/iosApp/iOSApp.swift diff --git a/experimental/examples/widgets-gallery/run-configurations.png b/examples/widgets-gallery/run-configurations.png similarity index 100% rename from experimental/examples/widgets-gallery/run-configurations.png rename to examples/widgets-gallery/run-configurations.png diff --git a/examples/widgets-gallery/screenshots/desktop-run-configuration.png b/examples/widgets-gallery/screenshots/desktop-run-configuration.png deleted file mode 100644 index 3688407c6f..0000000000 Binary files a/examples/widgets-gallery/screenshots/desktop-run-configuration.png and /dev/null differ diff --git a/examples/widgets-gallery/settings.gradle.kts b/examples/widgets-gallery/settings.gradle.kts index f4ac8d1ff7..76eb8f5ec8 100644 --- a/examples/widgets-gallery/settings.gradle.kts +++ b/examples/widgets-gallery/settings.gradle.kts @@ -13,10 +13,15 @@ pluginManagement { kotlin("jvm").version(kotlinVersion) kotlin("multiplatform").version(kotlinVersion) kotlin("android").version(kotlinVersion) + id("com.android.base").version(agpVersion) id("com.android.application").version(agpVersion) id("com.android.library").version(agpVersion) id("org.jetbrains.compose").version(composeVersion) } } -include(":common", ":android", ":desktop") +rootProject.name = "widgets-gallery" + +include(":androidApp") +include(":shared") +include(":desktopApp") diff --git a/experimental/examples/widgets-gallery/shared/build.gradle.kts b/examples/widgets-gallery/shared/build.gradle.kts similarity index 100% rename from experimental/examples/widgets-gallery/shared/build.gradle.kts rename to examples/widgets-gallery/shared/build.gradle.kts diff --git a/examples/widgets-gallery/common/src/androidMain/AndroidManifest.xml b/examples/widgets-gallery/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/widgets-gallery/common/src/androidMain/AndroidManifest.xml rename to examples/widgets-gallery/shared/src/androidMain/AndroidManifest.xml diff --git a/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/main.android.kt b/examples/widgets-gallery/shared/src/androidMain/kotlin/main.android.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/main.android.kt rename to examples/widgets-gallery/shared/src/androidMain/kotlin/main.android.kt diff --git a/examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt similarity index 100% rename from examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt rename to examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt diff --git a/examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt similarity index 100% rename from examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt rename to examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt diff --git a/examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt similarity index 100% rename from examples/widgets-gallery/common/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt rename to examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Item.kt diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Theme.kt diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/MainView.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetView.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/WidgetsType.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Buttons.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Loaders.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/SnackBars.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/TextInputs.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Texts.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Toggles.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt diff --git a/examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/ResizablePanel.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/Text.kt diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt rename to examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/VerticalSplittable.kt diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p1.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p1.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p2.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p2.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p3.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p3.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p6.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable-nodpi/p6.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable/ic_instagram.xml b/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable/ic_instagram.xml rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable/ic_send.xml b/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable/ic_send.xml rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml diff --git a/examples/widgets-gallery/common/src/commonMain/resources/drawable/ic_twitter.xml b/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml similarity index 100% rename from examples/widgets-gallery/common/src/commonMain/resources/drawable/ic_twitter.xml rename to examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml diff --git a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/widgets-gallery/shared/src/desktopMain/kotlin/main.desktop.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/main.desktop.kt rename to examples/widgets-gallery/shared/src/desktopMain/kotlin/main.desktop.kt diff --git a/examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt similarity index 100% rename from examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt rename to examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt diff --git a/examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt similarity index 100% rename from examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt rename to examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt diff --git a/examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt similarity index 100% rename from examples/widgets-gallery/common/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt rename to examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt diff --git a/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt rename to examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt diff --git a/experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt rename to examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt diff --git a/experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt rename to examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt diff --git a/experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/main.ios.kt b/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/main.ios.kt similarity index 100% rename from experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/main.ios.kt rename to examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/main.ios.kt diff --git a/experimental/examples/codeviewer/.gitignore b/experimental/examples/codeviewer/.gitignore deleted file mode 100644 index 6e5f30477c..0000000000 --- a/experimental/examples/codeviewer/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea -.DS_Store -build/ -/captures -.externalNativeBuild -.cxx -iosApp/Podfile.lock -iosApp/Pods/* -iosApp/iosApp.xcworkspace/* -iosApp/iosApp.xcodeproj/* -!iosApp/iosApp.xcodeproj/project.pbxproj -shared/shared.podspec diff --git a/experimental/examples/codeviewer/README.md b/experimental/examples/codeviewer/README.md deleted file mode 100644 index 2489eae3dd..0000000000 --- a/experimental/examples/codeviewer/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Code Viewer -MPP Code Viewer example for desktop/android/iOS written in Multiplatform Compose library. - -## How to run - -Choose a run configuration for an appropriate target in IDE and run it. - -![run-configurations.png](run-configurations.png) - -To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. -Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then -using "Signing & Capabilities" tab of `Codeviewer` target. - -Then choose **iosApp** configuration in IDE and run it. - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -### Building native desktop distribution -``` -./gradlew :desktop:packageDistributionForCurrentOS -# outputs are written to desktop/build/compose/binaries -``` - -![Desktop](screenshots/codeviewer.png) \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/AndroidManifest.xml b/experimental/examples/codeviewer/androidApp/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 308d3a79b5..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/assets/data/EditorView.kt b/experimental/examples/codeviewer/androidApp/src/androidMain/assets/data/EditorView.kt deleted file mode 100644 index ea878feace..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/assets/data/EditorView.kt +++ /dev/null @@ -1,183 +0,0 @@ -/** - * This file is an example (we can open it in android application) - */ - -package org.jetbrains.codeviewer.ui.editor - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.text.selection.DisableSelection -import androidx.compose.material.AmbientContentColor -import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Surface -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.key -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.alpha -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.text.* -import androidx.compose.ui.unit.dp -import org.jetbrains.codeviewer.platform.SelectionContainer -import org.jetbrains.codeviewer.ui.common.AppTheme -import org.jetbrains.codeviewer.ui.common.Fonts -import org.jetbrains.codeviewer.ui.common.Settings -import org.jetbrains.codeviewer.util.loadableScoped -import org.jetbrains.codeviewer.util.withoutWidthConstraints -import kotlin.text.Regex.Companion.fromLiteral - -@Composable -fun EditorView(model: Editor, settings: Settings) = key(model) { - with (LocalDensity.current) { - SelectionContainer { - Surface( - Modifier.fillMaxSize(), - color = AppTheme.colors.backgroundDark, - ) { - val lines by loadableScoped(model.lines) - - if (lines != null) { - Box { - Lines(lines!!, settings) - Box( - Modifier - .offset( - x = settings.fontSize.toDp() * 0.5f * settings.maxLineSymbols - ) - .width(1.dp) - .fillMaxHeight() - .background(AppTheme.colors.backgroundLight) - ) - } - } else { - CircularProgressIndicator( - modifier = Modifier - .size(36.dp) - .padding(4.dp) - ) - } - } - } - } -} - -@Composable -private fun Lines(lines: Editor.Lines, settings: Settings) = with(DensityAmbient.current) { - val maxNumber = remember(lines.lineNumberDigitCount) { - (1..lines.lineNumberDigitCount).joinToString(separator = "") { "9" } - } - - Box(Modifier.fillMaxSize()) { - val scrollState = rememberLazyListState() - val lineHeight = settings.fontSize.toDp() * 1.6f - - LazyColumnFor( - lines.size, - modifier = Modifier.fillMaxSize(), - state = scrollState, - itemContent = { index -> - val line: Editor.Line? by loadable { lines.get(index) } - Box(Modifier.height(lineHeight)) { - if (line != null) { - Line(Modifier.align(Alignment.CenterStart), maxNumber, line!!, settings) - } - } - } - ) - - VerticalScrollbar( - Modifier.align(Alignment.CenterEnd), - scrollState, - lines.size, - lineHeight - ) - } -} - -// Поддержка русского языка -// دعم اللغة العربية -// 中文支持 -@Composable -private fun Line(modifier: Modifier, maxNumber: String, line: Editor.Line, settings: Settings) { - Row(modifier = modifier) { - DisableSelection { - Box { - LineNumber(maxNumber, Modifier.alpha(0f), settings) - LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings) - } - } - LineContent( - line.content, - modifier = Modifier - .weight(1f) - .withoutWidthConstraints() - .padding(start = 28.dp, end = 12.dp), - settings = settings - ) - } -} - -@Composable -private fun LineNumber(number: String, modifier: Modifier, settings: Settings) = Text( - text = number, - fontSize = settings.fontSize, - fontFamily = Fonts.jetbrainsMono(), - color = AmbientContentColor.current.copy(alpha = 0.30f), - modifier = modifier.padding(start = 12.dp) -) - -@Composable -private fun LineContent(content: Editor.Content, modifier: Modifier, settings: Settings) = Text( - text = if (content.isCode) { - codeString(content.value.value) - } else { - AnnotatedString(content.value.value) - }, - fontSize = settings.fontSize, - fontFamily = Fonts.jetbrainsMono(), - modifier = modifier, - softWrap = false -) - -private fun codeString(str: String) = buildAnnotatedString { - withStyle(AppTheme.code.simple) { - append(str.replace("\t", " ")) - addStyle(AppTheme.code.punctuation, ":") - addStyle(AppTheme.code.punctuation, "=") - addStyle(AppTheme.code.punctuation, "\"") - addStyle(AppTheme.code.punctuation, "[") - addStyle(AppTheme.code.punctuation, "]") - addStyle(AppTheme.code.punctuation, "{") - addStyle(AppTheme.code.punctuation, "}") - addStyle(AppTheme.code.punctuation, "(") - addStyle(AppTheme.code.punctuation, ")") - addStyle(AppTheme.code.punctuation, ",") - addStyle(AppTheme.code.keyword, "fun ") - addStyle(AppTheme.code.keyword, "val ") - addStyle(AppTheme.code.keyword, "var ") - addStyle(AppTheme.code.keyword, "private ") - addStyle(AppTheme.code.keyword, "internal ") - addStyle(AppTheme.code.keyword, "for ") - addStyle(AppTheme.code.keyword, "expect ") - addStyle(AppTheme.code.keyword, "actual ") - addStyle(AppTheme.code.keyword, "import ") - addStyle(AppTheme.code.keyword, "package ") - addStyle(AppTheme.code.value, "true") - addStyle(AppTheme.code.value, "false") - addStyle(AppTheme.code.value, Regex("[0-9]*")) - addStyle(AppTheme.code.annotation, Regex("^@[a-zA-Z_]*")) - addStyle(AppTheme.code.comment, Regex("^\\s*//.*")) - } -} - -private fun AnnotatedString.Builder.addStyle(style: SpanStyle, regexp: String) { - addStyle(style, fromLiteral(regexp)) -} - -private fun AnnotatedString.Builder.addStyle(style: SpanStyle, regexp: Regex) { - for (result in regexp.findAll(toString())) { - addStyle(style, result.range.first, result.range.last + 1) - } -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/res/drawable/ic_launcher_foreground.xml b/experimental/examples/codeviewer/androidApp/src/androidMain/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index cecdd7d062..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/experimental/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index 7353dbd1fd..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml b/experimental/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index 7353dbd1fd..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/res/values/ic_launcher_background.xml b/experimental/examples/codeviewer/androidApp/src/androidMain/res/values/ic_launcher_background.xml deleted file mode 100644 index 5950cfc18e..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/res/values/ic_launcher_background.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #3C3F41 - \ No newline at end of file diff --git a/experimental/examples/codeviewer/androidApp/src/androidMain/res/values/strings.xml b/experimental/examples/codeviewer/androidApp/src/androidMain/res/values/strings.xml deleted file mode 100644 index 19c9645e07..0000000000 --- a/experimental/examples/codeviewer/androidApp/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Code Viewer - \ No newline at end of file diff --git a/experimental/examples/codeviewer/build.gradle.kts b/experimental/examples/codeviewer/build.gradle.kts deleted file mode 100644 index 8d0c1f3d7c..0000000000 --- a/experimental/examples/codeviewer/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader - kotlin("jvm") apply false - kotlin("multiplatform") apply false - kotlin("android") apply false - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.compose") apply false -} - -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - mavenLocal() - } -} diff --git a/experimental/examples/codeviewer/desktopApp/src/jvmMain/resources/ic_launcher.png b/experimental/examples/codeviewer/desktopApp/src/jvmMain/resources/ic_launcher.png deleted file mode 100644 index db540cf91c..0000000000 Binary files a/experimental/examples/codeviewer/desktopApp/src/jvmMain/resources/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar b/experimental/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f0..0000000000 Binary files a/experimental/examples/codeviewer/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/experimental/examples/codeviewer/gradlew b/experimental/examples/codeviewer/gradlew deleted file mode 100755 index a69d9cb6c2..0000000000 --- a/experimental/examples/codeviewer/gradlew +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/experimental/examples/codeviewer/gradlew.bat b/experimental/examples/codeviewer/gradlew.bat deleted file mode 100644 index f127cfd49d..0000000000 --- a/experimental/examples/codeviewer/gradlew.bat +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/experimental/examples/codeviewer/screenshots/codeviewer.png b/experimental/examples/codeviewer/screenshots/codeviewer.png deleted file mode 100755 index 4ec6a56265..0000000000 Binary files a/experimental/examples/codeviewer/screenshots/codeviewer.png and /dev/null differ diff --git a/experimental/examples/codeviewer/settings.gradle.kts b/experimental/examples/codeviewer/settings.gradle.kts deleted file mode 100644 index a1d0b79e3e..0000000000 --- a/experimental/examples/codeviewer/settings.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - google() - mavenLocal() - } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("jvm").version(kotlinVersion) - kotlin("multiplatform").version(kotlinVersion) - kotlin("android").version(kotlinVersion) - id("com.android.base").version(agpVersion) - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - id("org.jetbrains.compose").version(composeVersion) - } -} - -rootProject.name = "codeviewer" - -include(":androidApp") -include(":shared") -include(":desktopApp") diff --git a/experimental/examples/codeviewer/shared/src/androidMain/AndroidManifest.xml b/experimental/examples/codeviewer/shared/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 59fb71fb1b..0000000000 --- a/experimental/examples/codeviewer/shared/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt deleted file mode 100644 index 497976a715..0000000000 --- a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/File.kt +++ /dev/null @@ -1,4 +0,0 @@ -package org.jetbrains.codeviewer.platform - -lateinit var _HomeFolder: java.io.File -actual val HomeFolder: File get() = _HomeFolder.toProjectFile() \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt deleted file mode 100644 index 4095a8bf60..0000000000 --- a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset - -actual fun Modifier.cursorForHorizontalResize() = this \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt deleted file mode 100644 index ad049b6045..0000000000 --- a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt +++ /dev/null @@ -1,16 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import android.annotation.SuppressLint -import androidx.compose.runtime.Composable -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.font.Font -import androidx.compose.ui.text.font.FontStyle -import androidx.compose.ui.text.font.FontWeight - -@SuppressLint("DiscouragedApi") -@Composable -actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font { - val context = LocalContext.current - val id = context.resources.getIdentifier(res, "font", context.packageName) - return Font(id, weight, style) -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt deleted file mode 100644 index 8832527ae0..0000000000 --- a/experimental/examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: ScrollState -) = Unit - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: LazyListState -) = Unit \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt deleted file mode 100644 index 8cb45b2de4..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/File.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import kotlinx.coroutines.CoroutineScope -import org.jetbrains.codeviewer.util.TextLines - -expect val HomeFolder: File - -interface File { - val name: String - val isDirectory: Boolean - val children: List - val hasChildren: Boolean - - fun readLines(scope: CoroutineScope): TextLines -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt deleted file mode 100644 index 28a5c3dec9..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.ui.Modifier - -expect fun Modifier.cursorForHorizontalResize(): Modifier \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt deleted file mode 100644 index 9d65e5b2e0..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewer.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.codeviewer.ui - -import org.jetbrains.codeviewer.ui.common.Settings -import org.jetbrains.codeviewer.ui.editor.Editors -import org.jetbrains.codeviewer.ui.filetree.FileTree - -class CodeViewer( - val editors: Editors, - val fileTree: FileTree, - val settings: Settings -) \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt deleted file mode 100644 index 7b1d27e57f..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Settings.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.codeviewer.ui.common - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.unit.sp - -class Settings { - var fontSize by mutableStateOf(13.sp) - val maxLineSymbols = 120 -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt deleted file mode 100644 index b849ea4a95..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Theme.kt +++ /dev/null @@ -1,32 +0,0 @@ -package org.jetbrains.codeviewer.ui.common - -import androidx.compose.material.darkColors -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.SpanStyle - -object AppTheme { - val colors: Colors = Colors() - - val code: Code = Code() - - class Colors( - val backgroundDark: Color = Color(0xFF2B2B2B), - val backgroundMedium: Color = Color(0xFF3C3F41), - val backgroundLight: Color = Color(0xFF4E5254), - - val material: androidx.compose.material.Colors = darkColors( - background = backgroundDark, - surface = backgroundMedium, - primary = Color.White - ), - ) - - class Code( - val simple: SpanStyle = SpanStyle(Color(0xFFA9B7C6)), - val value: SpanStyle = SpanStyle(Color(0xFF6897BB)), - val keyword: SpanStyle = SpanStyle(Color(0xFFCC7832)), - val punctuation: SpanStyle = SpanStyle(Color(0xFFA1C17E)), - val annotation: SpanStyle = SpanStyle(Color(0xFFBBB529)), - val comment: SpanStyle = SpanStyle(Color(0xFF808080)) - ) -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt deleted file mode 100644 index 30676f1ed6..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editor.kt +++ /dev/null @@ -1,60 +0,0 @@ -package org.jetbrains.codeviewer.ui.editor - -import androidx.compose.runtime.State -import androidx.compose.runtime.mutableStateOf -import kotlinx.coroutines.CoroutineScope -import org.jetbrains.codeviewer.platform.File -import org.jetbrains.codeviewer.util.EmptyTextLines -import org.jetbrains.codeviewer.util.SingleSelection - -class Editor( - val fileName: String, - val lines: (backgroundScope: CoroutineScope) -> Lines, -) { - var close: (() -> Unit)? = null - lateinit var selection: SingleSelection - - val isActive: Boolean - get() = selection.selected === this - - fun activate() { - selection.selected = this - } - - class Line(val number: Int, val content: Content) - - interface Lines { - val lineNumberDigitCount: Int get() = size.toString().length - val size: Int - operator fun get(index: Int): Line - } - - class Content(val value: State, val isCode: Boolean) -} - -fun Editor(file: File) = Editor( - fileName = file.name -) { backgroundScope -> - val textLines = try { - file.readLines(backgroundScope) - } catch (e: Throwable) { - e.printStackTrace() - EmptyTextLines - } - val isCode = file.name.endsWith(".kt", ignoreCase = true) - - fun content(index: Int): Editor.Content { - val text = textLines.get(index) - val state = mutableStateOf(text) - return Editor.Content(state, isCode) - } - - object : Editor.Lines { - override val size get() = textLines.size - - override fun get(index: Int) = Editor.Line( - number = index + 1, - content = content(index) - ) - } -} diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt deleted file mode 100644 index a6efd020d5..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/Editors.kt +++ /dev/null @@ -1,32 +0,0 @@ -package org.jetbrains.codeviewer.ui.editor - -import androidx.compose.runtime.mutableStateListOf -import org.jetbrains.codeviewer.platform.File -import org.jetbrains.codeviewer.util.SingleSelection - -class Editors { - private val selection = SingleSelection() - - var editors = mutableStateListOf() - private set - - val active: Editor? get() = selection.selected as Editor? - - fun open(file: File) { - val editor = Editor(file) - editor.selection = selection - editor.close = { - close(editor) - } - editors.add(editor) - editor.activate() - } - - private fun close(editor: Editor) { - val index = editors.indexOf(editor) - editors.remove(editor) - if (editor.isActive) { - selection.selected = editors.getOrNull(index.coerceAtMost(editors.lastIndex)) - } - } -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt deleted file mode 100644 index c6c5ef628e..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTree.kt +++ /dev/null @@ -1,72 +0,0 @@ -package org.jetbrains.codeviewer.ui.filetree - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import org.jetbrains.codeviewer.platform.File -import org.jetbrains.codeviewer.ui.editor.Editors - -class ExpandableFile( - val file: File, - val level: Int, -) { - var children: List by mutableStateOf(emptyList()) - val canExpand: Boolean get() = file.hasChildren - - fun toggleExpanded() { - children = if (children.isEmpty()) { - file.children - .map { ExpandableFile(it, level + 1) } - .sortedWith(compareBy({ it.file.isDirectory }, { it.file.name })) - .sortedBy { !it.file.isDirectory } - } else { - emptyList() - } - } -} - -class FileTree(root: File, private val editors: Editors) { - private val expandableRoot = ExpandableFile(root, 0).apply { - toggleExpanded() - } - - val items: List get() = expandableRoot.toItems() - - inner class Item constructor( - private val file: ExpandableFile - ) { - val name: String get() = file.file.name - - val level: Int get() = file.level - - val type: ItemType - get() = if (file.file.isDirectory) { - ItemType.Folder(isExpanded = file.children.isNotEmpty(), canExpand = file.canExpand) - } else { - ItemType.File(ext = file.file.name.substringAfterLast(".").lowercase()) - } - - fun open() = when (type) { - is ItemType.Folder -> file.toggleExpanded() - is ItemType.File -> editors.open(file.file) - } - } - - sealed class ItemType { - class Folder(val isExpanded: Boolean, val canExpand: Boolean) : ItemType() - class File(val ext: String) : ItemType() - } - - private fun ExpandableFile.toItems(): List { - fun ExpandableFile.addTo(list: MutableList) { - list.add(Item(this)) - for (child in children) { - child.addTo(list) - } - } - - val list = mutableListOf() - addTo(list) - return list - } -} diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt deleted file mode 100644 index 423abafa95..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.codeviewer.util - -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.layout - -fun Modifier.withoutWidthConstraints() = layout { measurable, constraints -> - val placeable = measurable.measure(constraints.copy(maxWidth = Int.MAX_VALUE)) - layout(constraints.maxWidth, placeable.height) { - placeable.place(0, 0) - } -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt deleted file mode 100644 index 1defe47d18..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/SingleSelection.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.codeviewer.util - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue - -class SingleSelection { - var selected: Any? by mutableStateOf(null) -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt b/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt deleted file mode 100644 index ce5361f017..0000000000 --- a/experimental/examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/util/TextLines.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.jetbrains.codeviewer.util - -interface TextLines { - val size: Int - fun get(index: Int): String -} - -object EmptyTextLines : TextLines { - override val size: Int - get() = 0 - - override fun get(index: Int): String = "" -} \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold.ttf deleted file mode 100644 index 5dc6ec2455..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf deleted file mode 100644 index 8a36bccfc6..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf deleted file mode 100644 index bba598e009..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf deleted file mode 100644 index ff89d25d37..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_italic.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_italic.ttf deleted file mode 100644 index 44e1f4a7f3..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_italic.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium.ttf deleted file mode 100644 index 017b81fb09..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf deleted file mode 100644 index 6da1d17537..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_regular.ttf b/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_regular.ttf deleted file mode 100644 index 7db854fd91..0000000000 Binary files a/experimental/examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_regular.ttf and /dev/null differ diff --git a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt b/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt deleted file mode 100644 index 9dfe0a9ca6..0000000000 --- a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/File.kt +++ /dev/null @@ -1,5 +0,0 @@ -@file:Suppress("NewApi") - -package org.jetbrains.codeviewer.platform - -actual val HomeFolder: File get() = java.io.File(System.getProperty("user.home")).toProjectFile() \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt b/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt deleted file mode 100644 index fdecfe3ceb..0000000000 --- a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.runtime.Composable -import androidx.compose.ui.text.font.Font -import androidx.compose.ui.text.font.FontStyle -import androidx.compose.ui.text.font.FontWeight - -@Composable -actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font = - androidx.compose.ui.text.platform.Font("font/$res.ttf", weight, style) \ No newline at end of file diff --git a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt b/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt deleted file mode 100644 index c8af7f095c..0000000000 --- a/experimental/examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.jetbrains.codeviewer.platform - -import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.rememberScrollbarAdapter -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: ScrollState -) = androidx.compose.foundation.VerticalScrollbar( - rememberScrollbarAdapter(scrollState), - modifier -) - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: LazyListState -) = androidx.compose.foundation.VerticalScrollbar( - rememberScrollbarAdapter(scrollState), - modifier -) \ No newline at end of file diff --git a/experimental/examples/falling-balls-mpp/.gitignore b/experimental/examples/falling-balls-mpp/.gitignore deleted file mode 100644 index 968bdd56ce..0000000000 --- a/experimental/examples/falling-balls-mpp/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -local.properties -iosApp/Podfile.lock -iosApp/Pods/* -iosApp/iosApp.xcworkspace/* -iosApp/iosApp.xcodeproj/* -!iosApp/iosApp.xcodeproj/project.pbxproj -shared/shared.podspec \ No newline at end of file diff --git a/experimental/examples/falling-balls-mpp/README.md b/experimental/examples/falling-balls-mpp/README.md deleted file mode 100644 index a7d18ef15f..0000000000 --- a/experimental/examples/falling-balls-mpp/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# Falling Balls game - -Game can run on Android, iOS, desktop or in a browser. - -*Prerequisites*: to run on iOS and Android, you should have "Kotlin Multiplatform Mobile" plugin installed either - in Android Studio or in AppCode with [installed CocoaPods](https://kotlinlang.org/docs/native-cocoapods.html). - - -## How to run - -Choose a run configuration for an appropriate target in IDE and run it. - -![run-configurations.png](run-configurations.png) - -To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. -Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then -using "Signing & Capabilities" tab of `iosApp` target. See also how to prepare XCode section below. - -Then choose **iosApp** configuration in IDE and run it. - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -## Run JS in browser with WebAssembly Skia via Gradle - -`./gradlew jsApp:jsBrowserDevelopmentRun` - -## Prepare Xcode to launch on iOS device - -1) **Add your Apple ID.** -Xcode -> Preferences... -> Accounts -![apple-id.png](apple-id.png) - -2) **Create certificates with XCode in temporary project.** -You can create a certificate in Xcode. Create a new iOS app in Xcode. -File -> New -> Project -Choose iOS, App: -![ios-app.png](ios-app.png) - -3) **In next dialog set any product name and choose your teamID.** - -4) **Run project on iOS Device.** -Xcode prompts you to install the certificate. Require password from login.keychain - -5) **Done** -After a successful launch on the device - you can delete this temporary project. -Certificates will remain in login.keychain - -## Run native on MacOS -Choose **shared[macosX64]** or **shared[macosArm64]** configuration in IDE and run it. - diff --git a/experimental/examples/falling-balls-mpp/gradle.properties b/experimental/examples/falling-balls-mpp/gradle.properties deleted file mode 100644 index 720f561017..0000000000 --- a/experimental/examples/falling-balls-mpp/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -kotlin.native.cocoapods.generate.wrapper=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx3g -org.jetbrains.compose.experimental.jscanvas.enabled=true -org.jetbrains.compose.experimental.macos.enabled=true -org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none -kotlin.native.useEmbeddableCompilerJar=true -kotlin.mpp.androidSourceSetLayoutVersion=2 -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.0 -agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 diff --git a/experimental/examples/falling-balls-mpp/gradle/wrapper/gradle-wrapper.jar b/experimental/examples/falling-balls-mpp/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f0..0000000000 Binary files a/experimental/examples/falling-balls-mpp/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/experimental/examples/falling-balls-mpp/gradle/wrapper/gradle-wrapper.properties b/experimental/examples/falling-balls-mpp/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae04661ee7..0000000000 --- a/experimental/examples/falling-balls-mpp/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/experimental/examples/falling-balls-mpp/gradlew b/experimental/examples/falling-balls-mpp/gradlew deleted file mode 100755 index a69d9cb6c2..0000000000 --- a/experimental/examples/falling-balls-mpp/gradlew +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/experimental/examples/falling-balls-mpp/gradlew.bat b/experimental/examples/falling-balls-mpp/gradlew.bat deleted file mode 100644 index f127cfd49d..0000000000 --- a/experimental/examples/falling-balls-mpp/gradlew.bat +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/experimental/examples/falling-balls-mpp/settings.gradle.kts b/experimental/examples/falling-balls-mpp/settings.gradle.kts deleted file mode 100644 index 95b7916058..0000000000 --- a/experimental/examples/falling-balls-mpp/settings.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - google() - } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("jvm").version(kotlinVersion) - kotlin("multiplatform").version(kotlinVersion) - kotlin("android").version(kotlinVersion) - id("com.android.base").version(agpVersion) - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - id("org.jetbrains.compose").version(composeVersion) - } -} - -rootProject.name = "falling-balls-mpp" - -include(":androidApp") -include(":shared") -include(":desktopApp") -include(":jsApp") diff --git a/experimental/examples/imageviewer/.gitignore b/experimental/examples/imageviewer/.gitignore deleted file mode 100644 index d27dff7cb0..0000000000 --- a/experimental/examples/imageviewer/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -build/ -/captures -.externalNativeBuild -.cxx -iosApp/Podfile.lock -iosApp/Pods/* -iosApp/iosApp.xcworkspace/* -iosApp/iosApp.xcodeproj/* -!iosApp/iosApp.xcodeproj/project.pbxproj -shared/shared.podspec diff --git a/experimental/examples/imageviewer/README.md b/experimental/examples/imageviewer/README.md deleted file mode 100755 index 72e6408ee5..0000000000 --- a/experimental/examples/imageviewer/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Imageviewer - -An example of image gallery for remote server image viewing, -based on Compose Multiplatform UI library (desktop, android and iOS). - -## How to run - -Choose a run configuration for an appropriate target in IDE and run it. - -![run-configurations.png](screenshots/run-configurations.png) - -To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. -Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then -using "Signing & Capabilities" tab of `iosApp` target. - -Then choose **iosApp** configuration in IDE and run it. - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -### Building native desktop distribution - -``` -./gradlew :desktop:packageDistributionForCurrentOS -# outputs are written to desktop/build/compose/binaries -``` - -### Running Android application - -- Get a [Google Maps API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key) -- Add to `local.properties` file located in the root directory (create if it doesn't exist): - - `MAPS_API_KEY=YOUR_KEY` where `YOUR_KEY` is your key from previous step; - - `sdk.dir=YOUR_SDK_PATH` where `YOUR_SDK_PATH` is a path to Android SDK in your system. -- Open project in IntelliJ IDEA or Android Studio and run `androidApp` configuration. diff --git a/experimental/examples/imageviewer/build.gradle.kts b/experimental/examples/imageviewer/build.gradle.kts deleted file mode 100644 index 0c00883af5..0000000000 --- a/experimental/examples/imageviewer/build.gradle.kts +++ /dev/null @@ -1,18 +0,0 @@ -plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader - kotlin("jvm") apply false - kotlin("multiplatform") apply false - kotlin("android") apply false - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.compose") apply false -} - -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - } -} diff --git a/experimental/examples/imageviewer/desktopApp/rules.pro b/experimental/examples/imageviewer/desktopApp/rules.pro deleted file mode 100644 index a01578e999..0000000000 --- a/experimental/examples/imageviewer/desktopApp/rules.pro +++ /dev/null @@ -1,12 +0,0 @@ -# Ktor --keep class io.ktor.** { *; } --keepclassmembers class io.ktor.** { volatile ; } --keep class io.ktor.client.engine.cio.** { *; } --keep class kotlinx.coroutines.** { *; } --dontwarn kotlinx.atomicfu.** --dontwarn io.netty.** --dontwarn com.typesafe.** --dontwarn org.slf4j.** - -# Obfuscation breaks coroutines/ktor for some reason --dontobfuscate diff --git a/experimental/examples/imageviewer/gradle.properties b/experimental/examples/imageviewer/gradle.properties deleted file mode 100644 index a99fa81d2b..0000000000 --- a/experimental/examples/imageviewer/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -kotlin.code.style=official -xcodeproj=iosApp -kotlin.native.cocoapods.generate.wrapper=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx3g -org.jetbrains.compose.experimental.jscanvas.enabled=true -org.jetbrains.compose.experimental.macos.enabled=true -org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none -kotlin.mpp.androidSourceSetLayoutVersion=2 -kotlin.native.useEmbeddableCompilerJar=true -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.10 -agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1008 diff --git a/experimental/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar b/experimental/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 943f0cbfa7..0000000000 Binary files a/experimental/examples/imageviewer/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/experimental/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties b/experimental/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties deleted file mode 100755 index f398c33c4b..0000000000 --- a/experimental/examples/imageviewer/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip -networkTimeout=10000 -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/experimental/examples/imageviewer/gradlew b/experimental/examples/imageviewer/gradlew deleted file mode 100755 index 65dcd68d65..0000000000 --- a/experimental/examples/imageviewer/gradlew +++ /dev/null @@ -1,244 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/experimental/examples/imageviewer/gradlew.bat b/experimental/examples/imageviewer/gradlew.bat deleted file mode 100755 index 93e3f59f13..0000000000 --- a/experimental/examples/imageviewer/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/experimental/examples/imageviewer/settings.gradle.kts b/experimental/examples/imageviewer/settings.gradle.kts deleted file mode 100644 index a2c5064a25..0000000000 --- a/experimental/examples/imageviewer/settings.gradle.kts +++ /dev/null @@ -1,28 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - google() - } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("jvm").version(kotlinVersion) - kotlin("multiplatform").version(kotlinVersion) - kotlin("plugin.serialization").version(kotlinVersion) - kotlin("android").version(kotlinVersion) - id("com.android.base").version(agpVersion) - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - id("org.jetbrains.compose").version(composeVersion) - } -} - -rootProject.name = "imageviewer" - -include(":androidApp") -include(":shared") -include(":desktopApp") diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png deleted file mode 100755 index 048bc8e40f..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png deleted file mode 100755 index c9208944b7..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_background.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png deleted file mode 100755 index 2d2fcf2c58..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_foreground.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png deleted file mode 100755 index 38ee5762aa..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-hdpi/ic_imageviewer_round.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png deleted file mode 100755 index 97ee3fe7a5..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png deleted file mode 100755 index a52e38227a..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_background.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png deleted file mode 100755 index fcab73e062..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_foreground.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png deleted file mode 100755 index 44e98c60bc..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-mdpi/ic_imageviewer_round.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png deleted file mode 100755 index 371b00a186..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png deleted file mode 100755 index 1c05cfbd31..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_background.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png deleted file mode 100755 index 98565fc895..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_foreground.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png deleted file mode 100755 index ba87f288ff..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xhdpi/ic_imageviewer_round.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png deleted file mode 100755 index 2facfba33e..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png deleted file mode 100755 index 98c5f7b447..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_background.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png deleted file mode 100755 index bad1d38f5a..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_foreground.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png deleted file mode 100755 index 9b44b12b16..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxhdpi/ic_imageviewer_round.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png deleted file mode 100755 index efe8478dd5..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png deleted file mode 100755 index 0023fa325b..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_background.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png deleted file mode 100755 index 422d7185b8..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_foreground.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png b/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png deleted file mode 100755 index 1843b0f85b..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/androidMain/res/mipmap-xxxhdpi/ic_imageviewer_round.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/dots.png b/experimental/examples/imageviewer/shared/src/commonMain/resources/dots.png deleted file mode 100755 index 4eb0c9f1e4..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/commonMain/resources/dots.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/ic_imageviewer_round.png b/experimental/examples/imageviewer/shared/src/commonMain/resources/ic_imageviewer_round.png deleted file mode 100755 index 1843b0f85b..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/commonMain/resources/ic_imageviewer_round.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-linux.png b/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-linux.png deleted file mode 100755 index 604b33eb09..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-linux.png and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-mac.icns b/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-mac.icns deleted file mode 100644 index 7783380ee0..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-mac.icns and /dev/null differ diff --git a/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-windows.ico b/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-windows.ico deleted file mode 100644 index 31bd09b389..0000000000 Binary files a/experimental/examples/imageviewer/shared/src/commonMain/resources/icon-windows.ico and /dev/null differ diff --git a/experimental/examples/minesweeper/build.gradle.kts b/experimental/examples/minesweeper/build.gradle.kts deleted file mode 100644 index 0c00883af5..0000000000 --- a/experimental/examples/minesweeper/build.gradle.kts +++ /dev/null @@ -1,18 +0,0 @@ -plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader - kotlin("jvm") apply false - kotlin("multiplatform") apply false - kotlin("android") apply false - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.compose") apply false -} - -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - } -} diff --git a/experimental/examples/minesweeper/gradle.properties b/experimental/examples/minesweeper/gradle.properties deleted file mode 100644 index 720f561017..0000000000 --- a/experimental/examples/minesweeper/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -kotlin.native.cocoapods.generate.wrapper=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx3g -org.jetbrains.compose.experimental.jscanvas.enabled=true -org.jetbrains.compose.experimental.macos.enabled=true -org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none -kotlin.native.useEmbeddableCompilerJar=true -kotlin.mpp.androidSourceSetLayoutVersion=2 -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.0 -agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 diff --git a/experimental/examples/minesweeper/gradle/wrapper/gradle-wrapper.properties b/experimental/examples/minesweeper/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae04661ee7..0000000000 --- a/experimental/examples/minesweeper/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/experimental/examples/todoapp-lite/.gitignore b/experimental/examples/todoapp-lite/.gitignore deleted file mode 100644 index e6c9b61384..0000000000 --- a/experimental/examples/todoapp-lite/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/ -.DS_Store -build/ -/captures -.externalNativeBuild -.cxx -iosApp/Podfile.lock -iosApp/Pods/* -iosApp/iosApp.xcworkspace/* -iosApp/iosApp.xcodeproj/* -!iosApp/iosApp.xcodeproj/project.pbxproj -shared/shared.podspec \ No newline at end of file diff --git a/experimental/examples/todoapp-lite/README.md b/experimental/examples/todoapp-lite/README.md deleted file mode 100755 index b072b23540..0000000000 --- a/experimental/examples/todoapp-lite/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# TodoApp (lite version) - -A simplified version of the [TodoApp example](https://github.com/JetBrains/compose-jb/tree/master/examples/todoapp), fully based on Jetpack Compose and without using any third-party libraries. - -Supported targets: Android, Desktop and iOS. - -## How to run - -Choose a run configuration for an appropriate target in IDE and run it. - -![run-configurations.png](run-configurations.png) - -To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. -Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then -using "Signing & Capabilities" tab of `iosApp` target. - -Then choose **iosApp** configuration in IDE and run it. - - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -## Building native desktop distribution -``` -./gradlew :desktopApp:packageDistributionForCurrentOS -# outputs are written to desktopApp/build/compose/binaries -``` -![Desktop](screenshots/todoapplite.png) diff --git a/experimental/examples/todoapp-lite/androidApp/src/androidMain/AndroidManifest.xml b/experimental/examples/todoapp-lite/androidApp/src/androidMain/AndroidManifest.xml deleted file mode 100755 index daf0c85ca6..0000000000 --- a/experimental/examples/todoapp-lite/androidApp/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - diff --git a/experimental/examples/todoapp-lite/build.gradle.kts b/experimental/examples/todoapp-lite/build.gradle.kts deleted file mode 100755 index 0c00883af5..0000000000 --- a/experimental/examples/todoapp-lite/build.gradle.kts +++ /dev/null @@ -1,18 +0,0 @@ -plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader - kotlin("jvm") apply false - kotlin("multiplatform") apply false - kotlin("android") apply false - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.compose") apply false -} - -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - } -} diff --git a/experimental/examples/todoapp-lite/gradle.properties b/experimental/examples/todoapp-lite/gradle.properties deleted file mode 100755 index 720f561017..0000000000 --- a/experimental/examples/todoapp-lite/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -kotlin.native.cocoapods.generate.wrapper=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx3g -org.jetbrains.compose.experimental.jscanvas.enabled=true -org.jetbrains.compose.experimental.macos.enabled=true -org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none -kotlin.native.useEmbeddableCompilerJar=true -kotlin.mpp.androidSourceSetLayoutVersion=2 -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.0 -agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 diff --git a/experimental/examples/todoapp-lite/gradle/wrapper/gradle-wrapper.jar b/experimental/examples/todoapp-lite/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index f3d88b1c2f..0000000000 Binary files a/experimental/examples/todoapp-lite/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/experimental/examples/todoapp-lite/gradle/wrapper/gradle-wrapper.properties b/experimental/examples/todoapp-lite/gradle/wrapper/gradle-wrapper.properties deleted file mode 100755 index ae04661ee7..0000000000 --- a/experimental/examples/todoapp-lite/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/experimental/examples/todoapp-lite/gradlew b/experimental/examples/todoapp-lite/gradlew deleted file mode 100755 index fbd7c51583..0000000000 --- a/experimental/examples/todoapp-lite/gradlew +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/experimental/examples/todoapp-lite/gradlew.bat b/experimental/examples/todoapp-lite/gradlew.bat deleted file mode 100755 index 5093609d51..0000000000 --- a/experimental/examples/todoapp-lite/gradlew.bat +++ /dev/null @@ -1,104 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/experimental/examples/todoapp-lite/screenshots/todoapplite.png b/experimental/examples/todoapp-lite/screenshots/todoapplite.png deleted file mode 100644 index 39702b6b87..0000000000 Binary files a/experimental/examples/todoapp-lite/screenshots/todoapplite.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/settings.gradle.kts b/experimental/examples/todoapp-lite/settings.gradle.kts deleted file mode 100755 index 279b5471e7..0000000000 --- a/experimental/examples/todoapp-lite/settings.gradle.kts +++ /dev/null @@ -1,26 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - google() - } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("jvm").version(kotlinVersion) - kotlin("multiplatform").version(kotlinVersion) - kotlin("android").version(kotlinVersion) - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - id("org.jetbrains.compose").version(composeVersion) - } -} - -rootProject.name = "todoapp-lite" - -include(":androidApp") -include(":shared") -include(":desktopApp") diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/AndroidManifest.xml b/experimental/examples/todoapp-lite/shared/src/androidMain/AndroidManifest.xml deleted file mode 100755 index ccd0950b6f..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt b/experimental/examples/todoapp-lite/shared/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt deleted file mode 100644 index b52bcab2c8..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/kotlin/example/todoapp/lite/common/Utils.kt +++ /dev/null @@ -1,75 +0,0 @@ -@file:JvmName("Utils") - -package example.todoapp.lite.common - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.IntrinsicSize -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.material.Button -import androidx.compose.material.Card -import androidx.compose.material.MaterialTheme -import androidx.compose.material.ProvideTextStyle -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp - -internal actual val MARGIN_SCROLLBAR: Dp = 0.dp - -internal actual interface ScrollbarAdapter - -@Composable -internal actual fun rememberScrollbarAdapter(scrollState: LazyListState): ScrollbarAdapter = - object : ScrollbarAdapter {} - -@Composable -internal actual fun VerticalScrollbar( - modifier: Modifier, - adapter: ScrollbarAdapter -) { - // no-op -} - -@Composable -internal actual fun Dialog( - title: String, - onCloseRequest: () -> Unit, - content: @Composable () -> Unit -) { - androidx.compose.ui.window.Dialog( - onDismissRequest = onCloseRequest, - ) { - Card(elevation = 8.dp) { - Column( - modifier = Modifier - .padding(8.dp) - .height(IntrinsicSize.Min) - ) { - ProvideTextStyle(MaterialTheme.typography.subtitle1) { - Text(text = title) - } - - Spacer(modifier = Modifier.height(8.dp)) - - Box(modifier = Modifier.weight(1F)) { - content() - } - - Spacer(modifier = Modifier.height(8.dp)) - - Button( - onClick = onCloseRequest, - modifier = Modifier.align(Alignment.End) - ) { - Text(text = "Done") - } - } - } - } -} diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/experimental/examples/todoapp-lite/shared/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 1f6bb29060..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/drawable/ic_launcher_background.xml b/experimental/examples/todoapp-lite/shared/src/androidMain/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 0d025f9bf6..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index 6b78462d61..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index 6b78462d61..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index 898f3ed59a..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index dffca3601e..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 64ba76f75e..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index dae5e08234..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index e5ed46597e..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index 14ed0af350..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index b0907cac3b..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index d8ae031549..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index 2c18de9e66..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png b/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index beed3cdd2c..0000000000 Binary files a/experimental/examples/todoapp-lite/shared/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/todoapp-lite/shared/src/androidMain/res/values/strings.xml b/experimental/examples/todoapp-lite/shared/src/androidMain/res/values/strings.xml deleted file mode 100644 index 5dee5cbdd0..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - TodoApp Lite - diff --git a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt b/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt deleted file mode 100644 index 89eb56caea..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/EditDialog.kt +++ /dev/null @@ -1,45 +0,0 @@ -package example.todoapp.lite.common - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.material.Checkbox -import androidx.compose.material.Text -import androidx.compose.material.TextField -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp - -@Composable -internal fun EditDialog( - item: TodoItem, - onCloseClicked: () -> Unit, - onTextChanged: (String) -> Unit, - onDoneChanged: (Boolean) -> Unit, -) { - Dialog( - title = "Edit todo", - onCloseRequest = onCloseClicked, - ) { - Column(horizontalAlignment = Alignment.CenterHorizontally) { - TextField( - value = item.text, - modifier = Modifier.weight(1F).fillMaxWidth().sizeIn(minHeight = 192.dp), - label = { Text("Todo text") }, - onValueChange = onTextChanged, - ) - - Spacer(modifier = Modifier.height(8.dp)) - - Row { - Text(text = "Completed", Modifier.padding(15.dp)) - - Checkbox( - checked = item.isDone, - onCheckedChange = onDoneChanged, - ) - } - } - } -} diff --git a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt b/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt deleted file mode 100644 index 7d8c390bdf..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/MainContent.kt +++ /dev/null @@ -1,158 +0,0 @@ -package example.todoapp.lite.common - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Checkbox -import androidx.compose.material.Divider -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.OutlinedTextField -import androidx.compose.material.Text -import androidx.compose.material.TopAppBar -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Add -import androidx.compose.material.icons.filled.Delete -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.input.key.Key -import androidx.compose.ui.text.AnnotatedString -import androidx.compose.ui.text.style.TextOverflow -import androidx.compose.ui.unit.dp - -@Composable -internal fun MainContent( - modifier: Modifier = Modifier, - items: List, - inputText: String, - onItemClicked: (id: Long) -> Unit, - onItemDoneChanged: (id: Long, isDone: Boolean) -> Unit, - onItemDeleteClicked: (id: Long) -> Unit, - onAddItemClicked: () -> Unit, - onInputTextChanged: (String) -> Unit, -) { - Column(modifier) { - TopAppBar(title = { Text(text = "Todo List") }) - - Box(Modifier.weight(1F)) { - ListContent( - items = items, - onItemClicked = onItemClicked, - onItemDoneChanged = onItemDoneChanged, - onItemDeleteClicked = onItemDeleteClicked - ) - } - - Input( - text = inputText, - onAddClicked = onAddItemClicked, - onTextChanged = onInputTextChanged - ) - } -} - -@Composable -private fun ListContent( - items: List, - onItemClicked: (id: Long) -> Unit, - onItemDoneChanged: (id: Long, isDone: Boolean) -> Unit, - onItemDeleteClicked: (id: Long) -> Unit, -) { - Box { - val listState = rememberLazyListState() - - LazyColumn(state = listState) { - items(items) { item -> - Item( - item = item, - onClicked = { onItemClicked(item.id) }, - onDoneChanged = { onItemDoneChanged(item.id, it) }, - onDeleteClicked = { onItemDeleteClicked(item.id) } - ) - - Divider() - } - } - - VerticalScrollbar( - modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(), - adapter = rememberScrollbarAdapter(scrollState = listState) - ) - } -} - -@Composable -private fun Item( - item: TodoItem, - onClicked: () -> Unit, - onDoneChanged: (Boolean) -> Unit, - onDeleteClicked: () -> Unit -) { - Row(modifier = Modifier.clickable(onClick = onClicked)) { - Spacer(modifier = Modifier.width(8.dp)) - - Checkbox( - checked = item.isDone, - modifier = Modifier.align(Alignment.CenterVertically), - onCheckedChange = onDoneChanged, - ) - - Spacer(modifier = Modifier.width(8.dp)) - - Text( - text = AnnotatedString(item.text), - modifier = Modifier.weight(1F).align(Alignment.CenterVertically), - maxLines = 1, - overflow = TextOverflow.Ellipsis - ) - - Spacer(modifier = Modifier.width(8.dp)) - - IconButton(onClick = onDeleteClicked) { - Icon( - imageVector = Icons.Default.Delete, - contentDescription = null - ) - } - - Spacer(modifier = Modifier.width(MARGIN_SCROLLBAR)) - } -} - -@OptIn(ExperimentalComposeUiApi::class) -@Composable -private fun Input( - text: String, - onTextChanged: (String) -> Unit, - onAddClicked: () -> Unit -) { - Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(8.dp)) { - OutlinedTextField( - value = text, - modifier = Modifier - .weight(weight = 1F) - .onKeyUp(key = Key.Enter, action = onAddClicked), - onValueChange = onTextChanged, - label = { Text(text = "Add a todo") } - ) - - Spacer(modifier = Modifier.width(8.dp)) - - IconButton(onClick = onAddClicked) { - Icon( - imageVector = Icons.Default.Add, - contentDescription = null - ) - } - } -} diff --git a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt b/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt deleted file mode 100644 index 91dfe7df5b..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/RootStore.kt +++ /dev/null @@ -1,80 +0,0 @@ -package example.todoapp.lite.common - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue - -internal class RootStore { - - var state: RootState by mutableStateOf(initialState()) - private set - - fun onItemClicked(id: Long) { - setState { copy(editingItemId = id) } - } - - fun onItemDoneChanged(id: Long, isDone: Boolean) { - setState { - updateItem(id = id) { it.copy(isDone = isDone) } - } - } - - fun onItemDeleteClicked(id: Long) { - setState { copy(items = items.filterNot { it.id == id }) } - } - - fun onAddItemClicked() { - setState { - val newItem = - TodoItem( - id = items.maxOfOrNull(TodoItem::id)?.plus(1L) ?: 1L, - text = inputText, - ) - - copy(items = items + newItem, inputText = "") - } - } - - fun onInputTextChanged(text: String) { - setState { copy(inputText = text) } - } - - fun onEditorCloseClicked() { - setState { copy(editingItemId = null) } - } - - fun onEditorTextChanged(text: String) { - setState { - updateItem(id = requireNotNull(editingItemId)) { it.copy(text = text) } - } - } - - fun onEditorDoneChanged(isDone: Boolean) { - setState { - updateItem(id = requireNotNull(editingItemId)) { it.copy(isDone = isDone) } - } - } - - private fun RootState.updateItem(id: Long, transformer: (TodoItem) -> TodoItem): RootState = - copy(items = items.updateItem(id = id, transformer = transformer)) - - private fun List.updateItem(id: Long, transformer: (TodoItem) -> TodoItem): List = - map { item -> if (item.id == id) transformer(item) else item } - - private fun initialState(): RootState = - RootState( - items = (1L..5L).map { id -> - TodoItem(id = id, text = "Some text $id") - } - ) - - private inline fun setState(update: RootState.() -> RootState) { - state = state.update() - } - - data class RootState( - val items: List = emptyList(), - val inputText: String = "", - val editingItemId: Long? = null, - ) -} diff --git a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt b/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt deleted file mode 100644 index 94da3f2834..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/TodoItem.kt +++ /dev/null @@ -1,7 +0,0 @@ -package example.todoapp.lite.common - -internal data class TodoItem( - val id: Long = 0L, - val text: String = "", - val isDone: Boolean = false -) diff --git a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt b/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt deleted file mode 100644 index 9345b740a2..0000000000 --- a/experimental/examples/todoapp-lite/shared/src/commonMain/kotlin/example/todoapp/lite/common/Utils.kt +++ /dev/null @@ -1,41 +0,0 @@ -package example.todoapp.lite.common - -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.input.key.Key -import androidx.compose.ui.input.key.KeyEventType -import androidx.compose.ui.input.key.key -import androidx.compose.ui.input.key.onKeyEvent -import androidx.compose.ui.input.key.type -import androidx.compose.ui.unit.Dp - -internal expect val MARGIN_SCROLLBAR: Dp - -internal expect interface ScrollbarAdapter - -@Composable -internal expect fun rememberScrollbarAdapter(scrollState: LazyListState): ScrollbarAdapter - -@Composable -internal expect fun VerticalScrollbar( - modifier: Modifier, - adapter: ScrollbarAdapter -) - -@Composable -internal expect fun Dialog( - title: String, - onCloseRequest: () -> Unit, - content: @Composable () -> Unit -) - -internal fun Modifier.onKeyUp(key: Key, action: () -> Unit): Modifier = - onKeyEvent { event -> - if ((event.type == KeyEventType.KeyUp) && (event.key == key)) { - action() - true - } else { - false - } - } diff --git a/experimental/examples/validateExamples.sh b/experimental/examples/validateExamples.sh deleted file mode 100644 index 54c1b3dda4..0000000000 --- a/experimental/examples/validateExamples.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Script to build most of the examples, to verify if they can compile. -# Don't add examples, which don't depend on maven.pkg.jetbrains.space, because they won't be able to compile. - -set -euo pipefail - -if [ "$#" -ne 2 ]; then -echo "Specify Compose and Kotlin version. For example: ./validateExamples.sh 1.1.1 1.6.10" -exit 1 -fi -COMPOSE_VERSION=$1 -KOTLIN_VERSION=$2 - - -runGradle() { - pushd $1 - ./gradlew $2 -Pcompose.version=$COMPOSE_VERSION -Pkotlin.version=$KOTLIN_VERSION --rerun-tasks - popd -} - -runGradle chat-mpp packageDistributionForCurrentOS -runGradle codeviewer packageDistributionForCurrentOS -runGradle falling-balls-mpp packageDistributionForCurrentOS -runGradle imageviewer packageDistributionForCurrentOS -runGradle minesweeper packageDistributionForCurrentOS -runGradle todoapp-lite packageDistributionForCurrentOS -runGradle visual-effects packageDistributionForCurrentOS -runGradle widgets-gallery packageDistributionForCurrentOS diff --git a/experimental/examples/validateExamplesAndroid.sh b/experimental/examples/validateExamplesAndroid.sh deleted file mode 100644 index 184c045ad8..0000000000 --- a/experimental/examples/validateExamplesAndroid.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Script to build most of the examples, to verify if they can compile. -# Don't add examples, which don't depend on maven.pkg.jetbrains.space, because they won't be able to compile. - -set -euo pipefail - -if [ "$#" -ne 2 ]; then -echo "Specify Compose and Kotlin version. For example: ./validateExamplesAndroid.sh 1.1.1 1.6.10" -exit 1 -fi -COMPOSE_VERSION=$1 -KOTLIN_VERSION=$2 - - -runGradle() { - pushd $1 - ./gradlew $2 -Pcompose.version=$COMPOSE_VERSION -Pkotlin.version=$KOTLIN_VERSION --rerun-tasks - popd -} - -runGradle chat-mpp installDebug -runGradle codeviewer installDebug -runGradle falling-balls-mpp installDebug -runGradle imageviewer installDebug -runGradle minesweeper installDebug -runGradle todoapp-lite installDebug -runGradle visual-effects installDebug -runGradle widgets-gallery installDebug diff --git a/experimental/examples/validateExamplesWithJs.sh b/experimental/examples/validateExamplesWithJs.sh deleted file mode 100644 index f7bf5cf09e..0000000000 --- a/experimental/examples/validateExamplesWithJs.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# Script to build most of the examples, to verify if they can compile. -# Don't add examples, which don't depend on maven.pkg.jetbrains.space, because they won't be able to compile. - -set -euo pipefail - -if [ "$#" -ne 2 ]; then -echo "Specify Compose and Kotlin version. For example: ./validateExamplesWithJs.sh 1.1.1 1.6.10" -exit 1 -fi -COMPOSE_VERSION=$1 -KOTLIN_VERSION=$2 - - -runGradle() { - pushd $1 - ./gradlew $2 -Pcompose.version=$COMPOSE_VERSION -Pkotlin.version=$KOTLIN_VERSION --rerun-tasks - popd -} - -runGradle chat-mpp jsBrowserProductionWebpack -#runGradle codeviewer jsBrowserProductionWebpack -runGradle falling-balls-mpp jsBrowserProductionWebpack -#runGradle imageviewer jsBrowserProductionWebpack -runGradle minesweeper jsBrowserProductionWebpack -#runGradle todoapp-lite jsBrowserProductionWebpack -#runGradle visual-effects jsBrowserProductionWebpack -#runGradle widgets-gallery jsBrowserProductionWebpack diff --git a/experimental/examples/visual-effects/.gitignore b/experimental/examples/visual-effects/.gitignore deleted file mode 100644 index 180e034383..0000000000 --- a/experimental/examples/visual-effects/.gitignore +++ /dev/null @@ -1,21 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -build/ -/captures -.externalNativeBuild -.cxx -iosApp/Podfile.lock -iosApp/Pods/* -iosApp/iosApp.xcworkspace/* -iosApp/iosApp.xcodeproj/* -!iosApp/iosApp.xcodeproj/project.pbxproj -shared/shared.podspec \ No newline at end of file diff --git a/experimental/examples/visual-effects/README.md b/experimental/examples/visual-effects/README.md deleted file mode 100644 index ba75334da2..0000000000 --- a/experimental/examples/visual-effects/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Visual Effects - -Several visual effects implemented with Compose Multiplatform, used in 1.0 release announce video. - -*Prerequisites*: to run on iOS and Android, you should have "Kotlin Multiplatform Mobile" plugin installed either -in Android Studio or in AppCode with [installed CocoaPods](https://kotlinlang.org/docs/native-cocoapods.html). - - -## How to run - -Choose a run configuration for an appropriate target in IDE and run it. - -![run-configurations.png](run-configurations.png) - -To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. -Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then -using "Signing & Capabilities" tab of `iosApp` target. - -Then choose **iosApp** configuration in IDE and run it. - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - diff --git a/experimental/examples/visual-effects/build.gradle.kts b/experimental/examples/visual-effects/build.gradle.kts deleted file mode 100644 index 8d0c1f3d7c..0000000000 --- a/experimental/examples/visual-effects/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader - kotlin("jvm") apply false - kotlin("multiplatform") apply false - kotlin("android") apply false - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.compose") apply false -} - -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - mavenLocal() - } -} diff --git a/experimental/examples/visual-effects/gradle.properties b/experimental/examples/visual-effects/gradle.properties deleted file mode 100644 index 4d9867c59b..0000000000 --- a/experimental/examples/visual-effects/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -kotlin.native.cocoapods.generate.wrapper=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx3g -org.jetbrains.compose.experimental.jscanvas.enabled=true -org.jetbrains.compose.experimental.macos.enabled=true -org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.mpp.androidSourceSetLayoutVersion=2 -kotlin.native.cacheKind=none -kotlin.native.useEmbeddableCompilerJar=true -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.0 -agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 diff --git a/experimental/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar b/experimental/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f0..0000000000 Binary files a/experimental/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/experimental/examples/visual-effects/gradle/wrapper/gradle-wrapper.properties b/experimental/examples/visual-effects/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae04661ee7..0000000000 --- a/experimental/examples/visual-effects/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/experimental/examples/visual-effects/gradlew b/experimental/examples/visual-effects/gradlew deleted file mode 100755 index a69d9cb6c2..0000000000 --- a/experimental/examples/visual-effects/gradlew +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/experimental/examples/visual-effects/gradlew.bat b/experimental/examples/visual-effects/gradlew.bat deleted file mode 100644 index f127cfd49d..0000000000 --- a/experimental/examples/visual-effects/gradlew.bat +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/experimental/examples/visual-effects/settings.gradle.kts b/experimental/examples/visual-effects/settings.gradle.kts deleted file mode 100644 index 665c2f3deb..0000000000 --- a/experimental/examples/visual-effects/settings.gradle.kts +++ /dev/null @@ -1,27 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - google() - } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("jvm").version(kotlinVersion) - kotlin("multiplatform").version(kotlinVersion) - kotlin("android").version(kotlinVersion) - id("com.android.base").version(agpVersion) - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - id("org.jetbrains.compose").version(composeVersion) - } -} - -rootProject.name = "visual-effects" - -include(":androidApp") -include(":shared") -include(":desktopApp") diff --git a/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png b/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png deleted file mode 100644 index a73ddd7989..0000000000 Binary files a/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png and /dev/null differ diff --git a/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg b/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg deleted file mode 100644 index 3e5ce57f72..0000000000 --- a/experimental/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/experimental/examples/widgets-gallery/.gitignore b/experimental/examples/widgets-gallery/.gitignore deleted file mode 100644 index e6c9b61384..0000000000 --- a/experimental/examples/widgets-gallery/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/ -.DS_Store -build/ -/captures -.externalNativeBuild -.cxx -iosApp/Podfile.lock -iosApp/Pods/* -iosApp/iosApp.xcworkspace/* -iosApp/iosApp.xcodeproj/* -!iosApp/iosApp.xcodeproj/project.pbxproj -shared/shared.podspec \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/README.md b/experimental/examples/widgets-gallery/README.md deleted file mode 100644 index 0121f321d1..0000000000 --- a/experimental/examples/widgets-gallery/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Widgets gallery - -This example is derived from -[ComposeCookBook](https://github.com/Gurupreet/ComposeCookBook) project -by Gurupreet Singh ([@Gurupreet](https://github.com/Gurupreet)) -published under [MIT license](third_party/ComposeCookBook_LICENSE.txt). - -An example of Compose application for Desktop, Android and iOS platforms, -demonstrating how to use various Material widgets. - -## How to run - -Choose a run configuration for an appropriate target in IDE and run it. - -![run-configurations.png](run-configurations.png) - -To run on iOS device, please correct `TEAM_ID` value in `iosApp/Configuration/Config.xcconfig` with your Apple Team ID. -Alternatively, you may setup signing within XCode opening `iosApp/iosApp.xcworkspace` and then -using "Signing & Capabilities" tab of `iosApp` target. - -Then choose **iosApp** configuration in IDE and run it. - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -### Building native desktop distribution -``` -./gradlew :desktop:packageDistributionForCurrentOS -# outputs are written to desktop/build/compose/binaries -``` diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/AndroidManifest.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/AndroidManifest.xml deleted file mode 100644 index fc44b2f2bc..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_background.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_background.xml deleted file mode 100644 index 07d5da9cbf..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1146..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cfe52..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cfe52..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a571e60098..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 61da551c55..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c41dd28531..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index db5080a752..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 6dba46dab1..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index da31a871c8..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 15ac681720..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index b216f2d313..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index f25a419744..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index e96783ccce..0000000000 Binary files a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values-night/themes.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values-night/themes.xml deleted file mode 100644 index 710bfabb30..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values-night/themes.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/colors.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/colors.xml deleted file mode 100644 index 6040e1f218..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/colors.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - #ffa5d6a7 - #ff4caf50 - #ff388e3c - #FF03DAC5 - #ff80deea - #FF833AB4 - #FF000000 - #FFFFFFFF - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/strings.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/strings.xml deleted file mode 100644 index 49dfce059f..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - ComposeWidgets - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/themes.xml b/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/themes.xml deleted file mode 100644 index 50dcf6d3d9..0000000000 --- a/experimental/examples/widgets-gallery/androidApp/src/androidMain/res/values/themes.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/build.gradle.kts b/experimental/examples/widgets-gallery/build.gradle.kts deleted file mode 100644 index 8d0c1f3d7c..0000000000 --- a/experimental/examples/widgets-gallery/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - // this is necessary to avoid the plugins to be loaded multiple times - // in each subproject's classloader - kotlin("jvm") apply false - kotlin("multiplatform") apply false - kotlin("android") apply false - id("com.android.application") apply false - id("com.android.library") apply false - id("org.jetbrains.compose") apply false -} - -allprojects { - repositories { - google() - mavenCentral() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - mavenLocal() - } -} diff --git a/experimental/examples/widgets-gallery/gradle.properties b/experimental/examples/widgets-gallery/gradle.properties deleted file mode 100644 index 720f561017..0000000000 --- a/experimental/examples/widgets-gallery/gradle.properties +++ /dev/null @@ -1,16 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -kotlin.native.cocoapods.generate.wrapper=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx3g -org.jetbrains.compose.experimental.jscanvas.enabled=true -org.jetbrains.compose.experimental.macos.enabled=true -org.jetbrains.compose.experimental.uikit.enabled=true -kotlin.native.cacheKind=none -kotlin.native.useEmbeddableCompilerJar=true -kotlin.mpp.androidSourceSetLayoutVersion=2 -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.8.0 -agp.version=7.1.3 -compose.version=1.4.0-alpha01-dev1004 diff --git a/experimental/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar b/experimental/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f0..0000000000 Binary files a/experimental/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/experimental/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.properties b/experimental/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index ae04661ee7..0000000000 --- a/experimental/examples/widgets-gallery/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/experimental/examples/widgets-gallery/gradlew b/experimental/examples/widgets-gallery/gradlew deleted file mode 100755 index a69d9cb6c2..0000000000 --- a/experimental/examples/widgets-gallery/gradlew +++ /dev/null @@ -1,240 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/experimental/examples/widgets-gallery/gradlew.bat b/experimental/examples/widgets-gallery/gradlew.bat deleted file mode 100644 index 53a6b238d4..0000000000 --- a/experimental/examples/widgets-gallery/gradlew.bat +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/experimental/examples/widgets-gallery/settings.gradle.kts b/experimental/examples/widgets-gallery/settings.gradle.kts deleted file mode 100644 index 76eb8f5ec8..0000000000 --- a/experimental/examples/widgets-gallery/settings.gradle.kts +++ /dev/null @@ -1,27 +0,0 @@ -pluginManagement { - repositories { - gradlePluginPortal() - maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") - google() - } - - plugins { - val kotlinVersion = extra["kotlin.version"] as String - val agpVersion = extra["agp.version"] as String - val composeVersion = extra["compose.version"] as String - - kotlin("jvm").version(kotlinVersion) - kotlin("multiplatform").version(kotlinVersion) - kotlin("android").version(kotlinVersion) - id("com.android.base").version(agpVersion) - id("com.android.application").version(agpVersion) - id("com.android.library").version(agpVersion) - id("org.jetbrains.compose").version(composeVersion) - } -} - -rootProject.name = "widgets-gallery" - -include(":androidApp") -include(":shared") -include(":desktopApp") diff --git a/experimental/examples/widgets-gallery/shared/src/androidMain/AndroidManifest.xml b/experimental/examples/widgets-gallery/shared/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 3c65a79fe0..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt deleted file mode 100644 index 7ec4cd59c7..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.Dp - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: ScrollState -) = Unit - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: LazyListState, - itemCount: Int, - averageItemSize: Dp -) = Unit \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt deleted file mode 100644 index be73331ce2..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/androidMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.runtime.Composable -import androidx.compose.foundation.isSystemInDarkTheme as androidSystemIsInDarkTheme - -@Composable -actual fun isSystemInDarkTheme(): Boolean = - androidSystemIsInDarkTheme() \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt b/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt deleted file mode 100644 index dd9df15318..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/model/Tweet.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.compose.demo.widgets.data.model - -data class Tweet( - val id: Int, - val text: String, - val author: String, - val handle: String, - val time: String, - val authorImageId: String, - val likesCount: Int, - val commentsCount: Int, - val retweetCount: Int, - val source: String, - val tweetImageId: String? = null -) \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt deleted file mode 100644 index c6b3b3af40..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset - -expect fun Modifier.cursorForHorizontalResize(): Modifier \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt b/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt deleted file mode 100644 index af32b07b1d..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Color.kt +++ /dev/null @@ -1,23 +0,0 @@ -package org.jetbrains.compose.demo.widgets.theme - -import androidx.compose.ui.graphics.Color - -val green200 = Color(0xffa5d6a7) -val green500 = Color(0xff4caf50) -val green700 = Color(0xff388e3c) - -val blue500 = Color(0xFF3F51B5) -val blue200 = Color(0xFF9FA8DA) -val blue700 = Color(0xFF303F9F) - -val purple200 = Color(0xFFB39DDB) -val purple = Color(0xFF833AB4) -val purple700 = Color(0xFF512DA8) - -val orange200 = Color(0xFFff7961) -val orange500 = Color(0xFFf44336) -val orange700 = Color(0xFFba000d) - - -val teal200 = Color(0xff80deea) -val twitterColor = Color(0xFF1DA1F2) diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt b/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt deleted file mode 100644 index 764221a766..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Shape.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.compose.demo.widgets.theme - -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Shapes -import androidx.compose.ui.unit.dp - -val shapes = Shapes( - small = RoundedCornerShape(4.dp), - medium = RoundedCornerShape(4.dp), - large = RoundedCornerShape(0.dp) -) \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt b/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt deleted file mode 100644 index bda3b064fa..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/theme/Type.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.jetbrains.compose.demo.widgets.theme - -import androidx.compose.material.Typography -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.sp - -val typography = Typography( - body1 = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp - ), - body2 = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 14.sp - ), - button = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.W500, - fontSize = 14.sp - ), - caption = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 12.sp, - ), - subtitle1 = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - color = Color.Gray - ), - subtitle2 = TextStyle( - fontFamily = FontFamily.Default, - fontWeight = FontWeight.Normal, - fontSize = 14.sp, - color = Color.Gray - ), -) \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt b/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt deleted file mode 100644 index 228604e27d..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/utils/LayoutModifiers.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.jetbrains.compose.demo.widgets.ui.utils - -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.layout - -fun Modifier.withoutWidthConstraints() = layout { measurable, constraints -> - val placeable = measurable.measure(constraints.copy(maxWidth = Int.MAX_VALUE)) - layout(constraints.maxWidth, placeable.height) { - placeable.place(0, 0) - } -} \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg deleted file mode 100644 index 51e7bf4c7c..0000000000 Binary files a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg and /dev/null differ diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg deleted file mode 100644 index 6ac860ec0c..0000000000 Binary files a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg and /dev/null differ diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg deleted file mode 100644 index 24e4a48089..0000000000 Binary files a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg and /dev/null differ diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg deleted file mode 100644 index a8d79560ff..0000000000 Binary files a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg and /dev/null differ diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml deleted file mode 100644 index abd196bb92..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml deleted file mode 100644 index 6ec2e846e1..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml b/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml deleted file mode 100644 index ed54306c20..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt deleted file mode 100644 index 4fa07e3eb5..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.input.pointer.PointerIcon -import androidx.compose.ui.input.pointer.pointerHoverIcon -import androidx.compose.ui.input.pointer.pointerMoveFilter -import java.awt.Cursor - -actual fun Modifier.cursorForHorizontalResize(): Modifier = - this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR))) diff --git a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt b/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt deleted file mode 100644 index b4ba358b2f..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Scrollbar.kt +++ /dev/null @@ -1,30 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.rememberScrollbarAdapter -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.Dp - -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: ScrollState -) = androidx.compose.foundation.VerticalScrollbar( - rememberScrollbarAdapter(scrollState), - modifier -) - -@OptIn(ExperimentalFoundationApi::class) -@Composable -actual fun VerticalScrollbar( - modifier: Modifier, - scrollState: LazyListState, - itemCount: Int, - averageItemSize: Dp -) = androidx.compose.foundation.VerticalScrollbar( - rememberScrollbarAdapter(scrollState), - modifier -) \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt b/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt deleted file mode 100644 index c479cb8cf0..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/desktopMain/kotlin/org/jetbrains/compose/demo/widgets/platform/System.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import org.jetbrains.skiko.SystemTheme - -actual fun isSystemInDarkTheme(): Boolean = org.jetbrains.skiko.currentSystemTheme == SystemTheme.DARK \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt b/experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt deleted file mode 100644 index a49921fe64..0000000000 --- a/experimental/examples/widgets-gallery/shared/src/iosMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Mouse.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.jetbrains.compose.demo.widgets.platform - -import androidx.compose.ui.Modifier -import androidx.compose.ui.geometry.Offset - -actual fun Modifier.cursorForHorizontalResize() = this \ No newline at end of file diff --git a/experimental/examples/widgets-gallery/third_party/ComposeCookBook_LICENSE.txt b/experimental/examples/widgets-gallery/third_party/ComposeCookBook_LICENSE.txt deleted file mode 100644 index 928f38ee9d..0000000000 --- a/experimental/examples/widgets-gallery/third_party/ComposeCookBook_LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Gurupreet Singh - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file