diff --git a/examples/README.md b/examples/README.md index 0319f064b7..3d9d382898 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/falling-balls/README.md b/examples/falling-balls/README.md deleted file mode 100644 index 14804331d0..0000000000 --- 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 8475d8902c..0000000000 --- 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 0b1c80d006..0000000000 --- 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/iosApp/Configuration/Config.xcconfig b/examples/falling-balls/iosApp/Configuration/Config.xcconfig deleted file mode 100644 index e6ec51dad2..0000000000 --- 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/src/jsMain/kotlin/main.js.kt b/examples/falling-balls/jsApp/src/jsMain/kotlin/main.js.kt deleted file mode 100644 index d646ee78b8..0000000000 --- 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 e68a4bccdb..0000000000 --- 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 9f32e9dd8a..0000000000 --- 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 b88d1299aa..0000000000 --- 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 d638f6ee24..0000000000 --- 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 1c4b55ab06..0000000000 --- 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 618bdd6d1d..0000000000 --- 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 7e0e22e86a..0000000000 --- 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 be803b013d..0000000000 --- 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 0000000000..0cf145bd7b --- /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 0d7ab8e11f..e09546327c 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 ef41726dc2..2285f4485a 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 0000000000..b459df13ca --- /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 7606f45918..31d4aef6ca 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 0000000000..72742a58ba --- /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/falling-balls/gradle.properties b/examples/graphics-2d/gradle.properties similarity index 100% rename from examples/falling-balls/gradle.properties rename to examples/graphics-2d/gradle.properties 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 0000000000..d5037986d0 --- /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 bf37d47794..c810131d7a 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 e9915e5fcf..56163e6393 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/falling-balls/jsApp/build.gradle.kts b/examples/graphics-2d/jsApp/build.gradle.kts similarity index 91% rename from examples/falling-balls/jsApp/build.gradle.kts rename to examples/graphics-2d/jsApp/build.gradle.kts index 144006fa94..b6fc37668c 100644 --- a/examples/falling-balls/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 0000000000..5c9cd84953 --- /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 0000000000..c70f31b9a4 --- /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 6ed7a53ada..7e76f0ab40 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 0df0b481ae..adff5037ca 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 0000000000..ec2120b6db --- /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 0000000000..181a5833e6 --- /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 3dd3fe22d9..b9e71feb0d 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 0000000000..7554db7834 --- /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 58f5b65adb..09f813e468 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 731435037e..53814c8559 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 b4bbe9d4a8..9480152ed2 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 14b96bfab0..118ca63df1 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 a72e93b88b..a31d098c94 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 154bdcfbbd..155ae15cdf 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 77842f6123..a852418e1a 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 13c2d47b20..967c9db826 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 3a81aca773..6d00968141 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 b1df36b5ee..0a01191f6b 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 88fb8f8025..696cd60117 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 34070537f4..16f04f3b3e 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 71a41bb2d8..a3ca49a495 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 0000000000..d7bf7955f4 --- /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 e18ac5a1f9..887b30fbb4 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 0000000000..303963a3f0 --- /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 cc933fc2bb..c33d60853c 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 0000000000..c075a8db12 --- /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 0000000000..181a5833e6 --- /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 3dd3fe22d9..b9e71feb0d 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 0000000000..ec2120b6db --- /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 0000000000..181a5833e6 --- /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 0000000000..83f87cbc24 --- /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 0000000000..d450440347 --- /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 0000000000..181a5833e6 --- /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 0000000000..7ceb8d6bfe --- /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/minesweeper/.gitignore b/examples/minesweeper/.gitignore deleted file mode 100644 index fedf972a67..0000000000 --- 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 7af7e15f4b..0000000000 --- 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 68d98e4f57..0000000000 --- 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 dfd8f1bf23..0000000000 --- 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 137e249746..0000000000 --- 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 4970ea42ed..0000000000 --- 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 413fe24a13..0000000000 --- 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 0c00883af5..0000000000 --- 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 730a5109ad..0000000000 --- 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 732c30af6a..0000000000 --- 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.properties b/examples/minesweeper/gradle.properties deleted file mode 100644 index 73998f2d5e..0000000000 --- a/examples/minesweeper/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.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 -# 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/minesweeper/gradle/wrapper/gradle-wrapper.jar b/examples/minesweeper/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 249e5832f0..0000000000 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 84a0b92f9a..0000000000 --- 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 a69d9cb6c2..0000000000 --- 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 f127cfd49d..0000000000 --- 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 f752d0e2f8..0000000000 --- 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 39a69e8216..0000000000 --- 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 ee7e3ca03f..0000000000 --- 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 fb88a396bf..0000000000 --- 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 4aa7c5350b..0000000000 --- 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 f7f6457b31..0000000000 --- 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 9a269f5eaa..0000000000 --- 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 4aa7c5350b..0000000000 --- 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 0648e8602f..0000000000 --- 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/build.gradle.kts b/examples/minesweeper/jsApp/build.gradle.kts deleted file mode 100644 index 144006fa94..0000000000 --- a/examples/minesweeper/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/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt b/examples/minesweeper/jsApp/src/jsMain/kotlin/main.js.kt deleted file mode 100644 index b36b64e9ad..0000000000 --- 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 9dd212786b..0000000000 --- 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 d859ff0870..0000000000 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 568741e54f..0000000000 --- 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 460fdeb8f2..0000000000 --- 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 ed7f8f9d4b..0000000000 --- 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 ef0837a8c9..0000000000 --- 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 5e07958636..0000000000 --- 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 88b034d366..0000000000 --- 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/validateExamplesIos.sh b/examples/validateExamplesIos.sh index 6da14bb210..3efc7b4a63 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 180e034383..0000000000 --- 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 0de5218670..0000000000 --- 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 3074e926f5..0000000000 --- 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 a0575f7eb2..0000000000 --- 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 ad0432f6f6..0000000000 --- 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 045ce66fb5..0000000000 --- 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 d23a35eb38..0000000000 --- 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 8d0c1f3d7c..0000000000 --- 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 1cebd3ec6a..0000000000 --- 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 621ebdf728..0000000000 --- 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 51a3f03b2c..0000000000 --- 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.2 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 249e5832f0..0000000000 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 84a0b92f9a..0000000000 --- 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 a69d9cb6c2..0000000000 --- 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 f127cfd49d..0000000000 --- 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 bad995c745..0000000000 --- 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 d2282704e8..0000000000 --- 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 ee7e3ca03f..0000000000 --- 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 fb88a396bf..0000000000 --- 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 4aa7c5350b..0000000000 --- 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 f7f6457b31..0000000000 --- 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 9a269f5eaa..0000000000 --- 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 4aa7c5350b..0000000000 --- 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 0648e8602f..0000000000 --- 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 d859ff0870..0000000000 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 1b7a2ddc8b..0000000000 --- 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 aa74c78616..0000000000 --- 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 de749acb75..0000000000 --- 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 137c31e24a..0000000000 --- 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 ebfd7e4ac6..0000000000 --- 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 f9748e02e3..0000000000 --- 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 0fc90a38ca..0000000000 --- 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 a73ddd7989..0000000000 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 3e5ce57f72..0000000000 --- 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 fcb552987e..0000000000 --- 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 8861ae7ddb..0000000000 --- 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 ebfd7e4ac6..0000000000 --- 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 c8004b488b..0000000000 --- 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 334c22b781..0000000000 --- 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