Skip to content

Commit

Permalink
designsystem module (Background, Gradient 추가) (#14)
Browse files Browse the repository at this point in the history
* [feat] GradientColors

* [feat] BackGroundTheme

* [chore] internal 지시자 추가

* [feat] apply BackgroundTheme, GradientColors

* [chore] designsystem Preview
  • Loading branch information
murjune authored Jan 22, 2024
1 parent fd6b25c commit f90f430
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 5 deletions.
14 changes: 14 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/theme/Background.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.moya.funch.theme

import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp

@Immutable
data class BackgroundTheme(
val color: Color = Color.Unspecified,
val tonalElevation: Dp = Dp.Unspecified,
)

val LocalBackgroundTheme = staticCompositionLocalOf { BackgroundTheme() }
14 changes: 14 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/theme/Gradient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.moya.funch.theme

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

@Immutable
data class GradientColors(
val top: Color = Color.Unspecified,
val bottom: Color = Color.Unspecified,
val container: Color = Color.Unspecified,
)

val LocalGradientColors = staticCompositionLocalOf { GradientColors() }
47 changes: 45 additions & 2 deletions core/designsystem/src/main/java/com/moya/funch/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.moya.funch.theme

import androidx.compose.foundation.layout.Column
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.tooling.preview.Preview

private val LocalFunchColors = staticCompositionLocalOf<FunchColorSchema> {
error("No FunchColors provided")
Expand All @@ -13,6 +17,11 @@ private val LocalFunchTypography = staticCompositionLocalOf<FunchTypography> {
error("No FunchTypography provided")
}

private val DarkGradientColors =
GradientColors(top = Gray900, bottom = Gray900)

private val DarkAndroidBackgroundTheme = BackgroundTheme(color = Gray900)

object FunchTheme {
val colors: FunchColorSchema @Composable get() = LocalFunchColors.current
val typography: FunchTypography @Composable get() = LocalFunchTypography.current
Expand All @@ -39,9 +48,43 @@ fun FunchTheme(
) {
// this version provides only dark theme
val colors = funchDarkColorSchema()
val gradientColors = DarkGradientColors
val typography = funchTypography()
ProvidePophoryColorAndTypography(colors, typography) {
MaterialTheme(content = content)
val backgroundTheme = DarkAndroidBackgroundTheme

CompositionLocalProvider(
LocalGradientColors provides gradientColors,
LocalBackgroundTheme provides backgroundTheme,
) {
ProvidePophoryColorAndTypography(colors, typography) {
MaterialTheme(content = content)
}
}
}

// TODO : 추후 삭제
@Preview("FunchTheme 예시")
@Composable
private fun NiaThemePreview() {
FunchTheme {
val color = LocalBackgroundTheme.current.color
Surface(
color = color
) {
Column {
Text(
text = "Hello, Funch!",
color = FunchTheme.colors.white,
style = FunchTheme.typography.t1
)
Text(
text = "Hello, Funch!",
color = FunchTheme.colors.white,
style = FunchTheme.typography.sbt1
)
}

}

}
}
5 changes: 2 additions & 3 deletions core/designsystem/src/main/java/com/moya/funch/theme/Type.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ private val spoqaHanSansNeo = FontFamily(
R.font.spoqa_han_sans_neo_regular,
FontWeight.Normal,
FontStyle.Normal
)

),
)

@Stable
Expand Down Expand Up @@ -80,7 +79,7 @@ class FunchTypography internal constructor(
}
}

fun funchTypography(): FunchTypography {
internal fun funchTypography(): FunchTypography {
return FunchTypography(
t1 = TextStyle(
fontFamily = spoqaHanSansNeo,
Expand Down

0 comments on commit f90f430

Please sign in to comment.