📊 Capítulo 05: Material Design 3 & Temas
Especialização em Mobile Nativo Android
🗺️ O Sistema de Design Dinâmico do Material 3 no Android 12+
flowchart LR
WALLPAPER["Papel de Parede do Usuário (Android 12+)"]
--> DYNAMIC["dynamicLightColorScheme() / dynamicDarkColorScheme()"]
--> THEME["MaterialTheme(colorScheme, typography, shapes)"]
THEME --> UI["Composables usam MaterialTheme.colorScheme.primary"]
THEME --> DARK{"isSystemInDarkTheme()"}
DARK --> |"true"| DARK_PALETTE["Paleta Escura de Alto Contraste"]
DARK --> |"false"| LIGHT_PALETTE["Paleta Clara Vibrante"]
style WALLPAPER fill:#ede7f6,stroke:#512da8,stroke-width:2px
style DYNAMIC fill:#fff3e0,stroke:#ff9800,stroke-width:2px
style THEME fill:#e8f5e9,stroke:#4caf50,stroke-width:2px
style UI fill:#e1f5fe,stroke:#03a9f4,stroke-width:1.5px
style DARK fill:#37474f,stroke:#263238,stroke-width:2px,color:#ffffff
style DARK_PALETTE fill:#263238,stroke:#000000,stroke-width:1.5px,color:#ffffff
style LIGHT_PALETTE fill:#c8e6c9,stroke:#2e7d32,stroke-width:1.5px
🎯 Slide 1: Dynamic Color (Cores do Wallpaper do Usuário)
@Composable
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
MaterialTheme(colorScheme = colorScheme, typography = Typography, content = content)
}
🎯 Slide 2: Superfícies e Containers M3
- O Material 3 substituiu sombras estáticas pesadas por Containers Tonais (
primaryContainer,secondaryContainer,surfaceVariant), garantindo legibilidade perfeita e menor consumo de bateria em telas OLED.
🎯 Slide 3: Scaffold Moderno
- Suporte nativo a
topBar,bottomBar,floatingActionButton,snackbarHoste controle automático deWindowInsets(respeitando a barra de status e o entalhe da câmera/notch).
Slide 1 de 1
Atalhos: ← → Navegar • Espaço Avançar • F Tela Cheia • Home Início • End Fim