diff --git a/CHANGELOG.md b/CHANGELOG.md index 22593eba1a7..0774c0cc195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,88 @@ +# 1.5.3 (October 2023) + +## Desktop + +### Fixes +- [Crash on text hover when accessibility is enabled on Windows](https://github.com/JetBrains/compose-multiplatform/issues/3742) + +## Dependencies + +This version of Compose Multiplatform is based on the next Jetpack Compose libraries: + +- [Compiler 1.5.3](https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.3) +- [Runtime 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.5.0) +- [UI 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.5.0) +- [Foundation 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.5.0) +- [Material 1.5.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.5.0) +- [Material3 1.1.1](https://developer.android.com/jetpack/androidx/releases/compose-material3#1.1.1) + +# 1.5.10-beta02 (September 2023) + +## Common + +### Features +* [Support kotlin 1.9.20-Beta2 with basic K2 support](https://github.com/JetBrains/compose-multiplatform/commit/393cfdd6638eee465b3c974fe9e6b3b0a1db57c1) +* [Implement `defaultTimePickerLayoutType` based on screen orientation](https://github.com/JetBrains/compose-multiplatform-core/pull/817) +* [Add an option to disable insets in `Popup`/`Dialog`](https://github.com/JetBrains/compose-multiplatform-core/pull/833) +* [Commonize insets `Modifier`'s \(additionally to `WindowInsets.*`\)](https://github.com/JetBrains/compose-multiplatform/issues/3563) + +### Fixes +* [`ExposedDropdownMenuBox.onExpandedChange` was not recomposed](https://github.com/JetBrains/compose-multiplatform/issues/3686) + +## iOS + +### Features +* Improve rendering performance + * [Avoid redundant compositing](https://github.com/JetBrains/compose-multiplatform-core/pull/813) + * [Don't send redundant synthetic moves](https://github.com/JetBrains/compose-multiplatform-core/pull/819) + * [Postpone `CAMetalDrawable` acquisition](https://github.com/JetBrains/compose-multiplatform-core/pull/820) + * [Move frame encoding to separate thread when possible](https://github.com/JetBrains/compose-multiplatform-core/pull/829) +* [Double tap and triple tap gesture handling in `TextField`s](https://github.com/JetBrains/compose-multiplatform/issues/2682) + +### Fixes +* [Expanded `ModalBottomSheet`: scrim doesn't occupy complete screen](https://github.com/JetBrains/compose-multiplatform/issues/3701) +* [Fix interop view intercepting touches for popups](https://github.com/JetBrains/compose-multiplatform-core/pull/835) +* [Fix applying `WindowInsets` inside `Popup`/`Dialog`](https://github.com/JetBrains/compose-multiplatform-core/pull/832) + + +## Desktop + +### Features + +* Improve accessibility support + * [Implement `Role.DropdownList` via `AccessibleRole.COMBO_BOX`](https://github.com/JetBrains/compose-multiplatform-core/pull/822) + * [Fix Compose `Role.Tab` to correctly translate to Java's `AccessibleRole.PAGE_TAB`](https://github.com/JetBrains/compose-multiplatform-core/pull/821) + * [Implement support for `SemanticsProperties.ProgressBarRangeInfo`](https://github.com/JetBrains/compose-multiplatform-core/pull/830) + +### Fixes +* [Can't type in `TextField` placed in `ModalBottomSheet`](https://github.com/JetBrains/compose-multiplatform/issues/3703) + +## Gradle Plugin + +### Features +* [Add API to not apply the Compose Compiler plugin](https://github.com/JetBrains/compose-multiplatform/pull/3722) + +### Fixes +* [Switch to notarytool for notarization](https://github.com/JetBrains/compose-multiplatform/pull/3642) + +## HTML library + +### Features +* [SVG - Add fillOpacity attribute](https://github.com/JetBrains/compose-multiplatform/pull/3725) + + +## Dependencies + +This version of Compose Multiplatform is based on the next Jetpack Compose libraries: + +* [Compiler 1.5.3](https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.5.3) +* [Runtime 1.5.1](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.5.1) +* [UI 1.5.1](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.5.1) +* [Foundation 1.5.1](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.5.1) +* [Material 1.5.1](https://developer.android.com/jetpack/androidx/releases/compose-material#1.5.1) +* [Material3 1.1.2](https://developer.android.com/jetpack/androidx/releases/compose-material3#1.1.2) + + # 1.5.2 (September 2023) ## Desktop diff --git a/ci/compose-uber-jar/gradle.properties b/ci/compose-uber-jar/gradle.properties index a4721c9a218..21cdea8a3db 100644 --- a/ci/compose-uber-jar/gradle.properties +++ b/ci/compose-uber-jar/gradle.properties @@ -1,2 +1,2 @@ -compose.version=1.5.1 +compose.version=1.5.2 kotlin.code.style=official diff --git a/ci/templates/desktop-template/gradle.properties b/ci/templates/desktop-template/gradle.properties index 1e2d69b4edc..f38317683d2 100644 --- a/ci/templates/desktop-template/gradle.properties +++ b/ci/templates/desktop-template/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/ci/templates/html-library-template/gradle.properties b/ci/templates/html-library-template/gradle.properties index 1e2d69b4edc..f38317683d2 100644 --- a/ci/templates/html-library-template/gradle.properties +++ b/ci/templates/html-library-template/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/ci/templates/multiplatform-template/gradle.properties b/ci/templates/multiplatform-template/gradle.properties index 1a553a85ae5..c0845dfbe2f 100644 --- a/ci/templates/multiplatform-template/gradle.properties +++ b/ci/templates/multiplatform-template/gradle.properties @@ -4,4 +4,4 @@ android.enableJetifier=true kotlin.code.style=official kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/README.md b/examples/README.md index 0319f064b7c..3d9d382898a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,9 +4,7 @@ | [Imageviewer](imageviewer) | Image Viewer application | Android, iOS, Desktop | | [Codeviewer](codeviewer) | File browser and code viewer application | Android, iOS, Desktop | | [Chat](chat) | A simple chat | Android, iOS, Desktop | -| [Minesweeper](minesweeper) | A simple game where you need to find hidden mines | Android, iOS, Desktop | -| [Falling Balls](falling-balls) | A simple game | Android, iOS, Desktop | -| [Visual effects](visual-effects) | Visual effects | Android, iOS, Desktop | +| [Graphics2D](graphics-2d) | 2D Games and graphics examples | Android, iOS, Desktop | | [Widgets Gallery](widgets-gallery) | Gallery of standard widgets | Android, iOS, Desktop | | [Todoapp Lite](todoapp-lite) | A simple todo app fully based on Compose | Android, iOS, Desktop | | [Issues tracker](issues) | GitHub issue tracker with an adaptive UI and ktor-client | Android, Desktop | diff --git a/examples/chat/gradle.properties b/examples/chat/gradle.properties index 3171ccd3f64..c2f765215a8 100644 --- a/examples/chat/gradle.properties +++ b/examples/chat/gradle.properties @@ -11,4 +11,4 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/cocoapods-ios-example/gradle.properties b/examples/cocoapods-ios-example/gradle.properties index 85ae4d75423..ad74f4bfd3e 100644 --- a/examples/cocoapods-ios-example/gradle.properties +++ b/examples/cocoapods-ios-example/gradle.properties @@ -21,4 +21,4 @@ org.jetbrains.compose.experimental.uikit.enabled=true #Versions kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 \ No newline at end of file +compose.version=1.5.2 \ No newline at end of file diff --git a/examples/codeviewer/gradle.properties b/examples/codeviewer/gradle.properties index 3171ccd3f64..c2f765215a8 100644 --- a/examples/codeviewer/gradle.properties +++ b/examples/codeviewer/gradle.properties @@ -11,4 +11,4 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/falling-balls/README.md b/examples/falling-balls/README.md deleted file mode 100644 index 14804331d07..00000000000 --- a/examples/falling-balls/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Falling Balls game - -Game can run on Android, iOS, desktop or in a browser. - -## Setting up your development environment - -To setup the environment, please consult these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment). - -## How to run - -Choose a run configuration for an appropriate target in Android Studio and run it. - -![run-configurations.png](run-configurations.png) - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -## Run native on MacOS -Choose **shared[macosX64]** or **shared[macosArm64]** configuration in IDE and run it. - diff --git a/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml b/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml deleted file mode 100644 index 8475d8902cf..00000000000 --- a/examples/falling-balls/androidApp/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Falling Balls - \ No newline at end of file diff --git a/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt deleted file mode 100644 index 0b1c80d0064..00000000000 --- a/examples/falling-balls/desktopApp/src/jvmMain/kotlin/Main.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -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)) - ) { - MainView() - } diff --git a/examples/falling-balls/gradle.properties b/examples/falling-balls/gradle.properties deleted file mode 100644 index 2e30567e908..00000000000 --- a/examples/falling-balls/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -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.useEmbeddableCompilerJar=true -kotlin.mpp.androidSourceSetLayoutVersion=2 -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.9.10 -agp.version=8.0.2 -compose.version=1.5.1 - -# TODO: remove when switching to 1.9.10. See: https://youtrack.jetbrains.com/issue/KT-60852 -# usage: ./gradlew :jsApp:jsBrowserRun -Pworkaround.kotlin.js.kt60852=true -# setting it to `true` breaks other targets (see shared/build.gradle.kts), so it should be used to run the web app only. -workaround.kotlin.js.kt60852=false diff --git a/examples/falling-balls/iosApp/Configuration/Config.xcconfig b/examples/falling-balls/iosApp/Configuration/Config.xcconfig deleted file mode 100644 index e6ec51dad28..00000000000 --- a/examples/falling-balls/iosApp/Configuration/Config.xcconfig +++ /dev/null @@ -1,3 +0,0 @@ -TEAM_ID= -BUNDLE_ID=org.jetbrains.FallingBalls -APP_NAME=FallingBalls diff --git a/examples/falling-balls/jsApp/build.gradle.kts b/examples/falling-balls/jsApp/build.gradle.kts deleted file mode 100644 index 144006fa941..00000000000 --- a/examples/falling-balls/jsApp/build.gradle.kts +++ /dev/null @@ -1,24 +0,0 @@ -plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - js(IR) { - browser() - binaries.executable() - } - sourceSets { - val jsMain by getting { - dependencies { - implementation(project(":shared")) - implementation(compose.ui) - } - } - } -} - -compose.experimental { - web.application {} -} - diff --git a/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt deleted file mode 100644 index d646ee78b8e..00000000000 --- a/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt +++ /dev/null @@ -1,15 +0,0 @@ - /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.ui.window.Window -import org.jetbrains.skiko.wasm.onWasmReady - -fun main() { - onWasmReady { - Window("Falling Balls") { - MainView() - } - } -} diff --git a/examples/falling-balls/jsApp/src/jsMain/resources/index.html b/examples/falling-balls/jsApp/src/jsMain/resources/index.html deleted file mode 100644 index e68a4bccdb8..00000000000 --- a/examples/falling-balls/jsApp/src/jsMain/resources/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - compose multiplatform web demo - - - - -

compose multiplatform web demo

