android: remove unnecessary currentDestination variable

This commit is contained in:
Harsh Shandilya 2022-01-19 12:49:51 +05:30
parent 7dbedf7e82
commit 77d15ae6c6
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -51,7 +51,6 @@ fun LobstersApp(
val scaffoldState = rememberScaffoldState() val scaffoldState = rememberScaffoldState()
val listState = rememberLazyListState() val listState = rememberLazyListState()
val navController = rememberNavController() val navController = rememberNavController()
var currentDestination by remember { mutableStateOf(Destinations.Hottest.getRoute()) }
var isFabVisible by remember { mutableStateOf(false) } var isFabVisible by remember { mutableStateOf(false) }
val nestedScrollConnection = remember { val nestedScrollConnection = remember {
object : NestedScrollConnection { object : NestedScrollConnection {
@ -88,9 +87,6 @@ fun LobstersApp(
} }
} }
} }
navController.addOnDestinationChangedListener { _, destination, _ ->
currentDestination = destination.route ?: Destinations.Hottest.getRoute()
}
LobstersTheme( LobstersTheme(
providedValues = providedValues =
arrayOf( arrayOf(
@ -113,7 +109,9 @@ fun LobstersApp(
topBar = { ClawAppBar(modifier = Modifier.statusBarsPadding()) }, topBar = { ClawAppBar(modifier = Modifier.statusBarsPadding()) },
floatingActionButton = { floatingActionButton = {
ClawFab( ClawFab(
isFabVisible = isFabVisible && currentDestination == Destinations.Hottest.getRoute(), isFabVisible =
isFabVisible &&
navController.currentDestination?.route == Destinations.Hottest.getRoute(),
listState = listState, listState = listState,
modifier = Modifier.navigationBarsPadding(), modifier = Modifier.navigationBarsPadding(),
) )