dimsuz
06/08/2020, 11:25 AMColorStateList
in code? I mean not loading from resources (colorSL
), but actually specifying states and colors manually.louiscad
06/08/2020, 11:39 AMdimsuz
06/08/2020, 12:08 PMlouiscad
06/08/2020, 12:09 PMFlow
based as well with StateFlow
šdimsuz
06/08/2020, 12:10 PMlouiscad
06/08/2020, 12:10 PMdimsuz
06/08/2020, 12:11 PMlouiscad
06/08/2020, 12:11 PMdimsuz
06/08/2020, 12:11 PMlouiscad
06/08/2020, 12:12 PMdimsuz
06/08/2020, 12:17 PMThemeableUi
delegate does all the hooking magic), applyStyle
is my custom extension:
class MyLayout : ContourLayout, Ui by ThemeableUi {
val title = textView {
// Will be called automatically on theme change
applyStyle { theme ->
add(theme.textStyles.largeTitle)
textColor(theme.colors.accent)
}
text = "Hello, world!"
applyLayout(
x = centerHorizontallyTo { parent.centerX() },
y = centerVerticallyTo { parent.centerY() }
)
}
Theme class looks like this:
sealed class Theme {
abstract val id: String
abstract val description: ThemeDescription
abstract val textStyles: TextStyles
abstract val colors: Colors
data class Light(
override val id: String,
override val description: ThemeDescription,
override val textStyles: TextStyles,
override val colors: Colors
) : Theme() { /* constructor omitted */ }
data class Dark(
override val id: String,
override val description: ThemeDescription,
override val textStyles: TextStyles,
override val colors: Colors
) : Theme() { /* constructor omitted */ }
}
airbnb/paris
for applying view styles dynamically