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

Material3 with Jetpack Compose

Yuki Anzai
October 05, 2022

Material3 with Jetpack Compose

Yuki Anzai

October 05, 2022
Tweet

More Decks by Yuki Anzai

Other Decks in Technology

Transcript

  1. .BUFSJBM%FTJHOͱ͸ w 6*ઃܭͷϕετϓϥΫςΟεΛαϙʔτ͢ΔΨΠυϥΠϯɺίϯϙʔωϯ τɺ͓Αͼπʔϧ܈ .BUFSJBM%FTJHO . ೥ʙ .BUFSJBM%FTJHO . ೥ʙ

    .BUFSJBM5IFNJOHͱ.BUFSJBM $PNQPOFOUTͷίʔυ͕௥Ճ͞Εͨ .BUFSJBM%FTJHO . ೥ʙ EZOBNJDDPMPSͷΑ͏ͳ.BUFSJBM :PVͷػೳ͕௥Ճ͞Εͨ
  2. .ͷ໰୊఺ w 5ZQPHSBQIZ w ໊લ͔Β࢖༻Օॴ͕૝૾͠ʹ͍͘ w ྫʣ"MFSU%JBMPHͷλΠτϧ͸TVCUJUMF w $PMPS w

    QSJNBSZ4VSGBDFͷΑ͏ͳத్൒୺ͳఆ͕ٛ૿͖͑ͯͨ w ৭ΛબͿͷ͕೉͍͠ʢTFDPOEBSZɺEBSLUIFNF༻ʣ w EZOBNJDDPMPSରԠͰ͖ͳ͍ʢDPOUSBTUΛอূͰ͖ͳ͍ʣ
  3. IUUQTNNBUFSJBMJPTUZMFTTIBQFTIBQFTDBMFUPLFOTGCBCFBCDGDD ff GF 3PMF WBMVF /POF EQ 3FDUBOHMF &YUSB4NBMM EQ

    3PVOE$PSOFS 5PQ EQ EQ EQ EQ 3PVOE$PSOFS 4NBMM EQ 3PVOE$PSOFS .FEJVN EQ 3PVOE$PSOFS -BSHF EQ 3PVOE$PSOFS &OE EQ EQ EQ EQ 3PVOE$PSOFS 5PQ EQ EQ EQ EQ 3PVOE$PSOFS &YUSB-BSHF EQ 3PVOE$PSOFS 5PQ EQ EQ EQ EQ 3PVOE$PSOFS 'VMM  $JSDMF
  4. 3PMF ࢖༻Օॴ /POF EQ #BOOFST #PUUPNBQQCBST 'VMMTDSFFOEJBMPHT -JTUT  /BWJHBUJPOCBST

    /BWJHBUJPOSBJMT 1SPHSFTTJOEJDBUPST  4FBSDIWJFX GVMMTDSFFO 4JEFTIFFUT EPDLFE 5BCT 5PQBQQCBST &YUSB4NBMM EQ "VUPDPNQMFUFNFOV 4FMFDUNFOV 4OBDLCBST 4UBOEBSENFOV 5FYU fi FMET 4NBMM EQ $IJQT 3JDIUPPMUJQ .FEJVN EQ $BSET 4NBMM'"#T -BSHF EQ &YUFOEFE'"#T '"#T /BWJHBUJPOESBXFST &YUSB-BSHF EQ #PUUPNTIFFUT EPDLFE %JBMPHT 'MPBUJOHTIFFUT -BSHF'"#T  4FBSDIWJFX EPDLFE 5JNFQJDLFS 5JNFJOQVU 'VMM  #BEHF #VUUPOT *DPOCVUUPOT 4MJEFST 4XJUDIFT 4FBSDICBS IUUQTNNBUFSJBMJPTUZMFTTIBQFTIBQFTDBMFUPLFOTCGCGDFBEFBGBEED
  5. .ͷUZQPHSBQIZ w ͭͷ3PMF w %JTQMBZ w )FBEMJOF w 5JUMF w

    #PEZ w -BCFM w 3PMF͝ͱʹͭͷTDBMF w -BSHF w .FEJVN w 4NBMM
  6. 3PMF 4DBMF MJOFIFJHIU GPOUTJ[F USBDLJOH XFJHIU %JTQMBZ -BSHF  

      .FEJVN     4NBMM     )FBEMJOF -BSHF     .FEJVN     4NBMM     5JUMF -BSHF     .FEJVN     4NBMM     #PEZ -BSHF     .FEJVN     4NBMM     -BCFM -BSHF     .FEJVN     4NBMM     ˎBOESPJEYDPNQPTFNBUFSJBMNBUFSJBMͰఆٛ͞Ε͍ͯΔ஋ɻҰ෦IUUQTNNBUFSJBMJPTUZMFTUZQPHSBQIZUZQFTDBMFUPLFOTͱҟͳΔɻ
  7. 3PMF 4DBMF ࢖༻Օॴ %JTQMBZ ͳ͠ )FBEMJOF -BSHF ͳ͠ .FEJVN -BSHF5PQ"QQ#BSͷUJUMF

    4NBMM "MFSU%JBMPHͷUJUMF  .FEJVN5PQ"QQ#BSͷUJUMF 5JUMF -BSHF 5PQ"QQ#BSͷUJUMF  $FOUFS"MJHOFE5PQ"QQ#BSͷUJUMF  .FEJVN5PQ"QQ#BSͷখ͘͞ͳͬͨͱ͖ͷUJUMF  -BSHF5PQ"QQ#BSͷখ͘͞ͳͬͨͱ͖ͷUJUMF .FEJVN ͳ͠ 4NBMM 5BCͷUFYU
  8. 3PMF 4DBMF ࢖༻Օॴ #PEZ -BSHF -JTU*UFNͷIFBEMJOF5FYU  5FYU'JFMEͷMBCFMʢେ͖͍ͱ͖ʣͱQMBDFIPMEFS .FEJVN -JTU*UFNͷTVQQPSUJOH5FYU

     "MFSU%JBMPHͷUFYU  4OBDLCBSͷUFYU 4NBMM 5FYU'JFMEͷMBCFMʢখ͍͞ͱ͖ʣ -BCFM -BSHF #VUUPOͷUFYU 'MPBUJOH"DUJPO#VUUPOͷUFYU "MFSU%JBMPHͷCVUUPOUFYU  $IJQͷMBCFM %SPQ%PXO.FOV*UFNͷUFYU  4OBDLCBSͷBDUJPO .FEJVN /BWJHBUJPO3BJMͷMBCFM  /BWJHBUJPO#BSͷMBCFM 4NBMM -JTU*UFNͷPWFSMJOF5FYUͱUSBJMJOH$POUFOU  #BEHFͷUFYU
  9. $PMPS3PMFT BDDFOU SPMFT QSJNBSZSPMFT 1SJNBSZ 0O1SJNBSZ 1SJNBSZ $POUBJOFS 0O1SJNBSZ $POUBJOFS

    TFDPOEBSZSPMFT 4FDPOEBSZ 0O4FDPOEBSZ 4FDPOEBSZ $POUBJOFS 0O4FDPOEBSZ $POUBJOFS UFSUJBSZSPMFT 5FSUJBSZ 0O5FSUJBSZ 5FSUJBSZ $POUBJOFS 0O5FSUJBSZ $POUBJOFS OFVUSBM SPMFT #BDLHSPVOE 0O#BDLHSPVOE 4VSGBDF 0O4VSGBDF 4VSGBDF7BSJBOU 0O4VSGBDF 7BSJBOU 0VUMJOF 0VUMJOF7BSJBOU FSSPS SPMFT &SSPS 0O&SSPS &SSPS$POUBJOFS 0O&SSPS $POUBJOFS
  10. ͦͷଞͷ$PMPS3PMFT w *OWFSTF1SJNBSZ1SJNBSZ MJHIU 1SJNBSZ EBSL  w *OWFSTF4VSGBDF/FVUSBM MJHIU

    /FVUSBM EBSL  w *OWFSTF0O4VSGBDF/FVUSBM MJHIU /FVUSBM EBSL  w 4VSGBDF5JOU1SJNBSZ1SJNBSZ MJHIU 1SJNBSZ EBSL  w 4DSJN/FVUSBM IUUQTNNBUFSJBMJPTUZMFTDPMPSUIFDPMPSTZTUFNUPLFOTʹ͸TIBEPX΋͋Γ·͕͢ MJCSBSZʹ͸ఆٛ͞Ε͍ͯ·ͤΜ
  11. import androidx.compose.material3.* @Composable fun MyAppTheme( darkTheme: Boolean = isSystemInDarkTheme(), dynamicColor:

    Boolean = true, content: @Composable () -> Unit ) { val colorScheme = if (dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } else { if (darkTheme) DarkColorScheme else LightColorScheme } MaterialTheme( colorScheme = colorScheme, typography = Typography, shapes = Shapes, content = content ) }
  12. import androidx.compose.material3.* @Composable fun MyAppTheme( darkTheme: Boolean = isSystemInDarkTheme(), dynamicColor:

    Boolean = true, content: @Composable () -> Unit ) { val colorScheme = if (dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } else { if (darkTheme) DarkColorScheme else LightColorScheme } MaterialTheme( colorScheme = colorScheme, typography = Typography, shapes = Shapes, content = content ) }
  13. %BZdBU$BSET import androidx.compose.material3.* @Composable fun MyAppTheme( darkTheme: Boolean = isSystemInDarkTheme(),

    dynamicColor: Boolean = true, content: @Composable () -> Unit ) { val colorScheme = if (dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { val context = LocalContext.current if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) } else { if (darkTheme) DarkColorScheme else LightColorScheme } MaterialTheme( colorScheme = colorScheme, typography = Typography, shapes = Shapes, content = content ) }
  14. 4IBQFT @Immutable class Shapes( // Shapes None and Full are

    omitted as None is a RectangleShape and Full is a CircleShape. val extraSmall: CornerBasedShape = ShapeDefaults.ExtraSmall, val small: CornerBasedShape = ShapeDefaults.Small, val medium: CornerBasedShape = ShapeDefaults.Medium, val large: CornerBasedShape = ShapeDefaults.Large, val extraLarge: CornerBasedShape = ShapeDefaults.ExtraLarge, ) {
  15. 4IBQFT @Immutable class Shapes( // Shapes None and Full are

    omitted as None is a RectangleShape and Full is a CircleShape. val extraSmall: CornerBasedShape = ShapeDefaults.ExtraSmall, val small: CornerBasedShape = ShapeDefaults.Small, val medium: CornerBasedShape = ShapeDefaults.Medium, val large: CornerBasedShape = ShapeDefaults.Large, val extraLarge: CornerBasedShape = ShapeDefaults.ExtraLarge, ) { object ShapeDefaults { /** Extra small sized corner shape */ val ExtraSmall: CornerBasedShape = ShapeTokens.CornerExtraSmall /** Small sized corner shape */ val Small: CornerBasedShape = ShapeTokens.CornerSmall … }
  16. 4IBQF4ZTUFN5PLFOͷ࣮૷ internal object ShapeTokens { … val CornerExtraSmall = RoundedCornerShape(4.0.dp)

    val CornerExtraSmallTop = RoundedCornerShape( topStart = 4.0.dp, topEnd = 4.0.dp, bottomEnd = 0.0.dp, bottomStart = 0.0.dp ) … val CornerNone = RectangleShape val CornerSmall = RoundedCornerShape(8.0.dp) }
  17. 5ZQPHSBQIZ @Immutable class Typography( val displayLarge: TextStyle = TypographyTokens.DisplayLarge, val

    displayMedium: TextStyle = TypographyTokens.DisplayMedium, val displaySmall: TextStyle = TypographyTokens.DisplaySmall, val headlineLarge: TextStyle = TypographyTokens.HeadlineLarge, val headlineMedium: TextStyle = TypographyTokens.HeadlineMedium, val headlineSmall: TextStyle = TypographyTokens.HeadlineSmall, val titleLarge: TextStyle = TypographyTokens.TitleLarge, val titleMedium: TextStyle = TypographyTokens.TitleMedium, val titleSmall: TextStyle = TypographyTokens.TitleSmall, val bodyLarge: TextStyle = TypographyTokens.BodyLarge, val bodyMedium: TextStyle = TypographyTokens.BodyMedium, val bodySmall: TextStyle = TypographyTokens.BodySmall, val labelLarge: TextStyle = TypographyTokens.LabelLarge, val labelMedium: TextStyle = TypographyTokens.LabelMedium, val labelSmall: TextStyle = TypographyTokens.LabelSmall, ) {
  18. $PMPS4DIFNF @Stable class ColorScheme( primary: Color, onPrimary: Color, primaryContainer: Color,

    onPrimaryContainer: Color, inversePrimary: Color, secondary: Color, onSecondary: Color, secondaryContainer: Color, onSecondaryContainer: Color, tertiary: Color, onTertiary: Color, … scrim: Color, ) {
  19. $PMPS4DIFNF fun lightColorScheme( primary: Color = ColorLightTokens.Primary, onPrimary: Color =

    ColorLightTokens.OnPrimary, primaryContainer: Color = ColorLightTokens.PrimaryContainer, onPrimaryContainer: Color = ColorLightTokens.OnPrimaryContainer, inversePrimary: Color = ColorLightTokens.InversePrimary, secondary: Color = ColorLightTokens.Secondary, onSecondary: Color = ColorLightTokens.OnSecondary, secondaryContainer: Color = ColorLightTokens.SecondaryContainer, onSecondaryContainer: Color = ColorLightTokens.OnSecondaryContainer, tertiary: Color = ColorLightTokens.Tertiary, onTertiary: Color = ColorLightTokens.OnTertiary, … scrim: Color = ColorLightTokens.Scrim, ): ColorScheme =
  20. val md_theme_light_primary = Color(0xFF006399) val md_theme_light_onPrimary = Color(0xFFFFFFFF) … val

    md_theme_dark_primary = Color(0xFF95CCFF) val md_theme_dark_onPrimary = Color(0xFF003352) … val seed = Color(0xFF1DA1F2) private val LightColors = lightColorScheme( primary = md_theme_light_primary, onPrimary = md_theme_light_onPrimary, … ) private val DarkColors = darkColorScheme( primary = md_theme_dark_primary, onPrimary = md_theme_dark_onPrimary, … ) …
  21. w ֬ೝՕॴ͕ͦͷը໘͚ͩ w .ͱ.྆ํͷϥΠ ϒϥϦʹґଘ w JNQPSUઌΛؒҧ͑ΔՄ ೳੑ͕͋Δ w ΞϓϦ༻ͷ

    $PNQPTBCMF͕.ͱ .޲͚྆ํඞཁ Ұ౓ʹશͯΛ .ʹ͢Δ ը໘͝ͱʹ .ʹ͢Δ w ΞϓϦશମͷݟͨ ໨͕มΘΔ w ֬ೝՕॴ͕ଟͯ͘ େม w JNQPSUઌͷؒҧ͍ ͕ى͜Βͳ͍
  22. w ֬ೝՕॴ͕ͦͷը໘͚ͩ w .ͱ.྆ํͷϥΠ ϒϥϦʹґଘ w JNQPSUઌΛؒҧ͑ΔՄ ೳੑ͕͋Δ w ΞϓϦ༻ͷ

    $PNQPTBCMF͕.ͱ .޲͚྆ํඞཁ w ֬ೝՕॴ͕ͦͷίϯ ϙʔωϯτ͚ͩ w .ͱ.྆ํͷϥΠ ϒϥϦʹґଘ w ը໘಺ʹ.ͱ. ͷݟͨ໨͕ࠞࡏͯ͠͠ ·͏ Ұ౓ʹશͯΛ .ʹ͢Δ ը໘͝ͱʹ .ʹ͢Δ ίϯϙʔωϯτ͝ͱʹ .ʹ͢Δ w ΞϓϦશମͷݟͨ ໨͕มΘΔ w ֬ೝՕॴ͕ଟͯ͘ େม w JNQPSUઌͷؒҧ͍ ͕ى͜Βͳ͍
  23. w ֬ೝՕॴ͕ͦͷը໘͚ͩ w .ͱ.྆ํͷϥΠ ϒϥϦʹґଘ w JNQPSUઌΛؒҧ͑ΔՄ ೳੑ͕͋Δ w ΞϓϦ༻ͷ

    $PNQPTBCMF͕.ͱ .޲͚྆ํඞཁ w ֬ೝՕॴ͕ͦͷίϯ ϙʔωϯτ͚ͩ w .ͱ.྆ํͷϥΠ ϒϥϦʹґଘ w ը໘಺ʹ.ͱ. ͷݟͨ໨͕ࠞࡏͯ͠͠ ·͏ Ұ౓ʹશͯΛ .ʹ͢Δ ը໘͝ͱʹ .ʹ͢Δ ίϯϙʔωϯτ͝ͱʹ .ʹ͢Δ w ΞϓϦશମͷݟͨ ໨͕มΘΔ w ֬ೝՕॴ͕ଟͯ͘ େม w JNQPSUઌͷؒҧ͍ ͕ى͜Βͳ͍ খن໛ΞϓϦʹ͓͢͢Ί େن໛ΞϓϦʹ͓͢͢Ί
  24. . GPOU TJ[F . GPOU TJ[F EJTQMBZ EJTQMBZ-BSHF  EJTQMBZ

    EJTQMBZ.FEJVN  IFBEMJOF  EJTQMBZ4NBMM  IFBEMJOF  IFBEMJOF-BSHF  IFBEMJOF  IFBEMJOF.FEJVN  IFBEMJOF  IFBEMJOF4NBMM  IFBEMJOF  UJUMF-BSHF  IFBEMJOF  /" .BUFSJBM5IFNFUZQPHSBQIZ ͷରԠදʢଠࣈ͸ಉ͡GPOUTJ[Fʣ . GPOU TJ[F . GPOU TJ[F TVCUJUMF  UJUMF.FEJVN  TVCUJUMF  UJUMF4NBMM  CPEZ  CPEZ-BSHF  CPEZ  CPEZ.FEJVN  DBQUJPO  CPEZ4NBMM  CVUUPO  MBCFM-BSHF  PWFSMJOF  MBCFM.FEJVN  /" MBCFM4NBMM  IUUQTNBUFSJBMJPCMPHNJHSBUJOHNBUFSJBM
  25. 4UFQ.BUFSJBM5IFNFTIBQFT Λஔ͖׵͑Δ MaterialTheme.shapes.* MaterialTheme.shapes.* w DNE TIJGU 3 TNBMM EQ

    NFEJVN EQ MBSHF EQ FYUSB4NBMM EQ TNBMM EQ  NFEJVN EQ MBSHF EQ  FYUSB-BSHF EQ
  26. 4UFQ.༻ͷDPMPS UZQPHSBQIZ TIBQFΛ༻ҙ͢Δ import androidx.compose.material3.darkColorScheme import androidx.compose.material3.lightColorScheme import androidx.compose.material3.Shapes import

    androidx.compose.material3.Typography val LightColors = lightColorScheme( … ) val DarkColors = darkColorScheme( … ) val Typography3 = Typography() val Shapes3 = Shapes()
  27. 4UFQ.ͷ.BUFSJBM5IFNFͰXSBQ͢Δ @Composable fun MyTheme( darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable

    () -> Unit ) { androidx.compose.material3.MaterialTheme( colorScheme = if (!darkTheme) LightColors else DarkColors, typography = Typography3, shapes = Shapes3, ) { MaterialTheme( colors = if (!darkTheme) LightColorPalette else DarkColorPalette, typography = Typography, shapes = Shapes, content = content ) } }
  28. @Composable fun MaterialTheme( … ) { … CompositionLocalProvider( LocalColors provides

    rememberedColors, LocalContentAlpha provides ContentAlpha.high, LocalIndication provides rippleIndication, LocalRippleTheme provides MaterialRippleTheme, LocalShapes provides shapes, LocalTextSelectionColors provides selectionColors, LocalTypography provides typography ) { ProvideTextStyle(value = typography.body1) { PlatformMaterialTheme(content) } } } . .Ͱผͷ஋Λ ઃఆ .Ͱ΋ಉ͡஋Λ ઃఆ
  29. @Composable fun MyTheme( darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable ()

    -> Unit ) { androidx.compose.material3.MaterialTheme( colorScheme = if (!darkTheme) LightColors else DarkColors, typography = Typography3, shapes = Shapes3, ) { MaterialTheme( colors = if (!darkTheme) LightColorPalette else DarkColorPalette, typography = Typography, shapes = Shapes, content = content ) } } -PDBM3JQQMF5IFNF  -PDBM5FYU4FMFDUJPO$PMPST͸ .ͷ.BUFSJBM5IFNFʹΑΔઃఆ஋
  30. val colors = if (!darkTheme) LightColorPalette else DarkColorPalette val colorScheme

    = if (!darkTheme) { LightColors.copy( surface = colors.surface, onSurface = colors.onSurface, background = colors.background, onBackground = colors.onBackground, ) } else { DarkColors.copy( surface = colors.surface, onSurface = colors.onSurface, background = colors.background, onBackground = colors.onBackground, ) } androidx.compose.material3.MaterialTheme( colorScheme = colorScheme, … ) { MaterialTheme( colors = colors, … ) }
  31. 4UFQDVTUPNDPNQPTBCMFʹஔ͖׵͑Δ @Composable fun SettingList( … ) { ListItem( modifier =

    modifier, … ) } @Composable fun SettingList( … ) { MyListItem( modifier = modifier, … ) }
  32. 4UFQDVTUPNDPNQPTBCMF಺ͷJNQPSUจΛஔ͖׵͑Δ import androidx.compose.material.ListItem @OptIn(ExperimentalMaterialApi::class) @Composable fun MyListItem( modifier: Modifier =

    Modifier, … ) { ListItem( modifier = modifier, … ) } import androidx.compose.material3.ListItem @OptIn(ExperimentalMaterialApi::class) @Composable fun MyListItem( modifier: Modifier = Modifier, … ) { ListItem( modifier = modifier, … ) }
  33. 4UFQίϯϙʔωϯτͷมߋʹରԠ͢Δ @OptIn(ExperimentalMaterialApi::class) @Composable fun MyListItem( modifier: Modifier = Modifier, …

    ) { ListItem( text = …, … ) } @OptIn(ExperimentalMaterial3Api::class) @Composable fun MyListItem( modifier: Modifier = Modifier, … ) { ListItem( headlineText = …, … ) }
  34. EJTBCMFETUBUF val contentAlpha = if (enabled) LocalContentAlpha.current else ContentAlpha.disabled CompositionLocalProvider(LocalContentAlpha

    provides contentAlpha, content = content) %JTBCMFETUBUFTIUUQTNNBUFSJBMJPGPVOEBUJPOTJOUFSBDUJPOTUBUFT . w DPOUFOUPO4VSGBDF BMQIB w DPOUBJOFSPO4VSGBDF BMQIB val contentColor = colors.contentColor(enabled).value CompositionLocalProvider(LocalContentColor provides contentColor, content = content) .
  35. ListItem( headlineText = { Text("Hello Android") }, supportingText = {

    Text("Hello Android") }, colors = ListItemDefaults.colors( headlineColor = if (enabled) { MaterialTheme.colorScheme.onSurface } else { MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f) }, supportingColor = if (enabled) { MaterialTheme.colorScheme.onSurfaceVariant } else { MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.38f) } ) ) -JTU*UFN%FGBVMUTDPMPST Ͱ͸EJTBCMF࣌ͷ৭͕ࢦఆͰ͖ΔͷͰɺ ࠓޙFOBCMFEΛࢦఆͰ͖ΔΑ͏ʹͳΔ͔΋ʜ
  36. 4DBGGPMETDBGGPME4UBUF͕ͳ͘ͳͬͨ val scaffoldState = rememberScaffoldState() if (showSnackbar) { val message

    = … LaunchedEffect(Unit) { scaffoldState.snackbarHostState.showSnackbar(message) onSnackbarShown() } } Scaffold( scaffoldState = scaffoldState, … ) { .
  37. 4DBGGPMETDBGGPME4UBUF͕ͳ͘ͳͬͨ . val snackbarHostState = remember { SnackbarHostState() } if

    (showSnackbar) { val message = … LaunchedEffect(Unit) { snackbarHostState.showSnackbar(message) onSnackbarShown() } } Scaffold( snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, … ) {
  38. 5PQ"QQ#BS TopAppBar( …, backgroundColor = MaterialTheme.colors.onBackground, contentColor = MaterialTheme.colors.background )

    . . TopAppBar( …, colors = TopAppBarDefaults.smallTopAppBarColors( containerColor = MaterialTheme.colorScheme.inverseSurface, navigationIconContentColor = MaterialTheme.colorScheme.inverseOnSurface, titleContentColor = MaterialTheme.colorScheme.inverseOnSurface, actionIconContentColor = MaterialTheme.colorScheme.inverseOnSurface, ) )
  39. %SPQEPXO.FOV*UFN w DPOUFOUˠUFYU w 3PX4DPQF͡Όͳ͘ͳͬͨ w ࠷ޙͷҾ਺͡Όͳ͘ͳͬͨ DropdownMenuItem( onClick =

    { … } ) { Text(it) } DropdownMenuItem( text = { Text(it) }, onClick = { … } ) . .
  40. -JTU*UFN w UFYUˠIFBEMJOF5FYU w TFDPOEBSZ5FYUˠTVQQPSUJOH5FYU w JDPOˠMFBEJOH$POUFOU w USBJMJOHˠUSBJMJOH$POUFOU w

    TJOHMF-JOF4FDPOEBSZ5FYUˠͳ͠ w DPMPST-JTU*UFN$PMPST௥Ճ w UPOBM&MFWBUJPO%Q TIBEPX&MFWBUJPO%Q௥Ճʢॳظ஋͸EQʣ ListItem( headlineText = { Text("Hello Android") } ) . . ListItem { Text("Hello Android") }