Skip to content

Commit

Permalink
Minor additions for bottom navigation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nassdk committed Jan 6, 2022
1 parent 4f7d270 commit 3650cb3
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
10 changes: 5 additions & 5 deletions core/navigation/src/main/java/com/nassdk/navigation/Screens.kt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.nassdk.navigation

sealed class Screens {
sealed class Screens : NavTarget {

object Splash : NavTarget {
object Splash : Screens() {
override val route: String = "splash"
}

object Flow : NavTarget {
object Flow : Screens() {
override val route: String = "flow"
}

object Flights : NavTarget {
object Flights : Screens() {
override val route: String = "flights"
}

object Profile : NavTarget {
object Profile : Screens() {
override val route: String = "profile"
}
}
1 change: 1 addition & 0 deletions core/ui/src/main/java/com/nassdk/ui/theme/Color.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ val White = Color(0xFFFFFFFF)
val Black = Color(0xFF000000)
val White_F1F1F1 = Color(0xFFF1F1F1)
val Blue_4A536B = Color(0xFF4A536B)
val Blue_9099B1 = Color(0xFF9099B1)
val Gray_979797 = Color(0xFF979797)
val Gray_D8D8D8 = Color(0xFFD8D8D8)
val Orange_FF9A8D = Color(0xFFFF9A8D)
8 changes: 6 additions & 2 deletions core/ui/src/main/java/com/nassdk/ui/theme/Palette.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ internal val DarkPalette = AeroColors(
primaryText = Black,
secondaryText = Gray_979797,
spinnerColor = Orange_FF9A8D,
secondaryBackground = White
secondaryBackground = White,
tintPrimary = Blue_4A536B,
tintSecondary = Blue_9099B1
)

internal val LightPalette = AeroColors(
primaryBackground = White_F1F1F1,
primaryText = Black,
secondaryText = Gray_979797,
spinnerColor = Orange_FF9A8D,
secondaryBackground = White
secondaryBackground = White,
tintPrimary = Blue_4A536B,
tintSecondary = Blue_9099B1
)
2 changes: 2 additions & 0 deletions core/ui/src/main/java/com/nassdk/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ data class AeroColors(
val secondaryText: Color,
val spinnerColor: Color,
val secondaryBackground: Color,
val tintPrimary: Color,
val tintSecondary: Color
)

object AeroTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.currentBackStackEntryAsState
import com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.google.accompanist.systemuicontroller.rememberSystemUiController
Expand All @@ -28,6 +30,9 @@ fun FlowScreen(flowGraphBuilder: NavGraphBuilder.() -> Unit) {
val navItems = arrayOf(TabItem.FLIGHTS, TabItem.PROFILE)
val isDarkMode = isSystemInDarkTheme()

val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route

val systemUiController = rememberSystemUiController()

SideEffect(
Expand All @@ -45,11 +50,24 @@ fun FlowScreen(flowGraphBuilder: NavGraphBuilder.() -> Unit) {
content = {
navItems.forEach { target ->
BottomNavigationItem(
selected = false,
selected = currentRoute == target.route,
selectedContentColor = AeroTheme.colors.tintPrimary,
unselectedContentColor = AeroTheme.colors.tintSecondary,
alwaysShowLabel = true,
onClick = {
navController.navigate(target.route) {
launchSingleTop = true
}
navController.navigate(
route = target.route, builder = {
navController.graph.startDestinationRoute?.let { route ->
popUpTo(
route = route, popUpToBuilder = {
saveState = true
}
)
}
launchSingleTop = true
restoreState = true
}
)
},
label = {
Text(text = stringResource(id = target.title))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ fun SplashScreen(
navController.navigate(
route = Screens.Flow.route,
builder = {
popUpTo(Screens.Splash.route) {
inclusive = true
}
popUpTo(
route = Screens.Splash.route, popUpToBuilder = {
inclusive = true
}
)
}
)
}
Expand Down

0 comments on commit 3650cb3

Please sign in to comment.