Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

designsystem module (Background, Gradient 추가) #14

Merged
merged 5 commits into from
Jan 22, 2024
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
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
Copy link
Collaborator

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,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
Loading