Browse Source

App templates: change code

pull/3/head
Igor Demin 4 years ago
parent
commit
9ae0b36750
  1. 16
      templates/desktop-template/src/main/kotlin/main.kt
  2. 1
      templates/multiplatform-template/common/src/androidMain/kotlin/AndroidApp.kt
  3. 18
      templates/multiplatform-template/common/src/commonMain/kotlin/App.kt
  4. 1
      templates/multiplatform-template/common/src/desktopMain/kotlin/DesktopApp.kt

16
templates/desktop-template/src/main/kotlin/main.kt

@ -1,6 +1,20 @@
import androidx.compose.desktop.Window
import androidx.compose.foundation.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
fun main() = Window {
Text("Hello, World!")
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
Button(onClick = {
text = "Hello, Desktop!"
}) {
Text(text)
}
}
}

1
templates/multiplatform-template/common/src/androidMain/kotlin/AndroidApp.kt

@ -0,0 +1 @@
actual fun getPlatformName(): String = "Android"

18
templates/multiplatform-template/common/src/commonMain/kotlin/App.kt

@ -1,7 +1,19 @@
import androidx.compose.foundation.Text
import androidx.compose.runtime.Composable
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.*
@Composable
fun App() {
Text("Hello, World!")
}
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
Button(onClick = {
text = "Hello, ${getPlatformName()}"
}) {
Text(text)
}
}
}
expect fun getPlatformName(): String

1
templates/multiplatform-template/common/src/desktopMain/kotlin/DesktopApp.kt

@ -0,0 +1 @@
actual fun getPlatformName(): String = "Desktop"
Loading…
Cancel
Save