Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SingleAccountPageOpeningFromAccounts #325

Open
wants to merge 1 commit into
base: end
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.navigation.NavDestination
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.example.compose.rally.ui.components.RallyTabRow
Expand All @@ -48,8 +49,7 @@ fun RallyApp() {
val navController = rememberNavController()
val currentBackStack by navController.currentBackStackEntryAsState()
val currentDestination = currentBackStack?.destination
val currentScreen =
rallyTabRowScreens.find { it.route == currentDestination?.route } ?: Overview
val currentScreen = getCurrentScreen(currentDestination)

Scaffold(
topBar = {
Expand All @@ -69,3 +69,13 @@ fun RallyApp() {
}
}
}

private fun getCurrentScreen(currentDestination: NavDestination?) : RallyDestination {
val currentScreen = rallyTabRowScreens.find { it.route == currentDestination?.route } ?: previousScreen
setLastScreen(currentScreen)
return currentScreen
}

private fun setLastScreen(currentScreen: RallyDestination?){
previousScreen = currentScreen ?: Overview
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ object SingleAccount : RallyDestination {

// Screens to be displayed in the top RallyTabRow
val rallyTabRowScreens = listOf(Overview, Accounts, Bills)
var previousScreen : RallyDestination = Overview