Skip to content

Commit 5d3f3b9

Browse files
feat(android): add dark mode support following system theme (#101)
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent ef836b7 commit 5d3f3b9

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

android/app/src/main/java/com/pika/app/ui/theme/Color.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ package com.pika.app.ui.theme
33
import androidx.compose.ui.graphics.Color
44

55
val PikaBlue = Color(0xFF2C6BED)
6+
val PikaBlueDark = Color(0xFF5A8DF5)
67
val PikaBg = Color(0xFFF6F7FB)
8+
val PikaBgDark = Color(0xFF121212)
79

android/app/src/main/java/com/pika/app/ui/theme/Theme.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.pika.app.ui.theme
22

3-
import androidx.compose.foundation.background
3+
import androidx.compose.foundation.isSystemInDarkTheme
44
import androidx.compose.material3.MaterialTheme
55
import androidx.compose.material3.darkColorScheme
66
import androidx.compose.material3.lightColorScheme
77
import androidx.compose.runtime.Composable
8-
import androidx.compose.ui.Modifier
98
import androidx.compose.ui.graphics.Color
109

1110
private val LightColors =
@@ -15,10 +14,19 @@ private val LightColors =
1514
background = PikaBg,
1615
)
1716

17+
private val DarkColors =
18+
darkColorScheme(
19+
primary = PikaBlueDark,
20+
surface = Color(0xFF1E1E1E),
21+
background = PikaBgDark,
22+
)
23+
1824
@Composable
1925
fun PikaTheme(content: @Composable () -> Unit) {
26+
val colorScheme = if (isSystemInDarkTheme()) DarkColors else LightColors
27+
2028
MaterialTheme(
21-
colorScheme = LightColors,
29+
colorScheme = colorScheme,
2230
typography = androidx.compose.material3.Typography(),
2331
content = content,
2432
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<resources xmlns:tools="http://schemas.android.com/tools">
2+
<style name="Theme.Pika" parent="Theme.MaterialComponents.DayNight.NoActionBar">
3+
<item name="android:statusBarColor" tools:targetApi="l">@android:color/transparent</item>
4+
<item name="android:windowLightStatusBar" tools:targetApi="m">false</item>
5+
</style>
6+
</resources>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<resources xmlns:tools="http://schemas.android.com/tools">
22
<style name="Theme.Pika" parent="Theme.MaterialComponents.DayNight.NoActionBar">
3-
<item name="android:statusBarColor" tools:targetApi="l">#FFFFFFFF</item>
3+
<item name="android:statusBarColor" tools:targetApi="l">@android:color/transparent</item>
4+
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
45
</style>
56
</resources>

0 commit comments

Comments
 (0)