// SPDX-License-Identifier: GPL-3.0-or-later // MyIce Kotlin Multiplatform — schedule/convocation viewer // Copyright (C) 2026 parano.ch // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package ch.parano.myicek import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Window import androidx.compose.ui.window.WindowPosition import androidx.compose.ui.window.application import androidx.compose.ui.window.rememberWindowState import ch.parano.myicek.auth.DesktopOAuthClient import com.russhwolf.settings.Settings import java.util.prefs.Preferences fun main() = application { val storage = WindowStateStorage(Settings()) val saved = storage.load() val windowState = rememberWindowState( width = saved?.width?.dp ?: 1024.dp, height = saved?.height?.dp ?: 768.dp, position = if (saved != null) WindowPosition(saved.x.dp, saved.y.dp) else WindowPosition(0.dp, 0.dp), ) Window( onCloseRequest = ::exitApplication, title = "MyIce", state = windowState, ) { LaunchedEffect(Unit) { snapshotFlow { windowState.size to windowState.position } .collect { (size, position) -> storage.save( width = size.width.value.toInt(), height = size.height.value.toInt(), x = position.x.value.toInt(), y = position.y.value.toInt(), ) Preferences.userRoot().flush() } } App(oauthClient = DesktopOAuthClient()) } }