package moe.lava.neon

import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import moe.lava.neon.ui.App
import moe.lava.neon.ui.di.initKoin

// The UI is designed with touchscreens in mind; on desktop elements may look gigantic
// So scale them down a bit
const val scaleFactor = 0.75f

fun main() = application {
    initKoin {
        printLogger()
    }
    Window(
        onCloseRequest = ::exitApplication,
        title = "Neon",
    ) {
        val systemScale = System.getenv("GDK_SCALE")?.toFloatOrNull() ?: 1f
        val systemDpiScale = System.getenv("GDK_DPI_SCALE")?.toFloatOrNull() ?: 1f
        val density = Density(
            density = LocalDensity.current.density * systemScale * scaleFactor,
            fontScale = systemDpiScale
        )
        CompositionLocalProvider(LocalDensity provides density) {
            App()
        }
    }
}
