-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dfad24
commit 67c2877
Showing
20 changed files
with
133 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,48 @@ | ||
package dev.schlaubi.tonbrett.app | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.ui.graphics.Color | ||
|
||
object ColorScheme { | ||
val container = Color(17, 18, 20) | ||
val secondaryContainer = Color(43, 45, 49) | ||
val searchBarColor = Color(30, 31, 34) | ||
val textColor = Color.White | ||
val active = Color(87, 242, 135) | ||
val disabled = Color.LightGray | ||
val blurple = Color(88, 101, 242) | ||
val error = Color(237, 66, 69) | ||
// Currently no auto update, due to: https://github.com/JetBrains/compose-multiplatform/issues/1986 | ||
@Composable | ||
expect fun isSystemInDarkMode(): Boolean | ||
|
||
sealed interface ColorScheme { | ||
val container: Color | ||
val secondaryContainer: Color | ||
val searchBarColor: Color | ||
val textColor: Color | ||
val active: Color | ||
val disabled: Color | ||
val blurple: Color | ||
val error: Color | ||
|
||
companion object { | ||
val current: ColorScheme | ||
@Composable | ||
get() = if (isSystemInDarkMode()) DarkColorScheme else LightColorTheme | ||
} | ||
} | ||
|
||
private object DarkColorScheme : ColorScheme { | ||
override val container = Color(17, 18, 20) | ||
override val secondaryContainer = Color(43, 45, 49) | ||
override val searchBarColor = Color(30, 31, 34) | ||
override val textColor = Color.White | ||
override val active = Color(87, 242, 135) | ||
override val disabled = Color.LightGray | ||
override val blurple = Color(88, 101, 242) | ||
override val error = Color(237, 66, 69) | ||
} | ||
|
||
private object LightColorTheme : ColorScheme { | ||
override val container = Color(255, 255, 255) | ||
override val secondaryContainer = Color(242, 243, 245) | ||
override val searchBarColor = Color(227, 229, 232) | ||
override val textColor = Color.Black | ||
override val active = Color(87, 242, 135) | ||
override val disabled = Color.DarkGray | ||
override val blurple = Color(88, 101, 242) | ||
override val error = Color(237, 66, 69) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/shared/src/desktopMain/kotlin/dev/schlaubi/tonbrett/app/ColorScheme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.schlaubi.tonbrett.app | ||
|
||
import androidx.compose.runtime.* | ||
import com.jthemedetecor.OsThemeDetector | ||
import org.jetbrains.skiko.SystemTheme | ||
import org.jetbrains.skiko.currentSystemTheme | ||
|
||
@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) | ||
} | ||
} | ||
|
||
return darkTheme | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.schlaubi.tonbrett.app | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.foundation.isSystemInDarkTheme as composeIsSystemInDarkTheme1 | ||
|
||
@Composable | ||
actual fun isSystemInDarkMode() = composeIsSystemInDarkTheme1() |
Oops, something went wrong.