Revert "android: remove unnecessary currentDestination variable"

This reverts commit 77d15ae6c6.
This commit is contained in:
Harsh Shandilya 2022-02-01 01:01:10 +05:30
parent ad818c40a6
commit 6eb815ec3b
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -49,6 +49,9 @@ fun LobstersApp(
val systemUiController = rememberSystemUiController()
val listState = rememberLazyListState()
val navController = rememberNavController()
// The destination needs to be tracked here rather than used directly since
// `NavController#currentDestination` is not a Composable state.
var currentDestination by remember { mutableStateOf(Destinations.Hottest.getRoute()) }
var isFabVisible by remember { mutableStateOf(false) }
val nestedScrollConnection = remember {
object : NestedScrollConnection {
@ -85,6 +88,9 @@ fun LobstersApp(
}
}
}
navController.addOnDestinationChangedListener { _, destination, _ ->
currentDestination = destination.route ?: Destinations.Hottest.getRoute()
}
LobstersTheme(
LocalUriHandler provides urlLauncher,
LocalHTMLConverter provides htmlConverter,
@ -103,9 +109,7 @@ fun LobstersApp(
topBar = { ClawAppBar(modifier = Modifier.statusBarsPadding()) },
floatingActionButton = {
ClawFab(
isFabVisible =
isFabVisible &&
navController.currentDestination?.route == Destinations.Hottest.getRoute(),
isFabVisible = isFabVisible && currentDestination == Destinations.Hottest.getRoute(),
listState = listState,
modifier = Modifier.navigationBarsPadding(),
)