Skip to content
Snippets Groups Projects
Commit fda95709 authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

Add language chooser

parent d8c72b22
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,10 @@ import app.softwork.bootstrapcompose.Color ...@@ -5,8 +5,10 @@ import app.softwork.bootstrapcompose.Color
import components.* import components.*
import kotlinx.browser.localStorage import kotlinx.browser.localStorage
import kotlinx.browser.window import kotlinx.browser.window
import localization.English
import localization.Hungarian import localization.Hungarian
import localization.LocalLang import localization.LocalLang
import localization.Localization
import org.jetbrains.compose.web.css.* import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.* import org.jetbrains.compose.web.dom.*
import org.jetbrains.compose.web.renderComposable import org.jetbrains.compose.web.renderComposable
...@@ -32,7 +34,7 @@ fun main() { ...@@ -32,7 +34,7 @@ fun main() {
?: window.matchMedia("(prefers-color-scheme: dark)").matches ?: window.matchMedia("(prefers-color-scheme: dark)").matches
var mosogepStyle by mutableStateOf(Style(dark)) var mosogepStyle by mutableStateOf(Style(dark))
val lang = Hungarian() var lang by mutableStateOf<Localization>(Hungarian())
renderComposable(rootElementId = "root") { renderComposable(rootElementId = "root") {
Style(mosogepStyle) Style(mosogepStyle)
Style(CardStyle) Style(CardStyle)
...@@ -71,6 +73,9 @@ fun main() { ...@@ -71,6 +73,9 @@ fun main() {
) )
Text("MosógépSCH") Text("MosógépSCH")
} }
Div(
attrs = { classes(mosogepStyle.options) }
) {
switch( switch(
label = "Sötét téma", label = "Sötét téma",
value = mosogepStyle.dark, value = mosogepStyle.dark,
...@@ -79,6 +84,19 @@ fun main() { ...@@ -79,6 +84,19 @@ fun main() {
localStorage["darkMode"] = "$it" localStorage["darkMode"] = "$it"
} }
) )
// todo make this a dropdown menu
switch(
label = "magyar",
value = lang is Hungarian,
onSet = {
if (lang is Hungarian) {
lang = English()
} else {
lang = Hungarian()
}
}
)
}
} }
} }
Main(attrs = { Main(attrs = {
......
...@@ -47,6 +47,6 @@ fun Localization.machineStatus(status: MachineStatus): String = when(status) { ...@@ -47,6 +47,6 @@ fun Localization.machineStatus(status: MachineStatus): String = when(status) {
MachineStatus.NotAvailable -> notAvailable MachineStatus.NotAvailable -> notAvailable
} }
val LocalLang = compositionLocalOf { Hungarian() } val LocalLang = compositionLocalOf<Localization> { Hungarian() }
fun Int.padded() = this.toString().padStart(2, '0') fun Int.padded() = this.toString().padStart(2, '0')
\ No newline at end of file
...@@ -42,6 +42,11 @@ class Style(val dark: Boolean = false): StyleSheet() { ...@@ -42,6 +42,11 @@ class Style(val dark: Boolean = false): StyleSheet() {
flexGrow(0) flexGrow(0)
property("z-index", 2000) property("z-index", 2000)
} }
val options by style {
display(DisplayStyle.Flex)
flexDirection(FlexDirection.Row)
gap(1.em)
}
} }
val LocalStyle = compositionLocalOf { Style() } val LocalStyle = compositionLocalOf { Style() }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment