Skip to content

Commit

Permalink
Use system look and feel by default
Browse files Browse the repository at this point in the history
  • Loading branch information
szeweq committed Mar 1, 2021
1 parent 0c3db43 commit d7d5e97
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions src/main/kotlin/szewek/craftery/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,49 @@ import szewek.craftery.layout.TabsView
import szewek.craftery.layout.ViewManager
import szewek.craftery.layout.hover
import szewek.craftery.views.*
import javax.swing.UIManager

internal val colorsDark = darkColors(
primary = Color(0xff394739),
onPrimary = Color.White
)

fun main() = Window(title = "Craftery") {
DesktopMaterialTheme(
colors = colorsDark
) {
Scaffold(
topBar = {
TopAppBar(Modifier.height(40.dp)) {
Row(Modifier.fillMaxHeight().weight(1f), verticalAlignment = Alignment.CenterVertically) {
TabsView(ViewManager.views)
}
Box(Modifier.fillMaxHeight().requiredWidth(28.dp).padding(vertical = 6.dp)) {
val menuToggle = remember { mutableStateOf(false) }
val iconSize = 28.dp
val dismiss = { menuToggle.value = false }
fun main() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
} catch (e: Exception) {
println("Unable to set system Look and Feel")
e.printStackTrace()
}

IconButton({ menuToggle.value = true }) {
Icon(Icons.Default.Menu, "Menu", Modifier.size(iconSize))
Window(title = "Craftery") {
DesktopMaterialTheme(
colors = colorsDark
) {
Scaffold(
topBar = {
TopAppBar(Modifier.height(40.dp)) {
Row(Modifier.fillMaxHeight().weight(1f), verticalAlignment = Alignment.CenterVertically) {
TabsView(ViewManager.views)
}
DropdownMenu(menuToggle.value, dismiss, offset = DpOffset(-iconSize, 0.dp)) {
menuContent(dismiss)
Box(Modifier.fillMaxHeight().requiredWidth(28.dp).padding(vertical = 6.dp)) {
val menuToggle = remember { mutableStateOf(false) }
val iconSize = 28.dp
val dismiss = { menuToggle.value = false }

IconButton({ menuToggle.value = true }) {
Icon(Icons.Default.Menu, "Menu", Modifier.size(iconSize))
}
DropdownMenu(menuToggle.value, dismiss, offset = DpOffset(-iconSize, 0.dp)) {
menuContent(dismiss)
}
}
}
}
) {
val v = ViewManager.active
if (v == null) welcome() else v.content()
}
) {
val v = ViewManager.active
if (v == null) welcome() else v.content()
}
}
}
Expand Down

0 comments on commit d7d5e97

Please sign in to comment.