diff --git a/composeApp/src/commonMain/kotlin/ui/presentation/App.kt b/composeApp/src/commonMain/kotlin/ui/presentation/App.kt index fc9f567..ba286d0 100644 --- a/composeApp/src/commonMain/kotlin/ui/presentation/App.kt +++ b/composeApp/src/commonMain/kotlin/ui/presentation/App.kt @@ -1,6 +1,7 @@ package ui.presentation import androidx.compose.animation.AnimatedContent +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.* import androidx.compose.material3.* import androidx.compose.runtime.* @@ -17,6 +18,7 @@ import ui.composables.AttributedString import ui.composables.FooterView import ui.theme.AppTheme +@OptIn(ExperimentalMaterial3Api::class) @Composable @Preview fun App(darkTheme: Boolean, dynamicColor: Boolean, viewModel: AppViewModel) { @@ -29,6 +31,8 @@ fun App(darkTheme: Boolean, dynamicColor: Boolean, viewModel: AppViewModel) { var length by remember { mutableFloatStateOf(20f) } var textState by remember { mutableStateOf("") } + val interactionSource = remember { MutableInteractionSource() } + LaunchedEffect(Unit) { textState = viewModel.getRandomString(length = length.toInt()) } @@ -62,16 +66,21 @@ fun App(darkTheme: Boolean, dynamicColor: Boolean, viewModel: AppViewModel) { verticalAlignment = Alignment.CenterVertically ) { Slider( - colors = SliderDefaults.colors(thumbColor = Color.White), modifier = Modifier.width(200.dp), value = length, valueRange = 10f..25f, onValueChange = { isAnimating = true length = it - textState = viewModel.getRandomString(length = length.toInt()) + textState = viewModel.getRandomString(length = length.toInt()) + }, + thumb = { + SliderDefaults.Thumb( + interactionSource = interactionSource, + modifier = Modifier.height(30.dp) + ) }, - onValueChangeFinished = { isAnimating = false } + onValueChangeFinished = { isAnimating = false }, ) Text( text = "${length.toInt()}", diff --git a/composeApp/src/desktopMain/kotlin/main.kt b/composeApp/src/desktopMain/kotlin/main.kt index bab1bdd..75db1ed 100644 --- a/composeApp/src/desktopMain/kotlin/main.kt +++ b/composeApp/src/desktopMain/kotlin/main.kt @@ -2,7 +2,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.window.Window @@ -12,22 +11,21 @@ import di.SettingsProvider.provideSettingsRepository import ui.presentation.App import ui.presentation.AppViewModel -fun main() = application { +fun main() { val viewModel = AppViewModel( passwordGeneratorRepository = providePasswordGeneratorRepository(), settingsRepository = provideSettingsRepository() ) - Window(onCloseRequest = ::exitApplication, title = "AuroraKMP") { - Box( - modifier = Modifier - .background(if (isSystemInDarkTheme()) Color.Black else Color.White) - .fillMaxSize() - ) { - App( - darkTheme = isSystemInDarkTheme(), - dynamicColor = false, - viewModel = remember { viewModel } - ) + + application { + Window(onCloseRequest = ::exitApplication, title = "AuroraKMP") { + Box( + modifier = Modifier + .background(if (isSystemInDarkTheme()) Color.Black else Color.White) + .fillMaxSize() + ) { + App(darkTheme = isSystemInDarkTheme(), dynamicColor = false, viewModel = viewModel) + } } } }