Added functionality of automatic splash transition for light-dark mode

This commit is contained in:
Anthony La committed 2023-06-03 11:58:53 -07:00
1 parent 45487abc09
commit 09a6e2f031
7 files changed
+21 -2

No files matched your search

@@ -19,6 +19,7 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.Theme_LiveWallpaper)
setContent {
LiveWallpaperTheme (isDarkMode(), isDynamicTheming()) {
Surface(elevation = 5.dp) {
@@ -1,6 +1,7 @@
package com.anthonyla.livewallpaper.themes
import android.os.Build
import androidx.compose.material.darkColors
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Typography
import androidx.compose.material3.lightColorScheme
@@ -119,6 +120,7 @@ fun LiveWallpaperTheme(
useDynamicTheme: Boolean,
content: @Composable () -> Unit
) { // Check if dynamic theming is enabled in settings
val context = LocalContext.current
val colors = when {((Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)) && useDynamicTheme -> {
if (useDarkTheme) dynamicDarkColorScheme(context)
@@ -2,8 +2,10 @@ package com.anthonyla.livewallpaper.ui
import android.app.Activity
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect