Skip to content

Commit

Permalink
[feat] : FunchTheme
Browse files Browse the repository at this point in the history
  • Loading branch information
murjune committed Jan 22, 2024
1 parent 30ff117 commit b676a08
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions core/designsystem/src/main/java/com/moya/funch/theme/Theme.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.moya.funch.theme

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf

private val LocalFunchColors = staticCompositionLocalOf<FunchColorSchema> {
error("No FunchColors provided")
}
private val LocalFunchTypography = staticCompositionLocalOf<FunchTypography> {
error("No FunchTypography provided")
}

object FunchTheme {
val colors: FunchColorSchema @Composable get() = LocalFunchColors.current
val typography: FunchTypography @Composable get() = LocalFunchTypography.current
}

@Composable
fun ProvidePophoryColorAndTypography(
colors: FunchColorSchema,
typography: FunchTypography,
content: @Composable () -> Unit,
) {
val provideColors = remember { colors.copy() }
provideColors.update(colors)
val provideTypography = remember { typography.copy() }
provideTypography.update(typography)
CompositionLocalProvider(
LocalFunchColors provides provideColors, LocalFunchTypography provides provideTypography, content = content
)
}

@Composable
fun FunchTheme(
content: @Composable () -> Unit,
) {
// this version provides only dark theme
val colors = funchDarkColorSchema()
val typography = funchTypography()
ProvidePophoryColorAndTypography(colors, typography) {
MaterialTheme(content = content)
}
}

0 comments on commit b676a08

Please sign in to comment.