diff --git a/templates/desktop-template/src/main/kotlin/main.kt b/templates/desktop-template/src/main/kotlin/main.kt index 5a7386dd8a..fed3f24ab9 100644 --- a/templates/desktop-template/src/main/kotlin/main.kt +++ b/templates/desktop-template/src/main/kotlin/main.kt @@ -1,6 +1,6 @@ -import androidx.compose.desktop.DesktopMaterialTheme import androidx.compose.desktop.ui.tooling.preview.Preview import androidx.compose.material.Button +import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -15,7 +15,7 @@ import androidx.compose.ui.window.application fun App() { var text by remember { mutableStateOf("Hello, World!") } - DesktopMaterialTheme { + MaterialTheme { Button(onClick = { text = "Hello, Desktop!" }) { diff --git a/templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt b/templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt index ea85703371..52cb3575e1 100644 --- a/templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt +++ b/templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt @@ -4,16 +4,13 @@ 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() - } + App() } } } \ No newline at end of file diff --git a/templates/multiplatform-template/common/src/commonMain/kotlin/App.kt b/templates/multiplatform-template/common/src/commonMain/kotlin/App.kt index 8595c8b72e..543a87dabc 100644 --- a/templates/multiplatform-template/common/src/commonMain/kotlin/App.kt +++ b/templates/multiplatform-template/common/src/commonMain/kotlin/App.kt @@ -1,4 +1,5 @@ import androidx.compose.material.Button +import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -8,12 +9,14 @@ import androidx.compose.runtime.setValue @Composable fun App() { - var text by remember { mutableStateOf("Hello, World!") } + MaterialTheme { + var text by remember { mutableStateOf("Hello, World!") } - Button(onClick = { - text = "Hello, ${getPlatformName()}" - }) { - Text(text) + Button(onClick = { + text = "Hello, ${getPlatformName()}" + }) { + Text(text) + } } } diff --git a/templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt b/templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt index d60069e49a..2543564b01 100644 --- a/templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt +++ b/templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt @@ -1,11 +1,8 @@ -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() - } + App() } } \ No newline at end of file diff --git a/tutorials/Desktop_Components/README.md b/tutorials/Desktop_Components/README.md index 2413fbb314..65a50933f8 100644 --- a/tutorials/Desktop_Components/README.md +++ b/tutorials/Desktop_Components/README.md @@ -172,89 +172,6 @@ fun TextBox(text: String = "Item") { Lazy component -## Theme applying - -Scrollbars support themes to change their appearance. The example below shows how to use the `DesktopMaterialTheme` appearance for the scrollbar. - -```kotlin -import androidx.compose.desktop.DesktopMaterialTheme -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.fillMaxHeight -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.rememberScrollbarAdapter -import androidx.compose.foundation.rememberScrollState -import androidx.compose.material.Text -import androidx.compose.foundation.VerticalScrollbar -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.verticalScroll -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import androidx.compose.ui.window.Window -import androidx.compose.ui.window.application -import androidx.compose.ui.window.rememberWindowState - -fun main() = application { - Window( - onCloseRequest = ::exitApplication, - title = "Scrollbars", - state = rememberWindowState(width = 250.dp, height = 400.dp) - ) { - DesktopMaterialTheme { - Box( - modifier = Modifier.fillMaxSize() - .background(color = Color(180, 180, 180)) - .padding(10.dp) - ) { - val state = rememberScrollState(0) - - Column( - modifier = Modifier - .verticalScroll(state) - .fillMaxSize() - .padding(end = 12.dp) - ) { - for (item in 0..30) { - TextBox("Item #$item") - if (item < 30) { - Spacer(modifier = Modifier.height(5.dp)) - } - } - } - VerticalScrollbar( - modifier = Modifier.align(Alignment.CenterEnd) - .fillMaxHeight(), - adapter = rememberScrollbarAdapter(state) - ) - } - } - } -} - -@Composable -fun TextBox(text: String = "Item") { - Box( - modifier = Modifier.height(32.dp) - .fillMaxWidth() - .background(color = Color(0, 0, 0, 20)) - .padding(start = 10.dp), - contentAlignment = Alignment.CenterStart - ) { - Text(text = text) - } -} -``` - -Themed scrollbar - - ## Tooltips You can add tooltip to any components using `BoxWithTooltip`. Basically `BoxWithTooltip` is a `Box` with the ability to show a tooltip, and has the same arguments and behavior as `Box`. diff --git a/tutorials/Desktop_Components/themed_scrollbar.gif b/tutorials/Desktop_Components/themed_scrollbar.gif deleted file mode 100644 index 75bec0473b..0000000000 Binary files a/tutorials/Desktop_Components/themed_scrollbar.gif and /dev/null differ