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
51 changes: 45 additions & 6 deletions app/src/main/java/com/kiero/core/designsystem/theme/Color.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,50 @@
package com.kiero.core.designsystem.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color

val Purple80 = Color(0xFFD0BCFF)
val PurpleGrey80 = Color(0xFFCCC2DC)
val Pink80 = Color(0xFFEFB8C8)
val White = Color(0xFFFFFFFF)
val Gray100 = Color(0xFFF5F5F5)
val Gray200 = Color(0xFFD6D6D6)
val Gray300 = Color(0xFFC2C2C2)
val Gray400 = Color(0xFFADADAD)
val Gray500 = Color(0xFF999999)
val Gray600 = Color(0xFF848484)
val Gray700 = Color(0xFF707070)
val Gray800 = Color(0xFF5C5C5C)
val Gray900 = Color(0xFF2D2F34)
val Black = Color(0xFF232428)

val Purple40 = Color(0xFF6650a4)
val PurpleGrey40 = Color(0xFF625b71)
val Pink40 = Color(0xFF7D5260)
val Main = Color(0xFF00FFE1)
val Schedule1 = Color(0xFFCFFFFA)
val Schedule2 = Color(0xFFFFFEE9)
val Schedule3 = Color(0xFFBFFFE3)
val Schedule4 = Color(0xFF34D9D3)
val Schedule5 = Color(0xFF7BBDFF)
val Point = Color(0xFFFF7BA2)

@Immutable
data class KieroColors(
val white: Color = White,
val black: Color = Black,

val main: Color = Main,
val schedule1: Color = Schedule1,
val schedule2: Color = Schedule2,
val schedule3: Color = Schedule3,
val schedule4: Color = Schedule4,
val schedule5: Color = Schedule5,
val point: Color = Point,

val gray100: Color = Gray100,
val gray200: Color = Gray200,
val gray300: Color = Gray300,
val gray400: Color = Gray400,
val gray500: Color = Gray500,
val gray600: Color = Gray600,
val gray700: Color = Gray700,
val gray800: Color = Gray800,
val gray900: Color = Gray900,
)

val defaultKieroColors = KieroColors()
86 changes: 45 additions & 41 deletions app/src/main/java/com/kiero/core/designsystem/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,57 +1,61 @@
package com.kiero.core.designsystem.theme

import android.os.Build
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.ui.platform.LocalContext
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.staticCompositionLocalOf

private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)
val localKieroColors = staticCompositionLocalOf { defaultKieroColors }

val localKieroTypography = staticCompositionLocalOf { defaultKieroTypography }

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40

/* Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
primary = Black,
background = White,
surface = White,
onPrimary = White,
onBackground = Black,
onSurface = Black
)

object KieroTheme {
val colors: KieroColors
@Composable
@ReadOnlyComposable
get() = localKieroColors.current

val typography: KieroTypography
@Composable
@ReadOnlyComposable
get() = localKieroTypography.current
}

@Composable
fun KieroTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
fun ProvideKieroColorsAndTypography(
colors: KieroColors,
typography: KieroTypography,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
CompositionLocalProvider(
localKieroColors provides colors,
localKieroTypography provides typography,
content = content
)
}

@Composable
fun KieroTheme(
content: @Composable () -> Unit
) {
ProvideKieroColorsAndTypography(
colors = defaultKieroColors,
typography = defaultKieroTypography
) {
MaterialTheme(
colorScheme = LightColorScheme,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

갓승재) LightTheme로 고정이니까, 명시적으로 적어준거 아주 좋은데요

content = content
)
}
}
180 changes: 155 additions & 25 deletions app/src/main/java/com/kiero/core/designsystem/theme/Type.kt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3) 피그마 DS 보다가 생각난건데용 별건아니고...
보통 typography 에 행간,자간 별로 세분화되어있는 케이스가 많은데 지금 프로젝트에서는 각 font(SemiBold,Bold,Regular) 마다 행간, 자간이 하나로 통일된게 많아서 아래 처럼 상수로 빼줘도 좋을 것 같긴합니다.
ex) SemiBold 행간 130% -> 140% 으로 변경해주세요! 했을 때 일괄적으로 변경하기 쉬울 것 같아서 써봤어요. 안고쳐도 되고 그냥 참고만.. ㅎㅎ

private object TypographyDefaults {
    val RegularLetterSpacing = (-0.005).em
    val RegularLineHeight = 1.3.em
    
    val SemiBoldLetterSpacing = (-0.01).em
    val SemiBoldLineHeight = 1.4.em
    
    val BoldLetterSpacing = (-0.01).em
    val BoldLineHeight = 1.4.em
}
  body1 = TextStyle(
            fontFamily = NotoSansFont.regular,
            fontSize = 18.sp,
            letterSpacing = TypographyDefaults.RegularLetterSpacing,
            lineHeight = TypographyDefaults.RegularLineHeight,
        ),
//사용할 때 이런식으로?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추가적으로 만약 어떻게 해도 뭔가 디자인과 안맞는다 싶으면 TextStyle의 파라미터 중 하나인

platformStyle = PlatformTextStyle(
                includeFontPadding = false 
            ),
            

을 통해 안드로이드 폰트 기본 패딩을 제거해보고 사용해보셔도 좋을 것 같아요 이거도 혹시나 필요하다면 이런게 있다 정도만 생각해셔도 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상수로 빼주니 깔끔하네요!

Original file line number Diff line number Diff line change
@@ -1,35 +1,165 @@
package com.kiero.core.designsystem.theme

import androidx.compose.material3.Typography
import androidx.compose.runtime.Immutable
import androidx.compose.ui.text.PlatformTextStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import com.kiero.R

// 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
object NotoSansFont {
val semiBold = FontFamily(Font(R.font.notosans_semibold))
val bold = FontFamily(Font(R.font.notosans_bold))
val regular = FontFamily(Font(R.font.notosans_regular))
}

private object TypographyDefaults {
val RegularLetterSpacing = (-0.005).em
val RegularLineHeight = 1.3.em

val SemiBoldLetterSpacing = (-0.01).em
val SemiBoldLineHeight = 1.4.em

val BoldLetterSpacing = (-0.01).em
val BoldLineHeight = 1.4.em

val PlatformStyle = PlatformTextStyle(
includeFontPadding = false
)
/* 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
}

sealed interface TypographyTokens {
@Immutable
data class Regular(
val body1: TextStyle,
val body2: TextStyle,
val body3: TextStyle,
val body4: TextStyle,
val body5: TextStyle,
)

@Immutable
data class SemiBold(
val title1: TextStyle,
val title2: TextStyle,
val title3: TextStyle,
val title4: TextStyle,
)
*/

