Browse Source

Remove DesktopMaterialTheme from documentation and tenmplates

pull/1227/head
Igor Demin 3 years ago
parent
commit
fc98620ed7
  1. 4
      templates/desktop-template/src/main/kotlin/main.kt
  2. 3
      templates/multiplatform-template/android/src/main/java/com/myapplication/MainActivity.kt
  3. 3
      templates/multiplatform-template/common/src/commonMain/kotlin/App.kt
  4. 3
      templates/multiplatform-template/desktop/src/jvmMain/kotlin/main.kt
  5. 83
      tutorials/Desktop_Components/README.md
  6. BIN
      tutorials/Desktop_Components/themed_scrollbar.gif

4
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!"
}) {

3
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()
}
}
}
}

3
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,6 +9,7 @@ import androidx.compose.runtime.setValue
@Composable
fun App() {
MaterialTheme {
var text by remember { mutableStateOf("Hello, World!") }
Button(onClick = {
@ -16,5 +18,6 @@ fun App() {
Text(text)
}
}
}
expect fun getPlatformName(): String

3
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()
}
}
}

83
tutorials/Desktop_Components/README.md

@ -172,89 +172,6 @@ fun TextBox(text: String = "Item") {
<img alt="Lazy component" src="lazy_scrollbar.gif" height="412" />
## 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)
}
}
```
<img alt="Themed scrollbar" src="themed_scrollbar.gif" height="412" />
## 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`.

BIN
tutorials/Desktop_Components/themed_scrollbar.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 MiB

Loading…
Cancel
Save