Created
December 18, 2020 12:00
-
-
Save tkuenneth/456853d36ae31ff9f2cf9ead1cd87e70 to your computer and use it in GitHub Desktop.
A Compose for Desktop example showing an AlertDialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thomaskuenneth | |
import androidx.compose.desktop.AppManager | |
import androidx.compose.desktop.Window | |
import androidx.compose.material.AlertDialog | |
import androidx.compose.material.Button | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.mutableStateOf | |
import androidx.compose.runtime.remember | |
import androidx.compose.ui.window.Menu | |
import androidx.compose.ui.window.MenuBar | |
import androidx.compose.ui.window.MenuItem | |
fun main() { | |
AppManager.setMenu(MenuBar( | |
Menu("File", MenuItem("Quit", onClick = { | |
AppManager.exit() | |
})) | |
)) | |
Window(title = "AlertDialogDemo") { | |
val show = remember { mutableStateOf(false) } | |
Button(onClick = { | |
show.value = true | |
}) { | |
Text("Show AlertDialog") | |
} | |
if (show.value) { | |
AlertDialog(onDismissRequest = {}, | |
title = { | |
Text("A title") | |
}, | |
text = { | |
Text("A text") | |
}, | |
confirmButton = { | |
Button(onClick = {}) { | |
Text("A button") | |
} | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment