Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Make the amoledDark theme follow Material You
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhasDissa committed Jul 16, 2023
1 parent 3c06efd commit 3b030ae
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/src/main/java/com/bnyro/recorder/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import androidx.core.view.WindowCompat
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
tertiary = Pink80,
)

private val LightColorScheme = lightColorScheme(
primary = Purple40,
secondary = PurpleGrey40,
tertiary = Pink40
tertiary = Pink40,

/* Other default colors to override
background = Color(0xFFFFFBFE),
Expand All @@ -41,23 +41,29 @@ private val LightColorScheme = lightColorScheme(
private val AmoledDarkColorScheme = darkColorScheme(
primary = Color(0xFFEE665B),
background = Color(0xFF000000),
onPrimary = Color(0xFFFFFFFF)
onPrimary = Color(0xFFFFFFFF),
)

@Composable
fun RecordYouTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
amoledDark:Boolean = false,
content: @Composable () -> Unit
amoledDark: Boolean = false,
content: @Composable () -> Unit,
) {
val colorScheme = when {
amoledDark && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
dynamicDarkColorScheme(context).copy(background = Color.Black)
}

amoledDark -> AmoledDarkColorScheme
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}

darkTheme -> DarkColorScheme
else -> LightColorScheme
}
Expand All @@ -70,11 +76,11 @@ fun RecordYouTheme(
activity.window.statusBarColor = colorScheme.background.toArgb()
WindowCompat.getInsetsController(
activity.window,
view
view,
).isAppearanceLightStatusBars = !darkTheme
WindowCompat.getInsetsController(
activity.window,
view
view,
).isAppearanceLightNavigationBars = !darkTheme
}
}
Expand All @@ -83,6 +89,6 @@ fun RecordYouTheme(
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
content = content,
)
}

0 comments on commit 3b030ae

Please sign in to comment.