diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 3b86109..0c0c338 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -3,20 +3,7 @@ - - - - - - - - - - - - - - + diff --git a/app/src/main/java/com/anthonyla/livewallpaper/MainActivity.kt b/app/src/main/java/com/anthonyla/livewallpaper/MainActivity.kt index f455130..0126e0c 100644 --- a/app/src/main/java/com/anthonyla/livewallpaper/MainActivity.kt +++ b/app/src/main/java/com/anthonyla/livewallpaper/MainActivity.kt @@ -4,6 +4,10 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.viewModels +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material.Surface +import androidx.compose.runtime.Composable +import androidx.compose.ui.unit.dp import com.anthonyla.livewallpaper.data.settings.SettingsViewModel import com.anthonyla.livewallpaper.themes.LiveWallpaperTheme import com.anthonyla.livewallpaper.ui.LiveWallpaperApp @@ -16,9 +20,27 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { - LiveWallpaperTheme { - LiveWallpaperApp(settingsViewModel) + LiveWallpaperTheme (isDarkMode(), isDynamicTheming()) { + Surface(elevation = 5.dp) { + LiveWallpaperApp(settingsViewModel) + } } } } -} \ No newline at end of file + + @Composable + private fun isDarkMode(): Boolean { + return when (settingsViewModel.getDarkMode()) { + true -> true + false -> false + null -> isSystemInDarkTheme() + } + } + + private fun isDynamicTheming(): Boolean { + return when (settingsViewModel.getDynamicTheme()) { + true, null -> true + false -> false + } + } +} diff --git a/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavScreens.kt b/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavScreens.kt index ddc7329..2218a41 100644 --- a/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavScreens.kt +++ b/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavScreens.kt @@ -17,4 +17,5 @@ sealed class BottomNavScreens(val route: String, @StringRes val resourceId: Int, object Wallpaper : BottomNavScreens("wallpaper", R.string.wallpaper, Icons.Filled.Home) object Library : BottomNavScreens("library", R.string.library, Icons.Filled.List) object Configure : BottomNavScreens("configure", R.string.configure, Icons.Filled.Settings) + } \ No newline at end of file diff --git a/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavigationBar.kt b/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavigationBar.kt index a6b5cdf..019af50 100644 --- a/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavigationBar.kt +++ b/app/src/main/java/com/anthonyla/livewallpaper/navigation/BottomNavigationBar.kt @@ -7,6 +7,8 @@ import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarDefaults import androidx.compose.material3.NavigationBarDefaults.containerColor import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.NavigationBarItemDefaults +import androidx.compose.material3.NavigationDrawerItemDefaults import androidx.compose.material3.Text import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable @@ -27,7 +29,8 @@ import androidx.navigation.compose.currentBackStackEntryAsState @Composable fun BottomNavigationBar( navController: NavController, - screens: List + screens: List, + modifier: Modifier = Modifier ) { NavigationBar( containerColor = containerColor, @@ -40,11 +43,12 @@ fun BottomNavigationBar( val currentDestination = navBackStackEntry?.destination screens.forEach { screen -> NavigationBarItem( + colors = NavigationBarItemDefaults.colors(), selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true, label = { Text( text = stringResource(id = screen.resourceId), - fontWeight = FontWeight.SemiBold + fontWeight = FontWeight.SemiBold, ) }, icon = { Icon(screen.icon, diff --git a/app/src/main/java/com/anthonyla/livewallpaper/navigation/TopBar.kt b/app/src/main/java/com/anthonyla/livewallpaper/navigation/TopBar.kt new file mode 100644 index 0000000..0407e1b --- /dev/null +++ b/app/src/main/java/com/anthonyla/livewallpaper/navigation/TopBar.kt @@ -0,0 +1,41 @@ +package com.anthonyla.livewallpaper.navigation + + +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Favorite +import androidx.compose.material.icons.filled.MoreVert +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarDefaults.windowInsets +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.navigation.NavController +import com.anthonyla.livewallpaper.R + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun TopBar ( + navController: NavController, + modifier: Modifier = Modifier +) { + CenterAlignedTopAppBar( + title = {}, + navigationIcon = {}, + windowInsets = windowInsets, + colors = TopAppBarDefaults.centerAlignedTopAppBarColors(), + scrollBehavior = null, + actions = { + IconButton(onClick = { /* doSomething() */ }) { + Icon( + imageVector = Icons.Filled.MoreVert, + contentDescription = stringResource(R.string.MoreVertIcon) + ) + } + } + ) + +} \ No newline at end of file diff --git a/app/src/main/java/com/anthonyla/livewallpaper/themes/Theme.kt b/app/src/main/java/com/anthonyla/livewallpaper/themes/Theme.kt index b8fa3e8..ab7f207 100644 --- a/app/src/main/java/com/anthonyla/livewallpaper/themes/Theme.kt +++ b/app/src/main/java/com/anthonyla/livewallpaper/themes/Theme.kt @@ -1,10 +1,17 @@ package com.anthonyla.livewallpaper.themes -import androidx.compose.foundation.isSystemInDarkTheme +import android.os.Build import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Typography import androidx.compose.material3.lightColorScheme import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp private val LightColors = lightColorScheme( @@ -72,19 +79,57 @@ private val DarkColors = darkColorScheme( scrim = md_theme_dark_scrim, ) +val typography = Typography( + headlineSmall = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 24.sp, + lineHeight = 32.sp, + letterSpacing = 0.sp + ), + titleLarge = TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 18.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + bodyLarge = TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.15.sp + ), + bodyMedium = TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 14.sp, + lineHeight = 20.sp, + letterSpacing = 0.25.sp + ), + labelMedium = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 12.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) +) + + @Composable fun LiveWallpaperTheme( - useDarkTheme: Boolean = isSystemInDarkTheme(), - content: @Composable() () -> Unit -) { - val colors = if (!useDarkTheme) { - LightColors - } else { - DarkColors - } - - MaterialTheme( - colorScheme = colors, - content = content - ) + useDarkTheme: Boolean, + 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) + else dynamicLightColorScheme(context) + } + useDarkTheme -> DarkColors + else -> LightColors + } + MaterialTheme( + colorScheme = colors, + typography = typography, + content = content + ) } \ No newline at end of file diff --git a/app/src/main/java/com/anthonyla/livewallpaper/ui/LiveWallpaperApp.kt b/app/src/main/java/com/anthonyla/livewallpaper/ui/LiveWallpaperApp.kt index 8f251f1..125dc15 100644 --- a/app/src/main/java/com/anthonyla/livewallpaper/ui/LiveWallpaperApp.kt +++ b/app/src/main/java/com/anthonyla/livewallpaper/ui/LiveWallpaperApp.kt @@ -18,27 +18,31 @@ import androidx.navigation.compose.rememberNavController import com.anthonyla.livewallpaper.data.settings.SettingsViewModel import com.anthonyla.livewallpaper.navigation.BottomNavScreens import com.anthonyla.livewallpaper.navigation.BottomNavigationBar +import com.anthonyla.livewallpaper.navigation.TopBar import com.anthonyla.livewallpaper.navigation.bottomNav import com.google.accompanist.systemuicontroller.rememberSystemUiController @OptIn(ExperimentalMaterial3Api::class) @Composable fun LiveWallpaperApp(settingsViewModel: SettingsViewModel, modifier: Modifier = Modifier) { + val navController = rememberNavController() + SetTransparentSystemBars() // Bottom navigation - val navController = rememberNavController() val bottomNavOptions = listOf( BottomNavScreens.Wallpaper, BottomNavScreens.Library, BottomNavScreens.Configure ) Scaffold ( + topBar = { + TopBar(navController = navController) + }, bottomBar = { BottomNavigationBar(navController = navController, screens = bottomNavOptions) }, - ) { - innerPadding -> NavHost ( + ) { innerPadding -> NavHost ( navController, startDestination = "bottomNavigation", Modifier.padding(innerPadding) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4deb24c..629f778 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -3,4 +3,5 @@ Library Configure Wallpaper + Options \ No newline at end of file