Navigation
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package `in`.sminnovations.attendanceapp.navigation
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
|
||||
@Composable
|
||||
fun BottomNavAnimatedIcon(
|
||||
isSelected: Boolean,
|
||||
icon: ImageVector,
|
||||
selectedIcon: ImageVector,
|
||||
contentDescription: String?
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = isSelected,
|
||||
transitionSpec = {
|
||||
fadeIn(animationSpec = tween(300)) togetherWith fadeOut(animationSpec = tween(300))
|
||||
}, label = "animated icon"
|
||||
) { targetState ->
|
||||
Icon(
|
||||
imageVector = if (targetState) selectedIcon else icon,
|
||||
contentDescription = contentDescription,
|
||||
tint = if (targetState) MaterialTheme.colorScheme.surface else MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package `in`.sminnovations.attendanceapp.navigation
|
||||
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import `in`.sminnovations.attendanceapp.navigation.data.BottomNavItem
|
||||
import `in`.sminnovations.attendanceapp.screens.history.HistoryScreen
|
||||
import `in`.sminnovations.attendanceapp.screens.home.ui.HomeScreen
|
||||
import `in`.sminnovations.attendanceapp.screens.settings.SettingsScreen
|
||||
|
||||
|
||||
@Composable
|
||||
fun Navigation(
|
||||
navController: NavHostController,
|
||||
items: List<BottomNavItem>,
|
||||
) {
|
||||
NavHost(navController, startDestination = items[0].route) {
|
||||
composable(items[0].route) {
|
||||
HomeScreen()
|
||||
}
|
||||
composable(items[1].route) {
|
||||
HistoryScreen()
|
||||
}
|
||||
composable(items[2].route) {
|
||||
SettingsScreen()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package `in`.sminnovations.attendanceapp.navigation.data
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.AddCircle
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.outlined.AddCircle
|
||||
import androidx.compose.material.icons.outlined.Search
|
||||
import androidx.compose.material.icons.outlined.Settings
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
|
||||
data class BottomNavItem(
|
||||
val icon: ImageVector,
|
||||
val selectedIcon: ImageVector,
|
||||
val label: String,
|
||||
val route: String
|
||||
)
|
||||
val navItems = listOf(
|
||||
BottomNavItem(Icons.Outlined.Search, Icons.Filled.Search, "Scan", "scan"),
|
||||
BottomNavItem(Icons.Outlined.AddCircle, Icons.Filled.AddCircle, "Records", "records"),
|
||||
BottomNavItem(Icons.Outlined.Settings, Icons.Filled.Settings, "Settings", "settings")
|
||||
)
|
||||
Reference in New Issue
Block a user