Browse Source

Use DesktopMaterialTheme instead of MaterialTheme

update-web-docs
Igor Demin 3 years ago
parent
commit
19d7eabc7f
  1. 3
      templates/desktop-template/src/main/kotlin/main.kt
  2. 3
      templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt
  3. 2
      templates/multiplatform-template/common/src/commonMain/kotlin/App.kt
  4. 3
      templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt

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

@ -1,3 +1,4 @@
import androidx.compose.desktop.DesktopMaterialTheme
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.material.Text
import androidx.compose.material.Button
@ -11,7 +12,7 @@ import androidx.compose.ui.window.application
fun Screen() {
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
DesktopMaterialTheme {
Button(onClick = {
text = "Hello, Desktop!"
}) {

3
templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt

@ -4,13 +4,16 @@ import App
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MaterialTheme {
App()
}
}
}
}

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

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

3
templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt

@ -1,8 +1,11 @@
import androidx.compose.desktop.DesktopMaterialTheme
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
DesktopMaterialTheme {
App()
}
}
}
Loading…
Cancel
Save