Skip to content

Commit 49451ab

Browse files
committed
Dark Theme
1 parent 4258417 commit 49451ab

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ android {
4949

5050
dependencies {
5151
implementation("io.coil-kt:coil-compose:2.2.2")
52+
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
5253
implementation "com.google.accompanist:accompanist-flowlayout:$accompanist_version"
5354
implementation "com.google.accompanist:accompanist-pager:$accompanist_version"
5455
implementation "com.google.accompanist:accompanist-pager-indicators:$accompanist_version"

app/src/main/java/com/example/doubanmovie/ui/movie/MovieScreen.kt

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ import com.example.doubanmovie.data.MovieComment
4646
import com.example.doubanmovie.data.MovieItem
4747
import com.example.doubanmovie.ui.components.RatingBar
4848
import com.example.doubanmovie.ui.theme.DoubanMovieTheme
49-
import com.example.doubanmovie.ui.theme.Grey100
50-
import com.example.doubanmovie.ui.theme.Grey200
49+
import com.example.doubanmovie.ui.theme.LightGrey
5150
import com.google.accompanist.flowlayout.FlowRow
5251
import com.google.accompanist.pager.ExperimentalPagerApi
5352
import com.google.accompanist.pager.HorizontalPager
@@ -394,10 +393,9 @@ fun MovieRank() {
394393
}
395394
item {
396395
Surface(
397-
color = Color.LightGray.copy(alpha = 0.2f),
398-
contentColor = Color.Gray,
399396
modifier = Modifier.fillMaxHeight(),
400-
shape = RoundedCornerShape(10.dp),
397+
color = LightGrey,
398+
shape = MaterialTheme.shapes.medium,
401399
) {
402400
Column(
403401
modifier = Modifier.padding(16.dp),
@@ -479,7 +477,8 @@ fun SearchMovieBody(onFilterItemClick: () -> Unit = {}) {
479477
}
480478
items(tagList) { item ->
481479
Surface(
482-
color = Grey100,
480+
modifier = Modifier.fillMaxHeight(),
481+
color = Color.LightGray.copy(0.2f),
483482
shape = MaterialTheme.shapes.small,
484483
) {
485484
Text(
@@ -573,10 +572,10 @@ fun FilterItem(
573572
contentPadding = PaddingValues(12.dp)
574573
) {
575574
items(data.items) { item ->
576-
Card(
575+
Surface(
577576
modifier = Modifier.padding(4.dp),
578-
backgroundColor = Color.LightGray.copy(alpha = 0.2f),
579-
elevation = 0.dp,
577+
color = LightGrey,
578+
shape = MaterialTheme.shapes.small
580579
) {
581580
Text(
582581
item,
@@ -739,7 +738,7 @@ fun MovieFavorite(favorite: Boolean = false) {
739738
fun MovieTags(tags: List<String>) {
740739
FlowRow(mainAxisSpacing = 8.dp, crossAxisSpacing = 8.dp) {
741740
tags.forEach { item ->
742-
Surface(color = Grey200, shape = RoundedCornerShape(4.dp)) {
741+
Surface(color = LightGrey, shape = MaterialTheme.shapes.small) {
743742
Row(
744743
modifier = Modifier.padding(4.dp),
745744
verticalAlignment = Alignment.CenterVertically
@@ -1018,11 +1017,6 @@ private val movieList = listOf(
10181017
"https://img2.doubanio.com/view/photo/m_ratio_poster/public/p2879301401.webp",
10191018
rating = 7.6f
10201019
),
1021-
MovieItem(
1022-
"妈妈!",
1023-
"https://img2.doubanio.com/view/photo/m_ratio_poster/public/p2879572001.webp",
1024-
rating = 7.4f
1025-
),
10261020
MovieItem(
10271021
"平凡英雄",
10281022
"https://img3.doubanio.com/view/photo/m_ratio_poster/public/p2880994870.webp",

app/src/main/java/com/example/doubanmovie/ui/theme/Color.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ package com.example.doubanmovie.ui.theme
22

33
import androidx.compose.ui.graphics.Color
44

5-
val Purple200 = Color(0xFFBB86FC)
6-
val Purple500 = Color(0xFF6200EE)
75
val Purple700 = Color(0xFF3700B3)
8-
val Teal200 = Color(0xFF03DAC5)
96

107
val Green200 = Color(0xFF01B62C)
118
val Orange200 = Color(0xFFFF8C0E)
12-
13-
val Grey50 = Color(0xFFFAFAFA)
14-
val Grey100 = Color(0xFFF5F5F5)
15-
val Grey200 = Color(0xFFEEEEEE)
9+
val LightGrey = Color.LightGray.copy(0.2f)

app/src/main/java/com/example/doubanmovie/ui/theme/Theme.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import androidx.compose.material.MaterialTheme
55
import androidx.compose.material.darkColors
66
import androidx.compose.material.lightColors
77
import androidx.compose.runtime.Composable
8+
import com.google.accompanist.systemuicontroller.rememberSystemUiController
89

910
private val DarkColorPalette = darkColors(
10-
primary = Purple200,
11+
primary = Green200,
1112
primaryVariant = Purple700,
12-
secondary = Teal200
13+
secondary = Orange200
1314
)
1415

1516
private val LightColorPalette = lightColors(
@@ -34,6 +35,11 @@ fun DoubanMovieTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Compo
3435
} else {
3536
LightColorPalette
3637
}
38+
val systemUiController = rememberSystemUiController()
39+
systemUiController.setSystemBarsColor(
40+
color = colors.background
41+
)
42+
3743

3844
MaterialTheme(
3945
colors = colors,

0 commit comments

Comments
 (0)