Skip to content

Commit

Permalink
RENAME ColorTokens to ColorScheme
Browse files Browse the repository at this point in the history
  • Loading branch information
ninovanhooff committed Dec 13, 2024
1 parent 157a953 commit b708aa7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.q42.template.ui.theme

import androidx.compose.ui.graphics.Color

interface AppColorTokens {
interface AppColorScheme {
val buttonText: Color
val accent: Color
val textPrimary: Color
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.q42.template.ui.theme

import androidx.compose.ui.graphics.Color

object AppColorTokensDark: AppColorTokens {
object AppColorSchemeDark: AppColorScheme {
override val buttonText: Color = White
override val accent: Color = PurpleGrey80
override val textPrimary = White
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nl.q42.template.ui.theme

import androidx.compose.ui.graphics.Color

object AppColorTokensLight : AppColorTokens {
object AppColorSchemeLight : AppColorScheme {
override val buttonText: Color = White
override val accent: Color = Purple40
override val textPrimary = Black
Expand Down
15 changes: 9 additions & 6 deletions core/ui/src/main/kotlin/nl/q42/template/ui/theme/AppTheme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ package nl.q42.template.ui.theme
import android.annotation.SuppressLint
import android.app.Activity
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalRippleConfiguration
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
Expand All @@ -24,17 +27,17 @@ import nl.q42.template.ui.compose.composables.widgets.AppSurface
*/

private val LocalAppTypography = staticCompositionLocalOf { AppTypography() }
private val LocalAppColorTokens = staticCompositionLocalOf<AppColorTokens> {
private val LocalAppColorScheme = staticCompositionLocalOf<AppColorScheme> {
// Dummy default, will be replaced for the actual tokens by the Provider
AppColorTokensLight
AppColorSchemeLight
}
private val LocalAppShapes = staticCompositionLocalOf { AppShapes() }

@Composable
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
typography: AppTypography = AppTheme.typography,
colors: AppColorTokens = AppTheme.colors,
colors: AppColorScheme = AppTheme.colors,
shapes: AppShapes = AppTheme.shapes,

content: @Composable () -> Unit
Expand All @@ -50,7 +53,7 @@ fun AppTheme(

CompositionLocalProvider(
LocalAppTypography provides typography,
LocalAppColorTokens provides if (darkTheme) AppColorTokensDark else AppColorTokensLight,
LocalAppColorScheme provides if (darkTheme) AppColorSchemeDark else AppColorSchemeLight,
LocalAppShapes provides shapes,
/** configures the ripple for material components */
LocalRippleConfiguration provides AppRippleConfiguration,
Expand All @@ -68,10 +71,10 @@ object AppTheme {
@Composable
@ReadOnlyComposable
get() = LocalAppTypography.current
val colors: AppColorTokens
val colors: AppColorScheme
@Composable
@ReadOnlyComposable
get() = LocalAppColorTokens.current
get() = LocalAppColorScheme.current
val shapes: AppShapes
@Composable
@ReadOnlyComposable
Expand Down

0 comments on commit b708aa7

Please sign in to comment.