-
- -
- - - diff --git a/examples/falling-balls/settings.gradle.kts b/examples/falling-balls/settings.gradle.kts deleted file mode 100644 index 9f32e9dd8a6..00000000000 --- a/examples/falling-balls/settings.gradle.kts +++ /dev/null @@ -1,32 +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) - } -} - -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0") -} - -rootProject.name = "falling-balls-mpp" - -include(":androidApp") -include(":shared") -include(":desktopApp") -include(":jsApp") diff --git a/examples/falling-balls/shared/build.gradle.kts b/examples/falling-balls/shared/build.gradle.kts deleted file mode 100644 index b88d1299aa7..00000000000 --- a/examples/falling-balls/shared/build.gradle.kts +++ /dev/null @@ -1,125 +0,0 @@ -@file:Suppress("OPT_IN_IS_NOT_ENABLED") - -import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler - - -plugins { - kotlin("multiplatform") - id("com.android.library") - id("org.jetbrains.compose") -} - -version = "1.0-SNAPSHOT" - -kotlin { - androidTarget() - - jvm("desktop") - - js(IR) { - browser() - } - - macosX64 { - binaries { - executable { - entryPoint = "main" - } - } - } - macosArm64 { - binaries { - executable { - entryPoint = "main" - } - } - } - - listOf( - iosX64(), - iosArm64(), - iosSimulatorArm64() - ).forEach { iosTarget -> - iosTarget.binaries.framework { - baseName = "shared" - isStatic = true - } - } - - val enableKjsWorkaround = project.properties["workaround.kotlin.js.kt60852"] == "true" - - fun KotlinDependencyHandler.addCommonDependencies() { - implementation(compose.ui) - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) - } - - sourceSets { - val commonMain by getting { - dependencies { - if (!enableKjsWorkaround) { - addCommonDependencies() - } - } - } - val androidMain by getting { - dependencies { - api("androidx.activity:activity-compose:1.7.2") - api("androidx.appcompat:appcompat:1.6.1") - api("androidx.core:core-ktx:1.10.1") - } - } - val iosMain by creating { - dependsOn(commonMain) - } - val iosX64Main by getting { - dependsOn(iosMain) - } - val iosArm64Main by getting { - dependsOn(iosMain) - } - val iosSimulatorArm64Main by getting { - dependsOn(iosMain) - } - val desktopMain by getting { - dependencies { - implementation(compose.desktop.common) - } - } - val macosMain by creating { - dependsOn(commonMain) - } - val macosArm64Main by getting { - dependsOn(macosMain) - } - val jsMain by getting { - dependencies { - if (enableKjsWorkaround) { - addCommonDependencies() - } - } - } - } -} - -android { - compileSdk = 34 - namespace = "org.jetbrains.fallingballs" - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - sourceSets["main"].res.srcDirs("src/androidMain/res") - sourceSets["main"].resources.srcDirs("src/commonMain/resources") - - defaultConfig { - minSdk = 26 - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } -} diff --git a/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt b/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt deleted file mode 100644 index d638f6ee249..00000000000 --- a/examples/falling-balls/shared/src/androidMain/kotlin/main.android.kt +++ /dev/null @@ -1,12 +0,0 @@ -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember - -object AndroidTime : Time { - override fun now(): Long = System.nanoTime() -} - -@Composable -fun MainView() { - val game = remember { Game(AndroidTime) } - FallingBalls(game) -} \ No newline at end of file diff --git a/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt deleted file mode 100644 index 1c4b55ab066..00000000000 --- a/examples/falling-balls/shared/src/desktopMain/kotlin/main.desktop.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember - -object JvmTime : Time { - override fun now(): Long = System.nanoTime() -} - -@Composable -fun MainView() { - val game = remember { Game(JvmTime) } - FallingBalls(game) -} - -@Preview -@Composable -fun GamePreview() { - MainView() -} \ No newline at end of file diff --git a/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt b/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt deleted file mode 100644 index 618bdd6d1d9..00000000000 --- a/examples/falling-balls/shared/src/iosMain/kotlin/main.ios.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - - -import androidx.compose.runtime.remember -import androidx.compose.ui.window.ComposeUIViewController -import platform.UIKit.UIViewController - -object IosTime : Time { - override fun now(): Long = kotlin.system.getTimeNanos() -} - -fun MainViewController() : UIViewController = ComposeUIViewController { - val game = remember { Game(IosTime) } - FallingBalls(game) -} - diff --git a/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt deleted file mode 100644 index 7e0e22e86a8..00000000000 --- a/examples/falling-balls/shared/src/jsMain/kotlin/main.js.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.foundation.layout.* -import androidx.compose.material.RadioButton -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import bouncingBalls.BouncingBallsApp - -object JsTime : Time { - override fun now(): Long = kotlinx.browser.window.performance.now().toLong() -} - -@Composable -fun MainView() { - val selectedExample = remember { mutableStateOf(Examples.FallingBalls) } - - Column(modifier = Modifier.fillMaxSize()) { - ExamplesChooser(selectedExample) - Spacer(modifier = Modifier.height(24.dp)) - - when (selectedExample.value) { - Examples.FallingBalls -> { - val game = remember { Game(JsTime) } - FallingBalls(game) - } - Examples.BouncingBalls -> { - BouncingBallsApp(10) - } - } - } -} - -@Composable -private fun ExamplesChooser(selected: MutableState) { - Column { - Row(verticalAlignment = Alignment.CenterVertically) { - Text("Choose an example: ", fontSize = 16.sp) - - Examples.values().forEach { - Row(verticalAlignment = Alignment.CenterVertically) { - RadioButton(selected = selected.value == it, onClick = { - selected.value = it - }) - Text(it.name) - } - } - } - } -} - -private enum class Examples { - FallingBalls, - BouncingBalls -} - diff --git a/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt b/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt deleted file mode 100644 index be803b013d6..00000000000 --- a/examples/falling-balls/shared/src/macosMain/kotlin/main.macos.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.ui.window.Window -import androidx.compose.runtime.remember -import androidx.compose.ui.unit.dp -import platform.AppKit.NSApp -import platform.AppKit.NSApplication - -object MacosTime : Time { - override fun now(): Long = kotlin.system.getTimeNanos() -} - -fun main() { - NSApplication.sharedApplication() - Window("Falling Balls") { - val game = remember { Game(MacosTime) } - FallingBalls(game) - } - NSApp?.run() -} diff --git a/examples/falling-balls/.gitignore b/examples/graphics-2d/.gitignore similarity index 100% rename from examples/falling-balls/.gitignore rename to examples/graphics-2d/.gitignore diff --git a/examples/falling-balls/.run/desktopApp.run.xml b/examples/graphics-2d/.run/desktopApp.run.xml similarity index 100% rename from examples/falling-balls/.run/desktopApp.run.xml rename to examples/graphics-2d/.run/desktopApp.run.xml diff --git a/examples/graphics-2d/README.md b/examples/graphics-2d/README.md new file mode 100644 index 00000000000..0cf145bd7b9 --- /dev/null +++ b/examples/graphics-2d/README.md @@ -0,0 +1,24 @@ +# Graphics2D + +Example can run on Android, iOS, desktop or in a browser. + +## Setting up your development environment + +To setup the environment, please consult +these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment). + +## How to run + +Choose a run configuration for an appropriate target in Android Studio and run it. + +![run-configurations.png](run-configurations.png) + +## Run on desktop via Gradle + +`./gradlew desktopApp:run` + +## Run experimental native on MacOS + +`./gradlew runDebugExecutableMacosX64` (Works on Intel processors) +`./gradlew runDebugExecutableMacosArm64` (Works on Arm processors) + diff --git a/examples/falling-balls/androidApp/build.gradle.kts b/examples/graphics-2d/androidApp/build.gradle.kts similarity index 86% rename from examples/falling-balls/androidApp/build.gradle.kts rename to examples/graphics-2d/androidApp/build.gradle.kts index 0d7ab8e11fe..e09546327c0 100644 --- a/examples/falling-balls/androidApp/build.gradle.kts +++ b/examples/graphics-2d/androidApp/build.gradle.kts @@ -17,9 +17,9 @@ kotlin { android { compileSdk = 34 - namespace = "org.jetbrains.fallingballs" + namespace = "org.jetbrains.graphics2d" defaultConfig { - applicationId = "org.jetbrains.FallingBalls" + applicationId = "org.jetbrains.Graphics2D" minSdk = 26 targetSdk = 34 versionCode = 1 diff --git a/examples/falling-balls/androidApp/src/androidMain/AndroidManifest.xml b/examples/graphics-2d/androidApp/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/falling-balls/androidApp/src/androidMain/AndroidManifest.xml rename to examples/graphics-2d/androidApp/src/androidMain/AndroidManifest.xml diff --git a/examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt b/examples/graphics-2d/androidApp/src/androidMain/kotlin/org/jetbrains/graphics2d/MainActivity.kt similarity index 90% rename from examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt rename to examples/graphics-2d/androidApp/src/androidMain/kotlin/org/jetbrains/graphics2d/MainActivity.kt index ef41726dc2f..2285f4485a6 100644 --- a/examples/falling-balls/androidApp/src/androidMain/kotlin/org/jetbrains/fallingballs/MainActivity.kt +++ b/examples/graphics-2d/androidApp/src/androidMain/kotlin/org/jetbrains/graphics2d/MainActivity.kt @@ -1,4 +1,4 @@ -package org.jetbrains.fallingballs +package org.jetbrains.graphics2d import MainView import android.os.Bundle diff --git a/examples/graphics-2d/androidApp/src/androidMain/res/values/strings.xml b/examples/graphics-2d/androidApp/src/androidMain/res/values/strings.xml new file mode 100644 index 00000000000..b459df13ca9 --- /dev/null +++ b/examples/graphics-2d/androidApp/src/androidMain/res/values/strings.xml @@ -0,0 +1,3 @@ + + Graphics2D + \ No newline at end of file diff --git a/examples/falling-balls/apple-id.png b/examples/graphics-2d/apple-id.png similarity index 100% rename from examples/falling-balls/apple-id.png rename to examples/graphics-2d/apple-id.png diff --git a/examples/falling-balls/build.gradle.kts b/examples/graphics-2d/build.gradle.kts similarity index 100% rename from examples/falling-balls/build.gradle.kts rename to examples/graphics-2d/build.gradle.kts diff --git a/examples/falling-balls/desktopApp/build.gradle.kts b/examples/graphics-2d/desktopApp/build.gradle.kts similarity index 91% rename from examples/falling-balls/desktopApp/build.gradle.kts rename to examples/graphics-2d/desktopApp/build.gradle.kts index 7606f459184..31d4aef6ca9 100644 --- a/examples/falling-balls/desktopApp/build.gradle.kts +++ b/examples/graphics-2d/desktopApp/build.gradle.kts @@ -8,7 +8,7 @@ plugins { kotlin { jvm {} sourceSets { - val jvmMain by getting { + val jvmMain by getting { dependencies { implementation(compose.desktop.currentOs) implementation(project(":shared")) @@ -23,7 +23,7 @@ compose.desktop { nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "Falling Balls" + packageName = "Graphics2D" packageVersion = "1.0.0" windows { diff --git a/examples/graphics-2d/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/graphics-2d/desktopApp/src/jvmMain/kotlin/Main.kt new file mode 100644 index 00000000000..72742a58ba0 --- /dev/null +++ b/examples/graphics-2d/desktopApp/src/jvmMain/kotlin/Main.kt @@ -0,0 +1,30 @@ +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.coerceIn +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Window +import androidx.compose.ui.window.application +import androidx.compose.ui.window.rememberWindowState + + +private val INIT_SIZE = DpSize(800.dp, 800.dp) + +fun main() = + application { + val windowState = rememberWindowState(width = 800.dp, height = 800.dp) + + Window( + onCloseRequest = ::exitApplication, + resizable = false, + title = "Graphics2D", + state = windowState, + ) { + Graphics2D( + requestWindowSize = { w, h -> + windowState.size = windowState.size.copy( + width = w.coerceIn(INIT_SIZE.width, Float.MAX_VALUE.dp), + height = h.coerceIn(INIT_SIZE.height, Float.MAX_VALUE.dp) + ) + } + ) + } + } diff --git a/examples/minesweeper/gradle.properties b/examples/graphics-2d/gradle.properties similarity index 97% rename from examples/minesweeper/gradle.properties rename to examples/graphics-2d/gradle.properties index 2e30567e908..73998f2d5e5 100644 --- a/examples/minesweeper/gradle.properties +++ b/examples/graphics-2d/gradle.properties @@ -11,7 +11,7 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 # TODO: remove when switching to 1.9.10. See: https://youtrack.jetbrains.com/issue/KT-60852 # usage: ./gradlew :jsApp:jsBrowserRun -Pworkaround.kotlin.js.kt60852=true diff --git a/examples/falling-balls/gradle/wrapper/gradle-wrapper.jar b/examples/graphics-2d/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from examples/falling-balls/gradle/wrapper/gradle-wrapper.jar rename to examples/graphics-2d/gradle/wrapper/gradle-wrapper.jar diff --git a/examples/falling-balls/gradle/wrapper/gradle-wrapper.properties b/examples/graphics-2d/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from examples/falling-balls/gradle/wrapper/gradle-wrapper.properties rename to examples/graphics-2d/gradle/wrapper/gradle-wrapper.properties diff --git a/examples/falling-balls/gradlew b/examples/graphics-2d/gradlew similarity index 100% rename from examples/falling-balls/gradlew rename to examples/graphics-2d/gradlew diff --git a/examples/falling-balls/gradlew.bat b/examples/graphics-2d/gradlew.bat similarity index 100% rename from examples/falling-balls/gradlew.bat rename to examples/graphics-2d/gradlew.bat diff --git a/examples/falling-balls/ios-app.png b/examples/graphics-2d/ios-app.png similarity index 100% rename from examples/falling-balls/ios-app.png rename to examples/graphics-2d/ios-app.png diff --git a/examples/graphics-2d/iosApp/Configuration/Config.xcconfig b/examples/graphics-2d/iosApp/Configuration/Config.xcconfig new file mode 100644 index 00000000000..d5037986d05 --- /dev/null +++ b/examples/graphics-2d/iosApp/Configuration/Config.xcconfig @@ -0,0 +1,3 @@ +TEAM_ID= +BUNDLE_ID=org.jetbrains.Graphics2D +APP_NAME=Graphics2D diff --git a/examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/graphics-2d/iosApp/iosApp.xcodeproj/project.pbxproj similarity index 97% rename from examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj rename to examples/graphics-2d/iosApp/iosApp.xcodeproj/project.pbxproj index bf37d47794f..c810131d7a3 100644 --- a/examples/falling-balls/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/examples/graphics-2d/iosApp/iosApp.xcodeproj/project.pbxproj @@ -17,7 +17,7 @@ 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; - 7555FF7B242A565900829871 /* FallingBalls.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FallingBalls.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 7555FF7B242A565900829871 /* Graphics2D.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Graphics2D.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; @@ -54,7 +54,7 @@ 7555FF7C242A565900829871 /* Products */ = { isa = PBXGroup; children = ( - 7555FF7B242A565900829871 /* FallingBalls.app */, + 7555FF7B242A565900829871 /* Graphics2D.app */, ); name = Products; sourceTree = ""; @@ -97,7 +97,7 @@ ); name = iosApp; productName = iosApp; - productReference = 7555FF7B242A565900829871 /* FallingBalls.app */; + productReference = 7555FF7B242A565900829871 /* Graphics2D.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ diff --git a/examples/falling-balls/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from examples/falling-balls/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json rename to examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/examples/falling-balls/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from examples/falling-balls/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json rename to examples/graphics-2d/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/examples/falling-balls/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/graphics-2d/iosApp/iosApp/Assets.xcassets/Contents.json similarity index 100% rename from examples/falling-balls/iosApp/iosApp/Assets.xcassets/Contents.json rename to examples/graphics-2d/iosApp/iosApp/Assets.xcassets/Contents.json diff --git a/examples/falling-balls/iosApp/iosApp/ContentView.swift b/examples/graphics-2d/iosApp/iosApp/ContentView.swift similarity index 83% rename from examples/falling-balls/iosApp/iosApp/ContentView.swift rename to examples/graphics-2d/iosApp/iosApp/ContentView.swift index e9915e5fcff..56163e63933 100644 --- a/examples/falling-balls/iosApp/iosApp/ContentView.swift +++ b/examples/graphics-2d/iosApp/iosApp/ContentView.swift @@ -5,7 +5,7 @@ import shared struct ContentView: View { var body: some View { ComposeView() - .ignoresSafeArea(.keyboard) // Compose has own keyboard handler + .ignoresSafeArea(.all) // Compose has own keyboard handler } } diff --git a/examples/falling-balls/iosApp/iosApp/Info.plist b/examples/graphics-2d/iosApp/iosApp/Info.plist similarity index 100% rename from examples/falling-balls/iosApp/iosApp/Info.plist rename to examples/graphics-2d/iosApp/iosApp/Info.plist diff --git a/examples/falling-balls/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/graphics-2d/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from examples/falling-balls/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json rename to examples/graphics-2d/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/examples/falling-balls/iosApp/iosApp/iOSApp.swift b/examples/graphics-2d/iosApp/iosApp/iOSApp.swift similarity index 100% rename from examples/falling-balls/iosApp/iosApp/iOSApp.swift rename to examples/graphics-2d/iosApp/iosApp/iOSApp.swift diff --git a/examples/minesweeper/jsApp/build.gradle.kts b/examples/graphics-2d/jsApp/build.gradle.kts similarity index 91% rename from examples/minesweeper/jsApp/build.gradle.kts rename to examples/graphics-2d/jsApp/build.gradle.kts index 144006fa941..b6fc37668c1 100644 --- a/examples/minesweeper/jsApp/build.gradle.kts +++ b/examples/graphics-2d/jsApp/build.gradle.kts @@ -9,7 +9,7 @@ kotlin { binaries.executable() } sourceSets { - val jsMain by getting { + val jsMain by getting { dependencies { implementation(project(":shared")) implementation(compose.ui) diff --git a/examples/graphics-2d/jsApp/src/jsMain/kotlin/main.js.kt b/examples/graphics-2d/jsApp/src/jsMain/kotlin/main.js.kt new file mode 100644 index 00000000000..5c9cd849532 --- /dev/null +++ b/examples/graphics-2d/jsApp/src/jsMain/kotlin/main.js.kt @@ -0,0 +1,10 @@ +import androidx.compose.ui.window.Window +import org.jetbrains.skiko.wasm.onWasmReady + +fun main() { + onWasmReady { + Window("Graphics2D") { + MainView() + } + } +} diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png b/examples/graphics-2d/jsApp/src/jsMain/resources/assets/clock.png similarity index 100% rename from examples/minesweeper/jsApp/src/jsMain/resources/assets/clock.png rename to examples/graphics-2d/jsApp/src/jsMain/resources/assets/clock.png diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png b/examples/graphics-2d/jsApp/src/jsMain/resources/assets/flag.png similarity index 100% rename from examples/minesweeper/jsApp/src/jsMain/resources/assets/flag.png rename to examples/graphics-2d/jsApp/src/jsMain/resources/assets/flag.png diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png b/examples/graphics-2d/jsApp/src/jsMain/resources/assets/mine.png similarity index 100% rename from examples/minesweeper/jsApp/src/jsMain/resources/assets/mine.png rename to examples/graphics-2d/jsApp/src/jsMain/resources/assets/mine.png diff --git a/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml b/examples/graphics-2d/jsApp/src/jsMain/resources/compose-community-primary.xml similarity index 100% rename from examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.xml rename to examples/graphics-2d/jsApp/src/jsMain/resources/compose-community-primary.xml diff --git a/examples/graphics-2d/jsApp/src/jsMain/resources/index.html b/examples/graphics-2d/jsApp/src/jsMain/resources/index.html new file mode 100644 index 00000000000..c70f31b9a41 --- /dev/null +++ b/examples/graphics-2d/jsApp/src/jsMain/resources/index.html @@ -0,0 +1,16 @@ + + + + + compose multiplatform web demo + + + + +

compose multiplatform web demo

