Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Material 3 やめました / Good-bye M3 design system

Yuki Anzai
September 15, 2023

Material 3 やめました / Good-bye M3 design system

Yuki Anzai

September 15, 2023
Tweet

More Decks by Yuki Anzai

Other Decks in Technology

Transcript

  1. "HFOEB w 8IZ w 3FWJFX.BUFSJBM w 1BJOQPJOUPG.EFTJHOTZTUFN w *OTUFBEPG w

    )PXUPDSFBUFDVTUPNEFTJHOTZTUFN w )PXUPJNQMFNFOUDVTUPNEFTJHOTZTUFN
  2. .BUFSJBM%FTJHO w BOBEBQUBCMFTZTUFNPGHVJEFMJOFT DPNQPOFOUT BOEUPPMTUIBU TVQQPSUUIFCFTUQSBDUJDFTPGVTFSJOUFSGBDFEFTJHO .BUFSJBM%FTJHO . ʙ .BUFSJBM%FTJHO

    . ʙ .BUFSJBM5IFNJOH  .BUFSJBM$PNQPOFOUTJNQMFNFOUBUJPO .BUFSJBM%FTJHO . ʙ .BUFSJBM:PV  %ZOBNJDDPMPS
  3. %FTJHO5PLFOT w "EFTJHOWBMVFEF fi OFEXJUIBOBNFBWBSJBCMFUIBUIPMETUIFEFTJHO WBMVF w 6TF%FTJHO5PLFOTBDSPTTEFTJHO DPEF UPPMT

    BOEQMBUGPSNT w 1MBUGPSNJOEFQFOEFOUGPSNBU w DBOCFBQQMJFEDPOTJTUFOUMZ w 1MBDFTUIBUSFGFSUPUIFTBNF%FTJHO5PLFOXJMMIBWFUIFTBNFWBMVF
  4. 5ZQPHSBQIZPG. w 3PMFT w %JTQMBZ w )FBEMJOF w 5JUMF w

    #PEZ w -BCFM w TDBMFTQFS3PMF w -BSHF w .FEJVN w 4NBMM
  5. 1BJOQPJOUPG.DPMPS w 8FXBOUUPVTFCSBOEDPMPSOPUUPOBMQBMFUUFDPMPS w .BOVBMMZBEKVTUJOHUIFDPMPSTPOUIF.JTEJ ff i DVMU w /PUFOPVHIDPMPS

    w "EEJOHDVTUPNDPMPSEPFTOPUTVQQPSU%ZOBNJD$PMPS w "EEJOHDVTUPNDPMPSBMTPEPFTOPUTVQQPSU%BSL.PEF
  6. MyM3Theme { Surface { Row { Spacer( modifier = Modifier

    … .background(MaterialTheme.colorScheme.container) ) Box { MyM3Theme(darkTheme = true) { Surface { Spacer( modifier = Modifier … .background(MaterialTheme.colorScheme.container) ) } } } } } } M2 M3 isSystemInDarkTheme()TUJMMGBMTF MJHIU EBSL
  7. 1BJOQPJOUPG.DPMPS w 8FXBOUUPVTFCSBOEDPMPSOPUUPOBMQBMFUUFDPMPS w .BOVBMMZBEKVTUJOHUIFDPMPSTPOUIF.JTEJ ff i DVMU w /PUFOPVHIDPMPS

    w "EEJOHDVTUPNDPMPSEPFTOPUTVQQPSU%ZOBNJD$PMPS w "EEJOHDVTUPNDPMPSBMTPEPFTOPUTVQQPSU%BSL.PEF #FUUFSUPVTFBMMZPVSPXODPMPSEF fi OJUJPOT
  8. @Composable fun buttonColors( containerColor: Color = FilledButtonTokens.ContainerColor.toColor(), … ): ButtonColors

    = ButtonColors( containerColor = containerColor, … ) internal object FilledButtonTokens { val ContainerColor = ColorSchemeKeyTokens.Primary … } .
  9. internal enum class ColorSchemeKeyTokens { … Primary, … } @Composable

    fun buttonColors( containerColor: Color = FilledButtonTokens.ContainerColor.toColor(), … ): ButtonColors = ButtonColors( containerColor = containerColor, … ) internal object FilledButtonTokens { val ContainerColor = ColorSchemeKeyTokens.Primary … } .
  10. @Composable fun buttonColors( containerColor: Color = FilledButtonTokens.ContainerColor.toColor(), … ): ButtonColors

    = ButtonColors( containerColor = containerColor, … ) @ReadOnlyComposable @Composable internal fun ColorSchemeKeyTokens.toColor(): Color { return MaterialTheme.colorScheme.fromToken(this) } internal fun ColorScheme.fromToken(value: ColorSchemeKeyTokens): Color { return when (value) { … ColorSchemeKeyTokens.Primary -> primary … } } .
  11. )PXUPEFDJEFUIFUZQFPG4ZTUFN5PLFO w $BOXFHFUIFMQGSPNBEFTJHOFS  w ZFT w *EFOUJGZUIFUZQFTPGTZTUFNUPLFOZPVXJMMOFFEBOEUIFO JNQMFNFOUJU w

    OP w 1SFQBSFPOMZUIFDPMPSBOEUZQPHSBQIZBTTZTUFNUPLFO BEEBOE NBJOUBJOUIFOFDFTTBSZJUFNTXIJMFJNQMFNFOUJOHUIFBQQ
  12. )PXUPEFDJEFUIFUZQFPG4ZTUFN5PLFO w $BOXFHFUIFMQGSPNBEFTJHOFS  w ZFT w *EFOUJGZUIFUZQFTPGTZTUFNUPLFOZPVXJMMOFFEBOEUIFO JNQMFNFOUJU w

    OP w 1SFQBSFPOMZUIFDPMPSBOEUZQPHSBQIZBTTZTUFNUPLFO BEEBOE NBJOUBJOUIFOFDFTTBSZJUFNTXIJMFJNQMFNFOUJOHUIFBQQ
  13. 4ZTUFN5PLFO*OJUJBM4FUUJOHT w $PMPS w CBDLHSPVOE w GPSDPOUFOUT UFYUDPMPS w FHPO#BDLHSPVOE

    PO#BDLHSPVOE7BSJBOU w FHUFYU1SJNBSZ UFYU4FDPOEBSZ w FHDPOUFOU)JHI DPOUFOU.JE w QSJNBSZʢPQUJPOBMʣ
  14. android { … buildFeatures { compose = true } composeOptions

    { kotlinCompilerExtensionVersion = "1.5.1" } } dependencies { … implementation(platform("androidx.compose:compose-bom:2023.08.00")) implementation("androidx.compose.material3:material3") } CVJMEHSBEMFLUT DPSFEFTJHOTZTUFN
  15. $PMPS5PLFOT internal object MyColorLightTokens { val Primary = Color(0xFF3D6A00) val

    Background = Color(0xffffffff) val OnBackground = Color(0xde000000) } internal object MyColorDarkTokens { val Primary = Color(0xFF95D94A) val Background = Color(0xff141816) val OnBackground = Color(0xffffffff) } DPSFEFTJHOTZTUFN
  16. $VTUPN$PMPSDMBTT @Stable class MyColor( primary: Color, background: Color, onBackground: Color,

    ) { var primary by mutableStateOf(primary, structuralEqualityPolicy()) internal set var background by mutableStateOf(background, structuralEqualityPolicy()) internal set var onBackground by mutableStateOf(onBackground, structuralEqualityPolicy()) internal set … } DPSFEFTJHOTZTUFN
  17. fun lightMyColor( primary: Color = MyColorLightTokens.Primary, background: Color = MyColorLightTokens.Background,

    onBackground: Color = MyColorLightTokens.OnBackground, ): MyColor = MyColor( … ) fun darkMyColor( primary: Color = MyColorDarkTokens.Primary, background: Color = MyColorDarkTokens.Background, onBackground: Color = MyColorDarkTokens.OnBackground, ): MyColor = MyColor( … ) … internal val LocalMyColor = staticCompositionLocalOf { lightMyColor() } DPSFEFTJHOTZTUFN
  18. $PNQPTJUJPO-PDBM My blog article → https://y-anz-m.blogspot.com/2021/04/jetpack-compose-composition-local.html val MyLocalColor = staticCompositionLocalOf

    { Color.Red } Text( text = "hello", color = MyLocalColor.current, // Color.Red ) CompositionLocalProvider(MyLocalColor provides Color.Blue) { Text( text = "hello", color = MyLocalColor.current, // Color.Blue ) }
  19. 5ZQPHSBQIZ5PLFOT internal object MyTypographyTokens { val BodyLarge = TextStyle( fontFamily

    = FontFamily.SansSerif, fontWeight = FontWeight.Normal, fontSize = 16.sp, lineHeight = 24.0.sp, letterSpacing = 0.5.sp, ) val BodyMedium = TextStyle( fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Normal, fontSize = 14.sp, lineHeight = 20.0.sp, letterSpacing = 0.2.sp, ) } DPSFEFTJHOTZTUFN
  20. $VTUPN5ZQPHSBQIZDMBTT @Immutable data class MyTypography( val bodyLarge: TextStyle = MyTypographyTokens.BodyLarge,

    val bodyMedium: TextStyle = MyTypographyTokens.BodyMedium, ) internal val LocalMyTypography = staticCompositionLocalOf { MyTypography() } DPSFEFTJHOTZTUFN
  21. .Z5IFNFPCKFDU object MyTheme { val color: MyColor @Composable @ReadOnlyComposable get()

    = LocalMyColor.current val typography: MyTypography @Composable @ReadOnlyComposable get() = LocalMyTypography.current } DPSFEFTJHOTZTUFN
  22. @Composable internal fun BaseMyTheme( color: MyColor = MyTheme.color, typography: MyTypography

    = MyTheme.typography, content: @Composable () -> Unit, ) { val rememberedColors = remember { color.copy() }.apply { updateMyColorFrom(color) } val selectionColors = rememberTextSelectionColors(rememberedColors) CompositionLocalProvider( LocalIndication provides rememberRipple(), LocalRippleTheme provides MaterialRippleTheme, LocalTextSelectionColors provides selectionColors, LocalMyColor provides rememberedColors, LocalMyTypography provides typography, ) { ProvideTextStyle(value = typography.bodyLarge, content = content) } } DPSFEFTJHOTZTUFN
  23. @Composable internal fun BaseMyTheme( color: MyColor = MyTheme.color, typography: MyTypography

    = MyTheme.typography, content: @Composable () -> Unit, ) { val rememberedColors = remember { color.copy() }.apply { updateMyColorFrom(color) } val selectionColors = rememberTextSelectionColors(rememberedColors) CompositionLocalProvider( LocalIndication provides rememberRipple(), LocalRippleTheme provides MaterialRippleTheme, LocalTextSelectionColors provides selectionColors, LocalMyColor provides rememberedColors, LocalMyTypography provides typography, ) { ProvideTextStyle(value = typography.bodyLarge, content = content) } } DPSFEFTJHOTZTUFN
  24. @Composable internal fun BaseMyTheme( color: MyColor = MyTheme.color, typography: MyTypography

    = MyTheme.typography, content: @Composable () -> Unit, ) { val rememberedColors = remember { color.copy() }.apply { updateMyColorFrom(color) } val selectionColors = rememberTextSelectionColors(rememberedColors) CompositionLocalProvider( LocalIndication provides rememberRipple(), LocalRippleTheme provides MaterialRippleTheme, LocalTextSelectionColors provides selectionColors, LocalMyColor provides rememberedColors, LocalMyTypography provides typography, ) { ProvideTextStyle(value = typography.bodyLarge, content = content) } } DPSFEFTJHOTZTUFN
  25. @Composable internal fun BaseMyTheme( color: MyColor = MyTheme.color, typography: MyTypography

    = MyTheme.typography, content: @Composable () -> Unit, ) { … CompositionLocalProvider( LocalIndication provides rememberRipple(), LocalRippleTheme provides MaterialRippleTheme, … ) { ProvideTextStyle(value = typography.bodyLarge, content = content) } } @Immutable private object MaterialRippleTheme : RippleTheme { @Composable override fun defaultColor() = LocalContentColor.current @Composable override fun rippleAlpha() = RippleAlpha(…) } DPSFEFTJHOTZTUFN
  26. VTFSFNFNCFS3JQQMF JOBQQNPEVMF Box( modifier = Modifier… .clickable( onClick = onClick,

    role = Role.Button, interactionSource = remember { MutableInteractionSource() }, indication = rememberRipple( bounded = false, radius = 24.dp, ) ), ) {
  27. VTFSFNFNCFS3JQQMF JOBQQNPEVMF w JNQMFNFOUBXSBQQFSNFUIPEJOEFTJHOTZTUFNNPEVMF @Composable fun rememberRipple( bounded: Boolean =

    true, radius: Dp = Dp.Unspecified, color: Color = Color.Unspecified ): Indication { return androidx.compose.material.ripple.rememberRipple( bounded = bounded, radius = radius, color = color, ) } DPSFEFTJHOTZTUFN
  28. 5IFNFDPNQPTBCMFGPSBQQ w FRVJWBMFOUUPUIFUIFNFBVUPNBUJDBMMZDSFBUFEXIFODSFBUJOHBQSPKFDU w QVCMJD @Composable fun MyTheme( darkTheme: Boolean

    = isSystemInDarkTheme(), content: @Composable () -> Unit ) { BaseMyTheme( color = if (!darkTheme) lightMyColor() else darkMyColor(), typography = MyTypography(), content = content ) } DPSFEFTJHOTZTUFN
  29. .JHSBUJOHGSPN. PS. @Composable fun MyTheme( darkTheme: Boolean = isSystemInDarkTheme(), content:

    @Composable () -> Unit ) { BaseMyTheme( color = if (!darkTheme) lightMyColor() else darkMyColor(), typography = MyTypography(), ) { MaterialTheme( colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme, content = content ) } } DPSFEFTJHOTZTUFN
  30. *NQMFNFOUBUJPOPGDPNQPOFOUT w .DPNQPOFOUTDBOOPUCFVTFEBTJT @Preview @Composable private fun Preview() { MyTheme

    { androidx.compose.material3.Checkbox( checked = true, onCheckedChange = {} ) } }
  31. object CheckboxDefaults { @Composable fun colors( checkedColor: Color = MaterialTheme.colorScheme.fromToken(CheckboxTokens.SelectedContainerColor)

    … ): CheckboxColors = CheckboxColors( checkedBoxColor = checkedColor, … ) } object MaterialTheme { val colorScheme: ColorScheme @Composable @ReadOnlyComposable get() = LocalColorScheme.current … } ColorSchemeKeyTokens.Primary .
  32. @Composable fun MaterialTheme( colorScheme: ColorScheme = MaterialTheme.colorScheme, … ) {

    … CompositionLocalProvider( LocalColorScheme provides rememberedColorScheme, … ) { … } } object MaterialTheme { val colorScheme: ColorScheme @Composable @ReadOnlyComposable get() = LocalColorScheme.current … } .
  33. @Preview @Composable private fun Preview() { MaterialTheme( colorScheme = lightColorScheme(

    primary = Color.Blue ) ) { androidx.compose.material3.Checkbox( checked = true, onCheckedChange = {} ) } }
  34. $PNQPOFOUTPGDVTUPNEFTJHOTZTUFN w OBNFPGDPNQPOFOUT w DVSSFOUMZBQQVTFT. w /PˠOPQSF fi YFHʣ$IFDLCPY w

    :FTˠXJUIQSF fi YFHʣ.Z$IFDLCPY w BWPJEUIFNJTUBLFPGJNQPSUJOH.DPNQPOFOUT w SFOBNFBGUFSSFNPWJOH.EFQFOEFODJFTGSPNBQQNPEVMF
  35. @Composable fun Checkbox( checked: Boolean, onCheckedChange: ((Boolean) -> Unit)?, modifier:

    Modifier = Modifier, enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() } ) { TODO() } $VTUPN
  36. @Composable fun Checkbox( … ) { val borderColor = MyTheme.color.onBackground.copy(alpha

    = 0.4f) val disabledBorderColor = borderColor.let { it.copy(alpha = it.alpha * DisabledAlpha) } androidx.compose.material3.Checkbox( checked = checked, onCheckedChange = onCheckedChange, modifier = modifier, enabled = enabled, colors = CheckboxDefaults.colors( checkedColor = MyTheme.color.primary, uncheckedColor = borderColor, checkmarkColor = MyTheme.color.background, disabledCheckedColor = disabledBorderColor, disabledUncheckedColor = disabledBorderColor, disabledIndeterminateColor = disabledBorderColor ), interactionSource = interactionSource, ) } $VTUPN
  37. @Composable fun Checkbox( … ) { val borderColor = MyTheme.color.onBackground.copy(alpha

    = 0.4f) val disabledBorderColor = borderColor.let { it.copy(alpha = it.alpha * DisabledAlpha) } androidx.compose.material3.Checkbox( checked = checked, onCheckedChange = onCheckedChange, modifier = modifier, enabled = enabled, colors = CheckboxDefaults.colors( checkedColor = MyTheme.color.primary, uncheckedColor = borderColor, checkmarkColor = MyTheme.color.background, disabledCheckedColor = disabledBorderColor, disabledUncheckedColor = disabledBorderColor, disabledIndeterminateColor = disabledBorderColor ), interactionSource = interactionSource, ) } $VTUPN
  38. @Composable fun Checkbox( … ) { val borderColor = MyTheme.color.onBackground.copy(alpha

    = 0.4f) val disabledBorderColor = borderColor.let { it.copy(alpha = it.alpha * DisabledAlpha) } androidx.compose.material3.Checkbox( checked = checked, onCheckedChange = onCheckedChange, modifier = modifier, enabled = enabled, colors = CheckboxDefaults.colors( checkedColor = MyTheme.color.primary, uncheckedColor = borderColor, checkmarkColor = MyTheme.color.background, disabledCheckedColor = disabledBorderColor, disabledUncheckedColor = disabledBorderColor, disabledIndeterminateColor = disabledBorderColor ), interactionSource = interactionSource, ) } $VTUPN
  39. internal object MyColorLightTokens { val Primary = Color(0xFF3D6A00) val Background

    = Color(0xffffffff) val OnBackground = Color(0xde000000) val Border = Color(0x66000000) } internal object MyColorDarkTokens { val Primary = Color(0xFF95D94A) val Background = Color(0xff141816) val OnBackground = Color(0xffffffff) val Border = Color(0x66ffffff) } $VTUPN
  40. @Stable class MyColor( primary: Color, … border: Color, ) {

    … var border by mutableStateOf(border, structuralEqualityPolicy()) internal set fun copy( … border: Color = this.border, ): MyColor = MyColor( … border = border, ) } $VTUPN
  41. fun lightMyColor( … border: Color = MyColorLightTokens.Border, ): MyColor =

    MyColor( … border = border, ) fun darkMyColor( … border: Color = MyColorDarkTokens.Border, ): MyColor = MyColor( … border = border, ) $VTUPN
  42. @Composable fun Checkbox( … ) { val borderColor = MyTheme.color.border

    val disabledBorderColor = borderColor.let { it.copy(alpha = it.alpha * DisabledAlpha) } androidx.compose.material3.Checkbox( checked = checked, onCheckedChange = onCheckedChange, modifier = modifier, enabled = enabled, colors = CheckboxDefaults.colors( checkedColor = MyTheme.color.primary, uncheckedColor = borderColor, checkmarkColor = MyTheme.color.background, disabledCheckedColor = disabledBorderColor, disabledUncheckedColor = disabledBorderColor, disabledIndeterminateColor = disabledBorderColor ), interactionSource = interactionSource, ) } $VTUPN
  43. @Composable fun Divider( modifier: Modifier = Modifier, ) { androidx.compose.material3.Divider(

    modifier = modifier, thickness = 1.dp, color = MyTheme.color.border, ) } $VTUPN
  44. FH 4OBDLCBS w 4OBDLCBS%BUB w 4OBDLCBS3FTVMU w 4OBDLCBS%VSBUJPO w 4OBDLCBS)PTU4UBUF

    w 4OBDLCBS  w 4OBDLCBS)PTU  w SFNFNCFS4OBDLCBS)PTU4UBUF
  45. enum class SnackbarResult { Dismissed, ActionPerformed, } enum class SnackbarDuration

    { Short, Long, Indefinite } @JvmInline value class SnackbarData(val delegate: androidx.compose.material3.SnackbarData) $VTUPN
  46. @Composable fun Snackbar( snackbarData: SnackbarData, modifier: Modifier = Modifier, actionOnNewLine:

    Boolean = false, ) { androidx.compose.material3.Snackbar( snackbarData = snackbarData.delegate, modifier = modifier, actionOnNewLine = actionOnNewLine, shape = RoundedCornerShape(4.dp), containerColor = MyTheme.color.onBackground.copy(alpha = 0.9f) .compositeOver(MyTheme.color.background), contentColor = MyTheme.color.background, actionColor = MyTheme.color.background, actionContentColor = MyTheme.color.background, dismissActionContentColor = MyTheme.color.background, ) } $VTUPN
  47. @Composable fun Snackbar( snackbarData: SnackbarData, modifier: Modifier = Modifier, actionOnNewLine:

    Boolean = false, ) { androidx.compose.material3.Snackbar( snackbarData = snackbarData.delegate, modifier = modifier, actionOnNewLine = actionOnNewLine, shape = RoundedCornerShape(4.dp), containerColor = MyTheme.color.onBackground.copy(alpha = 0.9f) .compositeOver(MyTheme.color.background), contentColor = MyTheme.color.background, actionColor = MyTheme.color.background, actionContentColor = MyTheme.color.background, dismissActionContentColor = MyTheme.color.background, ) } $VTUPN
  48. @Stable class SnackbarHostState(val delegate: androidx.compose.material3.SnackbarHostState) { suspend fun showSnackbar( message:

    String, actionLabel: String? = null, withDismissAction: Boolean = false, duration: SnackbarDuration = … ): SnackbarResult { val result = delegate.showSnackbar( message = message, actionLabel = actionLabel, withDismissAction = withDismissAction, duration = when (duration) { SnackbarDuration.Short -> androidx.compose.material3.SnackbarDuration.Short … }, ) return when (result) { androidx.compose.material3.SnackbarResult.Dismissed -> SnackbarResult.Dismissed … } } } $VTUPN
  49. @Stable class SnackbarHostState(val delegate: androidx.compose.material3.SnackbarHostState) { suspend fun showSnackbar( message:

    String, actionLabel: String? = null, withDismissAction: Boolean = false, duration: SnackbarDuration = … ): SnackbarResult { val result = delegate.showSnackbar( message = message, actionLabel = actionLabel, withDismissAction = withDismissAction, duration = when (duration) { SnackbarDuration.Short -> androidx.compose.material3.SnackbarDuration.Short … }, ) return when (result) { androidx.compose.material3.SnackbarResult.Dismissed -> SnackbarResult.Dismissed … } } } $VTUPN
  50. @Composable fun SnackbarHost( hostState: SnackbarHostState, modifier: Modifier = Modifier, snackbar:

    @Composable (SnackbarData) -> Unit = { Snackbar(it) } ) { androidx.compose.material3.SnackbarHost( hostState = hostState.delegate, modifier = modifier, snackbar = { snackbar(SnackbarData(it)) }, ) } $VTUPN
  51. val snackbarHostState = rememberSnackbarHostState() LaunchedEffect(Unit) { snackbarHostState.showSnackbar(message = "message") }

    Scaffold( snackbarHost = { SnackbarHost( hostState = snackbarHostState, ) } ) { … } BQQ
  52. XSBQQFSPG5FYUDPNQPTBCMF w %FGBVMUWBMVFPGDPMPSTIPVMECF$PMPS6OTQFDJ fi FE @Composable fun Text( … color:

    Color = Color.Unspecified, … ) { androidx.compose.material3.Text( … color = color, … ) } 0, = MyTheme.color.onBackground, /( $VTUPN
  53. -PDBM$POUFOU$PMPS @Composable fun Text( … color: Color = Color.Unspecified, …

    style: TextStyle = LocalTextStyle.current ) { val textColor = color.takeOrElse { style.color.takeOrElse { LocalContentColor.current } } … BasicText( … ) }  UIFDPMPSTQFDJ fi FECZUIF DPMPSBSHVNFOU  UIFDPMPSTQFDJ fi FEJOTUZMF  UIFDPMPSPG -PDBM$POUFOU$PMPS .
  54. @Composable fun Button( … colors: ButtonColors = ButtonDefaults.buttonColors(), …, )

    { val containerColor = colors.containerColor(enabled).value val contentColor = colors.contentColor(enabled).value … Surface( … ) { CompositionLocalProvider(LocalContentColor provides contentColor) { ProvideTextStyle(value = MaterialTheme.typography.labelLarge) { Row( … verticalAlignment = Alignment.CenterVertically, content = content ) } } } } .
  55. Button( onClick = { }, ) { Text( text =

    "button", ) } Button( onClick = { }, enabled = false, ) { Text( text = "button", ) } .
  56. Button( onClick = { }, ) { Text( text =

    "button", color = MyTheme.color.onBackground, ) } Button( onClick = { }, enabled = false, ) { Text( text = "button", color = MyTheme.color.onBackground, ) } /( /(
  57. XSBQQFSPG*DPODPNQPTBCMF w %FGBVMUWBMVFPGUJOUTIPVMECF-PDBM$POUFOU$PMPSDVSSFOU @Composable fun Icon( … tint: Color =

    LocalContentColor.current, ) { androidx.compose.material3.Icon( … tint = tint, ) } 0, = MyTheme.color.onBackground, /( $VTUPN
  58. -PDBM5FYU4UZMF @Composable fun Text( … color: Color = Color.Unspecified, …

    style: TextStyle = LocalTextStyle.current ) { … val mergedStyle = style.merge( … ) BasicText( … mergedStyle, … ) } .
  59. 5PQ"QQ#BS @Composable fun TopAppBar( title: @Composable () -> Unit, …

    ) { SingleRowTopAppBar( … titleTextStyle = MaterialTheme.typography.fromToken(TopAppBarSmallTokens.HeadlineFont), … ) } val HeadlineFont = TypographyKeyTokens.TitleLarge .
  60. @Composable private fun SingleRowTopAppBar( … titleTextStyle: TextStyle, … ) {

    … Surface(…) { … TopAppBarLayout( … titleTextStyle = titleTextStyle, … ) } } .
  61. @Composable private fun TopAppBarLayout( … title: @Composable () -> Unit,

    titleTextStyle: TextStyle, … ) { Layout( { … Box( Modifier .layoutId("title") … ) { ProvideTextStyle(value = titleTextStyle) { CompositionLocalProvider( LocalContentColor provides titleContentColor, content = title ) } } … } .
  62. @Composable private fun TopAppBarLayout( … title: @Composable () -> Unit,

    titleTextStyle: TextStyle, … ) { Layout( { … Box( Modifier .layoutId("title") … ) { ProvideTextStyle(value = titleTextStyle) { CompositionLocalProvider( LocalContentColor provides titleContentColor, content = title ) } } … } @Composable fun ProvideTextStyle(value: TextStyle, content: @Composable () -> Unit) { val mergedStyle = LocalTextStyle.current.merge(value) CompositionLocalProvider(LocalTextStyle provides mergedStyle, content = content) } .
  63. -PDBM5FYU4UZMFQSPCMFN TopAppBar( title = { Text("title") } ) MaterialTheme.typography.titleLarge 0,

    /( TopAppBar( title = { Text( text = "title", style = MyTheme.typography.titleLarge ) } )
  64. @Composable fun TopAppBar( title: String, … ) { androidx.compose.material3.TopAppBar( title

    = { Text( text = title, style = MyTheme.typography.titleLarge ) }, … ) } $VTUPN
  65. 4ZTUFN5PLFOTPG# w DPMPS w UZQPHSBQIZ w EJNFOTJPO w EF fi

    OFTJ[FT TQBDJOH CPSEFSXJEUI SBEJVT  w PQBDJUZ w EF fi OFBMQIBXIFOEJTBCMFE https://blog.smartbank.co.jp/entry/2023/06/19/095816
  66. (SPVQJOH @Immutable class B43Color( backgroundColors: BackgroundColors, … ) { var

    backgroundColors by mutableStateOf(backgroundColors, structuralEqualityPolicy()) internal set … @Immutable data class BackgroundColors( val defaultBase: Color, val defaultAccent: Color, val inverseBase: Color, ) … }
  67. fun b43LightColor( backgroundColors: B43Color.BackgroundColors = B43Color.BackgroundColors( defaultBase = B43ColorBackgroundTokensLight.DefaultBase, defaultAccent

    = B43ColorBackgroundTokensLight.DefaultAccent, inverseBase = B43ColorBackgroundTokensLight.InverseBase, ), … ): B43Color = B43Color( backgroundColors = backgroundColors, … ) @Composable fun TopAppBar( … containerColor: Color = B43Theme.color.backgroundColors.defaultBase, … ) {
  68. %JNFOTJPO @Immutable data class B43Dimension( val border: B43DimensionBorder = B43DimensionBorder(),

    val radius: B43DimensionRadius = B43DimensionRadius(), val spacing: B43DimensionSpacing = B43DimensionSpacing(), ) @Immutable data class B43DimensionSpacing( … val small: Dp = B43DimensionSpacingTokens.Small, val medium: Dp = B43DimensionSpacingTokens.Medium, val large: Dp = B43DimensionSpacingTokens.Large, … ) Column( verticalArrangement = Arrangement.spacedBy(B43Theme.dimension.spacing.large), ) {
  69. 4VNNBSZ w *UJTEJ ffi DVMUUPVTF.TEFTJHOTZTUFNGPSBQQTUIBUIBWFB fi YFE CSBOEDPMPS w 5IFSFJTBXBZUPDSFBUFZPVSPXOEFTJHOTZTUFN

    w 1SFQBSFBNPEVMFGPSUIFDVTUPNEFTJHOTZTUFNBOEJNQMFNFOUUIF EFTJHOTZTUFNBOEDPNQPOFOUT w $PODFBM.JOTJEFUIFEFTJHOTZTUFNNPEVMF w 8FXBOUDPNQPOFOUTUIBUJOEFQFOEFOUPGUIF.EFTJHOTZTUFN