import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPlacement
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import org.jetbrains.compose.resources.painterResource
import yaep.composeapp.generated.resources.Res
import yaep.composeapp.generated.resources.moon

fun main() = application {
    Window(
        onCloseRequest = ::exitApplication,
        undecorated = true,
        title = "YAEP",
        icon = painterResource(Res.drawable.moon)
    ) {
        var useDarkMode by remember { mutableStateOf(true) }
        DesktopWindow(
            useDarkMode = useDarkMode,
            topBar = {
                AppBar(
                    useDarkMode = useDarkMode,
                    setDarkMode = { useDarkMode = it },
                    onCloseRequest = ::exitApplication,
                    windowState = rememberWindowState(
                        placement = WindowPlacement.Floating
                    )
                )
            }
        ) {
            App(modifier = Modifier.padding(it))
        }
    }
}