teksturepako
12/03/2024, 5:48 PMval windowData by WindowViewModel.windowData.collectAsState()
val windowState = rememberWindowState(
placement = windowData.placement,
isMinimized = windowData.isMinimized,
position = if (windowData.x != null && windowData.y != null)
{
WindowPosition.Absolute(x = windowData.x!!.dp, y = windowData.y!!.dp)
}
else WindowPosition(Alignment.Center),
width = windowData.width.dp,
height = windowData.height.dp
)
I load the windowState
from the windowData
which is a data class that saves the data to the disk as JSON when the application is closed, and loads it when you open the app.
DecoratedWindow(
state = windowState, // Here is the state used
onCloseRequest = {
WindowViewModel.updateWindowData(windowState) // Here I update the state using the custom view model
exitApplication()
exitProcess(0)
},
title = appName,
icon = painterResource("icons/pakku.svg"),
style = DecoratedWindowStyle.light()
) {
...
The issue is that the WindowPlacement
doesn't work. If I maximize the app and close it. This gets written to the disk:
{
"placement": "Maximized",
"isMinimized": false,
"x": -8,
"y": -8,
"width": 1936,
"height": 1056
}
But when I open the app the window is not maximized.
Is there anything I can do to maximize the window?