diff --git a/templates/desktop-template/build.gradle.kts b/templates/desktop-template/build.gradle.kts index 10f1f249c2..0f44468c04 100644 --- a/templates/desktop-template/build.gradle.kts +++ b/templates/desktop-template/build.gradle.kts @@ -10,12 +10,13 @@ plugins { repositories { mavenCentral() + google() maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") google() } dependencies { - implementation(compose.desktop.currentOs) + implementation(compose.desktop.macos_x64) } compose.desktop { diff --git a/templates/desktop-template/src/main/kotlin/main.kt b/templates/desktop-template/src/main/kotlin/main.kt index 3c1383e436..6a3bc61e7f 100644 --- a/templates/desktop-template/src/main/kotlin/main.kt +++ b/templates/desktop-template/src/main/kotlin/main.kt @@ -1,23 +1,27 @@ +import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.material.Text import androidx.compose.material.Button import androidx.compose.material.MaterialTheme -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue +import androidx.compose.runtime.* import androidx.compose.ui.window.Window import androidx.compose.ui.window.application -fun main() = application { - Window(onCloseRequest = ::exitApplication) { - var text by remember { mutableStateOf("Hello, World!") } +@Composable +@Preview +fun Screen() { + var text by remember { mutableStateOf("Hello, World!") } - MaterialTheme { - Button(onClick = { - text = "Hello, Desktop!" - }) { - Text(text) - } + MaterialTheme { + Button(onClick = { + text = "Hello, Desktop!" + }) { + Text(text) } } } + +fun main() = application { + Window(onCloseRequest = ::exitApplication) { + Screen() + } +} diff --git a/templates/multiplatform-template/common/build.gradle.kts b/templates/multiplatform-template/common/build.gradle.kts index ec7c4db090..454570df68 100644 --- a/templates/multiplatform-template/common/build.gradle.kts +++ b/templates/multiplatform-template/common/build.gradle.kts @@ -18,6 +18,11 @@ kotlin { api(compose.material) } } + named("desktopMain") { + dependencies { + implementation(compose.uiTooling) + } + } named("androidMain") { dependencies { api("androidx.appcompat:appcompat:1.3.0-beta01") diff --git a/templates/multiplatform-template/common/src/desktopMain/kotlin/DesktopApp.kt b/templates/multiplatform-template/common/src/desktopMain/kotlin/DesktopApp.kt index f3c8941cf5..77dd9128f6 100644 --- a/templates/multiplatform-template/common/src/desktopMain/kotlin/DesktopApp.kt +++ b/templates/multiplatform-template/common/src/desktopMain/kotlin/DesktopApp.kt @@ -1 +1,10 @@ -actual fun getPlatformName(): String = "Desktop" \ No newline at end of file +import androidx.compose.runtime.Composable +import androidx.compose.desktop.ui.tooling.preview.Preview + +actual fun getPlatformName(): String = "Desktop" + +@Preview +@Composable +fun AppPreview() { + App() +} \ No newline at end of file