Bye bye BottomNavBar.kt
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
package `in`.sminnovations.attendanceapp.navigation
|
||||
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import `in`.sminnovations.attendanceapp.navigation.data.BottomNavItem
|
||||
|
||||
|
||||
@Composable
|
||||
fun BottomNavigationBar(
|
||||
navController: NavController,
|
||||
items: List<BottomNavItem>,
|
||||
) {
|
||||
NavigationBar {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
items.forEach { item ->
|
||||
NavigationBarItem(icon = {
|
||||
BottomNavAnimatedIcon(
|
||||
isSelected = currentRoute == item.route,
|
||||
icon = item.icon,
|
||||
selectedIcon = item.selectedIcon,
|
||||
contentDescription = item.label
|
||||
)
|
||||
},
|
||||
label = { Text(text = item.label) },
|
||||
alwaysShowLabel = true,
|
||||
selected = currentRoute == item.route,
|
||||
onClick = {
|
||||
navController.navigate(item.route) {
|
||||
navController.graph.startDestinationRoute?.let { route ->
|
||||
popUpTo(route) {
|
||||
saveState = true
|
||||
}
|
||||
}
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user