Added filled-unfilled icon transitions

This commit is contained in:
Anthony La committed 2023-06-06 10:55:37 -07:00
1 parent ccf60009cc
commit b363e6d511
8 files changed
+51 -33

No files matched your search

+1
View File
@@ -66,6 +66,7 @@ dependencies {
implementation("androidx.compose.material:material:1.5.0-beta01")
implementation("androidx.datastore:datastore:1.1.0-alpha04")
implementation("androidx.datastore:datastore-preferences:1.1.0-alpha04")
implementation("androidx.compose.material:material-icons-extended:1.5.0-beta01")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
@@ -0,0 +1,27 @@
package com.anthonyla.livewallpaper.data.navigation
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AddToPhotos
import androidx.compose.material.icons.filled.Home
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.filled.Tune
import androidx.compose.material.icons.filled.Wallpaper
import androidx.compose.material.icons.outlined.AddToPhotos
import androidx.compose.material.icons.outlined.Home
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.Tune
import androidx.compose.material.icons.rounded.Home
import androidx.compose.material.icons.rounded.Menu
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.ui.graphics.vector.ImageVector
import com.anthonyla.livewallpaper.R
/**
* List of screens for the bottom navigation bar
*/
sealed class BottomNavScreens(val route: String, @StringRes val resourceId: Int, val unfilledIcon: ImageVector, val filledIcon: ImageVector) {
object Wallpaper : BottomNavScreens("wallpaper", R.string.wallpaper, Icons.Outlined.Home, Icons.Filled.Home)
object Library : BottomNavScreens("library", R.string.library, Icons.Outlined.AddToPhotos, Icons.Filled.AddToPhotos)
object Configure : BottomNavScreens("configure", R.string.configure, Icons.Outlined.Settings, Icons.Filled.Settings)
}
@@ -1,4 +1,4 @@
package com.anthonyla.livewallpaper.navigation
package com.anthonyla.livewallpaper.data.navigation
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
@@ -1,7 +1,9 @@
package com.anthonyla.livewallpaper.navigation
package com.anthonyla.livewallpaper.data.navigation
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.ui.graphics.vector.ImageVector
import com.anthonyla.livewallpaper.R
@@ -9,6 +11,6 @@ import com.anthonyla.livewallpaper.R
/**
* List of screens for app settings
*/
sealed class SettingsNavScreens(val route: String, @StringRes val resourceId: Int, val icon: ImageVector) {
object Settings : SettingsNavScreens("settings", R.string.settings, Icons.Rounded.Settings)
sealed class SettingsNavScreens(val route: String, @StringRes val resourceId: Int, val unfilledIcon: ImageVector, val filledIcon: ImageVector) {
object Settings : SettingsNavScreens("settings", R.string.settings, Icons.Outlined.Settings, Icons.Filled.Settings)
}
@@ -1,19 +0,0 @@
package com.anthonyla.livewallpaper.navigation
import androidx.annotation.StringRes
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Home
import androidx.compose.material.icons.rounded.Menu
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.ui.graphics.vector.ImageVector
import com.anthonyla.livewallpaper.R
/**
* List of screens for the bottom navigation bar
*/
sealed class BottomNavScreens(val route: String, @StringRes val resourceId: Int, val icon: ImageVector) {
object Wallpaper : BottomNavScreens("wallpaper", R.string.wallpaper, Icons.Rounded.Home)
object Library : BottomNavScreens("library", R.string.library, Icons.Rounded.Menu)
object Configure : BottomNavScreens("configure", R.string.configure, Icons.Rounded.Settings)
}
@@ -1,4 +1,4 @@
package com.anthonyla.livewallpaper.navigation
package com.anthonyla.livewallpaper.ui
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
@@ -18,6 +18,7 @@ import androidx.navigation.NavController
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.currentBackStackEntryAsState
import com.anthonyla.livewallpaper.data.navigation.BottomNavScreens
/**
@@ -49,9 +50,13 @@ fun BottomNavigationBar(
fontWeight = FontWeight.SemiBold,
) },
icon = {
Icon(screen.icon,
contentDescription = "${stringResource(id = screen.resourceId)} Icon",
) },
if (currentDestination != null) {
Icon(imageVector =
if (currentDestination.route == screen.route) screen.filledIcon else screen.unfilledIcon,
contentDescription = "${stringResource(id = screen.resourceId)} Icon",
)
}
},
alwaysShowLabel = false,
onClick = {
navController.navigate(screen.route) {
@@ -17,9 +17,8 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.currentBackStackEntryAsState
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.navGraph
import com.anthonyla.livewallpaper.data.navigation.BottomNavScreens
import com.anthonyla.livewallpaper.data.navigation.navGraph
import com.google.accompanist.systemuicontroller.rememberSystemUiController
@Composable
@@ -2,6 +2,7 @@ package com.anthonyla.livewallpaper.ui
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.rounded.MoreVert
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.DropdownMenu
@@ -15,6 +16,7 @@ import androidx.compose.material3.TopAppBarDefaults.windowInsets
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
@@ -22,7 +24,7 @@ import androidx.compose.ui.res.stringResource
import androidx.navigation.NavController
import androidx.navigation.NavGraph.Companion.findStartDestination
import com.anthonyla.livewallpaper.R
import com.anthonyla.livewallpaper.navigation.SettingsNavScreens
import com.anthonyla.livewallpaper.data.navigation.SettingsNavScreens
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -39,10 +41,11 @@ fun TopLevelBar (
scrollBehavior = null,
actions = {
IconButton(
onClick = { expanded = !expanded }
onClick = {
expanded = !expanded }
) {
Icon(
imageVector = Icons.Rounded.MoreVert,
imageVector = Icons.Filled.MoreVert,
contentDescription = stringResource(R.string.MoreVertIcon)
)
DropdownMenu(