Skip to content

Commit

Permalink
Remove DesktopMaterialTheme from documentation and tenmplates
Browse files Browse the repository at this point in the history
  • Loading branch information
igordmn committed Sep 28, 2021
1 parent 493d7c7 commit fc98620
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 98 deletions.
4 changes: 2 additions & 2 deletions templates/desktop-template/src/main/kotlin/main.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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!"
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}
83 changes: 0 additions & 83 deletions tutorials/Desktop_Components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Binary file removed tutorials/Desktop_Components/themed_scrollbar.gif
Binary file not shown.

0 comments on commit fc98620

Please sign in to comment.