Splash screen colors

closes #50
This commit is contained in:
Sad Ellie 2023-05-01 20:28:33 +03:00
parent e1337d755e
commit 34521e306e
7 changed files with 84 additions and 14 deletions

View File

@ -18,18 +18,24 @@
package com.sadellie.unitto
import android.app.Activity
import androidx.compose.animation.core.tween
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalNavigationDrawer
import androidx.compose.material3.rememberDrawerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.platform.LocalView
import androidx.core.view.WindowCompat
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavDestination.Companion.hierarchy
@ -103,12 +109,11 @@ internal fun UnittoApp() {
typography = AppTypography,
animationSpec = tween(250)
) {
val statusBarColor = when (currentRoute) {
// Match text field container color
TopLevelDestinations.Calculator -> MaterialTheme.colorScheme.surfaceVariant
else -> MaterialTheme.colorScheme.background
val localView = LocalView.current
val backgroundColor = MaterialTheme.colorScheme.background
val useDarkIcons by remember(backgroundColor) {
mutableStateOf(backgroundColor.luminance() > 0.5f)
}
val navigationBarColor = MaterialTheme.colorScheme.background
ModalNavigationDrawer(
drawerState = drawerState,
@ -142,9 +147,10 @@ internal fun UnittoApp() {
)
}
SideEffect {
sysUiController.setNavigationBarColor(navigationBarColor)
sysUiController.setStatusBarColor(statusBarColor)
LaunchedEffect(useDarkIcons) {
WindowCompat.setDecorFitsSystemWindows((localView.context as Activity).window, false)
sysUiController.setNavigationBarColor(Color.Transparent, useDarkIcons)
sysUiController.setStatusBarColor(Color.Transparent, useDarkIcons)
}
}
}

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FCFCF7</color>
</resources>

View File

@ -1,3 +1,7 @@
<resources>
<style name="Theme.Unitto" parent="@android:style/Theme.Material.NoActionBar"/>
<style name="Theme.Unitto" parent="@android:style/Theme.Material.NoActionBar">
<item name="android:windowBackground">@color/window_background</item>
<item name="android:statusBarColor">@color/window_background</item>
<item name="android:navigationBarColor">@color/window_background</item>
</style>
</resources>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a unit converter for Android
~ Copyright (c) 2023 Elshan Agaev
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="window_background">@android:color/system_neutral1_900</color>
</resources>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a unit converter for Android
~ Copyright (c) 2023 Elshan Agaev
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="window_background">#1B1B1B</color>
</resources>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Unitto is a unit converter for Android
~ Copyright (c) 2023 Elshan Agaev
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<color name="window_background">@android:color/system_neutral1_50</color>
</resources>

View File

@ -18,4 +18,5 @@
<resources>
<color name="ic_launcher_icon_background">#FCFCF7</color>
<color name="window_background">#FFFFFF</color>
</resources>