Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
*/
package soup.movie.core.designsystem.theme

import androidx.compose.material3.ColorScheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Stable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color

@Stable
data class MovieColors(
internal val material: ColorScheme,
val star: Color,
val dim: Color,
val cgv: Color,
Expand All @@ -39,19 +35,9 @@ data class MovieColors(
val ageTag19: Color,
val ageTagAll: Color,
val ageTagUnknown: Color,
) {
val primary: Color get() = material.primary
val secondary: Color get() = material.secondary
val background: Color get() = material.background
val surface: Color get() = material.surface
val error: Color get() = material.error
val onBackground: Color get() = material.onBackground
val onSurface: Color get() = material.onSurface
val onError: Color get() = material.onError
}
)

fun lightMovieColors(
material: ColorScheme = lightColorScheme(),
star: Color = Color(0xFFFFC107),
dim: Color = Color(0xDDFFFFFF),
cgv: Color = Color.White,
Expand All @@ -67,7 +53,6 @@ fun lightMovieColors(
ageTagAll: Color = Color(0xFF4CAF50),
ageTagUnknown: Color = Color(0xFF9E9E9E),
): MovieColors = MovieColors(
material = material,
star = star,
dim = dim,
cgv = cgv,
Expand All @@ -85,7 +70,6 @@ fun lightMovieColors(
)

fun darkMovieColors(
material: ColorScheme = darkColorScheme(),
star: Color = Color(0xFFFFC107),
dim: Color = Color(0xAA000000),
cgv: Color = Color.White,
Expand All @@ -101,7 +85,6 @@ fun darkMovieColors(
ageTagAll: Color = Color(0xFF81C784),
ageTagUnknown: Color = Color(0xFFE0E0E0),
): MovieColors = MovieColors(
material = material,
star = star,
dim = dim,
cgv = cgv,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,51 @@
*/
package soup.movie.core.designsystem.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.ColorScheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Shapes
import androidx.compose.material3.Typography
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.platform.LocalContext

private val LightMovieColors = lightMovieColors(
material = lightColorScheme(),
)
private val LightMovieColors = lightMovieColors()

private val DarkMovieColors = darkMovieColors(
material = darkColorScheme(),
)
private val DarkMovieColors = darkMovieColors()

@Composable
fun MovieTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit,
) {
val colors = if (darkTheme) {
val movieColors = if (darkTheme) {
DarkMovieColors
} else {
LightMovieColors
}
CompositionLocalProvider(LocalMovieColors provides colors) {
val context = LocalContext.current
val colors = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (darkTheme) {
dynamicDarkColorScheme(context = context)
} else {
dynamicLightColorScheme(context = context)
}
} else {
if (darkTheme) {
darkColorScheme()
} else {
lightColorScheme()
}
}
CompositionLocalProvider(LocalMovieColors provides movieColors) {
MaterialTheme(
colorScheme = colors.material,
colorScheme = colors,
content = content,
)
}
Expand All @@ -56,6 +71,10 @@ object MovieTheme {
@Composable
get() = LocalMovieColors.current

val colorScheme: ColorScheme
@Composable
get() = MaterialTheme.colorScheme

val typography: Typography
@Composable
get() = MaterialTheme.typography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,25 @@ fun BoxOffice(
) {
Text(
text = "박스오피스",
color = MovieTheme.colors.onSurface,
style = MovieTheme.typography.bodyMedium,
modifier = Modifier.alpha(0.7f),
)
Text(
text = stringResource(R.string.rank, uiModel.rank),
color = MovieTheme.colors.onSurface,
style = MovieTheme.typography.titleMedium,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(top = 2.dp),
)
Text(
text = stringResource(R.string.rank_date, uiModel.rankDate),
color = MovieTheme.colors.surface,
color = MovieTheme.colorScheme.surface,
style = MovieTheme.typography.bodyMedium,
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier
.padding(top = 6.dp)
.background(
color = MovieTheme.colors.onSurface,
color = MovieTheme.colorScheme.onSurface,
shape = RoundedCornerShape(percent = 50),
)
.padding(vertical = 1.dp, horizontal = 8.dp),
Expand All @@ -88,28 +85,28 @@ fun BoxOffice(
) {
Text(
text = "누적 관객수",
color = MovieTheme.colors.onSurface,
color = MovieTheme.colorScheme.onSurface,
style = MovieTheme.typography.bodyMedium,
modifier = Modifier.alpha(0.7f),
)
Text(
text = stringResource(R.string.audience, uiModel.audience),
color = MovieTheme.colors.onSurface,
color = MovieTheme.colorScheme.onSurface,
style = MovieTheme.typography.titleMedium,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(top = 2.dp),
)
Text(
text = stringResource(R.string.screen_days, uiModel.screenDays),
color = MovieTheme.colors.surface,
color = MovieTheme.colorScheme.surface,
style = MovieTheme.typography.bodyMedium,
fontSize = 12.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier
.padding(top = 6.dp)
.background(
color = MovieTheme.colors.onSurface,
color = MovieTheme.colorScheme.onSurface,
shape = RoundedCornerShape(percent = 50),
)
.padding(vertical = 1.dp, horizontal = 8.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal fun DetailError(
) {
Text(
text = stringResource(R.string.common_retry),
color = MovieTheme.colors.secondary,
color = MovieTheme.colorScheme.secondary,
modifier = Modifier.padding(horizontal = 16.dp),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal fun DetailHeader(
modifier = Modifier
.weight(1f)
.padding(end = 8.dp, top = 12.dp, bottom = 12.dp),
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.headlineSmall,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
Expand Down Expand Up @@ -114,14 +114,14 @@ internal fun DetailHeader(
Row {
Text(
text = "개봉",
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.alpha(0.5f),
)
Text(
text = movie.openDate,
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.fillMaxWidth().padding(start = 8.dp),
Expand All @@ -133,7 +133,7 @@ internal fun DetailHeader(
Row(modifier = Modifier.padding(top = 8.dp)) {
Text(
text = "등급",
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.alpha(0.5f),
Expand All @@ -148,7 +148,7 @@ internal fun DetailHeader(
else -> R.string.movie_age_unknown
},
),
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.fillMaxWidth().padding(start = 8.dp),
Expand All @@ -161,14 +161,14 @@ internal fun DetailHeader(
Row(modifier = Modifier.padding(top = 8.dp)) {
Text(
text = "장르",
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.alpha(0.5f),
)
Text(
text = genres.joinToString(separator = ", "),
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.fillMaxWidth().padding(start = 8.dp),
Expand All @@ -182,14 +182,14 @@ internal fun DetailHeader(
Row(modifier = Modifier.padding(top = 8.dp)) {
Text(
text = "국가",
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.alpha(0.5f),
)
Text(
text = nations.joinToString(separator = ", "),
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.fillMaxWidth().padding(start = 8.dp),
Expand All @@ -203,14 +203,14 @@ internal fun DetailHeader(
Row(modifier = Modifier.padding(top = 8.dp)) {
Text(
text = "러닝타임",
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.alpha(0.5f),
)
Text(
text = stringResource(R.string.time_minute, uiModel.showTm),
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.fillMaxWidth().padding(start = 8.dp),
Expand All @@ -228,14 +228,14 @@ internal fun DetailHeader(
Row(modifier = Modifier.padding(top = 8.dp)) {
Text(
text = "배급",
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.alpha(0.5f),
)
Text(
text = companies,
color = MovieTheme.colors.onBackground,
color = MovieTheme.colorScheme.onBackground,
style = MovieTheme.typography.bodyMedium,
fontSize = 14.sp,
modifier = Modifier.fillMaxWidth().padding(start = 8.dp),
Expand Down
Loading
Loading