+
+ +
+ + + diff --git a/examples/falling-balls/jsApp/src/jsMain/resources/styles.css b/examples/graphics-2d/jsApp/src/jsMain/resources/styles.css similarity index 100% rename from examples/falling-balls/jsApp/src/jsMain/resources/styles.css rename to examples/graphics-2d/jsApp/src/jsMain/resources/styles.css diff --git a/examples/falling-balls/run-configurations.png b/examples/graphics-2d/run-configurations.png similarity index 100% rename from examples/falling-balls/run-configurations.png rename to examples/graphics-2d/run-configurations.png diff --git a/examples/minesweeper/settings.gradle.kts b/examples/graphics-2d/settings.gradle.kts similarity index 96% rename from examples/minesweeper/settings.gradle.kts rename to examples/graphics-2d/settings.gradle.kts index 6ed7a53ada8..7e76f0ab40e 100644 --- a/examples/minesweeper/settings.gradle.kts +++ b/examples/graphics-2d/settings.gradle.kts @@ -24,7 +24,7 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0") } -rootProject.name = "minesweeper" +rootProject.name = "graphics-2d" include(":androidApp") include(":shared") diff --git a/examples/minesweeper/shared/build.gradle.kts b/examples/graphics-2d/shared/build.gradle.kts similarity index 94% rename from examples/minesweeper/shared/build.gradle.kts rename to examples/graphics-2d/shared/build.gradle.kts index 0df0b481ae0..adff5037ca6 100644 --- a/examples/minesweeper/shared/build.gradle.kts +++ b/examples/graphics-2d/shared/build.gradle.kts @@ -15,7 +15,6 @@ kotlin { androidTarget() jvm("desktop") - js(IR) { browser() } @@ -52,7 +51,7 @@ kotlin { implementation(compose.ui) implementation(compose.runtime) implementation(compose.foundation) - implementation(compose.material) + implementation(compose.material3) @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) implementation(compose.components.resources) } @@ -95,13 +94,9 @@ kotlin { implementation(compose.desktop.common) } } - val macosMain by creating { dependsOn(commonMain) } - val macosX64Main by getting { - dependsOn(macosMain) - } val macosArm64Main by getting { dependsOn(macosMain) } @@ -117,7 +112,7 @@ kotlin { android { compileSdk = 34 - namespace = "org.jetbrains.minesweeper" + namespace = "org.jetbrains.Graphics2D" sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") sourceSets["main"].res.srcDirs("src/androidMain/res") sourceSets["main"].resources.srcDirs("src/commonMain/resources") diff --git a/examples/falling-balls/shared/src/androidMain/AndroidManifest.xml b/examples/graphics-2d/shared/src/androidMain/AndroidManifest.xml similarity index 100% rename from examples/falling-balls/shared/src/androidMain/AndroidManifest.xml rename to examples/graphics-2d/shared/src/androidMain/AndroidManifest.xml diff --git a/examples/graphics-2d/shared/src/androidMain/kotlin/main.android.kt b/examples/graphics-2d/shared/src/androidMain/kotlin/main.android.kt new file mode 100644 index 00000000000..ec2120b6db4 --- /dev/null +++ b/examples/graphics-2d/shared/src/androidMain/kotlin/main.android.kt @@ -0,0 +1,6 @@ +import androidx.compose.runtime.Composable + +@Composable +fun MainView() { + Graphics2D() +} diff --git a/examples/graphics-2d/shared/src/androidMain/kotlin/minesweeper/MineSweeper.android.kt b/examples/graphics-2d/shared/src/androidMain/kotlin/minesweeper/MineSweeper.android.kt new file mode 100644 index 00000000000..181a5833e6a --- /dev/null +++ b/examples/graphics-2d/shared/src/androidMain/kotlin/minesweeper/MineSweeper.android.kt @@ -0,0 +1,3 @@ +package minesweeper + +actual fun hasRightClick() = false diff --git a/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt b/examples/graphics-2d/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt similarity index 79% rename from examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt rename to examples/graphics-2d/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt index 3dd3fe22d9c..b9e71feb0d2 100644 --- a/examples/visual-effects/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt +++ b/examples/graphics-2d/shared/src/androidMain/kotlin/platform/PointerEventKind.android.kt @@ -1,4 +1,4 @@ -package org.jetbrains.compose.demo.visuals.platform +package visualeffects import androidx.compose.ui.Modifier diff --git a/examples/graphics-2d/shared/src/commonMain/kotlin/Graphics2D.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/Graphics2D.kt new file mode 100644 index 00000000000..7554db78343 --- /dev/null +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/Graphics2D.kt @@ -0,0 +1,110 @@ +import androidx.compose.foundation.clickable +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material3.Button +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import bouncingballs.BouncingBallsApp +import fallingballs.FallingBalls +import minesweeper.MineSweeper +import visualeffects.NYContent +import visualeffects.RotatingWords +import visualeffects.WaveEffectGrid + +private val TOP_APP_BAR_HEIGHT = 100.dp +private val EMPTY_WINDOW_RESIZER: (width: Dp, height: Dp) -> Unit = { w, h -> } + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun Graphics2D(requestWindowSize: ((width: Dp, height: Dp) -> Unit) = EMPTY_WINDOW_RESIZER) { + val exampleState: MutableState = remember { mutableStateOf(null) } + val example = exampleState.value + + MaterialTheme( + colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme() + ) { + Scaffold( + topBar = { + TopAppBar( + navigationIcon = { + if (example != null) { + Icon( + imageVector = Icons.Default.ArrowBack, + contentDescription = "Back", + modifier = Modifier.clickable { + exampleState.value = null + } + ) + } + }, + title = { + Text(example?.name ?: "Choose example") + } + ) + } + ) { + Box(Modifier.padding(it)) { + if (example == null) { + LazyColumn(Modifier.padding(horizontal = 16.dp)) { + items(examples) { + Button(onClick = { + exampleState.value = it + }) { + Text(it.name) + } + } + } + } else { + example.content { w, h -> + requestWindowSize(w, h + TOP_APP_BAR_HEIGHT) + } + } + } + + } + } +} + +private class Example( + val name: String, + val content: @Composable (requestWindowSize: ((width: Dp, height: Dp) -> Unit)) -> Unit +) + +private val examples: List = listOf( + Example("FallingBalls") { + FallingBalls() + }, + Example("BouncingBalls") { + BouncingBallsApp() + }, + Example("MineSweeper") { + MineSweeper(it) + }, + Example("RotatingWords") { + RotatingWords() + }, + Example("WaveEffectGrid") { + WaveEffectGrid() + }, + Example("Happy New Year!") { + NYContent() + }, +) diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/bouncingballs/BouncingBalls.kt similarity index 86% rename from examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/bouncingballs/BouncingBalls.kt index 58f5b65adb0..09f813e468d 100644 --- a/examples/falling-balls/shared/src/commonMain/kotlin/bouncingBalls/BouncingBalls.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/bouncingballs/BouncingBalls.kt @@ -1,28 +1,35 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package bouncingBalls +package bouncingballs import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.withFrameNanos import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.pointerInput -import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.unit.dp import kotlin.math.PI import kotlin.math.cos import kotlin.math.max +import kotlin.math.roundToInt import kotlin.math.sin import kotlin.random.Random @@ -52,17 +59,16 @@ fun BouncingBallsApp(initialBallsCount: Int = 5) { list } - Box( + BoxWithConstraints( modifier = Modifier.fillMaxWidth() .fillMaxHeight() .border(width = 1.dp, color = Color.Black) .noRippleClickable { items += BouncingBall.createBouncingBall(offset = it) - }.onSizeChanged { - areaWidth = it.width - areaHeight = it.height } ) { + areaWidth = maxWidth.value.roundToInt() + areaHeight = maxHeight.value.roundToInt() Balls(items) } diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/FallingBalls.common.kt similarity index 68% rename from examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/FallingBalls.common.kt index 731435037e2..53814c85593 100644 --- a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/FallingBalls.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/FallingBalls.common.kt @@ -1,11 +1,20 @@ +package fallingballs + import androidx.compose.foundation.background import androidx.compose.foundation.border -import androidx.compose.foundation.layout.* -import androidx.compose.material.Button -import androidx.compose.material.Slider -import androidx.compose.material.Text +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.width +import androidx.compose.material3.Button +import androidx.compose.material3.Slider +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember import androidx.compose.runtime.withFrameNanos import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -15,7 +24,8 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @Composable -fun FallingBalls(game: Game) { +fun FallingBalls() { + val game = remember { Game() } val density = LocalDensity.current Column { Text( @@ -23,7 +33,10 @@ fun FallingBalls(game: Game) { fontSize = 20.sp, color = Color(218, 120, 91) ) - Text("Score: ${game.score} Time: ${game.elapsed / 1_000_000} Blocks: ${game.numBlocks.toInt()}", fontSize = 20.sp) + Text( + "Score: ${game.score} Time: ${game.elapsed / 1_000_000} Blocks: ${game.numBlocks.toInt()}", + fontSize = 20.sp + ) Row { if (!game.started) { Slider( @@ -33,9 +46,6 @@ fun FallingBalls(game: Game) { ) } Button( - modifier = Modifier - .border(2.dp, Color(255, 215, 0)) - .background(Color.Yellow), onClick = { game.started = !game.started if (game.started) { @@ -45,18 +55,6 @@ fun FallingBalls(game: Game) { ) { Text(if (game.started) "Stop" else "Start", fontSize = 25.sp) } - if (game.started) { - Button( - modifier = Modifier - .offset(10.dp, 0.dp) - .border(2.dp, Color(255, 215, 0)) - .background(Color.Yellow), - onClick = { - game.togglePause() - }) { - Text(if (game.paused) "Resume" else "Pause", fontSize = 25.sp) - } - } } if (game.started) { Box(modifier = Modifier.height(20.dp)) @@ -76,12 +74,14 @@ fun FallingBalls(game: Game) { LaunchedEffect(Unit) { while (true) { + var previousTimeNanos = withFrameNanos { it } withFrameNanos { - if (game.started && !game.paused && !game.finished) - game.update(it) + if (game.started && !game.paused && !game.finished) { + game.update((it - previousTimeNanos).coerceAtLeast(0)) + previousTimeNanos = it + } } } } } } - diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Game.kt similarity index 50% rename from examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Game.kt index b4bbe9d4a82..9480152ed2d 100644 --- a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Game.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Game.kt @@ -1,23 +1,18 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ -import androidx.compose.runtime.* +package fallingballs + +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.* +import androidx.compose.ui.unit.dp import kotlin.random.Random -interface Time { - fun now(): Long -} - -class Game(val time: Time) { - private var previousTimeNanos: Long = Long.MAX_VALUE +class Game() { private val colors = arrayOf( Color.Red, Color.Blue, Color.Cyan, Color.Magenta, Color.Yellow, Color.Black ) - private var startTime = 0L var width by mutableStateOf(0.dp) var height by mutableStateOf(0.dp) @@ -36,30 +31,26 @@ class Game(val time: Time) { var numBlocks by mutableStateOf(5f) fun start() { - previousTimeNanos = time.now() - startTime = previousTimeNanos clicked = 0 started = true finished = false paused = false pieces.clear() repeat(numBlocks.toInt()) { index -> - pieces.add(PieceData(this, index * 1.5f + 5f, colors[index % colors.size]).also { piece -> - piece.position = Random.nextDouble(0.0, 100.0).toFloat() - }) + 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 = time.now() - } - - fun update(nanos: Long) { - val dt = (nanos - previousTimeNanos).coerceAtLeast(0) - previousTimeNanos = nanos - elapsed = nanos - startTime - pieces.forEach { it.update(dt) } + fun update(deltaTimeNanos: Long) { + elapsed += deltaTimeNanos + pieces.forEach { it.update(deltaTimeNanos) } } fun clicked(piece: PieceData) { @@ -69,4 +60,4 @@ class Game(val time: Time) { finished = true } } -} \ No newline at end of file +} diff --git a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Piece.kt similarity index 89% rename from examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Piece.kt index 14b96bfab02..118ca63df14 100644 --- a/examples/falling-balls/shared/src/commonMain/kotlin/fallingBalls/Piece.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/fallingballs/Piece.kt @@ -1,7 +1,4 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ +package fallingballs import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -53,4 +50,4 @@ data class PieceData(val game: Game, val velocity: Float, val color: Color) { game.clicked(this) } } -} \ No newline at end of file +} diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/BoardView.kt similarity index 95% rename from examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/BoardView.kt index a72e93b88b9..a31d098c949 100644 --- a/examples/minesweeper/shared/src/commonMain/kotlin/BoardView.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/BoardView.kt @@ -1,3 +1,5 @@ +package minesweeper + import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Box @@ -43,4 +45,4 @@ fun BoardView(game: GameController) = with(GameStyles) { } private fun GameStyles.getCellColor(cell: Cell): Color = - if (cell.isOpened) openedCellColor else closedCellColor \ No newline at end of file + if (cell.isOpened) openedCellColor else closedCellColor diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameController.kt similarity index 97% rename from examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameController.kt index 154bdcfbbd3..155ae15cdf8 100644 --- a/examples/minesweeper/shared/src/commonMain/kotlin/GameController.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameController.kt @@ -1,36 +1,50 @@ +package minesweeper + import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import kotlin.random.Random -class GameController(private val options: GameSettings, private val onWin: (() -> Unit)? = null, private val onLose: (() -> Unit)? = null) { +class GameController( + private val options: GameSettings, + private val onWin: (() -> Unit)? = null, + private val onLose: (() -> Unit)? = null +) { /** Number of rows in current board */ val rows: Int get() = options.rows + /** Number of columns in current board */ val columns: Int get() = options.columns + /** Number of bombs in current board */ val bombs: Int get() = options.mines + /** True if current game has started, false if game is finished or until first cell is opened or flagged */ var running by mutableStateOf(false) private set + /** True if game is ended (win or lose) */ var finished by mutableStateOf(false) private set + /** Total number of flags set on cells, used for calculation of number of remaining bombs */ var flagsSet by mutableStateOf(0) private set + /** Number of remaining cells */ var cellsToOpen by mutableStateOf(options.rows * options.columns - options.mines) private set + /** Game timer, increments every second while game is running */ var seconds by mutableStateOf(0) private set /** Global monotonic time, updated with [onTimeTick] */ private var time = 0L + /** The time when user starts the game by opening or flagging any cell */ private var startTime = 0L @@ -59,7 +73,7 @@ class GameController(private val options: GameSettings, private val onWin: (() - mines: Collection>, onWin: (() -> Unit)? = null, onLose: (() -> Unit)? = null - ) : this(GameSettings(rows, columns, mines.size), onWin, onLose) { + ) : this(GameSettings(rows, columns, mines.size), onWin, onLose) { for (row in cells) { for (cell in row) { cell.hasBomb = false @@ -290,4 +304,4 @@ class Cell(val row: Int, val column: Int) { var isOpened by mutableStateOf(false) var isFlagged by mutableStateOf(false) var bombsNear = 0 -} \ No newline at end of file +} diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameInteraction.kt similarity index 98% rename from examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameInteraction.kt index 77842f61234..a852418e1af 100644 --- a/examples/minesweeper/shared/src/commonMain/kotlin/gameInteraction.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/GameInteraction.kt @@ -1,3 +1,5 @@ +package minesweeper + import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.combinedClickable import androidx.compose.runtime.Composable diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/game.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt similarity index 89% rename from examples/minesweeper/shared/src/commonMain/kotlin/game.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt index 13c2d47b204..967c9db8268 100644 --- a/examples/minesweeper/shared/src/commonMain/kotlin/game.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt @@ -1,12 +1,14 @@ @file:Suppress("FunctionName") -import androidx.compose.runtime.* +package minesweeper + + import androidx.compose.foundation.* import androidx.compose.foundation.layout.* -import androidx.compose.material.* +import androidx.compose.material3.* +import androidx.compose.runtime.* import androidx.compose.ui.* import androidx.compose.ui.graphics.Color - import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.unit.* import org.jetbrains.compose.resources.ExperimentalResourceApi @@ -39,7 +41,7 @@ object GameStyles { } @Composable -fun Game(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLayout { +fun MineSweeper(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLayout { var message by remember { mutableStateOf(null) } val onWin = { message = "You win!" } @@ -101,9 +103,10 @@ fun Game(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLay } // Cells - Box(modifier = Modifier - .border(GameStyles.boardBorderWidth, Color.White) - .padding(GameStyles.boardPadding) + Box( + modifier = Modifier + .border(GameStyles.boardBorderWidth, Color.White) + .padding(GameStyles.boardPadding) ) { BoardView(game) } @@ -119,6 +122,6 @@ fun Game(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = MainLay } @Composable -private fun MainLayout(block:@Composable ColumnScope.() -> Unit) { +private fun MainLayout(block: @Composable ColumnScope.() -> Unit) { Column { block() } -} \ No newline at end of file +} diff --git a/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt similarity index 97% rename from examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt index 3a81aca7737..6d009681419 100644 --- a/examples/minesweeper/shared/src/commonMain/kotlin/widgets.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt @@ -1,11 +1,13 @@ @file:Suppress("FunctionName") +package minesweeper + import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* -import androidx.compose.material.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -80,4 +82,4 @@ fun NewGameButton(text: String, onClick: () -> Unit) { modifier = Modifier.padding(4.dp) ) } -} \ No newline at end of file +} diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/HappyNY.kt similarity index 65% rename from examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/HappyNY.kt index b1df36b5ee4..0a01191f6b1 100644 --- a/examples/visual-effects/shared/src/commonMain/kotlin/HappyNY.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/HappyNY.kt @@ -1,25 +1,45 @@ -package org.jetbrains.compose.demo.visuals +package visualeffects import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width 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.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshots.SnapshotStateList +import androidx.compose.runtime.withFrameNanos import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.* +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.draw.shadow import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.em import androidx.compose.ui.unit.sp -import org.jetbrains.compose.demo.visuals.platform.nanoTime -import kotlin.math.* +import kotlin.math.PI +import kotlin.math.abs +import kotlin.math.cos +import kotlin.math.sin import kotlin.random.Random const val width = 1200 @@ -97,16 +117,16 @@ class DoubleRocket(val particle: Particle) { state = STATE_SMALL_ROCKETS } - fun move(time: Long, prevTime: Long) { + fun move(timeElapsed: Long, deltaNanos: Long) { if (rocket.state == rocket.STATE_ROCKET) { - rocket.particle.move(time, prevTime) - rocket.particle.gravity(time, prevTime) + rocket.particle.move(deltaNanos) + rocket.particle.gravity(deltaNanos) } else { rocket.rockets.forEach { - it.move(time, prevTime) + it.move(timeElapsed, deltaNanos) } } - rocket.checkState(time) + rocket.checkState(timeElapsed) } @Composable @@ -126,8 +146,8 @@ 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) { + fun checkExplode(timeElapsed: Long) { + if (timeElapsed - startTime > 1200000000) { explode() } } @@ -136,7 +156,14 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0) 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) + Particle( + particle.x, + particle.y, + v * sin(angle) + particle.vx, + v * cos(angle) + particle.vy, + color, + 1 + ) } exploded = true } @@ -149,15 +176,15 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0) return true } - fun move(time: Long, prevTime: Long) { + fun move(timeElapsed: Long, deltaNanos: Long) { if (!exploded) { - particle.move(time, prevTime) - particle.gravity(time, prevTime) - checkExplode(time) + particle.move(deltaNanos) + particle.gravity(deltaNanos) + checkExplode(timeElapsed) } else { parts.forEach { - it.move(time, prevTime) - it.gravity(time, prevTime) + it.move(deltaNanos) + it.gravity(deltaNanos) } } } @@ -174,20 +201,30 @@ class Rocket(val particle: Particle, val color: Color, val startTime: Long = 0) } } -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) +class Particle( + var x: Double, + var y: Double, + var vx: Double, + var vy: Double, + val color: Color, + val type: Int = 0 +) { + fun move(deltaNanos: Long) { + x = (x + vx * deltaNanos / 30000000) + y = (y + vy * deltaNanos / 30000000) } - fun gravity(time: Long, prevTime: Long) { - vy = vy + 1.0f * (time - prevTime) / 300000000 + fun gravity(deltaNanos: Long) { + vy = vy + 1.0f * deltaNanos / 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)) + 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) @@ -199,7 +236,10 @@ class Particle(var x: Double, var y: Double, var vx: Double, var vy: Double, val val rocket = DoubleRocket(Particle(0.0, 1000.0, 2.1, -12.5, Color.White)) -fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: SnapshotStateList) { +fun prepareStarsAndSnowFlakes( + stars: SnapshotStateList, + snowFlakes: SnapshotStateList +) { for (i in 0..snowCount) { snowFlakes.add( SnowFlake( @@ -214,7 +254,15 @@ fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: Snapsh ) ) } - val colors = arrayOf(Color.Red, Color.Yellow, Color.Green, Color.Yellow, Color.Cyan, Color.Magenta, Color.White) + 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( @@ -227,58 +275,58 @@ fun prepareStarsAndSnowFlakes(stars: SnapshotStateList, snowFlakes: Snapsh } } -@OptIn(ExperimentalComposeUiApi::class) @Composable fun NYContent() { - var time by remember { mutableStateOf(nanoTime()) } var started by remember { mutableStateOf(false) } - var startTime = remember { nanoTime() } - var prevTime by remember { mutableStateOf(nanoTime()) } - val snowFlakes = remember { mutableStateListOf() } val stars = remember { mutableStateListOf() } var flickering2 by remember { mutableStateOf(true) } + val snowFlakes = remember { mutableStateListOf() } remember { prepareStarsAndSnowFlakes(stars, snowFlakes) } + var timeElapsedNanos by remember { mutableStateOf(0L) } Surface( modifier = Modifier.fillMaxSize().padding(5.dp).shadow(3.dp, RoundedCornerShape(20.dp)), color = Color.Black, shape = RoundedCornerShape(20.dp) ) { - LaunchedEffect(Unit) { while (true) { + var previousTimeNanos = withFrameNanos { it } 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 - } - } + val deltaTimeNanos = it - previousTimeNanos + timeElapsedNanos += deltaTimeNanos + previousTimeNanos = it + + if (flickering2) { + if (timeElapsedNanos > 15500000000) { //note, that startTime has been updated above + flickering2 = false + } + } + if (started) { + rocket.move(timeElapsedNanos, deltaTimeNanos) + } - if (flickering2) { - if (time - startTime > 15500000000) { //note, that startTime has been updated above - flickering2 = false + snowFlakes.forEach { + var y = it.y + ((it.v * deltaTimeNanos) / 30000000).dp + if (y > (height + 20).dp) { + y = -20.dp + } + it.y = y + } + } } } - if (started) { - rocket.move(time, prevTime) - } with(LocalDensity.current) { Box(Modifier.fillMaxSize()) { - - snow(time, prevTime, snowFlakes, startTime) - + snow(timeElapsedNanos, snowFlakes) starrySky(stars) - Row(modifier = Modifier.fillMaxSize(), verticalAlignment = Alignment.Bottom, horizontalArrangement = Arrangement.Center) { + Row( + modifier = Modifier.fillMaxSize(), + verticalAlignment = Alignment.Bottom, + horizontalArrangement = Arrangement.Center + ) { Text( fontSize = 10.em, text = "202", @@ -287,10 +335,10 @@ fun NYContent() { color = Color.White ) - val alpha = if (flickering2) flickeringAlpha(time) else 1.0f + val alpha = if (flickering2) flickeringAlpha(timeElapsedNanos) else 1.0f Text( fontSize = 10.em, - text = "3", + text = "4", modifier = Modifier.alpha(alpha).offset(0.dp, -15.dp), color = Color.White ) @@ -300,14 +348,15 @@ fun NYContent() { //HNY var i = 0 val angle = (HNYString.length / 2 * 5) * -1.0f - val color = colorHNY(time, startTime) + val color = colorHNY(timeElapsedNanos) HNYString.forEach { - val alpha = alphaHNY(i, time, startTime) + val alpha = alphaHNY(i, timeElapsedNanos) Text( fontSize = 14.sp, - text= it.toString(), + text = it.toString(), color = color, - modifier = Modifier.scale(5f).align(Alignment.Center).offset(0.dp, 85.dp) + 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++ @@ -326,9 +375,9 @@ fun NYContent() { } } -fun colorHNY(time: Long, startTime: Long): Color { +fun colorHNY(timeElapsed: Long): Color { val periodLength = 60 - val offset = ((time - startTime) / 80000000).toFloat() / periodLength + val offset = (timeElapsed.toFloat() / 80000000) / periodLength val color1 = Color.Red val color2 = Color.Yellow val color3 = Color.Magenta @@ -348,16 +397,16 @@ fun blend(color1: Color, color2: Color, fraction: Float): Color { ) } -fun alphaHNY(i: Int, time: Long, startTime: Long): Float { - val period = period(time, startTime, 200) - i +fun alphaHNY(i: Int, timeElapsed: Long): Float { + val period = period(timeElapsed, 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 { +fun period(timeElapsed: Long, periodLength: Int, speed: Int = 1): Int { val period = 200000000 / speed - return (((time - startTime) / period) % periodLength).toInt() + return ((timeElapsed / period) % periodLength).toInt() } fun flickeringAlpha(time: Long): Float { @@ -384,17 +433,15 @@ fun star(x: Dp, y: Dp, color: Color = Color.White, size: Dp) { } @Composable -fun snow(time: Long, prevTime: Long, snowFlakes: SnapshotStateList, startTime: Long) { - val deltaAngle = (time - startTime) / 100000000 +fun snow(timeElapsed: Long, snowFlakes: SnapshotStateList) { + val deltaAngle = timeElapsed.toFloat() / 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) + val x = it.x + (15 * sin(timeElapsed.toDouble() / 3000000000 + it.phase)).dp + snowFlake( + Modifier.offset(x, it.y).scale(it.scale).rotate(it.angle + deltaAngle * it.rotate), + it.alpha + ) } } } @@ -416,7 +463,8 @@ fun snowFlake(modifier: Modifier, alpha: Float = 0.8f) { 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) + 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) diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/PointerEvent.common.kt similarity index 77% rename from examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/PointerEvent.common.kt index 88fb8f80258..696cd60117d 100644 --- a/examples/visual-effects/shared/src/commonMain/kotlin/platform/PointerEventKind.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/PointerEvent.common.kt @@ -1,4 +1,4 @@ -package org.jetbrains.compose.demo.visuals.platform +package visualeffects import androidx.compose.foundation.gestures.awaitFirstDown import androidx.compose.foundation.gestures.forEachGesture @@ -6,6 +6,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.input.pointer.PointerEvent import androidx.compose.ui.input.pointer.pointerInput + enum class PointerEventKind { Move, In, @@ -14,7 +15,10 @@ enum class PointerEventKind { class Position(val x: Int, val y: Int) -expect fun Modifier.onPointerEvent(eventKind: PointerEventKind, onEvent: Position.() -> Unit): Modifier +expect fun Modifier.onPointerEvent( + eventKind: PointerEventKind, + onEvent: Position.() -> Unit +): Modifier fun Modifier.onPointerEventMobileImpl( eventKind: PointerEventKind, @@ -37,7 +41,10 @@ fun Modifier.onPointerEventMobileImpl( val event: PointerEvent = awaitPointerEvent() if (eventKind == PointerEventKind.Move) { - Position(event.changes.first().position.x.toInt(), event.changes.first().position.y.toInt()).onEvent() + Position( + event.changes.first().position.x.toInt(), + event.changes.first().position.y.toInt() + ).onEvent() } } while (event.changes.any { it.pressed }) @@ -49,4 +56,3 @@ fun Modifier.onPointerEventMobileImpl( } } } - diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt similarity index 88% rename from examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt index 34070537f4a..16f04f3b3e3 100644 --- a/examples/visual-effects/shared/src/commonMain/kotlin/RotatingWords.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt @@ -1,11 +1,11 @@ -package org.jetbrains.compose.demo.visuals +package visualeffects import androidx.compose.animation.core.* 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.Text +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember @@ -62,19 +62,27 @@ fun Words() { val color3 = Color(0xFD, 0xB6, 0x0D) val color4 = Color(0xFC, 0xF8, 0x4A) - Column(modifier = Modifier - .fillMaxSize() - .padding(16.dp) + 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) + Word( + position = baseText, + angle = 0f, + scale = 6f, + text = " Compose\nMultiplatform", + color = Color(52, 67, 235), + alpha = 0.4f + ) val size = 80.dp * scale - Image(logoImg, contentDescription = "Logo", + Image( + logoImg, contentDescription = "Logo", modifier = Modifier .offset(baseLogo.x - size / 2, baseLogo.y - size / 2) .size(size) @@ -84,8 +92,10 @@ fun Words() { } @Composable -fun Word(position: DpOffset, angle: Float, scale: Float, text: String, - color: Color, alpha: Float = 0.8f) { +fun Word( + position: DpOffset, angle: Float, scale: Float, text: String, + color: Color, alpha: Float = 0.8f +) { Text( modifier = Modifier .offset(position.x, position.y) diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/WaveEffect.kt similarity index 83% rename from examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt rename to examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/WaveEffect.kt index 71a41bb2d87..a3ca49a4956 100644 --- a/examples/visual-effects/shared/src/commonMain/kotlin/WaveEffect.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/WaveEffect.kt @@ -1,9 +1,9 @@ -package org.jetbrains.compose.demo.visuals +package visualeffects import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.* +import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -11,9 +11,6 @@ import androidx.compose.ui.draw.* import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.visuals.platform.PointerEventKind -import org.jetbrains.compose.demo.visuals.platform.nanoTime -import org.jetbrains.compose.demo.visuals.platform.onPointerEvent import kotlin.math.* @OptIn(ExperimentalComposeUiApi::class) @@ -25,23 +22,31 @@ fun WaveEffectGrid() { var centerY by remember { mutableStateOf(900) } var vX by remember { mutableStateOf(0) } var vY by remember { mutableStateOf(0) } + var timeElapsedNanos by remember { mutableStateOf(0L) } + + LaunchedEffect(Unit) { + while (true) { + var previousTimeNanos = withFrameNanos { it } + withFrameNanos { + val deltaTimeNanos = it - previousTimeNanos + timeElapsedNanos += deltaTimeNanos + previousTimeNanos = it + + if (State.entered) { + centerX = (centerX + vX * deltaTimeNanos / 1000000000).toInt() + if (centerX < -100) centerX = -100 + if (centerX > 2600) centerX = 2600 + vX = + (vX * (1 - deltaTimeNanos.toDouble() / 500000000) + 10 * (mouseX - centerX) * deltaTimeNanos / 1000000000).toInt() + centerY = (centerY + vY * deltaTimeNanos / 1000000000).toInt() + if (centerY < -100) centerY = -100 + if (centerY > 1800) centerY = 1800 + vY = + (vY * (1 - deltaTimeNanos.toDouble() / 500000000) + 5 * (mouseY - centerY) * deltaTimeNanos / 1000000000).toInt() - var time by remember { mutableStateOf(nanoTime()) } - var prevTime by remember { mutableStateOf(nanoTime()) } - - if (State.entered) { - 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( @@ -71,8 +76,8 @@ fun WaveEffectGrid() { 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) + val color = boxColor(x, y, timeElapsedNanos, pointerOffsetX, pointerOffsety) + Dot(size, Modifier.offset(x.dp, y.dp), color, timeElapsedNanos) x += shift * 2 } y += shift @@ -81,14 +86,6 @@ fun WaveEffectGrid() { HighPanel(pointerOffsetX, pointerOffsety) } - LaunchedEffect(Unit) { - while (true) { - withFrameNanos { - time = it - } - } - } - } } diff --git a/examples/minesweeper/shared/src/commonMain/resources/assets/clock.png b/examples/graphics-2d/shared/src/commonMain/resources/assets/clock.png similarity index 100% rename from examples/minesweeper/shared/src/commonMain/resources/assets/clock.png rename to examples/graphics-2d/shared/src/commonMain/resources/assets/clock.png diff --git a/examples/minesweeper/shared/src/commonMain/resources/assets/flag.png b/examples/graphics-2d/shared/src/commonMain/resources/assets/flag.png similarity index 100% rename from examples/minesweeper/shared/src/commonMain/resources/assets/flag.png rename to examples/graphics-2d/shared/src/commonMain/resources/assets/flag.png diff --git a/examples/minesweeper/shared/src/commonMain/resources/assets/mine.png b/examples/graphics-2d/shared/src/commonMain/resources/assets/mine.png similarity index 100% rename from examples/minesweeper/shared/src/commonMain/resources/assets/mine.png rename to examples/graphics-2d/shared/src/commonMain/resources/assets/mine.png diff --git a/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml b/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml new file mode 100644 index 00000000000..d7bf7955f44 --- /dev/null +++ b/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml @@ -0,0 +1,36 @@ + + + + + + + + diff --git a/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt b/examples/graphics-2d/shared/src/commonTest/kotlin/minesweeper/GameControllerTest.kt similarity index 99% rename from examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt rename to examples/graphics-2d/shared/src/commonTest/kotlin/minesweeper/GameControllerTest.kt index e18ac5a1f94..887b30fbb42 100644 --- a/examples/minesweeper/shared/src/commonTest/kotlin/GameControllerTest.kt +++ b/examples/graphics-2d/shared/src/commonTest/kotlin/minesweeper/GameControllerTest.kt @@ -1,3 +1,5 @@ +package minesweeper + import kotlin.test.* class GameControllerTest { diff --git a/examples/graphics-2d/shared/src/desktopMain/kotlin/minesweeper/MineSweeper.desktop.kt b/examples/graphics-2d/shared/src/desktopMain/kotlin/minesweeper/MineSweeper.desktop.kt new file mode 100644 index 00000000000..303963a3f06 --- /dev/null +++ b/examples/graphics-2d/shared/src/desktopMain/kotlin/minesweeper/MineSweeper.desktop.kt @@ -0,0 +1,3 @@ +package minesweeper + +actual fun hasRightClick() = true diff --git a/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt b/examples/graphics-2d/shared/src/desktopMain/kotlin/visualeffects/PointerEvent.desktop.kt similarity index 93% rename from examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt rename to examples/graphics-2d/shared/src/desktopMain/kotlin/visualeffects/PointerEvent.desktop.kt index cc933fc2bb0..c33d60853ce 100644 --- a/examples/visual-effects/shared/src/desktopMain/kotlin/platform/PointerEventKind.desktop.kt +++ b/examples/graphics-2d/shared/src/desktopMain/kotlin/visualeffects/PointerEvent.desktop.kt @@ -1,4 +1,4 @@ -package org.jetbrains.compose.demo.visuals.platform +package visualeffects import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -20,4 +20,4 @@ actual fun Modifier.onPointerEvent( return this.onPointerEvent(eventType) { Position(it.changes.first().position.x.toInt(), it.changes.first().position.y.toInt()).onEvent() } -} \ No newline at end of file +} diff --git a/examples/graphics-2d/shared/src/iosMain/kotlin/main.ios.kt b/examples/graphics-2d/shared/src/iosMain/kotlin/main.ios.kt new file mode 100644 index 00000000000..c075a8db126 --- /dev/null +++ b/examples/graphics-2d/shared/src/iosMain/kotlin/main.ios.kt @@ -0,0 +1,6 @@ +import androidx.compose.ui.window.ComposeUIViewController +import platform.UIKit.UIViewController + +fun MainViewController(): UIViewController = ComposeUIViewController { + Graphics2D() +} diff --git a/examples/graphics-2d/shared/src/iosMain/kotlin/minesweeper/MineSweeper.ios.kt b/examples/graphics-2d/shared/src/iosMain/kotlin/minesweeper/MineSweeper.ios.kt new file mode 100644 index 00000000000..181a5833e6a --- /dev/null +++ b/examples/graphics-2d/shared/src/iosMain/kotlin/minesweeper/MineSweeper.ios.kt @@ -0,0 +1,3 @@ +package minesweeper + +actual fun hasRightClick() = false diff --git a/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt b/examples/graphics-2d/shared/src/iosMain/kotlin/visualeffects/PointerEvent.ios.kt similarity index 79% rename from examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt rename to examples/graphics-2d/shared/src/iosMain/kotlin/visualeffects/PointerEvent.ios.kt index 3dd3fe22d9c..b9e71feb0d2 100644 --- a/examples/visual-effects/shared/src/iosMain/kotlin/platform/PointerEventKind.ios.kt +++ b/examples/graphics-2d/shared/src/iosMain/kotlin/visualeffects/PointerEvent.ios.kt @@ -1,4 +1,4 @@ -package org.jetbrains.compose.demo.visuals.platform +package visualeffects import androidx.compose.ui.Modifier diff --git a/examples/graphics-2d/shared/src/jsMain/kotlin/main.js.kt b/examples/graphics-2d/shared/src/jsMain/kotlin/main.js.kt new file mode 100644 index 00000000000..ec2120b6db4 --- /dev/null +++ b/examples/graphics-2d/shared/src/jsMain/kotlin/main.js.kt @@ -0,0 +1,6 @@ +import androidx.compose.runtime.Composable + +@Composable +fun MainView() { + Graphics2D() +} diff --git a/examples/graphics-2d/shared/src/jsMain/kotlin/minesweeper/MineSweeepr.js.kt b/examples/graphics-2d/shared/src/jsMain/kotlin/minesweeper/MineSweeepr.js.kt new file mode 100644 index 00000000000..181a5833e6a --- /dev/null +++ b/examples/graphics-2d/shared/src/jsMain/kotlin/minesweeper/MineSweeepr.js.kt @@ -0,0 +1,3 @@ +package minesweeper + +actual fun hasRightClick() = false diff --git a/examples/graphics-2d/shared/src/jsMain/kotlin/visualeffects/PointerEvent.js.kt b/examples/graphics-2d/shared/src/jsMain/kotlin/visualeffects/PointerEvent.js.kt new file mode 100644 index 00000000000..83f87cbc246 --- /dev/null +++ b/examples/graphics-2d/shared/src/jsMain/kotlin/visualeffects/PointerEvent.js.kt @@ -0,0 +1,26 @@ +package visualeffects + +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.Modifier +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.onPointerEvent + +@OptIn(ExperimentalComposeUiApi::class) +actual fun Modifier.onPointerEvent( + eventKind: PointerEventKind, + onEvent: Position.() -> Unit +): Modifier { + + val eventType: PointerEventType = when (eventKind) { + PointerEventKind.Move -> PointerEventType.Move + PointerEventKind.In -> PointerEventType.Enter + PointerEventKind.Out -> PointerEventType.Exit + } + + return this.onPointerEvent(eventType) { + Position( + it.changes.first().position.x.toInt(), + it.changes.first().position.y.toInt() + ).onEvent() + } +} diff --git a/examples/graphics-2d/shared/src/macosMain/kotlin/main.macos.kt b/examples/graphics-2d/shared/src/macosMain/kotlin/main.macos.kt new file mode 100644 index 00000000000..d4504403472 --- /dev/null +++ b/examples/graphics-2d/shared/src/macosMain/kotlin/main.macos.kt @@ -0,0 +1,11 @@ +import androidx.compose.ui.window.Window +import platform.AppKit.NSApp +import platform.AppKit.NSApplication + +fun main() { + NSApplication.sharedApplication() + Window("Graphics2D") { + Graphics2D() + } + NSApp?.run() +} diff --git a/examples/graphics-2d/shared/src/macosMain/kotlin/minesweeper/MineSweeper.macos.kt b/examples/graphics-2d/shared/src/macosMain/kotlin/minesweeper/MineSweeper.macos.kt new file mode 100644 index 00000000000..181a5833e6a --- /dev/null +++ b/examples/graphics-2d/shared/src/macosMain/kotlin/minesweeper/MineSweeper.macos.kt @@ -0,0 +1,3 @@ +package minesweeper + +actual fun hasRightClick() = false diff --git a/examples/graphics-2d/shared/src/macosMain/kotlin/visualeffects/PointerEventKind.macos.kt b/examples/graphics-2d/shared/src/macosMain/kotlin/visualeffects/PointerEventKind.macos.kt new file mode 100644 index 00000000000..7ceb8d6bfe3 --- /dev/null +++ b/examples/graphics-2d/shared/src/macosMain/kotlin/visualeffects/PointerEventKind.macos.kt @@ -0,0 +1,27 @@ +package visualeffects + +import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.Modifier +import androidx.compose.ui.input.pointer.PointerEventType +import androidx.compose.ui.input.pointer.onPointerEvent + + +@OptIn(ExperimentalComposeUiApi::class) +actual fun Modifier.onPointerEvent( + eventKind: PointerEventKind, + onEvent: Position.() -> Unit +): Modifier { + + val eventType: PointerEventType = when (eventKind) { + PointerEventKind.Move -> PointerEventType.Move + PointerEventKind.In -> PointerEventType.Enter + PointerEventKind.Out -> PointerEventType.Exit + } + + return this.onPointerEvent(eventType) { + Position( + it.changes.first().position.x.toInt(), + it.changes.first().position.y.toInt() + ).onEvent() + } +} diff --git a/examples/html/compose-bird/gradle.properties b/examples/html/compose-bird/gradle.properties index fc448992710..eac7330d499 100644 --- a/examples/html/compose-bird/gradle.properties +++ b/examples/html/compose-bird/gradle.properties @@ -1,3 +1,3 @@ kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/html/compose-in-js/gradle.properties b/examples/html/compose-in-js/gradle.properties index f03863f3662..9a4930525c0 100644 --- a/examples/html/compose-in-js/gradle.properties +++ b/examples/html/compose-in-js/gradle.properties @@ -3,4 +3,4 @@ kotlin.mpp.enableGranularSourceSetsMetadata=true kotlin.native.enableDependencyPropagation=false kotlin.js.webpack.major.version=4 kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/html/landing/gradle.properties b/examples/html/landing/gradle.properties index fc448992710..eac7330d499 100644 --- a/examples/html/landing/gradle.properties +++ b/examples/html/landing/gradle.properties @@ -1,3 +1,3 @@ kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/html/with-react/gradle.properties b/examples/html/with-react/gradle.properties index fc448992710..eac7330d499 100644 --- a/examples/html/with-react/gradle.properties +++ b/examples/html/with-react/gradle.properties @@ -1,3 +1,3 @@ kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/imageviewer/gradle.properties b/examples/imageviewer/gradle.properties index 6087fc3f966..d679c62ede6 100644 --- a/examples/imageviewer/gradle.properties +++ b/examples/imageviewer/gradle.properties @@ -11,4 +11,4 @@ kotlin.native.useEmbeddableCompilerJar=true kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/intellij-plugin/gradle.properties b/examples/intellij-plugin/gradle.properties index fc448992710..eac7330d499 100644 --- a/examples/intellij-plugin/gradle.properties +++ b/examples/intellij-plugin/gradle.properties @@ -1,3 +1,3 @@ kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/intellij-plugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt b/examples/intellij-plugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt index 581c8cbe914..dbe8091af07 100755 --- a/examples/intellij-plugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt +++ b/examples/intellij-plugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt @@ -8,9 +8,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.Surface import androidx.compose.ui.Modifier import androidx.compose.ui.awt.ComposePanel -import androidx.compose.ui.layout.Layout -import androidx.compose.ui.layout.MeasurePolicy -import androidx.compose.ui.layout.onGloballyPositioned import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.Project @@ -21,9 +18,7 @@ import com.jetbrains.compose.widgets.LazyScrollable import com.jetbrains.compose.widgets.Loaders import com.jetbrains.compose.widgets.TextInputs import com.jetbrains.compose.widgets.Toggles -import java.awt.Dimension import javax.swing.JComponent -import javax.swing.SwingUtilities /** diff --git a/examples/interop/ios-compose-in-swiftui/gradle.properties b/examples/interop/ios-compose-in-swiftui/gradle.properties index d90ce5fa886..6a393189e2a 100644 --- a/examples/interop/ios-compose-in-swiftui/gradle.properties +++ b/examples/interop/ios-compose-in-swiftui/gradle.properties @@ -3,4 +3,4 @@ xcodeproj=./iosApp org.gradle.jvmargs=-Xmx3g org.jetbrains.compose.experimental.uikit.enabled=true kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/interop/ios-compose-in-uikit/gradle.properties b/examples/interop/ios-compose-in-uikit/gradle.properties index 0846aada9a3..65e21ac13ef 100644 --- a/examples/interop/ios-compose-in-uikit/gradle.properties +++ b/examples/interop/ios-compose-in-uikit/gradle.properties @@ -5,4 +5,4 @@ org.jetbrains.compose.experimental.uikit.enabled=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/interop/ios-swiftui-in-compose/gradle.properties b/examples/interop/ios-swiftui-in-compose/gradle.properties index 0846aada9a3..65e21ac13ef 100644 --- a/examples/interop/ios-swiftui-in-compose/gradle.properties +++ b/examples/interop/ios-swiftui-in-compose/gradle.properties @@ -5,4 +5,4 @@ org.jetbrains.compose.experimental.uikit.enabled=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/interop/ios-uikit-in-compose/gradle.properties b/examples/interop/ios-uikit-in-compose/gradle.properties index 0846aada9a3..65e21ac13ef 100644 --- a/examples/interop/ios-uikit-in-compose/gradle.properties +++ b/examples/interop/ios-uikit-in-compose/gradle.properties @@ -5,4 +5,4 @@ org.jetbrains.compose.experimental.uikit.enabled=true # Enable kotlin/native experimental memory model kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/issues/gradle.properties b/examples/issues/gradle.properties index ab64d77fbe0..a416a41fc20 100644 --- a/examples/issues/gradle.properties +++ b/examples/issues/gradle.properties @@ -21,4 +21,4 @@ android.useAndroidX=true android.enableJetifier=true kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/minesweeper/.gitignore b/examples/minesweeper/.gitignore deleted file mode 100644 index fedf972a672..00000000000 --- a/examples/minesweeper/.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 diff --git a/examples/minesweeper/.run/desktopApp.run.xml b/examples/minesweeper/.run/desktopApp.run.xml deleted file mode 100644 index 7af7e15f4b9..00000000000 --- a/examples/minesweeper/.run/desktopApp.run.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - true - true - false - - - \ No newline at end of file diff --git a/examples/minesweeper/README.md b/examples/minesweeper/README.md deleted file mode 100644 index 68d98e4f57d..00000000000 --- a/examples/minesweeper/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Minesweeper - -A simple game powered by Compose Multiplatform. - -Game can run on Android, iOS, desktop or in a browser. - -## Setting up your development environment - -To setup the environment, please consult these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment). - -## How to run - -Choose a run configuration for an appropriate target in Android Studio and run it. - -![run-configurations.png](run-configurations.png) - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - -## Run native on MacOS -`./gradlew runDebugExecutableMacosX64` (Works on Intel processors) - -## Credits - \ No newline at end of file diff --git a/examples/minesweeper/androidApp/build.gradle.kts b/examples/minesweeper/androidApp/build.gradle.kts deleted file mode 100644 index dfd8f1bf236..00000000000 --- a/examples/minesweeper/androidApp/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -plugins { - kotlin("multiplatform") - id("com.android.application") - id("org.jetbrains.compose") -} - -kotlin { - androidTarget() - sourceSets { - val androidMain by getting { - dependencies { - implementation(project(":shared")) - } - } - } -} - -android { - compileSdk = 34 - namespace = "org.jetbrains.minesweeper" - defaultConfig { - applicationId = "org.jetbrains.ComposeMinesweeper" - minSdk = 26 - targetSdk = 34 - versionCode = 1 - versionName = "1.0" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } -} diff --git a/examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml b/examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 137e2497460..00000000000 --- a/examples/minesweeper/androidApp/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt b/examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt deleted file mode 100644 index 4970ea42edd..00000000000 --- a/examples/minesweeper/androidApp/src/androidMain/kotlin/MainActivity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.minesweeper - -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity -import MainView - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - MainView() - } - } -} diff --git a/examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml b/examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml deleted file mode 100644 index 413fe24a13d..00000000000 --- a/examples/minesweeper/androidApp/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Minesweeper - \ No newline at end of file diff --git a/examples/minesweeper/build.gradle.kts b/examples/minesweeper/build.gradle.kts deleted file mode 100644 index 0c00883af5a..00000000000 --- a/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/examples/minesweeper/desktopApp/build.gradle.kts b/examples/minesweeper/desktopApp/build.gradle.kts deleted file mode 100644 index 730a5109ad6..00000000000 --- a/examples/minesweeper/desktopApp/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - jvm {} - sourceSets { - val jvmMain by getting { - dependencies { - implementation(compose.desktop.currentOs) - implementation(project(":shared")) - } - } - } -} - -compose.desktop { - application { - mainClass = "MainKt" - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "Minesweeper" - packageVersion = "1.0.0" - - windows { - menuGroup = "Compose Examples" - // see https://wixtoolset.org/documentation/manual/v3/howtos/general/generate_guids.html - upgradeUuid = "2bf169f9-d851-49f0-b3a1-308966d473ca" - } - } - } -} diff --git a/examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt b/examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt deleted file mode 100644 index 732c30af6ab..00000000000 --- a/examples/minesweeper/desktopApp/src/jvmMain/kotlin/Main.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.window.* - -fun main() = application { - val windowState = rememberWindowState() - - Window( - onCloseRequest = ::exitApplication, - resizable = false, - title = "Minesweeper", - icon = painterResource("assets/mine.png"), - state = windowState - ) { - MainView(windowState) - } -} \ No newline at end of file diff --git a/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar b/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f09..00000000000 Binary files a/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/minesweeper/gradle/wrapper/gradle-wrapper.properties b/examples/minesweeper/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 84a0b92f9af..00000000000 --- a/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-8.2.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/minesweeper/gradlew b/examples/minesweeper/gradlew deleted file mode 100755 index a69d9cb6c20..00000000000 --- a/examples/minesweeper/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/examples/minesweeper/gradlew.bat b/examples/minesweeper/gradlew.bat deleted file mode 100644 index f127cfd49d4..00000000000 --- a/examples/minesweeper/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/examples/minesweeper/iosApp/Configuration/Config.xcconfig b/examples/minesweeper/iosApp/Configuration/Config.xcconfig deleted file mode 100644 index f752d0e2f8d..00000000000 --- a/examples/minesweeper/iosApp/Configuration/Config.xcconfig +++ /dev/null @@ -1,3 +0,0 @@ -TEAM_ID= -BUNDLE_ID=org.jetbrains.Minesweeper -APP_NAME=Minesweeper diff --git a/examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj deleted file mode 100644 index 39a69e8216d..00000000000 --- a/examples/minesweeper/iosApp/iosApp.xcodeproj/project.pbxproj +++ /dev/null @@ -1,382 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; - 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; - 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; - 7555FF7B242A565900829871 /* Minesweeper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Minesweeper.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - F85CB1118929364A9C6EFABC /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 058557D7273AAEEB004C7B11 /* Preview Content */ = { - isa = PBXGroup; - children = ( - 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; - }; - 7555FF72242A565900829871 = { - isa = PBXGroup; - children = ( - AB1DB47929225F7C00F7AF9C /* Configuration */, - 7555FF7D242A565900829871 /* iosApp */, - 7555FF7C242A565900829871 /* Products */, - ); - sourceTree = ""; - }; - 7555FF7C242A565900829871 /* Products */ = { - isa = PBXGroup; - children = ( - 7555FF7B242A565900829871 /* Minesweeper.app */, - ); - name = Products; - sourceTree = ""; - }; - 7555FF7D242A565900829871 /* iosApp */ = { - isa = PBXGroup; - children = ( - 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, - 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iOSApp.swift */, - 058557D7273AAEEB004C7B11 /* Preview Content */, - ); - path = iosApp; - sourceTree = ""; - }; - AB1DB47929225F7C00F7AF9C /* Configuration */ = { - isa = PBXGroup; - children = ( - AB3632DC29227652001CCB65 /* Config.xcconfig */, - ); - path = Configuration; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 7555FF7A242A565900829871 /* iosApp */ = { - isa = PBXNativeTarget; - buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; - buildPhases = ( - 0548D1B82A8FD49F002E7F63 /* Compile Kotlin */, - 7555FF77242A565900829871 /* Sources */, - 7555FF79242A565900829871 /* Resources */, - F85CB1118929364A9C6EFABC /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = iosApp; - productName = iosApp; - productReference = 7555FF7B242A565900829871 /* Minesweeper.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 7555FF73242A565900829871 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1130; - LastUpgradeCheck = 1130; - ORGANIZATIONNAME = orgName; - TargetAttributes = { - 7555FF7A242A565900829871 = { - CreatedOnToolsVersion = 11.3.1; - }; - }; - }; - buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 7555FF72242A565900829871; - productRefGroup = 7555FF7C242A565900829871 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 7555FF7A242A565900829871 /* iosApp */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 7555FF79242A565900829871 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, - 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 0548D1B82A8FD49F002E7F63 /* Compile Kotlin */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Compile Kotlin"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 7555FF77242A565900829871 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 7555FFA3242A565B00829871 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 7555FFA4242A565B00829871 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 7555FFA6242A565B00829871 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - DEVELOPMENT_TEAM = "${TEAM_ID}"; - ENABLE_PREVIEWS = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n"; - INFOPLIST_FILE = iosApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - "shared\n", - ); - PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; - PRODUCT_NAME = "${APP_NAME}"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 7555FFA7242A565B00829871 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - DEVELOPMENT_TEAM = "${TEAM_ID}"; - ENABLE_PREVIEWS = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n"; - INFOPLIST_FILE = iosApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - "shared\n", - ); - PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; - PRODUCT_NAME = "${APP_NAME}"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7555FFA3242A565B00829871 /* Debug */, - 7555FFA4242A565B00829871 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7555FFA6242A565B00829871 /* Debug */, - 7555FFA7242A565B00829871 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 7555FF73242A565900829871 /* Project object */; -} diff --git a/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index ee7e3ca03f8..00000000000 --- a/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index fb88a396bf3..00000000000 --- a/examples/minesweeper/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "60x60" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "60x60" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "20x20" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "83.5x83.5" - }, - { - "idiom" : "ios-marketing", - "scale" : "1x", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json deleted file mode 100644 index 4aa7c5350bf..00000000000 --- a/examples/minesweeper/iosApp/iosApp/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/minesweeper/iosApp/iosApp/ContentView.swift b/examples/minesweeper/iosApp/iosApp/ContentView.swift deleted file mode 100644 index f7f6457b31a..00000000000 --- a/examples/minesweeper/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -import UIKit -import SwiftUI -import shared - -struct ComposeView: UIViewControllerRepresentable { - func makeUIViewController(context: Context) -> UIViewController { - Main_iosKt.MainViewController() - } - - func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} -} - -struct ContentView: View { - var body: some View { - ComposeView() - .ignoresSafeArea(.keyboard) // Compose has own keyboard handler - } -} - - - diff --git a/examples/minesweeper/iosApp/iosApp/Info.plist b/examples/minesweeper/iosApp/iosApp/Info.plist deleted file mode 100644 index 9a269f5eaac..00000000000 --- a/examples/minesweeper/iosApp/iosApp/Info.plist +++ /dev/null @@ -1,48 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UIApplicationSceneManifest - - UIApplicationSupportsMultipleScenes - - - UILaunchScreen - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json b/examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json deleted file mode 100644 index 4aa7c5350bf..00000000000 --- a/examples/minesweeper/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/minesweeper/iosApp/iosApp/iOSApp.swift b/examples/minesweeper/iosApp/iosApp/iOSApp.swift deleted file mode 100644 index 0648e8602f2..00000000000 --- a/examples/minesweeper/iosApp/iosApp/iOSApp.swift +++ /dev/null @@ -1,10 +0,0 @@ -import SwiftUI - -@main -struct iOSApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} \ No newline at end of file diff --git a/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt b/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt deleted file mode 100644 index b36b64e9ad0..00000000000 --- a/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt +++ /dev/null @@ -1,16 +0,0 @@ - /* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.ui.window.Window -import org.jetbrains.skiko.wasm.onWasmReady - - -fun main() { - onWasmReady { - Window("Minesweeper") { - MainView() - } - } -} diff --git a/examples/minesweeper/jsApp/src/jsMain/resources/index.html b/examples/minesweeper/jsApp/src/jsMain/resources/index.html deleted file mode 100644 index 9dd212786b6..00000000000 --- a/examples/minesweeper/jsApp/src/jsMain/resources/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Title - - - -

compose multiplatform web demo

-
- -
- - - - \ No newline at end of file diff --git a/examples/minesweeper/run-configurations.png b/examples/minesweeper/run-configurations.png deleted file mode 100644 index d859ff0870f..00000000000 Binary files a/examples/minesweeper/run-configurations.png and /dev/null differ diff --git a/examples/minesweeper/shared/src/androidMain/AndroidManifest.xml b/examples/minesweeper/shared/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 568741e54f2..00000000000 --- a/examples/minesweeper/shared/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt b/examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt deleted file mode 100644 index 460fdeb8f27..00000000000 --- a/examples/minesweeper/shared/src/androidMain/kotlin/main.android.kt +++ /dev/null @@ -1,5 +0,0 @@ -import androidx.compose.runtime.Composable - -@Composable fun MainView() = Game() - -actual fun hasRightClick() = false diff --git a/examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt deleted file mode 100644 index ed7f8f9d4b9..00000000000 --- a/examples/minesweeper/shared/src/desktopMain/kotlin/main.desktop.kt +++ /dev/null @@ -1,15 +0,0 @@ -import androidx.compose.material.MaterialTheme -import androidx.compose.runtime.Composable -import androidx.compose.ui.window.WindowState - -@Composable -fun MainView(windowState: WindowState) = - MaterialTheme { - Game( - requestWindowSize = { w, h -> - windowState.size = windowState.size.copy(width = w, height = h) - } - ) - } - -actual fun hasRightClick() = true diff --git a/examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt b/examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt deleted file mode 100644 index ef0837a8c94..00000000000 --- a/examples/minesweeper/shared/src/iosMain/kotlin/main.ios.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.ui.window.ComposeUIViewController -import platform.UIKit.UIViewController - -fun MainViewController() : UIViewController = ComposeUIViewController { Game() } - -actual fun hasRightClick() = false \ No newline at end of file diff --git a/examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt b/examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt deleted file mode 100644 index 5e079586366..00000000000 --- a/examples/minesweeper/shared/src/jsMain/kotlin/main.js.kt +++ /dev/null @@ -1,6 +0,0 @@ -import androidx.compose.runtime.Composable - -@Composable -fun MainView() = Game() - -actual fun hasRightClick() = false diff --git a/examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt b/examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt deleted file mode 100644 index 88b034d366c..00000000000 --- a/examples/minesweeper/shared/src/macosMain/kotlin/main.macos.kt +++ /dev/null @@ -1,32 +0,0 @@ -import androidx.compose.foundation.* -import androidx.compose.foundation.layout.* -import androidx.compose.material.* -import androidx.compose.runtime.* -import androidx.compose.ui.* -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.drawscope.DrawScope -import androidx.compose.ui.graphics.painter.Painter -import androidx.compose.ui.input.pointer.* -import androidx.compose.ui.text.style.* -import androidx.compose.ui.text.font.* -import androidx.compose.ui.unit.* -import androidx.compose.ui.window.Window -import platform.AppKit.NSApplication -import platform.AppKit.NSApp - -fun main() { - NSApplication.sharedApplication() - Window("Minesweeper") { - MaterialTheme { - Game( - requestWindowSize = { _, _ -> - // TODO(not implemented yet - } - ) - } - } - NSApp?.run() -} - -actual fun hasRightClick() = false \ No newline at end of file diff --git a/examples/notepad/gradle.properties b/examples/notepad/gradle.properties index 1e2d69b4edc..f38317683d2 100644 --- a/examples/notepad/gradle.properties +++ b/examples/notepad/gradle.properties @@ -1,4 +1,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 kotlin.code.style=official kotlin.version=1.9.10 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/todoapp-lite/gradle.properties b/examples/todoapp-lite/gradle.properties index 3171ccd3f64..c2f765215a8 100755 --- a/examples/todoapp-lite/gradle.properties +++ b/examples/todoapp-lite/gradle.properties @@ -11,4 +11,4 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/examples/validateExamples.sh b/examples/validateExamples.sh index 6925f607d02..085bd4e5f0b 100755 --- a/examples/validateExamples.sh +++ b/examples/validateExamples.sh @@ -25,6 +25,5 @@ runGradle imageviewer packageDistributionForCurrentOS runGradle issues packageDistributionForCurrentOS runGradle notepad packageDistributionForCurrentOS runGradle todoapp-lite packageDistributionForCurrentOS -runGradle minesweeper packageDistributionForCurrentOS -runGradle visual-effects packageDistributionForCurrentOS +runGradle graphics-2d packageDistributionForCurrentOS runGradle widgets-gallery packageDistributionForCurrentOS diff --git a/examples/validateExamplesAndroid.sh b/examples/validateExamplesAndroid.sh index 24d077f496f..c7a581a6574 100644 --- a/examples/validateExamplesAndroid.sh +++ b/examples/validateExamplesAndroid.sh @@ -24,7 +24,7 @@ runGradle chat installDebug runGradle codeviewer installDebug runGradle imageviewer installDebug runGradle issues installDebug -runGradle minesweeper installDebug +runGradle graphics-2d installDebug runGradle todoapp-lite installDebug runGradle widgets-gallery installDebug runGradle todoapp installDebug diff --git a/examples/validateExamplesIos.sh b/examples/validateExamplesIos.sh index 6da14bb2106..3efc7b4a63b 100755 --- a/examples/validateExamplesIos.sh +++ b/examples/validateExamplesIos.sh @@ -33,9 +33,7 @@ runGradle() { runGradle chat runGradle codeviewer -runGradle falling-balls runGradle imageviewer runGradle todoapp-lite -runGradle visual-effects runGradle widgets-gallery -runGradle minesweeper +runGradle graphics-2d diff --git a/examples/visual-effects/.gitignore b/examples/visual-effects/.gitignore deleted file mode 100644 index 180e0343839..00000000000 --- a/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/examples/visual-effects/.run/desktopApp.run.xml b/examples/visual-effects/.run/desktopApp.run.xml deleted file mode 100644 index 0de52186703..00000000000 --- a/examples/visual-effects/.run/desktopApp.run.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - true - true - false - - - \ No newline at end of file diff --git a/examples/visual-effects/README.md b/examples/visual-effects/README.md deleted file mode 100644 index 3074e926f52..00000000000 --- a/examples/visual-effects/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# Visual Effects - -Several visual effects implemented with Compose Multiplatform, used in 1.0 release announce video. - -Supported targets: Android, Desktop and iOS. - -## Setting up your development environment - -To setup the environment, please consult these [instructions](https://github.com/JetBrains/compose-multiplatform-template#setting-up-your-development-environment). - -## How to run - -Choose a run configuration for an appropriate target in Android Studio and run it. - -![run-configurations.png](run-configurations.png) - -## Run on desktop via Gradle - -`./gradlew desktopApp:run` - diff --git a/examples/visual-effects/androidApp/build.gradle.kts b/examples/visual-effects/androidApp/build.gradle.kts deleted file mode 100644 index a0575f7eb2e..00000000000 --- a/examples/visual-effects/androidApp/build.gradle.kts +++ /dev/null @@ -1,35 +0,0 @@ -plugins { - kotlin("multiplatform") - id("com.android.application") - id("org.jetbrains.compose") -} - -kotlin { - androidTarget() - sourceSets { - val androidMain by getting { - dependencies { - implementation(project(":shared")) - } - } - } -} - -android { - compileSdk = 34 - namespace = "org.jetbrains.compose.demo.visuals" - defaultConfig { - applicationId = "org.jetbrains.VisualEffects" - minSdk = 26 - targetSdk = 34 - versionCode = 1 - versionName = "1.0" - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } -} diff --git a/examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml b/examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml deleted file mode 100644 index ad0432f6f63..00000000000 --- a/examples/visual-effects/androidApp/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt b/examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt deleted file mode 100644 index 045ce66fb52..00000000000 --- a/examples/visual-effects/androidApp/src/androidMain/kotlin/MainActivity.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import MainView -import android.os.Bundle -import androidx.activity.compose.setContent -import androidx.appcompat.app.AppCompatActivity - -class MainActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - MainView() - } - } -} \ No newline at end of file diff --git a/examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml b/examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml deleted file mode 100644 index d23a35eb385..00000000000 --- a/examples/visual-effects/androidApp/src/androidMain/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Visual Effects - \ No newline at end of file diff --git a/examples/visual-effects/build.gradle.kts b/examples/visual-effects/build.gradle.kts deleted file mode 100644 index 8d0c1f3d7c3..00000000000 --- a/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/examples/visual-effects/desktopApp/build.gradle.kts b/examples/visual-effects/desktopApp/build.gradle.kts deleted file mode 100644 index 1cebd3ec6a5..00000000000 --- a/examples/visual-effects/desktopApp/build.gradle.kts +++ /dev/null @@ -1,55 +0,0 @@ -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - kotlin("multiplatform") - id("org.jetbrains.compose") -} - -kotlin { - jvm {} - sourceSets { - val jvmMain by getting { - dependencies { - implementation(compose.desktop.currentOs) - implementation(project(":shared")) - } - } - } -} - -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" - } - } -} - -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/examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt b/examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt deleted file mode 100644 index 621ebdf7280..00000000000 --- a/examples/visual-effects/desktopApp/src/jvmMain/kotlin/main.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -fun main(args: Array) { - if (args.isEmpty()) return allSamples() - 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/visual-effects/gradle.properties b/examples/visual-effects/gradle.properties deleted file mode 100644 index 40e32276bdb..00000000000 --- a/examples/visual-effects/gradle.properties +++ /dev/null @@ -1,14 +0,0 @@ -kotlin.code.style=official -xcodeproj=./iosApp -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.useEmbeddableCompilerJar=true -# Enable kotlin/native experimental memory model -kotlin.native.binary.memoryModel=experimental -kotlin.version=1.9.10 -agp.version=8.0.2 -compose.version=1.5.1 diff --git a/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar b/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f09..00000000000 Binary files a/examples/visual-effects/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/examples/visual-effects/gradle/wrapper/gradle-wrapper.properties b/examples/visual-effects/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 84a0b92f9af..00000000000 --- a/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-8.2.1-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/examples/visual-effects/gradlew b/examples/visual-effects/gradlew deleted file mode 100755 index a69d9cb6c20..00000000000 --- a/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/examples/visual-effects/gradlew.bat b/examples/visual-effects/gradlew.bat deleted file mode 100644 index f127cfd49d4..00000000000 --- a/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/examples/visual-effects/iosApp/Configuration/Config.xcconfig b/examples/visual-effects/iosApp/Configuration/Config.xcconfig deleted file mode 100644 index bad995c745a..00000000000 --- a/examples/visual-effects/iosApp/Configuration/Config.xcconfig +++ /dev/null @@ -1,3 +0,0 @@ -TEAM_ID= -BUNDLE_ID=org.jetbrains.VisualEffects -APP_NAME=VisualEffects diff --git a/examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj b/examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj deleted file mode 100644 index d2282704e82..00000000000 --- a/examples/visual-effects/iosApp/iosApp.xcodeproj/project.pbxproj +++ /dev/null @@ -1,382 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 50; - objects = { - -/* Begin PBXBuildFile section */ - 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557BA273AAA24004C7B11 /* Assets.xcassets */; }; - 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */; }; - 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; }; - 7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 058557BA273AAA24004C7B11 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - 2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = ""; }; - 7555FF7B242A565900829871 /* VisualEffects.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VisualEffects.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - 7555FF8C242A565B00829871 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - AB3632DC29227652001CCB65 /* Config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - F85CB1118929364A9C6EFABC /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 058557D7273AAEEB004C7B11 /* Preview Content */ = { - isa = PBXGroup; - children = ( - 058557D8273AAEEB004C7B11 /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; - }; - 7555FF72242A565900829871 = { - isa = PBXGroup; - children = ( - AB1DB47929225F7C00F7AF9C /* Configuration */, - 7555FF7D242A565900829871 /* iosApp */, - 7555FF7C242A565900829871 /* Products */, - ); - sourceTree = ""; - }; - 7555FF7C242A565900829871 /* Products */ = { - isa = PBXGroup; - children = ( - 7555FF7B242A565900829871 /* VisualEffects.app */, - ); - name = Products; - sourceTree = ""; - }; - 7555FF7D242A565900829871 /* iosApp */ = { - isa = PBXGroup; - children = ( - 058557BA273AAA24004C7B11 /* Assets.xcassets */, - 7555FF82242A565900829871 /* ContentView.swift */, - 7555FF8C242A565B00829871 /* Info.plist */, - 2152FB032600AC8F00CF470E /* iOSApp.swift */, - 058557D7273AAEEB004C7B11 /* Preview Content */, - ); - path = iosApp; - sourceTree = ""; - }; - AB1DB47929225F7C00F7AF9C /* Configuration */ = { - isa = PBXGroup; - children = ( - AB3632DC29227652001CCB65 /* Config.xcconfig */, - ); - path = Configuration; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 7555FF7A242A565900829871 /* iosApp */ = { - isa = PBXNativeTarget; - buildConfigurationList = 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */; - buildPhases = ( - 0548D1BA2A8FD715002E7F63 /* Compile Kotlin */, - 7555FF77242A565900829871 /* Sources */, - 7555FF79242A565900829871 /* Resources */, - F85CB1118929364A9C6EFABC /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = iosApp; - productName = iosApp; - productReference = 7555FF7B242A565900829871 /* VisualEffects.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 7555FF73242A565900829871 /* Project object */ = { - isa = PBXProject; - attributes = { - LastSwiftUpdateCheck = 1130; - LastUpgradeCheck = 1130; - ORGANIZATIONNAME = orgName; - TargetAttributes = { - 7555FF7A242A565900829871 = { - CreatedOnToolsVersion = 11.3.1; - }; - }; - }; - buildConfigurationList = 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */; - compatibilityVersion = "Xcode 9.3"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 7555FF72242A565900829871; - productRefGroup = 7555FF7C242A565900829871 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 7555FF7A242A565900829871 /* iosApp */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 7555FF79242A565900829871 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 058557D9273AAEEB004C7B11 /* Preview Assets.xcassets in Resources */, - 058557BB273AAA24004C7B11 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 0548D1BA2A8FD715002E7F63 /* Compile Kotlin */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Compile Kotlin"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "cd \"$SRCROOT/..\"\n./gradlew :shared:embedAndSignAppleFrameworkForXcode\n"; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 7555FF77242A565900829871 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */, - 7555FF83242A565900829871 /* ContentView.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 7555FFA3242A565B00829871 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 7555FFA4242A565B00829871 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = AB3632DC29227652001CCB65 /* Config.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 7555FFA6242A565B00829871 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - DEVELOPMENT_TEAM = "${TEAM_ID}"; - ENABLE_PREVIEWS = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n"; - INFOPLIST_FILE = iosApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - "shared\n", - ); - PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; - PRODUCT_NAME = "${APP_NAME}"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 7555FFA7242A565B00829871 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_ASSET_PATHS = "\"iosApp/Preview Content\""; - DEVELOPMENT_TEAM = "${TEAM_ID}"; - ENABLE_PREVIEWS = YES; - FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)\n"; - INFOPLIST_FILE = iosApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - OTHER_LDFLAGS = ( - "$(inherited)", - "-framework", - "shared\n", - ); - PRODUCT_BUNDLE_IDENTIFIER = "${BUNDLE_ID}${TEAM_ID}"; - PRODUCT_NAME = "${APP_NAME}"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 7555FF76242A565900829871 /* Build configuration list for PBXProject "iosApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7555FFA3242A565B00829871 /* Debug */, - 7555FFA4242A565B00829871 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 7555FFA5242A565B00829871 /* Build configuration list for PBXNativeTarget "iosApp" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7555FFA6242A565B00829871 /* Debug */, - 7555FFA7242A565B00829871 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 7555FF73242A565900829871 /* Project object */; -} diff --git a/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json b/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json deleted file mode 100644 index ee7e3ca03f8..00000000000 --- a/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AccentColor.colorset/Contents.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "colors" : [ - { - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index fb88a396bf3..00000000000 --- a/examples/visual-effects/iosApp/iosApp/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "20x20" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "29x29" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "40x40" - }, - { - "idiom" : "iphone", - "scale" : "2x", - "size" : "60x60" - }, - { - "idiom" : "iphone", - "scale" : "3x", - "size" : "60x60" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "20x20" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "20x20" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "29x29" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "40x40" - }, - { - "idiom" : "ipad", - "scale" : "1x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "76x76" - }, - { - "idiom" : "ipad", - "scale" : "2x", - "size" : "83.5x83.5" - }, - { - "idiom" : "ios-marketing", - "scale" : "1x", - "size" : "1024x1024" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json b/examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json deleted file mode 100644 index 4aa7c5350bf..00000000000 --- a/examples/visual-effects/iosApp/iosApp/Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/visual-effects/iosApp/iosApp/ContentView.swift b/examples/visual-effects/iosApp/iosApp/ContentView.swift deleted file mode 100644 index f7f6457b31a..00000000000 --- a/examples/visual-effects/iosApp/iosApp/ContentView.swift +++ /dev/null @@ -1,21 +0,0 @@ -import UIKit -import SwiftUI -import shared - -struct ComposeView: UIViewControllerRepresentable { - func makeUIViewController(context: Context) -> UIViewController { - Main_iosKt.MainViewController() - } - - func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} -} - -struct ContentView: View { - var body: some View { - ComposeView() - .ignoresSafeArea(.keyboard) // Compose has own keyboard handler - } -} - - - diff --git a/examples/visual-effects/iosApp/iosApp/Info.plist b/examples/visual-effects/iosApp/iosApp/Info.plist deleted file mode 100644 index 9a269f5eaac..00000000000 --- a/examples/visual-effects/iosApp/iosApp/Info.plist +++ /dev/null @@ -1,48 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UIApplicationSceneManifest - - UIApplicationSupportsMultipleScenes - - - UILaunchScreen - - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/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 deleted file mode 100644 index 4aa7c5350bf..00000000000 --- a/examples/visual-effects/iosApp/iosApp/Preview Content/Preview Assets.xcassets/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} \ No newline at end of file diff --git a/examples/visual-effects/iosApp/iosApp/iOSApp.swift b/examples/visual-effects/iosApp/iosApp/iOSApp.swift deleted file mode 100644 index 0648e8602f2..00000000000 --- a/examples/visual-effects/iosApp/iosApp/iOSApp.swift +++ /dev/null @@ -1,10 +0,0 @@ -import SwiftUI - -@main -struct iOSApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -} \ No newline at end of file diff --git a/examples/visual-effects/run-configurations.png b/examples/visual-effects/run-configurations.png deleted file mode 100644 index d859ff0870f..00000000000 Binary files a/examples/visual-effects/run-configurations.png and /dev/null differ diff --git a/examples/visual-effects/settings.gradle.kts b/examples/visual-effects/settings.gradle.kts deleted file mode 100644 index 1b7a2ddc8b2..00000000000 --- a/examples/visual-effects/settings.gradle.kts +++ /dev/null @@ -1,31 +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) - } -} - -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version("0.4.0") -} - -rootProject.name = "visual-effects" - -include(":androidApp") -include(":shared") -include(":desktopApp") diff --git a/examples/visual-effects/shared/build.gradle.kts b/examples/visual-effects/shared/build.gradle.kts deleted file mode 100644 index aa74c786165..00000000000 --- a/examples/visual-effects/shared/build.gradle.kts +++ /dev/null @@ -1,80 +0,0 @@ -plugins { - kotlin("multiplatform") - id("com.android.library") - id("org.jetbrains.compose") -} - -version = "1.0-SNAPSHOT" - -kotlin { - androidTarget() - - jvm("desktop") - - listOf( - iosX64(), - iosArm64(), - iosSimulatorArm64() - ).forEach { iosTarget -> - iosTarget.binaries.framework { - baseName = "shared" - isStatic = true - } - } - - sourceSets { - val commonMain by getting { - dependencies { - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material) - implementation(compose.materialIconsExtended) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) - } - } - val androidMain by getting { - dependencies { - api("androidx.activity:activity-compose:1.7.2") - api("androidx.appcompat:appcompat:1.6.1") - api("androidx.core:core-ktx:1.10.1") - } - } - val iosMain by creating { - dependsOn(commonMain) - } - val iosX64Main by getting { - dependsOn(iosMain) - } - val iosArm64Main by getting { - dependsOn(iosMain) - } - val iosSimulatorArm64Main by getting { - dependsOn(iosMain) - } - val desktopMain by getting { - dependencies { - implementation(compose.desktop.common) - } - } - } -} - -android { - compileSdk = 34 - namespace = "org.jetbrains.visualeffects" - sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") - sourceSets["main"].res.srcDirs("src/androidMain/res") - sourceSets["main"].resources.srcDirs("src/commonMain/resources") - - defaultConfig { - minSdk = 26 - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } -} diff --git a/examples/visual-effects/shared/src/androidMain/AndroidManifest.xml b/examples/visual-effects/shared/src/androidMain/AndroidManifest.xml deleted file mode 100644 index de749acb75f..00000000000 --- a/examples/visual-effects/shared/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt b/examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt deleted file mode 100644 index 137c31e24a1..00000000000 --- a/examples/visual-effects/shared/src/androidMain/kotlin/main.android.kt +++ /dev/null @@ -1,5 +0,0 @@ -import androidx.compose.runtime.Composable -import org.jetbrains.compose.demo.visuals.AllSamplesView - -@Composable -fun MainView() = AllSamplesView() \ No newline at end of file diff --git a/examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt deleted file mode 100644 index ebfd7e4ac62..00000000000 --- a/examples/visual-effects/shared/src/androidMain/kotlin/platform/NanoTime.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.jetbrains.compose.demo.visuals.platform - -actual fun nanoTime(): Long = System.nanoTime() \ No newline at end of file diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt b/examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt deleted file mode 100644 index f9748e02e30..00000000000 --- a/examples/visual-effects/shared/src/commonMain/kotlin/AllSamlesView.kt +++ /dev/null @@ -1,90 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import androidx.compose.foundation.layout.* -import androidx.compose.material.* -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ArrowBack -import androidx.compose.runtime.Composable -import androidx.compose.runtime.MutableState -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp - -@Composable -fun SampleWithTopAppBar(sample: Screen, state: MutableState, content: @Composable (PaddingValues) -> Unit) { - Box(modifier = Modifier.fillMaxSize()) { - Scaffold( - topBar = { - TopAppBar( - title = { Text(text = sample.screen) }, - navigationIcon = - { - IconButton(onClick = {state.value = Screen.CHOOSE_SAMPLE}) { - Icon( - imageVector = Icons.Filled.ArrowBack, - contentDescription = "Back" - ) - } - } - ) - }, - content = content - ) - } -} - -enum class Screen(val screen: String) { - CHOOSE_SAMPLE("Choose a demo:"), - WORDS("Rotating Words"), - WAVE("Wave Effect"), - NY("Happy New Year!"); -} - -@Composable -fun MyButton(screenState: MutableState, to: Screen) { - Button(onClick = { - screenState.value = to - }) { - Text(fontSize = 20.sp, text = to.screen) - } -} - -@Composable -fun AllSamplesView() { - MaterialTheme { - val screenState: MutableState = remember { mutableStateOf(Screen.CHOOSE_SAMPLE) } - when (screenState.value) { - Screen.CHOOSE_SAMPLE -> { - Column(modifier = Modifier.fillMaxSize(), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally) - { - Text(modifier = Modifier.padding(10.dp), fontSize = 30.sp, text = Screen.CHOOSE_SAMPLE.screen) - MyButton(screenState, Screen.WORDS) - MyButton(screenState, Screen.WAVE) - MyButton(screenState, Screen.NY) - } - } - - Screen.WORDS -> { - SampleWithTopAppBar(Screen.WORDS, screenState) { - RotatingWords() - } - } - Screen.WAVE -> { - SampleWithTopAppBar(Screen.WAVE, screenState) { - WaveEffectGrid() - } - } - - Screen.NY -> { - SampleWithTopAppBar(Screen.NY, screenState) { - NYContent() - } - } - } - } -} diff --git a/examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt deleted file mode 100644 index 0fc90a38cae..00000000000 --- a/examples/visual-effects/shared/src/commonMain/kotlin/platform/NanoTime.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.jetbrains.compose.demo.visuals.platform - -expect fun nanoTime(): Long \ No newline at end of file diff --git a/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png b/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png deleted file mode 100644 index a73ddd79899..00000000000 Binary files a/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.png and /dev/null differ diff --git a/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg b/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg deleted file mode 100644 index 3e5ce57f729..00000000000 --- a/examples/visual-effects/shared/src/commonMain/resources/compose-community-primary.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt deleted file mode 100644 index fcb552987e4..00000000000 --- a/examples/visual-effects/shared/src/desktopMain/kotlin/WaveSettings.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.demo.visuals - -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.width -import androidx.compose.material.Checkbox -import androidx.compose.material.Slider -import androidx.compose.material.Text -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.unit.dp - -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) -} - -internal class SettingsState { - companion object { - var red by mutableStateOf(ColorSettings()) - var green by mutableStateOf(ColorSettings()) - var blue by mutableStateOf(ColorSettings()) - } -} - -@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/shared/src/desktopMain/kotlin/main.desktop.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/main.desktop.kt deleted file mode 100644 index 8861ae7ddb3..00000000000 --- a/examples/visual-effects/shared/src/desktopMain/kotlin/main.desktop.kt +++ /dev/null @@ -1,59 +0,0 @@ -package org.jetbrains.compose.demo.visuals - -import androidx.compose.foundation.layout.Column -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.* - -fun mainWords() = singleWindowApplication( - title = "Compose Demo", state = WindowState(size = DpSize(830.dp, 830.dp)) -) { - RotatingWords() -} - -@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) { - WaveEffectGrid() - } - - if (showControls) { - Window( - onCloseRequest = onCloseRequest, - state = WindowState(width = 200.dp, height = 400.dp, position = WindowPosition(1400.dp, 200.dp)) - ) { - Column { - SettingsPanel(SettingsState.red, "Red") - SettingsPanel(SettingsState.green, "Green") - SettingsPanel(SettingsState.blue, "Blue") - } - } - } -} - -fun mainWave(controls: Boolean) = application { - WaveEffect(::exitApplication, controls) -} - -@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 mainNY() = application { - NYWindow(::exitApplication) -} - - -fun allSamples() = application { - val windowState = remember { WindowState(width = 1200.dp, height = 900.dp) } - Window(onCloseRequest = ::exitApplication, title = "Visual effects", undecorated = false, transparent = false, state = windowState) { - AllSamplesView() - } -} diff --git a/examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt deleted file mode 100644 index ebfd7e4ac62..00000000000 --- a/examples/visual-effects/shared/src/desktopMain/kotlin/platform/NanoTime.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.jetbrains.compose.demo.visuals.platform - -actual fun nanoTime(): Long = System.nanoTime() \ No newline at end of file diff --git a/examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt b/examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt deleted file mode 100644 index c8004b488b0..00000000000 --- a/examples/visual-effects/shared/src/iosMain/kotlin/main.ios.kt +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -import androidx.compose.ui.window.ComposeUIViewController -import org.jetbrains.compose.demo.visuals.AllSamplesView -import platform.UIKit.UIViewController - -fun MainViewController() : UIViewController = ComposeUIViewController { AllSamplesView() } diff --git a/examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt b/examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt deleted file mode 100644 index 334c22b7817..00000000000 --- a/examples/visual-effects/shared/src/iosMain/kotlin/platform/NanoTime.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.jetbrains.compose.demo.visuals.platform - -actual fun nanoTime(): Long = kotlin.system.getTimeNanos() \ No newline at end of file diff --git a/examples/widgets-gallery/gradle.properties b/examples/widgets-gallery/gradle.properties index 3171ccd3f64..c2f765215a8 100644 --- a/examples/widgets-gallery/gradle.properties +++ b/examples/widgets-gallery/gradle.properties @@ -11,4 +11,4 @@ kotlin.mpp.androidSourceSetLayoutVersion=2 kotlin.native.binary.memoryModel=experimental kotlin.version=1.9.10 agp.version=8.0.2 -compose.version=1.5.1 +compose.version=1.5.2 diff --git a/gradle-plugins/build.gradle.kts b/gradle-plugins/build.gradle.kts index 54b2ded2454..b04154cc333 100644 --- a/gradle-plugins/build.gradle.kts +++ b/gradle-plugins/build.gradle.kts @@ -3,7 +3,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { alias(libs.plugins.kotlin.jvm) apply false - alias(libs.plugins.kotlin.serialization) apply false alias(libs.plugins.publish.plugin.portal) apply false alias(libs.plugins.shadow.jar) apply false alias(libs.plugins.download) apply false diff --git a/gradle-plugins/compose/build.gradle.kts b/gradle-plugins/compose/build.gradle.kts index 7c32c4fef5c..9cdadd0dace 100644 --- a/gradle-plugins/compose/build.gradle.kts +++ b/gradle-plugins/compose/build.gradle.kts @@ -3,7 +3,6 @@ import de.undercouch.gradle.tasks.download.Download plugins { alias(libs.plugins.kotlin.jvm) - alias(libs.plugins.kotlin.serialization) alias(libs.plugins.publish.plugin.portal) id("java-gradle-plugin") id("maven-publish") @@ -64,14 +63,11 @@ dependencies { testImplementation(kotlin("gradle-plugin-api")) embedded(libs.download.task) - embedded(libs.serialization.json) - embedded(libs.serialization.core) - embedded(libs.serialization.core.jvm) embedded(project(":preview-rpc")) embedded(project(":jdk-version-probe")) } -val packagesToRelocate = listOf("de.undercouch", "kotlinx.serialization") +val packagesToRelocate = listOf("de.undercouch") val shadow = tasks.named("shadowJar") { for (packageToRelocate in packagesToRelocate) { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt index 9ef6c357d9b..73b694b91a3 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt @@ -17,7 +17,8 @@ internal object ComposeCompilerCompatibility { "1.9.0" to "1.5.1", "1.9.10" to "1.5.2", "1.9.20-Beta" to "1.5.2.1-Beta2", - "1.9.20-Beta2" to "1.5.2.1-Beta3" + "1.9.20-Beta2" to "1.5.2.1-Beta3", + "1.9.20-RC" to "1.5.2.1-rc01", ) fun compilerVersionFor(kotlinVersion: String): String { diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalExtension.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalExtension.kt index a4b17ec9703..8c4a809c3e2 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalExtension.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalExtension.kt @@ -16,9 +16,4 @@ abstract class ExperimentalExtension @Inject constructor( fun web(action: Action) { action.execute(web) } - - val uikit: ExperimentalUiKitExtension = objects.newInstance(ExperimentalUiKitExtension::class.java) - fun uikit(action: Action) { - action.execute(uikit) - } } \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalUiKitApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalUiKitApplication.kt deleted file mode 100644 index 5f392d94878..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalUiKitApplication.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.dsl - -import org.gradle.api.Action -import org.gradle.api.model.ObjectFactory -import org.jetbrains.compose.internal.requiredDslProperty -import javax.inject.Inject - -@Suppress("unused") -abstract class ExperimentalUiKitApplication @Inject constructor( - val name: String, - val objects: ObjectFactory -) { - var bundleIdPrefix: String by requiredDslProperty("require property [bundleIdPrefix] in uikit.application { ...") - var projectName: String by requiredDslProperty("require property [projectName] in uikit.application { ...") - val configurations: List = listOf( - UiKitConfiguration("Debug"), - UiKitConfiguration("Release"), - ) - - val deployConfigurations: IosDeployConfigurations = objects.newInstance(IosDeployConfigurations::class.java) - fun deployConfigurations(fn: Action) { - fn.execute(deployConfigurations) - } -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalUiKitExtension.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalUiKitExtension.kt deleted file mode 100644 index a90d57c722c..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/ExperimentalUiKitExtension.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.dsl - -import org.gradle.api.Action -import org.gradle.api.model.ObjectFactory -import javax.inject.Inject - -abstract class ExperimentalUiKitExtension @Inject constructor( - objectFactory: ObjectFactory -) { - internal var _isApplicationInitialized = false - private set - - val application: ExperimentalUiKitApplication by lazy { - _isApplicationInitialized = true - objectFactory.newInstance(ExperimentalUiKitApplication::class.java, "main") - } - - fun application(fn: Action) { - fn.execute(application) - } -} - diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/IOSDevices.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/IOSDevices.kt deleted file mode 100644 index 15c01b5cb6a..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/IOSDevices.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.dsl - -/** - * iOS device type - * xcrun simctl list devices - */ -@Suppress("unused") -public enum class IOSDevices(val id: String) { - IPHONE_6S("com.apple.CoreSimulator.SimDeviceType.iPhone-6s"), - IPHONE_6S_PLUS("com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus"), - IPHONE_SE("com.apple.CoreSimulator.SimDeviceType.iPhone-SE"), - IPHONE_7("com.apple.CoreSimulator.SimDeviceType.iPhone-7"), - IPHONE_7_PLUS("com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus"), - IPHONE_8("com.apple.CoreSimulator.SimDeviceType.iPhone-8"), - IPHONE_8_PLUS("com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus"), - IPHONE_X("com.apple.CoreSimulator.SimDeviceType.iPhone-X"), - IPHONE_XS("com.apple.CoreSimulator.SimDeviceType.iPhone-XS"), - IPHONE_XS_MAX("com.apple.CoreSimulator.SimDeviceType.iPhone-XS-Max"), - IPHONE_XR("com.apple.CoreSimulator.SimDeviceType.iPhone-XR"), - IPHONE_11("com.apple.CoreSimulator.SimDeviceType.iPhone-11"), - IPHONE_11_PRO("com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro"), - IPHONE_11_PRO_MAX("com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max"), - IPHONE_SE_2nd_Gen("com.apple.CoreSimulator.SimDeviceType.iPhone-SE--2nd-generation-"), - IPHONE_12_MINI("com.apple.CoreSimulator.SimDeviceType.iPhone-12-mini"), - IPHONE_12("com.apple.CoreSimulator.SimDeviceType.iPhone-12"), - IPHONE_12_PRO("com.apple.CoreSimulator.SimDeviceType.iPhone-12-Pro"), - IPHONE_12_PRO_MAX("com.apple.CoreSimulator.SimDeviceType.iPhone-12-Pro-Max"), - IPHONE_13_PRO("com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro"), - IPHONE_13_PRO_MAX("com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro-Max"), - IPHONE_13_MINI("com.apple.CoreSimulator.SimDeviceType.iPhone-13-mini"), - IPHONE_13("com.apple.CoreSimulator.SimDeviceType.iPhone-13"), - IPOD_TOUCH_7th_Gen("com.apple.CoreSimulator.SimDeviceType.iPod-touch--7th-generation-"), - IPAD_MINI_4("com.apple.CoreSimulator.SimDeviceType.iPad-mini-4"), - IPAD_AIR_2("com.apple.CoreSimulator.SimDeviceType.iPad-Air-2"), - IPAD_PRO_9_7_INCH("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-"), - IPAD_PRO("com.apple.CoreSimulator.SimDeviceType.iPad-Pro"), - IPAD_5th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-"), - IPAD_PRO_12_9_INCH_2nd_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-"), - IPAD_PRO_10_5_INCH("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-"), - IPAD_6th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-"), - IPAD_7th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad--7th-generation-"), - IPAD_PRO_11_INCH("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch-"), - IPAD_PRO_12_9_INCH_3rd_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---3rd-generation-"), - IPAD_PRO_11_INCH_2nd_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--11-inch---2nd-generation-"), - IPAD_PRO_12_9_INCH_4th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---4th-generation-"), - IPAD_MINI_5th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-mini--5th-generation-"), - IPAD_AIR_3th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Air--3rd-generation-"), - IPAD_8th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad--8th-generation-"), - IPAD_9th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-9th-generation"), - IPAD_AIR_4th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Air--4th-generation-"), - IPAD_PRO_11_INCH_3rd_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Pro-11-inch-3rd-generation"), - IPAD_12_9_INCH_5th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-Pro-12-9-inch-5th-generation"), - IPAD_MINI_6th_Gen("com.apple.CoreSimulator.SimDeviceType.iPad-mini-6th-generation"), -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/IosDeployConfigurations.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/IosDeployConfigurations.kt deleted file mode 100644 index f6d6eb598ec..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/IosDeployConfigurations.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.dsl - -import org.gradle.api.Action -import org.gradle.api.model.ObjectFactory -import java.io.File -import javax.inject.Inject - -open class IosDeployConfigurations @Inject constructor( - val objects: ObjectFactory -) { - internal val deployTargets: MutableList = mutableListOf() - public fun simulator(id: String, configureSimulator: Action) { - val currentSimulator = objects.newInstance(DeployTarget.Simulator::class.java) - configureSimulator.execute(currentSimulator) - deployTargets.add(DeployTargetWithId(id, currentSimulator)) - } - - public fun localFile(id: String, configureLocalFile: Action) { - val current = objects.newInstance(DeployTarget.LocalFile::class.java) - configureLocalFile.execute(current) - deployTargets.add(DeployTargetWithId(id, current)) - } - - public fun connectedDevice(id: String, configureConnectedDevice: Action) { - val current = objects.newInstance(DeployTarget.ConnectedDevice::class.java) - configureConnectedDevice.execute(current) - deployTargets.add(DeployTargetWithId(id, current)) - } - -} - -sealed interface DeployTarget { - open class Simulator : DeployTarget { - var device: IOSDevices = IOSDevices.IPHONE_8 - } - - open class LocalFile : DeployTarget { - var outputFile: File? = null - } - - open class ConnectedDevice : DeployTarget { - var teamId: String? = null - } -} - -internal class DeployTargetWithId( - val id: String, - val deploy: DeployTarget -) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/UiKitConfiguration.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/UiKitConfiguration.kt deleted file mode 100644 index 23be7642e6f..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/dsl/UiKitConfiguration.kt +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.dsl - -class UiKitConfiguration( - val name: String -) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/checkExperimentalTargets.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/checkExperimentalTargets.kt index 532d77ec130..a5bb901ee21 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/checkExperimentalTargets.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/checkExperimentalTargets.kt @@ -25,7 +25,6 @@ private class TargetType( private val TargetType.gradlePropertyName get() = "org.jetbrains.compose.experimental.$id.enabled" private val EXPERIMENTAL_TARGETS: Set = setOf( - TargetType("uikit", presets = listOf("iosSimulatorArm64", "iosArm64", "iosX64")), TargetType("macos", presets = listOf("macosX64", "macosArm64")), TargetType("jscanvas", presets = listOf("jsIr", "js")), ) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureExperimental.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureExperimental.kt index ae6b6e55677..f900441e38e 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureExperimental.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/internal/configureExperimental.kt @@ -8,7 +8,6 @@ package org.jetbrains.compose.experimental.internal import org.gradle.api.Project import org.jetbrains.compose.ComposeExtension import org.jetbrains.compose.experimental.dsl.ExperimentalExtension -import org.jetbrains.compose.experimental.uikit.internal.configureExperimentalUikitApplication import org.jetbrains.compose.experimental.web.internal.configureExperimentalWebApplication import org.jetbrains.compose.web.WebExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension @@ -17,12 +16,6 @@ internal fun Project.configureExperimental( composeExt: ComposeExtension, experimentalExt: ExperimentalExtension ) { - if (experimentalExt.uikit._isApplicationInitialized) { - val mppExt = project.extensions.findByType(KotlinMultiplatformExtension::class.java) - ?: error("'org.jetbrains.kotlin.multiplatform' plugin is required for using 'compose.experimental.uikit {}'") - configureExperimentalUikitApplication(mppExt, experimentalExt.uikit.application) - } - if (experimentalExt.web._isApplicationInitialized) { val webExt = composeExt.extensions.getByType(WebExtension::class.java) webExt.targetsToConfigure(project) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlListData.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlListData.kt deleted file mode 100644 index 90d68114352..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlListData.kt +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -@file:Suppress("unused") - -package org.jetbrains.compose.experimental.uikit.internal - -import kotlinx.serialization.Serializable - -@Serializable -internal class SimctlListData( - val devicetypes: List = emptyList(), - val runtimes: List, - val devices: Map>, - val pairs: Map = emptyMap(), -) - -@Serializable -internal class DeviceTypeData( - val name: String? = null, - val minRuntimeVersion: Long? = null, - val bundlePath: String? = null, - val maxRuntimeVersion: Long? = null, - val identifier: String? = null, - val productFamily: String? = null -) - -@Serializable -internal class RuntimeData( - val name: String? = null, - val bundlePath: String? = null, - val buildversion: String? = null, - val runtimeRoot: String? = null, - val identifier: String, - val version: String, - val isAvailable: Boolean? = null, - val supportedDeviceTypes: List -) - -@Serializable -internal class SupportedDeviceTypeData( - val bundlePath: String? = null, - val name: String? = null, - val identifier: String, - val productFamily: String? = null -) - -@Serializable -internal class DeviceData( - val name: String, - val availabilityError: String? = null, - val dataPath: String? = null, - val dataPathSize: Long? = null, - val logPath: String? = null, - val udid: String, - /** - * Simulator may be unavailable after update Xcode version. - * By default, we think what simulator is available. - */ - val isAvailable: Boolean = true, - val deviceTypeIdentifier: String? = null, - val state: String, -) - -internal val DeviceData.booted: Boolean - get() = state == "Booted" - -@Serializable -internal class WatchAndPhonePairData( - val watch: DeviceInPairData? = null, - val phone: DeviceInPairData? = null -) - -@Serializable -internal class DeviceInPairData( - val name: String? = null, - val udid: String? = null, - val state: String? = null, -) diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt deleted file mode 100644 index 0aade06f79a..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/SimctlUtils.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import kotlinx.serialization.json.Json -import org.jetbrains.compose.internal.utils.MacUtils -import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask - -val json = Json { - ignoreUnknownKeys = true -} - -internal fun AbstractComposeIosTask.getSimctlListData(): SimctlListData { - lateinit var simctlResult: SimctlListData - runExternalTool( - MacUtils.xcrun, listOf("simctl", "list", "--json"), - processStdout = { stdout -> - simctlResult = json.decodeFromString(SimctlListData.serializer(), stdout) - } - ) - return simctlResult -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt deleted file mode 100644 index 17e090cb41c..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureExperimentalUikitApplication.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.jetbrains.compose.internal.utils.OS -import org.jetbrains.compose.internal.utils.currentOS -import org.jetbrains.compose.experimental.dsl.ExperimentalUiKitApplication -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension - -internal fun Project.configureExperimentalUikitApplication( - mppExt: KotlinMultiplatformExtension, - application: ExperimentalUiKitApplication -) { - if (currentOS != OS.MacOS) return - - configureIosDeployTasks( - mppExt = mppExt, - application = application, - ) -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt deleted file mode 100644 index f76f31be31f..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallIosDeployTask.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.jetbrains.compose.internal.utils.MacUtils -import org.jetbrains.compose.internal.utils.UnixUtils -import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask - -internal val Project.iosDeployExecutable get() = iosDeploySrc.resolve("build/Release/ios-deploy") - -private const val IOS_DEPLOY_GIT = "https://github.com/ios-control/ios-deploy.git" -private const val IOS_DEPLOY_TAG = "1.11.4" -private val Project.iosDeploySrc get() = rootProject.buildDir.resolve("ios-deploy-$IOS_DEPLOY_TAG-src") - -internal fun Project.configureInstallIosDeployTask() = - tasks.composeIosTask("iosInstallIosDeploy") { - onlyIf { !iosDeployExecutable.exists() } - doLast { - iosDeploySrc.deleteRecursively() - runExternalTool( - UnixUtils.git, - listOf( - "clone", - "--depth", "1", - "--branch", IOS_DEPLOY_TAG, - IOS_DEPLOY_GIT, - iosDeploySrc.absolutePath - ) - ) - runExternalTool( - MacUtils.xcodeBuild, - listOf("-target", "ios-deploy"), - workingDir = iosDeploySrc - ) - } - } diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt deleted file mode 100644 index 4d9c666bfd2..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureInstallXcodeGenTask.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.jetbrains.compose.internal.utils.MacUtils -import org.jetbrains.compose.internal.utils.UnixUtils -import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask - -internal val Project.xcodeGenExecutable get() = xcodeGenSrc.resolve(".build/apple/Products/Release/xcodegen") - -private const val XCODE_GEN_GIT = "https://github.com/yonaskolb/XcodeGen.git" -private const val XCODE_GEN_TAG = "2.26.0" -private val Project.xcodeGenSrc get() = rootProject.buildDir.resolve("xcodegen-$XCODE_GEN_TAG-src") - -fun Project.configureInstallXcodeGenTask() = - tasks.composeIosTask("iosInstallXcodeGen") { - onlyIf { !xcodeGenExecutable.exists() } - doLast { - xcodeGenSrc.deleteRecursively() - runExternalTool( - UnixUtils.git, - listOf( - "clone", - "--depth", "1", - "--branch", XCODE_GEN_TAG, - XCODE_GEN_GIT, - xcodeGenSrc.absolutePath - ) - ) - runExternalTool( - MacUtils.make, - listOf("build"), - workingDir = xcodeGenSrc - ) - } - } diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureIosDeployTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureIosDeployTasks.kt deleted file mode 100644 index 2a2e3f006b4..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureIosDeployTasks.kt +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.experimental.dsl.DeployTarget -import org.jetbrains.compose.experimental.dsl.ExperimentalUiKitApplication -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension - -const val SDK_PREFIFX_SIMULATOR = "iphonesimulator" -const val SDK_PREFIX_IPHONEOS = "iphoneos" -const val TEAM_ID_PROPERTY_KEY = "compose.ios.teamId" -const val BUILD_DIR_NAME = "build" -const val RELATIVE_PRODUCTS_PATH = "$BUILD_DIR_NAME/Build/Products" - -fun Project.getBuildIosDir(id: String) = buildDir.resolve("ios").resolve(id) - -internal fun Project.configureIosDeployTasks( - mppExt: KotlinMultiplatformExtension, - application: ExperimentalUiKitApplication, -) { - val projectName = application.projectName - val bundleIdPrefix = application.bundleIdPrefix - - val taskInstallXcodeGen: TaskProvider<*> = configureInstallXcodeGenTask() - val taskInstallIosDeploy: TaskProvider<*> = configureInstallIosDeployTask() - - application.deployConfigurations.deployTargets.forEach { target -> - val id = target.id // .replaceFirstChar { it.uppercase() } - when (target.deploy) { - is DeployTarget.Simulator -> { - registerSimulatorTasks( - mppExt = mppExt, - id = id, - deploy = target.deploy, - projectName = projectName, - bundleIdPrefix = bundleIdPrefix, - taskInstallXcodeGen = taskInstallXcodeGen, - configurations = application.configurations, - ) - } - is DeployTarget.LocalFile -> { - TODO("DeployTarget.LocalFile not implemented") - } - is DeployTarget.ConnectedDevice -> { - registerConnectedDeviceTasks( - mppExt = mppExt, - id = id, - deploy = target.deploy, - projectName = projectName, - bundleIdPrefix = bundleIdPrefix, - taskInstallXcodeGen = taskInstallXcodeGen, - taskInstallIosDeploy = taskInstallIosDeploy, - configurations = application.configurations, - ) - } - } - } -} - -inline fun TaskContainer.composeIosTask( - name: String, - args: List = emptyList(), - noinline configureFn: T.() -> Unit = {} -) = register(name, T::class.java, *args.toTypedArray()).apply { - configure { - it.group = "Compose iOS" - it.configureFn() - } -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt deleted file mode 100644 index ced8d72e000..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configurePackComposeUiKitApplicationForXCodeTask.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.jetbrains.compose.experimental.uikit.tasks.ExperimentalPackComposeApplicationForXCodeTask -import org.jetbrains.compose.internal.utils.fileToDir -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import java.io.File - -internal fun Project.configurePackComposeUiKitApplicationForXCodeTask( - mppExt: KotlinMultiplatformExtension, - id: String, - configName: String, - projectName: String, - targetBuildPath: File, - targetType: ExperimentalPackComposeApplicationForXCodeTask.UikitTarget, -) = tasks.register( - "packComposeUikitApplicationForXCode$id$configName", - ExperimentalPackComposeApplicationForXCodeTask::class.java -) { packTask -> - val buildType = project.provider { configName }.map { - if (it.equals("release", ignoreCase = true)) NativeBuildType.RELEASE - else NativeBuildType.DEBUG - }.orElse(NativeBuildType.DEBUG) - val target = mppExt.targets.getByName(targetType.targetName) as KotlinNativeTarget - val kotlinBinary = target.binaries.getExecutable(buildType.get()) - val targetBuildDir = project.provider { targetBuildPath }.fileToDir(project) - val executablePath = "${projectName}.app/${projectName}" - - packTask.targetType.set(targetType) - packTask.buildType.set(buildType) - packTask.dependsOn(kotlinBinary.linkTask) - packTask.kotlinBinary.set(kotlinBinary.outputFile) - packTask.destinationDir.set(targetBuildDir) - packTask.executablePath.set(executablePath) -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureTaskToGenerateXcodeProject.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureTaskToGenerateXcodeProject.kt deleted file mode 100644 index f6cfe929ca6..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/configureTaskToGenerateXcodeProject.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask - -internal fun Project.configureTaskToGenerateXcodeProject( - id: String, - projectName: String, - bundleIdPrefix: String, - getTeamId: () -> String? = { null }, - taskInstallXcodeGen: TaskProvider<*>, -): TaskProvider = tasks.composeIosTask("iosGenerateXcodeProject$id") { - dependsOn(taskInstallXcodeGen) - doLast { - val commonMainResources = file("src/commonMain/resources").absolutePath - val uikitMainResources = file("src/uikitMain/resources").absolutePath - val iosMainResources = file("src/iosMain/resources").absolutePath - val buildIosDir = getBuildIosDir(id) - buildIosDir.mkdirs() - buildIosDir.resolve("project.yml").writeText( - """ - name: $projectName - options: - bundleIdPrefix: $bundleIdPrefix - settings: - ${if (getTeamId() != null) "DEVELOPMENT_TEAM: \"${getTeamId()}\"" else ""} - CODE_SIGN_IDENTITY: "iPhone Developer" - CODE_SIGN_STYLE: Automatic - MARKETING_VERSION: "1.0" - CURRENT_PROJECT_VERSION: "4" - SDKROOT: iphoneos - targets: - $projectName: - type: application - platform: iOS - deploymentTarget: "12.0" - info: - path: plists/Ios/Info.plist - properties: - UILaunchStoryboardName: $projectName - settings: - LIBRARY_SEARCH_PATHS: "$(inherited)" - ENABLE_BITCODE: "YES" - ONLY_ACTIVE_ARCH: "NO" - VALID_ARCHS: "arm64" - sources: - - path: $commonMainResources - optional: true - buildPhase: resources - - path: $uikitMainResources - optional: true - buildPhase: resources - - path: $iosMainResources - optional: true - buildPhase: resources - """.trimIndent() - ) - runExternalTool(xcodeGenExecutable, emptyList(), workingDir = buildIosDir) - } -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt deleted file mode 100644 index 1a55d7b6d31..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerConnectedDeviceTasks.kt +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.internal.utils.MacUtils -import org.jetbrains.compose.experimental.dsl.DeployTarget -import org.jetbrains.compose.experimental.dsl.UiKitConfiguration -import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask -import org.jetbrains.compose.experimental.uikit.tasks.ExperimentalPackComposeApplicationForXCodeTask -import org.jetbrains.compose.internal.utils.getLocalProperty -import org.jetbrains.compose.internal.utils.localPropertiesFile -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension - -fun Project.registerConnectedDeviceTasks( - mppExt: KotlinMultiplatformExtension, - id: String, - deploy: DeployTarget.ConnectedDevice, - projectName: String, - bundleIdPrefix: String, - taskInstallXcodeGen: TaskProvider<*>, - taskInstallIosDeploy: TaskProvider<*>, - configurations: List, -) { - val xcodeProjectDir = getBuildIosDir(id).resolve("$projectName.xcodeproj") - val taskGenerateXcodeProject = configureTaskToGenerateXcodeProject( - id = id, - projectName = projectName, - bundleIdPrefix = bundleIdPrefix, - getTeamId = { - deploy.teamId ?: getLocalProperty(TEAM_ID_PROPERTY_KEY) - ?: error( - buildString { - appendLine("In local.properties (${localPropertiesFile.absolutePath})") - appendLine("Add property") - appendLine("$TEAM_ID_PROPERTY_KEY=***") - appendLine("Or set teamId in deploy with id: $id") - } - ) - }, - taskInstallXcodeGen = taskInstallXcodeGen, - ) - - for (configuration in configurations) { - val configName = configuration.name - val targetBuildPath = xcodeProjectDir.resolve(RELATIVE_PRODUCTS_PATH) - .resolve("$configName-iphoneos") - val iosCompiledAppDir = targetBuildPath.resolve("${projectName}.app") - - val taskPackageUiKitAppForXcode = configurePackComposeUiKitApplicationForXCodeTask( - mppExt = mppExt, - id = id, - configName = configName, - projectName = projectName, - targetBuildPath = targetBuildPath, - targetType = ExperimentalPackComposeApplicationForXCodeTask.UikitTarget.Arm64, - ) - - val taskBuild = tasks.composeIosTask("iosBuildIphoneOs$id$configName") { - dependsOn(taskGenerateXcodeProject) - dependsOn(taskPackageUiKitAppForXcode) - doLast { - // xcrun xcodebuild -showsdks (list all sdk) - val sdk = SDK_PREFIX_IPHONEOS + getSimctlListData().runtimes.first().version - val scheme = projectName // xcrun xcodebuild -list -project . (list all schemes) - - runExternalTool( - MacUtils.xcrun, - listOf( - "xcodebuild", - "-scheme", scheme, - "-project", ".", - "-configuration", configName, - "-derivedDataPath", BUILD_DIR_NAME, - "-arch", "arm64", - "-sdk", sdk, - "-allowProvisioningUpdates", - "-allowProvisioningDeviceRegistration", - ), - workingDir = xcodeProjectDir - ) - } - } - - val taskDeploy = tasks.composeIosTask("iosDeploy$id$configName") { - dependsOn(taskInstallIosDeploy) - dependsOn(taskBuild) - doLast { - runExternalTool( - iosDeployExecutable, - listOf( - "--debug", - "--bundle", iosCompiledAppDir.absolutePath, - ) - ) - } - } - } - -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt deleted file mode 100644 index 4175d321748..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/internal/registerSimulatorTasks.kt +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.internal - -import org.gradle.api.Project -import org.gradle.api.tasks.TaskProvider -import org.jetbrains.compose.internal.utils.Arch -import org.jetbrains.compose.internal.utils.MacUtils -import org.jetbrains.compose.internal.utils.currentArch -import org.jetbrains.compose.experimental.dsl.DeployTarget -import org.jetbrains.compose.experimental.dsl.UiKitConfiguration -import org.jetbrains.compose.experimental.uikit.tasks.AbstractComposeIosTask -import org.jetbrains.compose.experimental.uikit.tasks.ExperimentalPackComposeApplicationForXCodeTask -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension - -fun Project.registerSimulatorTasks( - mppExt: KotlinMultiplatformExtension, - id: String, - deploy: DeployTarget.Simulator, - projectName: String, - bundleIdPrefix: String, - taskInstallXcodeGen: TaskProvider<*>, - configurations: List, -) { - val xcodeProjectDir = getBuildIosDir(id).resolve("$projectName.xcodeproj") - val deviceName = "device-$id" - - val taskGenerateXcodeProject = configureTaskToGenerateXcodeProject( - id = id, - projectName = projectName, - bundleIdPrefix = bundleIdPrefix, - taskInstallXcodeGen = taskInstallXcodeGen, - ) - - val taskSimulatorDeleteUnavailable = tasks.composeIosTask("iosSimulatorDeleteUnavailable$id") { - doLast { - val device = getSimctlListData().devices.map { it.value }.flatten() - .firstOrNull { device: DeviceData -> - device.name == deviceName && !device.isAvailable - } - if (device != null) { - runExternalTool( - MacUtils.xcrun, - listOf("simctl", "delete", device.udid) - ) - } - } - } - - val taskCreateSimulator = tasks.composeIosTask("iosSimulatorCreate$id") { - dependsOn(taskSimulatorDeleteUnavailable) - onlyIf { getSimctlListData().devices.map { it.value }.flatten().none { it.name == deviceName } } - doFirst { - val availableRuntimes = getSimctlListData().runtimes.filter { runtime -> - runtime.supportedDeviceTypes.any { it.identifier == deploy.device.id } - } - val runtime = availableRuntimes.firstOrNull() ?: error("device not found is runtimes") - runExternalTool( - MacUtils.xcrun, - listOf("simctl", "create", deviceName, deploy.device.id, runtime.identifier) - ) - } - } - - val taskBootSimulator = tasks.composeIosTask("iosSimulatorBoot$id") { - dependsOn(taskCreateSimulator) - onlyIf { - getSimctlListData().devices.map { it.value }.flatten().any { it.name == deviceName && it.booted.not() } - } - doLast { - val device = getSimctlListData().devices.map { it.value }.flatten().firstOrNull { it.name == deviceName } - ?: error("device '$deviceName' not found") - - runExternalTool( - MacUtils.xcrun, - listOf("simctl", "boot", device.udid) - ) - runExternalTool( - MacUtils.open, - listOf( - "-a", "Simulator", - "--args", "-CurrentDeviceUDID", device.udid - ) - ) - } - } - - val simulatorArch = when (currentArch) { - Arch.X64 -> "x86_64" - Arch.Arm64 -> "arm64" - } - - for (configuration in configurations) { - val configName = configuration.name - val targetBuildPath = xcodeProjectDir.resolve(RELATIVE_PRODUCTS_PATH) - .resolve("$configName-iphonesimulator") - val iosCompiledAppDir = targetBuildPath.resolve("${projectName}.app") - - val taskPackageUiKitAppForXcode = configurePackComposeUiKitApplicationForXCodeTask( - mppExt = mppExt, - id = id, - configName = configName, - projectName = projectName, - targetBuildPath = targetBuildPath, - targetType = ExperimentalPackComposeApplicationForXCodeTask.UikitTarget.X64, - ) - - val taskBuild = tasks.composeIosTask("iosSimulatorBuild$id$configName") { - dependsOn(taskGenerateXcodeProject) - dependsOn(taskPackageUiKitAppForXcode) - doLast { - // xcrun xcodebuild -showsdks (list all sdk) - val sdk = SDK_PREFIFX_SIMULATOR + getSimctlListData().runtimes.first().version - val scheme = projectName // xcrun xcodebuild -list -project . (list all schemes) - runExternalTool( - MacUtils.xcrun, - listOf( - "xcodebuild", - "-scheme", scheme, - "-project", ".", - "-configuration", configName, - "-derivedDataPath", BUILD_DIR_NAME, - "-arch", simulatorArch, - "-sdk", sdk - ), - workingDir = xcodeProjectDir - ) - } - } - - val installIosSimulator = tasks.composeIosTask("iosSimulatorInstall$id$configName") { - dependsOn(taskBuild, taskBootSimulator) - doLast { - val device = getSimctlListData().devices.map { it.value }.flatten() - .firstOrNull { it.name == deviceName && it.booted } ?: error("device $deviceName not booted") - runExternalTool( - MacUtils.xcrun, - listOf("simctl", "install", device.udid, iosCompiledAppDir.absolutePath) - ) - } - } - - tasks.composeIosTask("iosDeploy$id$configName") { - dependsOn(installIosSimulator) - doFirst { - val device = getSimctlListData().devices.map { it.value }.flatten() - .firstOrNull { it.name == deviceName && it.booted } ?: error("device $deviceName not booted") - val bundleIdentifier = "$bundleIdPrefix.$projectName" - runExternalTool( - MacUtils.xcrun, - listOf("simctl", "launch", "--console", device.udid, bundleIdentifier) - ) - } - } - } - -} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/ExperimentalPackComposeApplicationForXCodeTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/ExperimentalPackComposeApplicationForXCodeTask.kt deleted file mode 100644 index efad8d3307f..00000000000 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/ExperimentalPackComposeApplicationForXCodeTask.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. - */ - -package org.jetbrains.compose.experimental.uikit.tasks - -import org.gradle.api.DefaultTask -import org.gradle.api.file.DirectoryProperty -import org.gradle.api.file.RegularFileProperty -import org.gradle.api.provider.Property -import org.gradle.api.tasks.* -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import java.io.File -import java.nio.file.Files -import java.nio.file.StandardCopyOption - -abstract class ExperimentalPackComposeApplicationForXCodeTask : DefaultTask() { - @get:Input - internal abstract val targetType: Property - - @get:Input - internal abstract val buildType: Property - - @get:InputFile - internal abstract val kotlinBinary: RegularFileProperty - - @get:Input - internal abstract val executablePath: Property - - @get:OutputDirectory - internal abstract val destinationDir: DirectoryProperty - - @TaskAction - fun run() { - val destinationDir = destinationDir.get().asFile - project.delete(destinationDir) - project.mkdir(destinationDir) - - val executableSource = kotlinBinary.get().asFile - val dsymSource = File(executableSource.absolutePath + ".dSYM") - - val executableDestination = destinationDir.resolve(executablePath.get()) - val dsymDestination = File(executableDestination.parentFile.absolutePath + ".dSYM") - - for (sourceFile in dsymSource.walk().filter { it.isFile }) { - val relativePath = sourceFile.relativeTo(dsymSource) - val destFile = dsymDestination.resolve(relativePath) - destFile.parentFile.mkdirs() - if (sourceFile.name == executableSource.name) { - sourceFile.copyTo(destFile.resolveSibling(executableDestination.name), true) - } else { - sourceFile.copyTo(destFile, true) - } - } - - executableDestination.parentFile.mkdirs() - // We need to preserve executable flag for resulting executable, "FileKt.copyTo" extension method does not allow this. - Files.copy(executableSource.toPath(), executableDestination.toPath(), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING) - } - - internal enum class UikitTarget(val simulator: Boolean, val targetName: String) { - X64(true, "uikitX64"), - Arm64(false, "uikitArm64") - } -} \ No newline at end of file diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/SyncComposeResourcesForIosTask.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/SyncComposeResourcesForIosTask.kt index 01797f9f7a8..8d4b7e72640 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/SyncComposeResourcesForIosTask.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/experimental/uikit/tasks/SyncComposeResourcesForIosTask.kt @@ -19,25 +19,34 @@ import kotlin.io.path.pathString import kotlin.io.path.relativeTo abstract class SyncComposeResourcesForIosTask : AbstractComposeIosTask() { - private fun missingTargetEnvAttributeError(attribute: String): Provider = - providers.provider { - error( - "Could not infer iOS target $attribute. Make sure to build " + - "via XCode (directly or via Kotlin Multiplatform Mobile plugin for Android Studio)") + + private fun Provider.orElseThrowMissingAttributeError(attribute: String): Provider { + val noProvidedValue = "__NO_PROVIDED_VALUE__" + return this.orElse(noProvidedValue).map { + if (it == noProvidedValue) { + error( + "Could not infer iOS target $attribute. Make sure to build " + + "via XCode (directly or via Kotlin Multiplatform Mobile plugin for Android Studio)") + } + it } + } @get:Input val xcodeTargetPlatform: Provider = providers.gradleProperty("compose.ios.resources.platform") .orElse(providers.environmentVariable("PLATFORM_NAME")) - .orElse(missingTargetEnvAttributeError("platform")) + .orElseThrowMissingAttributeError("platform") + @get:Input val xcodeTargetArchs: Provider> = providers.gradleProperty("compose.ios.resources.archs") .orElse(providers.environmentVariable("ARCHS")) - .orElse(missingTargetEnvAttributeError("architectures")) - .map { it.split(",", " ").filter { it.isNotBlank() } } + .orElseThrowMissingAttributeError("architectures") + .map { + it.split(",", " ").filter { it.isNotBlank() } + } @get:Input internal val iosTargets: SetProperty = objects.setProperty(IosTargetResources::class.java) diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt index 24a7d27f005..89cae4831e0 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt @@ -62,13 +62,18 @@ class GradlePluginTest : GradlePluginTestBase() { ) } + // We rely on this property to use gradle configuration cache in some tests. + // Enabling configuration cache unconditionally breaks out tests with gradle 7.3.3. + // Old comment: 'for some reason configuration cache + test kit + custom vars does not work' + private val GradleVersion.isAtLeastGradle8 + get() = this >= GradleVersion.version("8.0") + @Test fun iosResources() { Assumptions.assumeTrue(currentOS == OS.MacOS) val iosTestEnv = iosTestEnv() val testEnv = defaultTestEnvironment.copy( - // for some reason configuration cache + test kit + custom vars does not work - useGradleConfigurationCache = false, + useGradleConfigurationCache = TestProperties.gradleBaseVersionForTests.isAtLeastGradle8, additionalEnvVars = iosTestEnv.envVars ) @@ -91,8 +96,7 @@ class GradlePluginTest : GradlePluginTestBase() { Assumptions.assumeTrue(currentOS == OS.MacOS) val iosTestEnv = iosTestEnv() val testEnv = defaultTestEnvironment.copy( - // for some reason configuration cache + test kit + custom vars does not work - useGradleConfigurationCache = false, + useGradleConfigurationCache = TestProperties.gradleBaseVersionForTests.isAtLeastGradle8, additionalEnvVars = iosTestEnv.envVars ) with(testProject(TestProjects.iosMokoResources, testEnv)) { @@ -345,4 +349,4 @@ class GradlePluginTest : GradlePluginTestBase() { } return constructor.newInstance(socket, logger, {}) as RemoteConnection } -} \ No newline at end of file +} diff --git a/gradle-plugins/gradle.properties b/gradle-plugins/gradle.properties index fe6abc34215..cafb63b058e 100644 --- a/gradle-plugins/gradle.properties +++ b/gradle-plugins/gradle.properties @@ -2,7 +2,7 @@ org.gradle.parallel=true kotlin.code.style=official # Default version of Compose Libraries used by Gradle plugin -compose.version=1.5.1 +compose.version=1.5.2 # The latest version of Compose Compiler used by Gradle plugin. Used only in tests/CI. compose.tests.compiler.version=1.5.2 # The latest version of Kotlin compatible with compose.tests.compiler.version. Used only in tests/CI. diff --git a/gradle-plugins/gradle/libs.versions.toml b/gradle-plugins/gradle/libs.versions.toml index 67627f1d814..4281a1056aa 100644 --- a/gradle-plugins/gradle/libs.versions.toml +++ b/gradle-plugins/gradle/libs.versions.toml @@ -1,17 +1,12 @@ [versions] kotlin = "1.9.0" gradle-download-plugin = "5.5.0" -kotlinx-serialization = "1.2.1" [libraries] download-task = { module = "de.undercouch:gradle-download-task", version.ref = "gradle-download-plugin" } -serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } -serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" } -serialization-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core-jvm", version.ref = "kotlinx-serialization" } [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } shadow-jar = "com.github.johnrengelman.shadow:8.1.1" download = { id = "de.undercouch.download", version.ref = "gradle-download-plugin" } publish-plugin-portal = "com.gradle.plugin-publish:1.2.1" diff --git a/tutorials/HTML/Getting_Started/README.md b/tutorials/HTML/Getting_Started/README.md index 8b87e2ce214..75b9e051d3e 100644 --- a/tutorials/HTML/Getting_Started/README.md +++ b/tutorials/HTML/Getting_Started/README.md @@ -37,7 +37,7 @@ pluginManagement { // Add compose gradle plugin plugins { kotlin("multiplatform") version "1.9.10" - id("org.jetbrains.compose") version "1.5.1" + id("org.jetbrains.compose") version "1.5.2" } // Add maven repositories diff --git a/tutorials/Window_API_new/README.md b/tutorials/Window_API_new/README.md index ffe0b42b057..497998ff8c7 100644 --- a/tutorials/Window_API_new/README.md +++ b/tutorials/Window_API_new/README.md @@ -94,7 +94,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue -import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogWindow import androidx.compose.ui.window.Window import androidx.compose.ui.window.application @@ -107,7 +107,7 @@ fun main() = application { onCloseRequest = { isAskingToClose = true } ) { if (isAskingToClose) { - Dialog( + DialogWindow( onCloseRequest = { isAskingToClose = false }, title = "Close the document without saving?", ) { @@ -432,8 +432,8 @@ private fun onWindowRelocate(position: WindowPosition) { ## Dialogs There are two types of window – modal and regular. Below are the functions for creating each: -1. Window – regular window type. -2. Dialog – modal window type. This type locks its parent window until the user is finished working with it and closes the modal window. +1. `Window` – regular window type. +2. `DialogWindow` – modal window type. This type locks its parent window until the user is finished working with it and closes the modal window. You can see an example of both types of window below. @@ -445,7 +445,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment -import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogWindow import androidx.compose.ui.window.Window import androidx.compose.ui.window.WindowPosition import androidx.compose.ui.window.application @@ -462,7 +462,7 @@ fun main() = application { } if (isDialogOpen) { - Dialog( + DialogWindow( onCloseRequest = { isDialogOpen = false }, state = rememberDialogState(position = WindowPosition(Alignment.Center)) ) { @@ -584,7 +584,7 @@ fun main() = application { } } ``` -Note that `WindowDraggableArea` can be used only inside `singleWindowApplication`, `Window` and `Dialog`. If you need to use it in another Composable function, pass `WindowScope` as a receiver there: +Note that `WindowDraggableArea` can be used only inside `singleWindowApplication`, `Window` and `DialogWindow`. If you need to use it in another Composable function, pass `WindowScope` as a receiver there: ```kotlin import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box