mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 16:55:26 +02:00
parent
e1337d755e
commit
34521e306e
@ -18,18 +18,24 @@
|
|||||||
|
|
||||||
package com.sadellie.unitto
|
package com.sadellie.unitto
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.material3.DrawerValue
|
import androidx.compose.material3.DrawerValue
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ModalNavigationDrawer
|
import androidx.compose.material3.ModalNavigationDrawer
|
||||||
import androidx.compose.material3.rememberDrawerState
|
import androidx.compose.material3.rememberDrawerState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.ui.Modifier
|
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.hilt.navigation.compose.hiltViewModel
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import androidx.navigation.NavDestination.Companion.hierarchy
|
import androidx.navigation.NavDestination.Companion.hierarchy
|
||||||
@ -103,12 +109,11 @@ internal fun UnittoApp() {
|
|||||||
typography = AppTypography,
|
typography = AppTypography,
|
||||||
animationSpec = tween(250)
|
animationSpec = tween(250)
|
||||||
) {
|
) {
|
||||||
val statusBarColor = when (currentRoute) {
|
val localView = LocalView.current
|
||||||
// Match text field container color
|
val backgroundColor = MaterialTheme.colorScheme.background
|
||||||
TopLevelDestinations.Calculator -> MaterialTheme.colorScheme.surfaceVariant
|
val useDarkIcons by remember(backgroundColor) {
|
||||||
else -> MaterialTheme.colorScheme.background
|
mutableStateOf(backgroundColor.luminance() > 0.5f)
|
||||||
}
|
}
|
||||||
val navigationBarColor = MaterialTheme.colorScheme.background
|
|
||||||
|
|
||||||
ModalNavigationDrawer(
|
ModalNavigationDrawer(
|
||||||
drawerState = drawerState,
|
drawerState = drawerState,
|
||||||
@ -142,9 +147,10 @@ internal fun UnittoApp() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
SideEffect {
|
LaunchedEffect(useDarkIcons) {
|
||||||
sysUiController.setNavigationBarColor(navigationBarColor)
|
WindowCompat.setDecorFitsSystemWindows((localView.context as Activity).window, false)
|
||||||
sysUiController.setStatusBarColor(statusBarColor)
|
sysUiController.setNavigationBarColor(Color.Transparent, useDarkIcons)
|
||||||
|
sysUiController.setStatusBarColor(Color.Transparent, useDarkIcons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<color name="ic_launcher_background">#FCFCF7</color>
|
|
||||||
</resources>
|
|
@ -1,3 +1,7 @@
|
|||||||
<resources>
|
<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>
|
</resources>
|
21
core/base/src/main/res/values-night-v31/colors.xml
Normal file
21
core/base/src/main/res/values-night-v31/colors.xml
Normal 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>
|
21
core/base/src/main/res/values-night/colors.xml
Normal file
21
core/base/src/main/res/values-night/colors.xml
Normal 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>
|
21
core/base/src/main/res/values-v31/colors.xml
Normal file
21
core/base/src/main/res/values-v31/colors.xml
Normal 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>
|
@ -18,4 +18,5 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<color name="ic_launcher_icon_background">#FCFCF7</color>
|
<color name="ic_launcher_icon_background">#FCFCF7</color>
|
||||||
|
<color name="window_background">#FFFFFF</color>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user