This commit is contained in:
jaguh geraldoh 2024-02-12 17:14:49 +00:00 committed by GitHub
commit c17311ee01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 46 additions and 24 deletions

View file

@ -41,7 +41,7 @@ android {
dependencies { dependencies {
implementation "androidx.compose.ui:ui:$compose_version" implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version" implementation "androidx.compose.material3:material3"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version" implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version" implementation "androidx.compose.runtime:runtime:$compose_version"

View file

@ -20,8 +20,8 @@ import android.os.Bundle
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material.Surface import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
@ -42,7 +42,7 @@ class MainActivity : ComponentActivity() {
setContent { setContent {
AndroidDeveloperRoadmapTheme { AndroidDeveloperRoadmapTheme {
Surface( Surface(
color = MaterialTheme.colors.background color = MaterialTheme.colorScheme.background
) { ) {
AndroidRoadmap() AndroidRoadmap()
} }
@ -53,7 +53,7 @@ class MainActivity : ComponentActivity() {
@Composable @Composable
private fun AndroidRoadmap() { private fun AndroidRoadmap() {
val background = MaterialTheme.colors.background val background = MaterialTheme.colorScheme.background
CoilImage( CoilImage(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
@ -70,7 +70,7 @@ private fun AndroidRoadmap() {
) )
} }
@Preview(showBackground = true) @Preview(showBackground = true, showSystemUi = true)
@Composable @Composable
private fun DefaultPreview() { private fun DefaultPreview() {
AndroidDeveloperRoadmapTheme { AndroidDeveloperRoadmapTheme {

View file

@ -17,7 +17,7 @@
package io.getstream.androiddeveloperroadmap.ui.theme package io.getstream.androiddeveloperroadmap.ui.theme
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Shapes import androidx.compose.material3.Shapes
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
val Shapes = Shapes( val Shapes = Shapes(

View file

@ -16,37 +16,59 @@
package io.getstream.androiddeveloperroadmap.ui.theme package io.getstream.androiddeveloperroadmap.ui.theme
import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material.darkColors import androidx.compose.material3.darkColorScheme
import androidx.compose.material.lightColors import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
private val DarkColorPalette = darkColors( private val DarkColorScheme = darkColorScheme(
primary = Purple200, primary = Purple200,
primaryVariant = Purple700, secondary = Purple700,
secondary = Teal200 tertiary = Teal200
) )
private val LightColorPalette = lightColors( private val LightColorScheme = lightColorScheme(
primary = Purple500, primary = Purple500,
primaryVariant = Purple700, secondary = Purple700,
secondary = Teal200 tertiary = Teal200
) )
@Composable @Composable
fun AndroidDeveloperRoadmapTheme( fun AndroidDeveloperRoadmapTheme(
darkTheme: Boolean = isSystemInDarkTheme(), darkTheme: Boolean = isSystemInDarkTheme(),
dynamicColor: Boolean = true,
content: @Composable () -> Unit content: @Composable () -> Unit
) { ) {
val colors = if (darkTheme) { val colorScheme = when {
DarkColorPalette dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
} else { val context = LocalContext.current
LightColorPalette if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colorScheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
}
} }
MaterialTheme( MaterialTheme(
colors = colors, colorScheme = colorScheme,
typography = Typography, typography = Typography,
shapes = Shapes, shapes = Shapes,
content = content content = content

View file

@ -16,7 +16,7 @@
package io.getstream.androiddeveloperroadmap.ui.theme package io.getstream.androiddeveloperroadmap.ui.theme
import androidx.compose.material.Typography import androidx.compose.material3.Typography
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
@ -24,7 +24,7 @@ import androidx.compose.ui.unit.sp
// Set of Material typography styles to start with // Set of Material typography styles to start with
val Typography = Typography( val Typography = Typography(
body1 = TextStyle( bodyLarge = TextStyle(
fontFamily = FontFamily.Default, fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal, fontWeight = FontWeight.Normal,
fontSize = 16.sp fontSize = 16.sp

View file

@ -2,7 +2,7 @@ buildscript {
ext { ext {
compose_version = '1.5.2' compose_version = '1.5.2'
compose_compiler_version = '1.5.3' compose_compiler_version = '1.5.3'
compose_activity_version = '1.7.2' compose_activity_version = '1.8.2'
landscapist_version = '2.2.10' landscapist_version = '2.2.10'
zoomable_version = '1.5.1' zoomable_version = '1.5.1'
} }