Added functionality of automatic splash transition for light-dark mode
This commit is contained in:
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
setTheme(R.style.Theme_LiveWallpaper)
|
||||||
setContent {
|
setContent {
|
||||||
LiveWallpaperTheme (isDarkMode(), isDynamicTheming()) {
|
LiveWallpaperTheme (isDarkMode(), isDynamicTheming()) {
|
||||||
Surface(elevation = 5.dp) {
|
Surface(elevation = 5.dp) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.anthonyla.livewallpaper.themes
|
package com.anthonyla.livewallpaper.themes
|
||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import androidx.compose.material.darkColors
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Typography
|
import androidx.compose.material3.Typography
|
||||||
import androidx.compose.material3.lightColorScheme
|
import androidx.compose.material3.lightColorScheme
|
||||||
@@ -119,6 +120,7 @@ fun LiveWallpaperTheme(
|
|||||||
useDynamicTheme: Boolean,
|
useDynamicTheme: Boolean,
|
||||||
content: @Composable () -> Unit
|
content: @Composable () -> Unit
|
||||||
) { // Check if dynamic theming is enabled in settings
|
) { // Check if dynamic theming is enabled in settings
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val colors = when {((Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)) && useDynamicTheme -> {
|
val colors = when {((Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)) && useDynamicTheme -> {
|
||||||
if (useDarkTheme) dynamicDarkColorScheme(context)
|
if (useDarkTheme) dynamicDarkColorScheme(context)
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package com.anthonyla.livewallpaper.ui
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
|
<solid android:color="@color/default_splash_dark"/>
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
|
<solid android:color="@color/default_splash_light"/>
|
||||||
|
</shape>
|
||||||
@@ -7,4 +7,7 @@
|
|||||||
<color name="teal_700">#FF018786</color>
|
<color name="teal_700">#FF018786</color>
|
||||||
<color name="black">#FF000000</color>
|
<color name="black">#FF000000</color>
|
||||||
<color name="white">#FFFFFFFF</color>
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
<color name="transparent">#00FFFFFF</color>
|
||||||
|
<color name="default_splash_light">#FFFBFE</color>
|
||||||
|
<color name="default_splash_dark">#1C1B1F</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<style name="Theme.LiveWallpaper" parent="android:Theme.Material.Light.NoActionBar">
|
||||||
<style name="Theme.LiveWallpaper" parent="android:Theme.Material.Light.NoActionBar" />
|
<item name="android:windowBackground">@drawable/splash_background</item>
|
||||||
|
<item name="android:statusBarColor">@color/transparent</item>
|
||||||
|
<item name="android:navigationBarColor">@color/transparent</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user