Skip to content

Commit

Permalink
Fix windows start error
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Nov 19, 2023
1 parent 104497e commit 91611cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
6 changes: 0 additions & 6 deletions app/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ kotlin {
}
}

named("desktopMain") {
dependencies {
implementation(libs.os.theme.detector)
}
}

androidMain {
dependencies {
implementation(libs.androidx.browser)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
package dev.schlaubi.tonbrett.app

import androidx.compose.runtime.*
import com.jthemedetecor.OsThemeDetector
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import org.jetbrains.skiko.SystemTheme
import org.jetbrains.skiko.currentSystemTheme
import kotlin.time.Duration.Companion.seconds

@Composable
actual fun isSystemInDarkMode(): Boolean {
var darkTheme by remember {
mutableStateOf(currentSystemTheme == SystemTheme.DARK)
}

DisposableEffect(Unit) {
val darkThemeListener = { isDarkTheme: Boolean ->
darkTheme = isDarkTheme
}

val detector = OsThemeDetector.getDetector().apply {
registerListener(darkThemeListener)
}

onDispose {
detector.removeListener(darkThemeListener)
LaunchedEffect(Unit) {
while (isActive) {
darkTheme = currentSystemTheme == SystemTheme.DARK
delay(1.seconds)
}
}

Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-p

android-gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "android" }

os-theme-detector = { group = "com.github.Dansoftowner", name = "jSystemThemeDetector", version = "3.6" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
Expand Down

0 comments on commit 91611cc

Please sign in to comment.