2023-05-27 10:38:50 -07:00
|
|
|
package com.anthonyla.livewallpaper.ui
|
|
|
|
|
|
2023-05-30 17:40:10 -07:00
|
|
|
import android.app.Activity
|
2023-05-27 10:38:50 -07:00
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
|
|
import androidx.compose.material3.Scaffold
|
2023-05-31 13:56:14 -07:00
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.material3.TopAppBar
|
2023-05-27 10:38:50 -07:00
|
|
|
import androidx.compose.runtime.Composable
|
2023-05-28 23:43:42 -07:00
|
|
|
import androidx.compose.runtime.SideEffect
|
2023-05-27 10:38:50 -07:00
|
|
|
import androidx.compose.ui.Modifier
|
2023-05-28 23:43:42 -07:00
|
|
|
import androidx.compose.ui.graphics.Color
|
2023-05-30 17:40:10 -07:00
|
|
|
import androidx.compose.ui.graphics.toArgb
|
|
|
|
|
import androidx.compose.ui.platform.LocalView
|
|
|
|
|
import androidx.core.view.WindowCompat
|
2023-05-27 10:38:50 -07:00
|
|
|
import androidx.navigation.compose.NavHost
|
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
2023-05-31 13:56:14 -07:00
|
|
|
import com.anthonyla.livewallpaper.data.settings.SettingsViewModel
|
2023-05-27 10:38:50 -07:00
|
|
|
import com.anthonyla.livewallpaper.navigation.BottomNavScreens
|
|
|
|
|
import com.anthonyla.livewallpaper.navigation.BottomNavigationBar
|
2023-06-01 14:03:19 -07:00
|
|
|
import com.anthonyla.livewallpaper.navigation.TopBar
|
2023-05-27 10:38:50 -07:00
|
|
|
import com.anthonyla.livewallpaper.navigation.bottomNav
|
2023-05-28 23:43:42 -07:00
|
|
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
2023-05-27 10:38:50 -07:00
|
|
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
|
|
@Composable
|
2023-05-31 13:56:14 -07:00
|
|
|
fun LiveWallpaperApp(settingsViewModel: SettingsViewModel, modifier: Modifier = Modifier) {
|
2023-06-01 14:03:19 -07:00
|
|
|
val navController = rememberNavController()
|
|
|
|
|
|
2023-05-30 17:40:10 -07:00
|
|
|
SetTransparentSystemBars()
|
2023-05-27 10:38:50 -07:00
|
|
|
|
|
|
|
|
// Bottom navigation
|
|
|
|
|
val bottomNavOptions = listOf(
|
|
|
|
|
BottomNavScreens.Wallpaper,
|
|
|
|
|
BottomNavScreens.Library,
|
2023-05-28 23:43:42 -07:00
|
|
|
BottomNavScreens.Configure
|
2023-05-27 10:38:50 -07:00
|
|
|
)
|
|
|
|
|
Scaffold (
|
2023-06-01 14:03:19 -07:00
|
|
|
topBar = {
|
|
|
|
|
TopBar(navController = navController)
|
|
|
|
|
},
|
2023-05-28 23:43:42 -07:00
|
|
|
bottomBar = {
|
|
|
|
|
BottomNavigationBar(navController = navController, screens = bottomNavOptions)
|
|
|
|
|
},
|
2023-06-01 14:03:19 -07:00
|
|
|
) { innerPadding -> NavHost (
|
2023-05-28 23:43:42 -07:00
|
|
|
navController,
|
|
|
|
|
startDestination = "bottomNavigation",
|
|
|
|
|
Modifier.padding(innerPadding)
|
|
|
|
|
) {
|
2023-05-27 10:38:50 -07:00
|
|
|
bottomNav(navController)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-30 17:40:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun SetTransparentSystemBars() {
|
|
|
|
|
val systemUiController = rememberSystemUiController()
|
|
|
|
|
val view = LocalView.current
|
|
|
|
|
SideEffect {
|
|
|
|
|
with(view.context as Activity) {
|
|
|
|
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
|
|
|
|
systemUiController.setSystemBarsColor(
|
|
|
|
|
color = Color.Transparent,
|
|
|
|
|
// check if app is in dark mode or not
|
|
|
|
|
darkIcons = false
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-27 10:38:50 -07:00
|
|
|
}
|