-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
디자인시스템 color / typography 기반 잡기 (#32)
* feat : declare DobeDobeColors * feat : declare DobeDobeTypography * feat : apply colors and typography to Theme * refactor : lint * refactor : line break
- Loading branch information
Showing
3 changed files
with
135 additions
and
72 deletions.
There are no files selected for viewing
31 changes: 25 additions & 6 deletions
31
core/designsystem/src/main/kotlin/com/chipichipi/dobedobe/core/designsystem/theme/Color.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 |
---|---|---|
@@ -1,11 +1,30 @@ | ||
package com.chipichipi.dobedobe.core.designsystem.theme | ||
|
||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.graphics.Color | ||
|
||
val Purple80 = Color(0xFFD0BCFF) | ||
val PurpleGrey80 = Color(0xFFCCC2DC) | ||
val Pink80 = Color(0xFFEFB8C8) | ||
@Immutable | ||
class DobeDobeColors(isDarkTheme: Boolean = false) { | ||
val gray50 = Color(0xFFF9FAFB) | ||
val gray100 = Color(0xFFF3F4F6) | ||
val gray200 = Color(0xFFE5E7EB) | ||
val gray300 = Color(0xFFF0F5FC) | ||
val gray400 = Color(0xFF9CA3AF) | ||
val gray500 = Color(0xFF7A828C) | ||
val gray600 = Color(0xFF5F6875) | ||
val gray700 = Color(0xFF48505C) | ||
val gray800 = Color(0xFF333945) | ||
val gray900 = Color(0xFF262C36) | ||
|
||
val Purple40 = Color(0xFF6650a4) | ||
val PurpleGrey40 = Color(0xFF625b71) | ||
val Pink40 = Color(0xFF7D5260) | ||
val green1 = Color(0xFFD0BCFF) | ||
val green2 = Color(0xFFD0BCFF) | ||
val green3 = Color(0xFFD0BCFF) | ||
|
||
val white = Color.White | ||
val black = Color.Black | ||
|
||
val red = Color(0xFFD0BCFF) | ||
} | ||
|
||
internal val LocalDobeDobeColors = staticCompositionLocalOf { DobeDobeColors() } |
56 changes: 18 additions & 38 deletions
56
core/designsystem/src/main/kotlin/com/chipichipi/dobedobe/core/designsystem/theme/Theme.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 |
---|---|---|
@@ -1,65 +1,45 @@ | ||
package com.chipichipi.dobedobe.core.designsystem.theme | ||
|
||
import android.os.Build | ||
import androidx.annotation.ChecksSdkIntAtLeast | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material3.MaterialTheme | ||
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.runtime.ReadOnlyComposable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.platform.LocalContext | ||
|
||
private val DarkColorScheme = | ||
darkColorScheme( | ||
primary = Purple80, | ||
secondary = PurpleGrey80, | ||
tertiary = Pink80, | ||
) | ||
|
||
private val LightColorScheme = | ||
lightColorScheme( | ||
primary = Purple40, | ||
secondary = PurpleGrey40, | ||
tertiary = Pink40, | ||
) | ||
|
||
// TODO : change Light/Dark color | ||
private val LightAndroidBackgroundTheme = BackgroundTheme(color = Color.White) | ||
private val DarkAndroidBackgroundTheme = BackgroundTheme(color = Color.White) | ||
|
||
object DobeDobeTheme { | ||
val typography: DobeDobeTypography | ||
@ReadOnlyComposable | ||
@Composable | ||
get() = LocalDobeDobeTypography.current | ||
|
||
val colors: DobeDobeColors | ||
@ReadOnlyComposable | ||
@Composable | ||
get() = LocalDobeDobeColors.current | ||
} | ||
|
||
@Composable | ||
fun DobeDobeTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
dynamicColor: Boolean = true, | ||
content: @Composable () -> Unit, | ||
) { | ||
val colorScheme = | ||
when { | ||
dynamicColor && supportsDynamicTheming() -> { | ||
val context = LocalContext.current | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> DarkColorScheme | ||
else -> LightColorScheme | ||
} | ||
|
||
val backgroundTheme = if (darkTheme) DarkAndroidBackgroundTheme else LightAndroidBackgroundTheme | ||
val typography = remember { DobeDobeTypography() } | ||
val colors = remember { DobeDobeColors(darkTheme) } | ||
|
||
CompositionLocalProvider( | ||
LocalBackgroundTheme provides backgroundTheme, | ||
LocalDobeDobeTypography provides typography, | ||
LocalDobeDobeColors provides colors, | ||
) { | ||
MaterialTheme( | ||
colorScheme = colorScheme, | ||
typography = Typography, | ||
content = content, | ||
) | ||
} | ||
} | ||
|
||
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.S) | ||
private fun supportsDynamicTheming() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S |
120 changes: 92 additions & 28 deletions
120
core/designsystem/src/main/kotlin/com/chipichipi/dobedobe/core/designsystem/theme/Type.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 |
---|---|---|
@@ -1,36 +1,100 @@ | ||
package com.chipichipi.dobedobe.core.designsystem.theme | ||
|
||
import androidx.compose.material3.Typography | ||
import androidx.compose.runtime.Immutable | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.font.FontFamily | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.unit.sp | ||
|
||
// Set of Material typography styles to start with | ||
val Typography = | ||
Typography( | ||
bodyLarge = | ||
TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 16.sp, | ||
lineHeight = 24.sp, | ||
letterSpacing = 0.5.sp, | ||
), | ||
/* Other default text styles to override | ||
titleLarge = TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 22.sp, | ||
lineHeight = 28.sp, | ||
letterSpacing = 0.sp | ||
), | ||
labelSmall = TextStyle( | ||
fontFamily = FontFamily.Default, | ||
fontWeight = FontWeight.Medium, | ||
fontSize = 11.sp, | ||
lineHeight = 16.sp, | ||
letterSpacing = 0.5.sp | ||
) | ||
*/ | ||
@Immutable | ||
data class DobeDobeTypography internal constructor( | ||
val title1: TextStyle, | ||
val title2: TextStyle, | ||
val heading1: TextStyle, | ||
val heading2: TextStyle, | ||
val body1: TextStyle, | ||
val body2: TextStyle, | ||
val body3: TextStyle, | ||
val caption1: TextStyle, | ||
val caption2: TextStyle, | ||
) { | ||
constructor( | ||
systemFontFamily: FontFamily = FontFamily.Default, | ||
title1: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Bold, | ||
fontSize = 28.sp, | ||
lineHeight = 42.sp, | ||
letterSpacing = -(0.504).sp, | ||
), | ||
title2: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Bold, | ||
fontSize = 24.sp, | ||
lineHeight = 36.sp, | ||
letterSpacing = -(0.432).sp, | ||
), | ||
heading1: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.SemiBold, | ||
fontSize = 22.sp, | ||
lineHeight = 33.sp, | ||
letterSpacing = -(0.396).sp, | ||
), | ||
heading2: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.SemiBold, | ||
fontSize = 17.sp, | ||
lineHeight = 25.5.sp, | ||
letterSpacing = -(0.306).sp, | ||
), | ||
body1: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 16.sp, | ||
lineHeight = 24.sp, | ||
letterSpacing = -(0.288).sp, | ||
), | ||
body2: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 15.sp, | ||
lineHeight = 22.5.sp, | ||
letterSpacing = -(0.27).sp, | ||
), | ||
body3: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 14.sp, | ||
lineHeight = 21.sp, | ||
letterSpacing = -(0.252).sp, | ||
), | ||
caption1: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 12.sp, | ||
lineHeight = 18.sp, | ||
letterSpacing = -(0.216).sp, | ||
), | ||
caption2: TextStyle = TextStyle( | ||
fontFamily = systemFontFamily, | ||
fontWeight = FontWeight.Normal, | ||
fontSize = 10.sp, | ||
lineHeight = 15.sp, | ||
letterSpacing = -(0.18).sp, | ||
), | ||
) : this( | ||
title1 = title1, | ||
title2 = title2, | ||
heading1 = heading1, | ||
heading2 = heading2, | ||
body1 = body1, | ||
body2 = body2, | ||
body3 = body3, | ||
caption1 = caption1, | ||
caption2 = caption2, | ||
) | ||
} | ||
|
||
internal val LocalDobeDobeTypography = staticCompositionLocalOf { DobeDobeTypography() } |