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

Material Design 3 in Jetpack Compose

Material Design 3 in Jetpack Compose

Loveleen Kaur

May 08, 2023
Tweet

More Decks by Loveleen Kaur

Other Decks in Technology

Transcript

  1. Who am I? • Loveleen Kaur • Software Engineer -

    Android @ Astrotalk • Core Team Member @ Google Developer Groups Chandigarh • Android Educator @ Android Educators Community India • Phd Research Scholar • Develop Mobile Applications • Technical Speaker • Happy Android Developer :)
  2. • M3 is the latest version of Google’s open-source design

    system • New set of Design Capabilities What is Material Design 3?
  3. • M3 is the latest version of Google’s open-source design

    system • New set of Design Capabilities • Updated theming What is Material Design 3?
  4. • M3 is the latest version of Google’s open-source design

    system • New set of Design Capabilities • Updated theming • Material You personalization What is Material Design 3?
  5. • M3 is the latest version of Google’s open-source design

    system • New set of Design Capabilities • Updated theming • Material You personalization • Updates to Android 12 visual style and system UI What is Material Design 3?
  6. • M3 is the latest version of Google’s open-source design

    system • New set of Design Capabilities • Updated theming • Material You personalization • Updates to Android 12 visual style and system UI What is Material Design 3?
  7. • Compose is combination of 7 Maven Group Ids within

    androidx. • Each Group contains a targeted subset of functionality. Compose Material 3
  8. • Compose is combination of 7 Maven Group Ids within

    androidx. • Each Group contains a targeted subset of functionality • Each with its own set of release notes. Compose Material 3
  9. • Compose is combination of 7 Maven Group Ids within

    androidx. • Each Group contains a targeted subset of functionality • Each with its own set of release notes. Compose Material 3
  10. compose.animation Build animations in their Jetpack Compose applications to enrich

    the UX. compose.compiler Transform @Composable functions and enable optimizations with a Kotlin compiler plugin. compose.foundation Write Jetpack Compose applications with ready to use building blocks. compose.material Build Jetpack Compose UIs with ready to use Material Design Components. compose.material3 Build Jetpack Compose UIs with Material Design 3 Components. compose.runtime Fundamental building blocks of Compose's programming model and state management. compose.ui Fundamental components of compose UI needed to interact with the device, including layout, drawing, and input. Stable Release-1.0.1 Latest Update-April 19, 2023 Compose Material 3
  11. Declaring dependencies dependencies { implementation("androidx.compose.material3:material3:1.0.1") } android { buildFeatures {

    compose = true } composeOptions { kotlinCompilerExtensionVersion = "1.1.1" } kotlinOptions { jvmTarget = "1.8" } }
  12. • The foundation of a color scheme is the set

    of five key colors. Color Scheme
  13. • The foundation of a color scheme is the set

    of five key colors. • Each of these colors relate to a tonal palette of 13 tones. Color Scheme
  14. • The foundation of a color scheme is the set

    of five key colors. • Each of these colors relate to a tonal palette of 13 tones. Color Scheme
  15. Generating Color Scheme Color.kt contains the colors of your theme

    with all the roles defined for both light and dark theme colors. val md_theme_light_primary = Color(0xFF476810) val md_theme_light_onPrimary = Color(0xFFFFFFFF) val md_theme_light_primaryContainer = Color(0xFFC7F089) // .. // .. val md_theme_dark_primary = Color(0xFFACD370) val md_theme_dark_onPrimary = Color(0xFF213600) val md_theme_dark_primaryContainer = Color(0xFF324F00) // .. // ..
  16. Generating Color Scheme Theme.kt contains a setup for light and

    dark color schemes and the app theme. private val LightColorScheme = lightColorScheme( primary = md_theme_light_primary, onPrimary = md_theme_light_onPrimary, primaryContainer = md_theme_light_primaryContainer, onPrimaryContainer = md_theme_light_onPrimaryContainer, // .. ) private val DarkColorScheme = darkColorScheme( primary = md_theme_dark_primary, onPrimary = md_theme_dark_onPrimary, primaryContainer = md_theme_dark_primaryContainer, onPrimaryContainer = md_theme_dark_onPrimaryContainer, // .. )
  17. • Dynamic color is the key part of Material You.

    • This color palette is used as the starting point to generate light and dark color schemes. Dynamic Color Scheme
  18. • Dynamic color is the key part of Material You.

    • This color palette is used as the starting point to generate light and dark color schemes. • Dynamic color is available on Android 12 and above. Dynamic Color Scheme
  19. • Dynamic color is the key part of Material You.

    • This color palette is used as the starting point to generate light and dark color schemes. • Dynamic color is available on Android 12 and above. Dynamic Color Scheme
  20. Dynamic Color Scheme // Dynamic color is available on Android

    12+ val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S val colors = when { dynamicColor && darkTheme - > dynamicDarkColorScheme(LocalContext.current) dynamicColor && !darkTheme - > dynamicLightColorScheme(LocalContext.current) darkTheme - > darkColorScheme else - > lightColorScheme }
  21. Color Usage • Primary is the base color, used for

    main components like prominent buttons, active states, and the tint of elevated surfaces. • The secondary key color is used for less prominent components in the UI, such as filter chips, and expands the opportunity for color expression. • The tertiary key color is used to derive the roles of contrasting accents that can be used to balance primary and secondary colors or bring enhanced attention to an element.
  22. Defining Typography val replyTypography = Typography( titleLarge = TextStyle( fontWeight

    = FontWeight.SemiBold, fontSize = 22. sp, lineHeight = 28. sp, letterSpacing = 0. sp ), titleMedium = TextStyle( fontWeight = FontWeight.SemiBold, fontSize = 16. sp, lineHeight = 24. sp, letterSpacing = 0.15.sp ), ) ...
  23. Custom Typography bodyLarge = TextStyle( fontWeight = FontWeight.Normal, fontFamily =

    FontFamily.SansSerif, fontStyle = FontStyle.Italic, fontSize = 16. sp, lineHeight = 24. sp, letterSpacing = 0.15.sp, baselineShift = BaselineShift.Subscript ),
  24. • Material surfaces can be displayed in different shapes. •

    Shape scale defines style of container corners, offering a range of roundedness. Shapes
  25. • Material surfaces can be displayed in different shapes. •

    Shape scale defines style of container corners, offering a range of roundedness. • There are different sizes of shapes- Extra Small, Small, Medium, Large, Extra Large Shapes
  26. • Material surfaces can be displayed in different shapes. •

    Shape scale defines style of container corners, offering a range of roundedness. • There are different sizes of shapes- Extra Small, Small, Medium, Large, Extra Large Shapes
  27. Shapes val replyShapes = Shapes( extraSmall = RoundedCornerShape(4. dp), small

    = RoundedCornerShape(8. dp), medium = RoundedCornerShape(12. dp), large = RoundedCornerShape(16. dp), extraLarge = RoundedCornerShape(24. dp) )
  28. 1. Add M3 dependency alongside M2 dependency. 2. Add M3

    version(s) of your app’s theme(s) alongside M2 version(s) of your app’s theme(s). Steps of Migration
  29. 1. Add M3 dependency alongside M2 dependency. 2. Add M3

    version(s) of your app’s theme(s) alongside M2 version(s) of your app’s theme(s). 3. Migrate individual modules, screens, or composables to M3, depending on the size and complexity of your app. Steps of Migration
  30. 1. Add M3 dependency alongside M2 dependency. 2. Add M3

    version(s) of your app’s theme(s) alongside M2 version(s) of your app’s theme(s). 3. Migrate individual modules, screens, or composables to M3, depending on the size and complexity of your app. 4. Once fully migrated, remove the M2 version(s) of your app’s theme(s). Steps of Migration
  31. 1. Add M3 dependency alongside M2 dependency. 2. Add M3

    version(s) of your app’s theme(s) alongside M2 version(s) of your app’s theme(s). 3. Migrate individual modules, screens, or composables to M3, depending on the size and complexity of your app. 4. Once fully migrated, remove the M2 version(s) of your app’s theme(s). 5. Remove M2 dependency. Steps of Migration
  32. 1. Add M3 dependency alongside M2 dependency. 2. Add M3

    version(s) of your app’s theme(s) alongside M2 version(s) of your app’s theme(s). 3. Migrate individual modules, screens, or composables to M3, depending on the size and complexity of your app. 4. Once fully migrated, remove the M2 version(s) of your app’s theme(s). 5. Remove M2 dependency. Steps of Migration