Slide 121
Slide 121 text
private val styleButtonAppearanceMap by lazy {
fun bold(size: ButtonSize) =
ButtonStyle(size, ButtonType.Outlined, ButtonColors.Legacy.Primary)
fun heavy(size: ButtonSize) =
ButtonStyle(size, ButtonType.Filled, ButtonColors.Legacy.Primary)
fun regular(size: ButtonSize) =
ButtonStyle(size, ButtonType.Outlined, ButtonColors.Legacy.Regular)
// ...
mapOf(
R.style.TwitterButtonLargeBold to bold(ButtonSize.Legacy.Large()),
R.style.TwitterButtonSmallBold to bold(ButtonSize.Legacy.Small()),
// ...
)
}
internal fun styleToButtonAppearance(@StyleRes styleResId: Int): ButtonStyle =
styleButtonAppearanceMap[styleResId]
?:
error("There is no mapping for this legacy style.")