feat(macos):add background color for desktop app

This commit is contained in:
tapframe 2026-04-18 01:18:28 +05:30
parent da1b83c3b7
commit 462b81f8ad
2 changed files with 36 additions and 6 deletions

View file

@ -281,6 +281,16 @@ dependencies {
compose.desktop { compose.desktop {
application { application {
mainClass = "com.nuvio.app.DesktopAppKt" mainClass = "com.nuvio.app.DesktopAppKt"
nativeDistributions {
macOS {
infoPlist {
extraKeysRawXml = """
<key>NSRequiresAquaSystemAppearance</key>
<false/>
""".trimIndent()
}
}
}
} }
} }

View file

@ -1,13 +1,33 @@
package com.nuvio.app package com.nuvio.app
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.window.Window import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application import androidx.compose.ui.window.application
import java.awt.Color as AwtColor
fun main() = application { private val DesktopWindowBackground = AwtColor(0x0D, 0x0D, 0x0D)
Window(
onCloseRequest = ::exitApplication, private fun configureMacOsNativeAppearance() {
title = "Nuvio", val osName = System.getProperty("os.name")?.lowercase() ?: return
) { if (!osName.contains("mac")) return
App() System.setProperty("apple.awt.application.appearance", "NSAppearanceNameDarkAqua")
}
fun main() {
configureMacOsNativeAppearance()
application {
Window(
onCloseRequest = ::exitApplication,
title = "Nuvio",
) {
DisposableEffect(window) {
window.background = DesktopWindowBackground
window.contentPane.background = DesktopWindowBackground
window.rootPane.background = DesktopWindowBackground
onDispose { }
}
App()
}
} }
} }