Skip to content

Commit d0bad79

Browse files
committed
Update dark mode detection to use platformtools library
Replaced `isSystemInDarkTheme()` with `isSystemInDarkMode()` for dark mode detection using the `platformtools` library. Updated dependency version to `0.2.9` and replaced references in theme configuration and desktop app setup. Ensure compatibility and alignment with the updated library API.
1 parent 451ceab commit d0bad79

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

application/composeApp/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ kotlin {
6363

6464
implementation(libs.compose.navigation)
6565
implementation(libs.platformtools.darkmodedetector)
66-
6766
}
6867
}
6968

application/composeApp/src/jvmMain/kotlin/io/writeopia/desktop/MainDesktop.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,17 @@ import androidx.compose.material.CircularProgressIndicator
66
import androidx.compose.runtime.Composable
77
import androidx.compose.runtime.LaunchedEffect
88
import androidx.compose.runtime.collectAsState
9-
import androidx.compose.runtime.getValue
109
import androidx.compose.runtime.rememberCoroutineScope
1110
import androidx.compose.ui.Alignment
1211
import androidx.compose.ui.Modifier
1312
import androidx.compose.ui.input.key.KeyEvent
1413
import androidx.compose.ui.input.key.isAltPressed
1514
import androidx.compose.ui.unit.dp
16-
import androidx.compose.ui.window.ApplicationScope
17-
import androidx.compose.ui.window.Window
18-
import androidx.compose.ui.window.WindowPlacement
19-
import androidx.compose.ui.window.WindowPosition
20-
import androidx.compose.ui.window.application
21-
import androidx.compose.ui.window.rememberWindowState
15+
import androidx.compose.ui.window.*
2216
import io.github.kdroidfilter.platformtools.darkmodedetector.isSystemInDarkMode
2317
import io.github.kdroidfilter.platformtools.darkmodedetector.windows.setWindowsAdaptiveTitleBar
2418
import io.writeopia.common.utils.keyboard.KeyboardCommands
2519
import io.writeopia.common.utils.ui.GlobalToastBox
26-
import io.writeopia.model.isDarkTheme
2720
import io.writeopia.notemenu.di.UiConfigurationInjector
2821
import io.writeopia.notes.desktop.components.DesktopApp
2922
import io.writeopia.resources.CommonImages
@@ -165,9 +158,10 @@ private fun ApplicationScope.App(onCloseRequest: () -> Unit = ::exitApplication)
165158
},
166159
icon = CommonImages.logo()
167160
) {
168-
//Synchronize the topbar on Windows OS with the System Theme
161+
// Synchronize the topbar on Windows OS with the System Theme
169162
window.setWindowsAdaptiveTitleBar(
170-
dark = isSystemInDarkMode() //TODO Syncrhonize with the selected Theme by the user
163+
dark = isSystemInDarkMode()
164+
// TODO Syncrhonize with the selected Theme by the user
171165
)
172166

173167
Box(Modifier.fillMaxSize()) {

application/core/theme/src/commonMain/kotlin/io/writeopia/theme/Theme.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.writeopia.theme
22

3-
import androidx.compose.foundation.isSystemInDarkTheme
43
import androidx.compose.material3.MaterialTheme
54
import androidx.compose.material3.darkColorScheme
65
import androidx.compose.material3.lightColorScheme
@@ -9,6 +8,7 @@ import androidx.compose.runtime.CompositionLocalProvider
98
import androidx.compose.runtime.Immutable
109
import androidx.compose.runtime.staticCompositionLocalOf
1110
import androidx.compose.ui.graphics.Color
11+
import io.github.kdroidfilter.platformtools.darkmodedetector.isSystemInDarkMode
1212

1313
private val DarkColorPalette = darkColorScheme(
1414
primary = LIGHT_PURPLE,
@@ -71,7 +71,7 @@ val LocalWriteopiaColors = staticCompositionLocalOf {
7171

7272
@Composable
7373
fun WrieopiaTheme(
74-
darkTheme: Boolean = isSystemInDarkTheme(),
74+
darkTheme: Boolean = isSystemInDarkMode(),
7575
content: @Composable () -> Unit
7676
) {
7777
val globalBackground = if (darkTheme) Color(0xFF252525) else Color(0xFFF8F0F9)

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ ktlint = "12.1.2"
1616
ktx = "1.15.0"
1717
appCompat = "1.7.0"
1818
material = "1.12.0"
19-
platformtoolsDarkmodedetector = "0.2.8"
19+
platformtools = "0.2.9"
2020
postgresSocketFactory = "1.15.1"
2121
room = "2.7.0-beta01"
2222
compose = "2.8.7"
23-
agp = "8.6.1"
23+
agp = "8.9.0"
2424
kotlin = "2.1.10"
2525
composeTest = "1.7.8"
2626
webWorkerDriver = "2.0.0"
@@ -86,7 +86,7 @@ ktor-server-websocket = { module = "io.ktor:ktor-server-websockets-jvm" }
8686
ktor-server-netty = { module = "io.ktor:ktor-server-netty-jvm" }
8787
ktor-server-tests = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
8888
#material3-desktop = { module = "org.jetbrains.compose.material3:material3-desktop", version.ref = "material3" }
89-
platformtools-darkmodedetector = { module = "io.github.kdroidfilter:platformtools.darkmodedetector", version.ref = "platformtoolsDarkmodedetector" }
89+
platformtools-darkmodedetector = { module = "io.github.kdroidfilter:platformtools.darkmodedetector", version.ref = "platformtools" }
9090
sql-postgres-socket-factory = { module = "com.google.cloud.sql:postgres-socket-factory", version.ref = "postgresSocketFactory" }
9191
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
9292
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }

0 commit comments

Comments
 (0)