Browse Source

Migrate desktop templates/tutorials to 0.5.0-build226

pull/807/head
Igor Demin 3 years ago
parent
commit
cd7f4f4587
  1. 3
      tutorials/Tray_Notifications_MenuBar_new/README.md
  2. 22
      tutorials/Window_API_new/README.md

3
tutorials/Tray_Notifications_MenuBar_new/README.md

@ -38,6 +38,7 @@ fun main() = application {
if (isOpen) { if (isOpen) {
Window( Window(
onCloseRequest = ::exitApplication,
icon = remember { getMyAppIcon() } icon = remember { getMyAppIcon() }
) { ) {
val trayState = rememberTrayState() val trayState = rememberTrayState()
@ -136,7 +137,7 @@ fun main() {
if (isOpen) { if (isOpen) {
var isSubmenuShowing by remember { mutableStateOf(false) } var isSubmenuShowing by remember { mutableStateOf(false) }
Window { Window(onCloseRequest = { isOpen = false }) {
MenuBar { MenuBar {
Menu("Actions") { Menu("Actions") {
Item( Item(

22
tutorials/Window_API_new/README.md

@ -147,11 +147,11 @@ import java.awt.image.BufferedImage
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
fun main() = application { fun main() = application {
val state = rememberWindowState() var isVisible by remember { mutableStateOf(true) }
Window( Window(
onCloseRequest = { state.isVisible = false }, onCloseRequest = { isVisible = false },
state, visible = isVisible,
title = "Counter", title = "Counter",
) { ) {
var counter by remember { mutableStateOf(0) } var counter by remember { mutableStateOf(0) }
@ -164,13 +164,13 @@ fun main() = application {
Text(counter.toString()) Text(counter.toString())
} }
if (!state.isVisible && state.isOpen) { if (!isVisible) {
Tray( Tray(
remember { getTrayIcon() }, remember { getTrayIcon() },
hint = "Counter", hint = "Counter",
onAction = { state.isVisible = true }, onAction = { isVisible = true },
menu = { menu = {
Item("Exit", onClick = { state.isOpen = false }) Item("Exit", onClick = ::exitApplication)
}, },
) )
} }
@ -273,6 +273,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPlacement import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.application import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState import androidx.compose.ui.window.rememberWindowState
@ -429,12 +430,17 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogState
import androidx.compose.ui.window.Window import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.application import androidx.compose.ui.window.application
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
fun main() = application { fun main() = application {
Window { Window(
onCloseRequest = ::exitApplication,
) {
var isDialogOpen by remember { mutableStateOf(false) } var isDialogOpen by remember { mutableStateOf(false) }
Button(onClick = { isDialogOpen = true }) { Button(onClick = { isDialogOpen = true }) {
@ -444,7 +450,7 @@ fun main() = application {
if (isDialogOpen) { if (isDialogOpen) {
Dialog( Dialog(
onCloseRequest = { isDialogOpen = false }, onCloseRequest = { isDialogOpen = false },
initialAlignment = Alignment.Center state = DialogState(position = WindowPosition(Alignment.Center))
) { ) {
// Dialog's content // Dialog's content
} }

Loading…
Cancel
Save