@Immutable
data class Bold(
val headLine1: TextStyle,
val headLine2: TextStyle,
val headLine3: TextStyle,
val headLine4: TextStyle,
)
}

@Immutable
data class KieroTypography(
val regular: TypographyTokens.Regular,
val semiBold: TypographyTokens.SemiBold,
val bold: TypographyTokens.Bold,
)

val defaultKieroTypography = KieroTypography(
regular = TypographyTokens.Regular(
body1 = TextStyle(
fontFamily = NotoSansFont.regular,
fontSize = 18.sp,
letterSpacing = TypographyDefaults.RegularLetterSpacing,
lineHeight = TypographyDefaults.RegularLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
body2 = TextStyle(
fontFamily = NotoSansFont.regular,
fontSize = 16.sp,
letterSpacing = TypographyDefaults.RegularLetterSpacing,
lineHeight = TypographyDefaults.RegularLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
body3 = TextStyle(
fontFamily = NotoSansFont.regular,
fontSize = 14.sp,
letterSpacing = TypographyDefaults.RegularLetterSpacing,
lineHeight = TypographyDefaults.RegularLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
body4 = TextStyle(
fontFamily = NotoSansFont.regular,
fontSize = 12.sp,
letterSpacing = TypographyDefaults.RegularLetterSpacing,
lineHeight = TypographyDefaults.RegularLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
body5 = TextStyle(
fontFamily = NotoSansFont.regular,
fontSize = 10.sp,
letterSpacing = TypographyDefaults.RegularLetterSpacing,
lineHeight = TypographyDefaults.RegularLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
),
semiBold = TypographyTokens.SemiBold(
title1 = TextStyle(
fontFamily = NotoSansFont.semiBold,
fontSize = 22.sp,
letterSpacing = TypographyDefaults.SemiBoldLetterSpacing,
lineHeight = TypographyDefaults.SemiBoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
title2 = TextStyle(
fontFamily = NotoSansFont.semiBold,
fontSize = 20.sp,
letterSpacing = TypographyDefaults.SemiBoldLetterSpacing,
lineHeight = TypographyDefaults.SemiBoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
title3 = TextStyle(
fontFamily = NotoSansFont.semiBold,
fontSize = 16.sp,
letterSpacing = TypographyDefaults.SemiBoldLetterSpacing,
lineHeight = TypographyDefaults.SemiBoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
title4 = TextStyle(
fontFamily = NotoSansFont.semiBold,
fontSize = 14.sp,
letterSpacing = TypographyDefaults.SemiBoldLetterSpacing,
lineHeight = TypographyDefaults.SemiBoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
),
bold = TypographyTokens.Bold(
headLine1 = TextStyle(
fontFamily = NotoSansFont.bold,
fontSize = 22.sp,
letterSpacing = TypographyDefaults.BoldLetterSpacing,
lineHeight = TypographyDefaults.BoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
headLine2 = TextStyle(
fontFamily = NotoSansFont.bold,
fontSize = 20.sp,
letterSpacing = TypographyDefaults.BoldLetterSpacing,
lineHeight = TypographyDefaults.BoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
headLine3 = TextStyle(
fontFamily = NotoSansFont.bold,
fontSize = 16.sp,
letterSpacing = TypographyDefaults.BoldLetterSpacing,
lineHeight = TypographyDefaults.BoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
),
headLine4 = TextStyle(
fontFamily = NotoSansFont.bold,
fontSize = 14.sp,
letterSpacing = TypographyDefaults.BoldLetterSpacing,
lineHeight = TypographyDefaults.BoldLineHeight,
platformStyle = TypographyDefaults.PlatformStyle
)
)
)
Binary file added app/src/main/res/font/notosans_bold.ttf
Binary file not shown.
Binary file added app/src/main/res/font/notosans_regular.ttf
Binary file not shown.
Binary file added app/src/main/res/font/notosans_semibold.ttf
Binary file not shown.