Guilherme Delgado
07/20/2022, 10:12 AMGuilherme Delgado
07/20/2022, 10:13 AMfun main() = application {
var expand by remember { mutableStateOf(false) }
val width: Dp by animateDpAsState(
targetValue = if (expand) 1024.dp else 600.dp,
animationSpec = tween(durationMillis = 250, easing = FastOutSlowInEasing),
)
val height: Dp by animateDpAsState(
targetValue = if (expand) 1024.dp else 600.dp,
animationSpec = tween(durationMillis = 250, easing = FastOutSlowInEasing),
)
val dpSize: DpSize by remember { mutableStateOf(DpSize(width, height)) }
val windowState = rememberWindowState(size = dpSize)
Window(state = windowState) {
MyComposable(
onSomething = {
expand = !expand
//windowState.size = dpSize
})
}
}
Guilherme Delgado
07/20/2022, 10:15 AM//windowState.size = dpSize
directly, but this will not animate 🤔Guilherme Delgado
07/20/2022, 10:15 AMSean Proctor
07/24/2022, 8:08 PMwindowState.size = dpSize
immediately after val windowState = ...
Sean Proctor
07/24/2022, 8:19 PMLaunchedEffect(dpSize) {
windowState.size = dpSize
}
Guilherme Delgado
07/25/2022, 9:12 AMonSomething
- in this case - it’s actually being called inside a LaunchedEffect
, but the key is not the dpSize 🤔 will try to add it as key to see what happens (edit: nothing 😢).Guilherme Delgado
07/25/2022, 11:35 AMGuilherme Delgado
07/25/2022, 11:36 AMLaunchedEffect(animate) {
repeat(5) {
delay(1000)
windowState.size = DpSize(windowState.size.width + 100.dp, windowState.size.height)
}
}
quick test and this is the only way I can “animate” the windowState.size
🤮Guilherme Delgado
07/25/2022, 2:25 PM/**
* Creates a [WindowState] that is remembered across compositions.
*
* Changes to the provided initial values will **not** result in the state being recreated or
* changed in any way if it has already been created.
*
* @param placement the initial value for [WindowState.placement]
* @param isMinimized the initial value for [WindowState.isMinimized]
* @param position the initial value for [WindowState.position]
* @param size the initial value for [WindowState.size]
*/
🤔Sean Proctor
07/27/2022, 11:28 PMGuilherme Delgado
07/28/2022, 9:26 AM