Skip to content

Commit 7fcaa7f

Browse files
committed
[DESIGN/#5] 디자인시스템 테마 적용
1 parent 067a97c commit 7fcaa7f

File tree

5 files changed

+66
-1
lines changed

5 files changed

+66
-1
lines changed

core/designsystem/src/main/java/com/yapp/designsystem/theme/OrbitColors.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.yapp.designsystem.theme
33
import androidx.compose.runtime.getValue
44
import androidx.compose.runtime.mutableStateOf
55
import androidx.compose.runtime.setValue
6+
import androidx.compose.runtime.staticCompositionLocalOf
67
import androidx.compose.ui.graphics.Color
78

89
class OrbitColors(
@@ -111,3 +112,5 @@ class OrbitColors(
111112
success = other.success
112113
}
113114
}
115+
116+
val LocalColors = staticCompositionLocalOf { OrbitColors() }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.yapp.designsystem.theme
2+
3+
import androidx.compose.runtime.Composable
4+
import androidx.compose.runtime.ReadOnlyComposable
5+
6+
object OrbitTheme {
7+
val colors: OrbitColors
8+
@Composable
9+
@ReadOnlyComposable
10+
get() = LocalColors.current
11+
12+
val typography: OrbitTypography
13+
@Composable
14+
@ReadOnlyComposable
15+
get() = LocalTypography.current
16+
}

core/designsystem/src/main/java/com/yapp/designsystem/theme/OrbitTypography.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.yapp.designsystem.theme
22

33
import Pretendard
4+
import androidx.compose.runtime.staticCompositionLocalOf
45
import androidx.compose.ui.text.TextStyle
56
import androidx.compose.ui.text.font.FontWeight
67
import androidx.compose.ui.unit.sp
@@ -161,3 +162,5 @@ data class OrbitTypography(
161162
letterSpacing = (-0.11).sp
162163
)
163164
)
165+
166+
val LocalTypography = staticCompositionLocalOf { OrbitTypography() }
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.yapp.designsystem.theme
2+
3+
import android.app.Activity
4+
import androidx.compose.foundation.isSystemInDarkTheme
5+
import androidx.compose.material3.ProvideTextStyle
6+
import androidx.compose.runtime.Composable
7+
import androidx.compose.runtime.CompositionLocalProvider
8+
import androidx.compose.runtime.SideEffect
9+
import androidx.compose.runtime.remember
10+
import androidx.compose.ui.graphics.toArgb
11+
import androidx.compose.ui.platform.LocalView
12+
import androidx.core.view.WindowCompat
13+
14+
fun orbitColors() = OrbitColors()
15+
fun orbitFonts() = OrbitTypography()
16+
17+
@Composable
18+
fun OrbitTheme(
19+
darkTheme: Boolean = isSystemInDarkTheme(),
20+
colors: OrbitColors = orbitColors(),
21+
darkColors: OrbitColors = orbitColors(),
22+
typography: OrbitTypography = orbitFonts(),
23+
content: @Composable () -> Unit
24+
) {
25+
val currentColor = remember { if (darkTheme) darkColors else colors }
26+
val rememberedColors = remember { currentColor.copy() }.apply { updateColorFrom(currentColor) }
27+
CompositionLocalProvider(
28+
LocalColors provides rememberedColors,
29+
LocalTypography provides typography
30+
) {
31+
ProvideTextStyle(typography.body2Medium, content = content)
32+
}
33+
34+
val view = LocalView.current
35+
36+
if (!view.isInEditMode) {
37+
SideEffect {
38+
val window = (view.context as Activity).window
39+
window.statusBarColor = colors.gray_900.toArgb()
40+
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
41+
}
42+
}
43+
}

feature/navigator/src/main/java/com/yapp/navigator/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import androidx.compose.foundation.layout.only
1212
import androidx.compose.foundation.layout.systemBars
1313
import androidx.compose.foundation.layout.windowInsetsPadding
1414
import androidx.compose.ui.Modifier
15-
import com.yapp.orbit.ui.theme.OrbitTheme
15+
import com.yapp.designsystem.theme.OrbitTheme
1616
import dagger.hilt.android.AndroidEntryPoint
1717

1818
@AndroidEntryPoint

0 commit comments

Comments
 (0)