diff --git a/experimental/examples/chat-mpp/build.gradle.kts b/experimental/examples/chat-mpp/build.gradle.kts
index d433b5eb12..27c6ada080 100644
--- a/experimental/examples/chat-mpp/build.gradle.kts
+++ b/experimental/examples/chat-mpp/build.gradle.kts
@@ -50,7 +50,7 @@ kotlin {
// Workaround for an issue:
// https://youtrack.jetbrains.com/issue/KT-53561/Invalid-LLVM-module-inlinable-function-call-in-a-function-with-debug-info-must-have-a-dbg-location
- // Compose comiler produces nodes without line information sometimes that provokes Kotlin native compiler to report errors.
+ // Compose compiler produces nodes without line information sometimes that provokes Kotlin native compiler to report errors.
// TODO: remove workaround when switch to Kotlin 1.8
val disableKonanVerification = "-Xverify-compiler=false"
@@ -103,15 +103,15 @@ kotlin {
dependsOn(commonMain)
kotlin.srcDirs("src/jvmMain/kotlin")
dependencies {
- api("androidx.appcompat:appcompat:1.4.1")
- implementation("androidx.activity:activity-compose:1.4.0")
+ implementation("androidx.appcompat:appcompat:1.5.1")
+ implementation("androidx.activity:activity-compose:1.5.0")
}
}
val desktopMain by getting {
- dependencies {
+ dependencies {
implementation(compose.desktop.currentOs)
- }
+ }
}
val jsMain by getting {
@@ -195,13 +195,6 @@ afterEvaluate {
}
}
-// TODO: remove when https://youtrack.jetbrains.com/issue/KT-50778 fixed
-project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile::class.java).configureEach {
- kotlinOptions.freeCompilerArgs += listOf(
- "-Xir-dce-runtime-diagnostic=log"
- )
-}
-
android {
compileSdk = 32
@@ -222,4 +215,3 @@ android {
}
}
}
-
diff --git a/experimental/examples/chat-mpp/gradle.properties b/experimental/examples/chat-mpp/gradle.properties
index 2ef862b672..e6fa271a3c 100644
--- a/experimental/examples/chat-mpp/gradle.properties
+++ b/experimental/examples/chat-mpp/gradle.properties
@@ -7,6 +7,7 @@ kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.enableGranularSourceSetsMetadata=true
+# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
compose.desktop.verbose=true
android.useAndroidX=true
diff --git a/experimental/examples/chat-mpp/settings.gradle.kts b/experimental/examples/chat-mpp/settings.gradle.kts
index c4a781bdb9..3698d56c08 100644
--- a/experimental/examples/chat-mpp/settings.gradle.kts
+++ b/experimental/examples/chat-mpp/settings.gradle.kts
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
mavenLocal()
+ mavenCentral()
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
google()
@@ -8,15 +9,13 @@ pluginManagement {
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)
+
+ val agpVersion = extra["agp.version"] as String
id("com.android.application").version(agpVersion)
- id("com.android.library").version(agpVersion)
+
+ val composeVersion = extra["compose.version"] as String
id("org.jetbrains.compose").version(composeVersion)
}
}
diff --git a/experimental/examples/chat-mpp/src/androidMain/res/res/values/strings.xml b/experimental/examples/chat-mpp/src/androidMain/res/res/values/strings.xml
deleted file mode 100644
index 88a8d2c765..0000000000
--- a/experimental/examples/chat-mpp/src/androidMain/res/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Chat app
-
\ No newline at end of file
diff --git a/experimental/examples/chat-mpp/src/androidMain/res/values/strings.xml b/experimental/examples/chat-mpp/src/androidMain/res/values/strings.xml
index 88a8d2c765..5aafa46f8c 100644
--- a/experimental/examples/chat-mpp/src/androidMain/res/values/strings.xml
+++ b/experimental/examples/chat-mpp/src/androidMain/res/values/strings.xml
@@ -1,3 +1,3 @@
- Chat app
+ Chat
\ No newline at end of file
diff --git a/experimental/examples/falling-balls-mpp/build.gradle.kts b/experimental/examples/falling-balls-mpp/build.gradle.kts
index dde5bb35e1..24564df0c0 100644
--- a/experimental/examples/falling-balls-mpp/build.gradle.kts
+++ b/experimental/examples/falling-balls-mpp/build.gradle.kts
@@ -5,15 +5,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.compose.experimental.dsl.IOSDevices
-buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- google()
- maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
- }
-}
-
plugins {
id("com.android.application")
kotlin("multiplatform")
@@ -24,10 +15,10 @@ version = "1.0-SNAPSHOT"
repositories {
mavenLocal()
+ google()
mavenCentral()
- gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
- google()}
+}
kotlin {
android()
@@ -56,6 +47,13 @@ kotlin {
}
}
}
+
+ // Workaround for an issue:
+ // https://youtrack.jetbrains.com/issue/KT-53561/Invalid-LLVM-module-inlinable-function-call-in-a-function-with-debug-info-must-have-a-dbg-location
+ // Compose compiler produces nodes without line information sometimes that provokes Kotlin native compiler to report errors.
+ // TODO: remove workaround when switch to Kotlin 1.8
+ val disableKonanVerification = "-Xverify-compiler=false"
+
iosX64("uikitX64") {
binaries {
executable() {
@@ -63,7 +61,8 @@ kotlin {
freeCompilerArgs += listOf(
"-linker-option", "-framework", "-linker-option", "Metal",
"-linker-option", "-framework", "-linker-option", "CoreText",
- "-linker-option", "-framework", "-linker-option", "CoreGraphics"
+ "-linker-option", "-framework", "-linker-option", "CoreGraphics",
+ disableKonanVerification
)
}
}
@@ -75,10 +74,9 @@ kotlin {
freeCompilerArgs += listOf(
"-linker-option", "-framework", "-linker-option", "Metal",
"-linker-option", "-framework", "-linker-option", "CoreText",
- "-linker-option", "-framework", "-linker-option", "CoreGraphics"
+ "-linker-option", "-framework", "-linker-option", "CoreGraphics",
+ disableKonanVerification
)
- // TODO: the current compose binary surprises LLVM, so disable checks for now.
- freeCompilerArgs += "-Xdisable-phases=VerifyBitcode"
}
}
}
@@ -187,15 +185,6 @@ tasks.withType {
kotlinOptions.jvmTarget = "11"
}
-kotlin {
- targets.withType {
- binaries.all {
- // TODO: the current compose binary surprises LLVM, so disable checks for now.
- freeCompilerArgs += "-Xdisable-phases=VerifyBitcode"
- }
- }
-}
-
compose.desktop.nativeApplication {
targets(kotlin.targets.getByName("macosX64"))
distributions {
@@ -214,14 +203,6 @@ afterEvaluate {
}
}
-
-// TODO: remove when https://youtrack.jetbrains.com/issue/KT-50778 fixed
-project.tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile::class.java).configureEach {
- kotlinOptions.freeCompilerArgs += listOf(
- "-Xir-dce-runtime-diagnostic=log"
- )
-}
-
android {
compileSdk = 32
diff --git a/experimental/examples/falling-balls-mpp/gradle.properties b/experimental/examples/falling-balls-mpp/gradle.properties
index 09710e726b..e6fa271a3c 100644
--- a/experimental/examples/falling-balls-mpp/gradle.properties
+++ b/experimental/examples/falling-balls-mpp/gradle.properties
@@ -11,6 +11,7 @@ kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.binary.memoryModel=experimental
compose.desktop.verbose=true
android.useAndroidX=true
+kotlin.js.webpack.major.version=4
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
diff --git a/experimental/examples/falling-balls-mpp/settings.gradle.kts b/experimental/examples/falling-balls-mpp/settings.gradle.kts
index 80673ec582..6f533399e1 100644
--- a/experimental/examples/falling-balls-mpp/settings.gradle.kts
+++ b/experimental/examples/falling-balls-mpp/settings.gradle.kts
@@ -21,4 +21,3 @@ pluginManagement {
}
rootProject.name = "falling-balls-mpp"
-
diff --git a/experimental/examples/falling-balls-mpp/src/androidMain/res/values/strings.xml b/experimental/examples/falling-balls-mpp/src/androidMain/res/values/strings.xml
index 88a8d2c765..8475d8902c 100644
--- a/experimental/examples/falling-balls-mpp/src/androidMain/res/values/strings.xml
+++ b/experimental/examples/falling-balls-mpp/src/androidMain/res/values/strings.xml
@@ -1,3 +1,3 @@
- Chat app
+ Falling Balls
\ No newline at end of file
diff --git a/experimental/examples/minesweeper/build.gradle.kts b/experimental/examples/minesweeper/build.gradle.kts
index 291ad22f3c..a5045597e5 100644
--- a/experimental/examples/minesweeper/build.gradle.kts
+++ b/experimental/examples/minesweeper/build.gradle.kts
@@ -5,30 +5,23 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.compose.experimental.dsl.IOSDevices
-buildscript {
- repositories {
- mavenLocal()
- mavenCentral()
- google()
- maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
- }
-}
-
plugins {
- kotlin("multiplatform") version "1.7.10"
- id("org.jetbrains.compose") version "1.3.0-alpha01-dev827"
+ id("com.android.application")
+ kotlin("multiplatform")
+ id("org.jetbrains.compose")
}
version = "1.0-SNAPSHOT"
repositories {
mavenLocal()
+ google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
- google()
}
kotlin {
+ android()
jvm("desktop")
js(IR) {
browser()
@@ -54,6 +47,13 @@ kotlin {
}
}
}
+
+ // Workaround for an issue:
+ // https://youtrack.jetbrains.com/issue/KT-53561/Invalid-LLVM-module-inlinable-function-call-in-a-function-with-debug-info-must-have-a-dbg-location
+ // Compose compiler produces nodes without line information sometimes that provokes Kotlin native compiler to report errors.
+ // TODO: remove workaround when switch to Kotlin 1.8
+ val disableKonanVerification = "-Xverify-compiler=false"
+
iosX64("uikitX64") {
binaries {
executable() {
@@ -61,22 +61,22 @@ kotlin {
freeCompilerArgs += listOf(
"-linker-option", "-framework", "-linker-option", "Metal",
"-linker-option", "-framework", "-linker-option", "CoreText",
- "-linker-option", "-framework", "-linker-option", "CoreGraphics"
+ "-linker-option", "-framework", "-linker-option", "CoreGraphics",
+ disableKonanVerification
)
}
}
}
iosArm64("uikitArm64") {
- binaries {
- executable() {
+ binaries {
+ executable() {
entryPoint = "main"
freeCompilerArgs += listOf(
"-linker-option", "-framework", "-linker-option", "Metal",
"-linker-option", "-framework", "-linker-option", "CoreText",
- "-linker-option", "-framework", "-linker-option", "CoreGraphics"
+ "-linker-option", "-framework", "-linker-option", "CoreGraphics",
+ disableKonanVerification
)
- // TODO: the current compose binary surprises LLVM, so disable checks for now.
- freeCompilerArgs += "-Xdisable-phases=VerifyBitcode"
}
}
}
@@ -88,15 +88,23 @@ kotlin {
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.runtime)
-
- //TODO hotfix of issue https://github.com/JetBrains/compose-jb/issues/2113
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3")
}
}
val commonTest by getting {
dependencies {
- implementation(kotlin("test"))
+ implementation(kotlin("test-common"))
+ implementation(kotlin("test-annotations-common"))
+ }
+ }
+
+ val androidMain by getting {
+ dependsOn(commonMain)
+ kotlin.srcDirs("src/jvmMain/kotlin")
+ dependencies {
+ implementation("androidx.appcompat:appcompat:1.5.1")
+ implementation("androidx.activity:activity-compose:1.5.0")
}
}
@@ -180,15 +188,6 @@ tasks.withType {
kotlinOptions.jvmTarget = "11"
}
-kotlin {
- targets.withType {
- binaries.all {
- // TODO: the current compose binary surprises LLVM, so disable checks for now.
- freeCompilerArgs += "-Xdisable-phases=VerifyBitcode"
- }
- }
-}
-
// a temporary workaround for a bug in jsRun invocation - see https://youtrack.jetbrains.com/issue/KT-48273
afterEvaluate {
rootProject.extensions.configure {
@@ -197,3 +196,24 @@ afterEvaluate {
nodeVersion = "16.0.0"
}
}
+
+android {
+ compileSdk = 32
+
+ defaultConfig {
+ minSdk = 26
+ targetSdk = 32
+ }
+
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_11
+ targetCompatibility = JavaVersion.VERSION_11
+ }
+
+ sourceSets {
+ named("main") {
+ manifest.srcFile("src/androidMain/AndroidManifest.xml")
+ res.srcDirs("src/androidMain/res", "src/commonMain/resources")
+ }
+ }
+}
diff --git a/experimental/examples/minesweeper/gradle.properties b/experimental/examples/minesweeper/gradle.properties
index f3991bafab..e6fa271a3c 100644
--- a/experimental/examples/minesweeper/gradle.properties
+++ b/experimental/examples/minesweeper/gradle.properties
@@ -1,11 +1,17 @@
+compose.version=1.3.0-alpha01-dev827
+kotlin.version=1.7.10
+agp.version=7.0.4
+org.gradle.jvmargs=-Xmx3g
+kotlin.code.style=official
kotlin.native.cacheKind=none
kotlin.native.useEmbeddableCompilerJar=true
-org.gradle.jvmargs=-Xmx3g
-kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
+kotlin.mpp.enableGranularSourceSetsMetadata=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
compose.desktop.verbose=true
+android.useAndroidX=true
+kotlin.js.webpack.major.version=4
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
diff --git a/experimental/examples/minesweeper/settings.gradle.kts b/experimental/examples/minesweeper/settings.gradle.kts
index 4dda3a1cf1..037941996c 100644
--- a/experimental/examples/minesweeper/settings.gradle.kts
+++ b/experimental/examples/minesweeper/settings.gradle.kts
@@ -1,11 +1,22 @@
pluginManagement {
repositories {
mavenLocal()
- gradlePluginPortal()
mavenCentral()
- maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
+ gradlePluginPortal()
+ maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
google()
}
+ plugins {
+ val kotlinVersion = extra["kotlin.version"] as String
+ kotlin("multiplatform").version(kotlinVersion)
+ kotlin("android").version(kotlinVersion)
+
+ val agpVersion = extra["agp.version"] as String
+ id("com.android.application").version(agpVersion)
+
+ val composeVersion = extra["compose.version"] as String
+ id("org.jetbrains.compose").version(composeVersion)
+ }
}
rootProject.name = "minesweeper"
diff --git a/experimental/examples/minesweeper/src/androidMain/AndroidManifest.xml b/experimental/examples/minesweeper/src/androidMain/AndroidManifest.xml
new file mode 100644
index 0000000000..5890a77edf
--- /dev/null
+++ b/experimental/examples/minesweeper/src/androidMain/AndroidManifest.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/experimental/examples/minesweeper/src/androidMain/kotlin/MainActivity.kt b/experimental/examples/minesweeper/src/androidMain/kotlin/MainActivity.kt
new file mode 100644
index 0000000000..e3b0d1e9f3
--- /dev/null
+++ b/experimental/examples/minesweeper/src/androidMain/kotlin/MainActivity.kt
@@ -0,0 +1,15 @@
+package org.jetbrains.minesweeper
+
+import android.os.Bundle
+import androidx.activity.compose.setContent
+import androidx.appcompat.app.AppCompatActivity
+import Game
+
+class MainActivity : AppCompatActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ Game()
+ }
+ }
+}
diff --git a/experimental/examples/minesweeper/src/androidMain/kotlin/actualfuns.android.kt b/experimental/examples/minesweeper/src/androidMain/kotlin/actualfuns.android.kt
new file mode 100644
index 0000000000..b8ac63873d
--- /dev/null
+++ b/experimental/examples/minesweeper/src/androidMain/kotlin/actualfuns.android.kt
@@ -0,0 +1,7 @@
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.graphics.painter.Painter
+
+@Composable
+actual fun loadImage(src: String): Painter = loadImageAsColoredRect(src)
+
+actual fun isMobileDevice() = true
\ No newline at end of file
diff --git a/experimental/examples/minesweeper/src/androidMain/res/values/strings.xml b/experimental/examples/minesweeper/src/androidMain/res/values/strings.xml
new file mode 100644
index 0000000000..413fe24a13
--- /dev/null
+++ b/experimental/examples/minesweeper/src/androidMain/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ Minesweeper
+
\ No newline at end of file
diff --git a/experimental/examples/minesweeper/src/commonMain/kotlin/game.kt b/experimental/examples/minesweeper/src/commonMain/kotlin/game.kt
index 8c8f379439..90768fa701 100644
--- a/experimental/examples/minesweeper/src/commonMain/kotlin/game.kt
+++ b/experimental/examples/minesweeper/src/commonMain/kotlin/game.kt
@@ -5,7 +5,9 @@ import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
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.unit.*
import kotlin.math.max
@@ -13,6 +15,27 @@ import kotlin.math.max
@Composable
expect fun loadImage(src: String): Painter
+fun loadImageAsColoredRect(src: String): Painter {
+ // TODO Bundle pics and show images properly
+ val color = when (src) {
+ "assets/clock.png" -> Color.Blue
+ "assets/flag.png" -> Color.Green
+ "assets/mine.png" -> Color.Red
+ else -> Color.White
+ }
+
+ return object : Painter() {
+ override val intrinsicSize: Size
+ get() = Size(16f, 16f)
+
+ override fun DrawScope.onDraw() {
+ drawRect(color = color)
+ }
+ }
+}
+
+expect fun isMobileDevice(): Boolean
+
object Difficulty {
val EASY = GameSettings(9, 9, 10)
val MEDIUM = GameSettings(16, 16, 40)
diff --git a/experimental/examples/minesweeper/src/commonMain/kotlin/gameInteraction.kt b/experimental/examples/minesweeper/src/commonMain/kotlin/gameInteraction.kt
index ada6946f7a..32b0261038 100644
--- a/experimental/examples/minesweeper/src/commonMain/kotlin/gameInteraction.kt
+++ b/experimental/examples/minesweeper/src/commonMain/kotlin/gameInteraction.kt
@@ -1,30 +1,47 @@
+import androidx.compose.foundation.ExperimentalFoundationApi
+import androidx.compose.foundation.combinedClickable
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.*
+@OptIn(ExperimentalFoundationApi::class)
@Composable
fun Modifier.gameInteraction(open: () -> Unit, flag: () -> Unit, seek: () -> Unit): Modifier =
- pointerInput(open, flag, seek) {
- awaitPointerEventScope {
- while (true) {
- val event = awaitPointerEvent(PointerEventPass.Main)
- with(event) {
- if (type == PointerEventType.Press) {
- // TODO does not work yet, all events are of Unknown type (
- val lmb = buttons.isPrimaryPressed
- val rmb = buttons.isSecondaryPressed
+ if (isMobileDevice()) {
+ combinedClickable(
+ onClick = {
+ open()
+ },
+ onDoubleClick = {
+ seek()
+ },
+ onLongClick = {
+ flag()
+ }
+ )
+ } else {
+ pointerInput(open, flag, seek) {
+ awaitPointerEventScope {
+ while (true) {
+ val event = awaitPointerEvent(PointerEventPass.Main)
+ with(event) {
+ if (type == PointerEventType.Press) {
+ // TODO does not work yet, all events are of Unknown type (
+ val lmb = buttons.isPrimaryPressed
+ val rmb = buttons.isSecondaryPressed
- if (lmb && !rmb) {
- if (keyboardModifiers.isShiftPressed) {
- seek()
- } else {
- open()
+ if (lmb && !rmb) {
+ if (keyboardModifiers.isShiftPressed) {
+ seek()
+ } else {
+ open()
+ }
+ } else if (rmb && !lmb) {
+ flag()
}
- } else if (rmb && !lmb) {
- flag()
}
}
}
}
}
- }
\ No newline at end of file
+ }
diff --git a/experimental/examples/minesweeper/src/desktopMain/kotlin/main.desktop.kt b/experimental/examples/minesweeper/src/desktopMain/kotlin/main.desktop.kt
index 64665aa500..c12de62591 100644
--- a/experimental/examples/minesweeper/src/desktopMain/kotlin/main.desktop.kt
+++ b/experimental/examples/minesweeper/src/desktopMain/kotlin/main.desktop.kt
@@ -28,3 +28,5 @@ fun main() = application {
@Composable
actual fun loadImage(src: String): Painter = painterResource(src)
+
+actual fun isMobileDevice() = false
diff --git a/experimental/examples/minesweeper/src/commonMain/resources/assets/clock.png b/experimental/examples/minesweeper/src/desktopMain/resources/assets/clock.png
similarity index 100%
rename from experimental/examples/minesweeper/src/commonMain/resources/assets/clock.png
rename to experimental/examples/minesweeper/src/desktopMain/resources/assets/clock.png
diff --git a/experimental/examples/minesweeper/src/commonMain/resources/assets/flag.png b/experimental/examples/minesweeper/src/desktopMain/resources/assets/flag.png
similarity index 100%
rename from experimental/examples/minesweeper/src/commonMain/resources/assets/flag.png
rename to experimental/examples/minesweeper/src/desktopMain/resources/assets/flag.png
diff --git a/experimental/examples/minesweeper/src/commonMain/resources/assets/mine.png b/experimental/examples/minesweeper/src/desktopMain/resources/assets/mine.png
similarity index 100%
rename from experimental/examples/minesweeper/src/commonMain/resources/assets/mine.png
rename to experimental/examples/minesweeper/src/desktopMain/resources/assets/mine.png
diff --git a/experimental/examples/minesweeper/src/jsMain/kotlin/main.js.kt b/experimental/examples/minesweeper/src/jsMain/kotlin/main.js.kt
index 70ec13399d..1d1dd2d69f 100644
--- a/experimental/examples/minesweeper/src/jsMain/kotlin/main.js.kt
+++ b/experimental/examples/minesweeper/src/jsMain/kotlin/main.js.kt
@@ -19,21 +19,6 @@ fun main() {
}
@Composable
-actual fun loadImage(src: String): Painter {
- // TODO Bundle pics and show images properly
- val color = when (src) {
- "assets/clock.png" -> Color.Blue
- "assets/flag.png" -> Color.Green
- "assets/mine.png" -> Color.Red
- else -> Color.White
- }
-
- return object : Painter() {
- override val intrinsicSize: Size
- get() = Size(16f, 16f)
+actual fun loadImage(src: String): Painter = loadImageAsColoredRect(src)
- override fun DrawScope.onDraw() {
- drawRect(color = color)
- }
- }
-}
+actual fun isMobileDevice() = false
diff --git a/experimental/examples/minesweeper/src/macosMain/kotlin/main.macos.kt b/experimental/examples/minesweeper/src/macosMain/kotlin/main.macos.kt
index a28272f039..41ae920d49 100644
--- a/experimental/examples/minesweeper/src/macosMain/kotlin/main.macos.kt
+++ b/experimental/examples/minesweeper/src/macosMain/kotlin/main.macos.kt
@@ -30,21 +30,6 @@ fun main() {
}
@Composable
-actual fun loadImage(src: String): Painter {
- // TODO Bundle pics and show images properly
- val color = when (src) {
- "assets/clock.png" -> Color.Blue
- "assets/flag.png" -> Color.Green
- "assets/mine.png" -> Color.Red
- else -> Color.White
- }
-
- return object : Painter() {
- override val intrinsicSize: Size
- get() = Size(16f, 16f)
+actual fun loadImage(src: String): Painter = loadImageAsColoredRect(src)
- override fun DrawScope.onDraw() {
- drawRect(color = color)
- }
- }
-}
+actual fun isMobileDevice() = false
\ No newline at end of file
diff --git a/experimental/examples/minesweeper/src/uikitMain/kotlin/main.uikit.kt b/experimental/examples/minesweeper/src/uikitMain/kotlin/main.uikit.kt
index 0eba731740..1cfea076b5 100644
--- a/experimental/examples/minesweeper/src/uikitMain/kotlin/main.uikit.kt
+++ b/experimental/examples/minesweeper/src/uikitMain/kotlin/main.uikit.kt
@@ -3,46 +3,21 @@
* 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.Box
-import androidx.compose.foundation.layout.Column
-import androidx.compose.foundation.layout.height
import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
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.unit.dp
import androidx.compose.ui.window.Application
import androidx.compose.ui.main.defaultUIKitMain
fun main() {
defaultUIKitMain("Minesweeper", Application("Minesweeper") {
- Column {
- // To skip upper part of screen.
- Box(modifier = Modifier
- .height(100.dp))
- Game()
- }
+ Game()
})
}
@Composable
-actual fun loadImage(src: String): Painter {
- // TODO Bundle pics and show images properly
- val color = when (src) {
- "assets/clock.png" -> Color.Blue
- "assets/flag.png" -> Color.Green
- "assets/mine.png" -> Color.Red
- else -> Color.White
- }
+actual fun loadImage(src: String): Painter = loadImageAsColoredRect(src)
- return object : Painter() {
- override val intrinsicSize: Size
- get() = Size(16f, 16f)
-
- override fun DrawScope.onDraw() {
- drawRect(color = color)
- }
- }
-}
\ No newline at end of file
+actual fun isMobileDevice() = true
\ No newline at end of file