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.desktop.ui.tooling.preview.Preview
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.material.Button import androidx.compose.material.Button
@ -11,7 +12,7 @@ import androidx.compose.ui.window.application
fun Screen() { fun Screen() {
var text by remember { mutableStateOf("Hello, World!") } var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme { DesktopMaterialTheme {
Button(onClick = { Button(onClick = {
text = "Hello, Desktop!" 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 android.os.Bundle
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.MaterialTheme
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContent { setContent {
MaterialTheme {
App() App()
} }
} }
} }
}

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

@ -7,13 +7,11 @@ import androidx.compose.runtime.*
fun App() { fun App() {
var text by remember { mutableStateOf("Hello, World!") } var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
Button(onClick = { Button(onClick = {
text = "Hello, ${getPlatformName()}" text = "Hello, ${getPlatformName()}"
}) { }) {
Text(text) Text(text)
} }
} }
}
expect fun getPlatformName(): String 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.Window
import androidx.compose.ui.window.application import androidx.compose.ui.window.application
fun main() = application { fun main() = application {
Window(onCloseRequest = ::exitApplication) { Window(onCloseRequest = ::exitApplication) {
DesktopMaterialTheme {
App() App()
} }
} }
}
Loading…
Cancel
Save