Skip to content

Instantly share code, notes, and snippets.

@Peddro

Peddro/Color.kt Secret

Last active January 26, 2022 18:30
Show Gist options
  • Save Peddro/d42411227c2acadd6866226392954ce7 to your computer and use it in GitHub Desktop.
Save Peddro/d42411227c2acadd6866226392954ce7 to your computer and use it in GitHub Desktop.
val LightColors = H19Colors(
primary = Blue,
background = Color.White,
textPrimary = Color.White,
onPrimary = Color.White,
onBackground = DarkGrey,
isLight = true
)
class H19Colors(
primary: Color,
background: Color,
textPrimary: Color,
onPrimary: Color,
onBackground: Color,
isLight: Boolean
) {
var primary by mutableStateOf(primary)
private set
var background by mutableStateOf(background)
private set
var textPrimary by mutableStateOf(textPrimary)
private set
var onPrimary by mutableStateOf(onPrimary)
private set
var onBackground by mutableStateOf(onBackground)
private set
var isLight by mutableStateOf(isLight)
private set
fun copy(
primary: Color = this.primary,
background: Color = this.background,
textPrimary: Color = this.textPrimary,
onPrimary: Color = this.onPrimary,
onBackground: Color = this.onBackground,
isLight: Boolean = this.isLight
): H19Colors = H19Colors(
primary,
background,
textPrimary,
onPrimary,
onBackground,
isLight
)
fun updateColorsFrom(other: H19Colors) {
primary = other.primary
background = other.background
textPrimary = other.textPrimary
onPrimary = other.onPrimary
onBackground = other.onBackground
isLight = other.isLight
}
}
internal val LocalColors = staticCompositionLocalOf { LightColors }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment