@@ -39,12 +39,13 @@ import androidx.compose.ui.unit.dp
3939import androidx.compose.ui.unit.sp
4040import androidx.compose.ui.zIndex
4141import androidx.navigation.NavController
42+ import androidx.navigation.NavDestination.Companion.hasRoute
4243import androidx.navigation.compose.rememberNavController
4344import kotlinx.coroutines.launch
4445import to.bitkit.R
4546import to.bitkit.ui.Routes
47+ import to.bitkit.ui.navigateIfNotCurrent
4648import to.bitkit.ui.navigateToHome
47- import to.bitkit.ui.navigateToSettings
4849import to.bitkit.ui.screens.wallets.HomeRoutes
4950import to.bitkit.ui.shared.util.blockPointerInputPassthrough
5051import to.bitkit.ui.shared.util.clickableAlpha
@@ -102,16 +103,16 @@ fun DrawerMenu(
102103 drawerState = drawerState,
103104 onClickAddWidget = {
104105 if (! hasSeenWidgetsIntro) {
105- rootNavController.navigate (Routes .WidgetsIntro )
106+ rootNavController.navigateIfNotCurrent (Routes .WidgetsIntro )
106107 } else {
107- rootNavController.navigate (Routes .AddWidget )
108+ rootNavController.navigateIfNotCurrent (Routes .AddWidget )
108109 }
109110 },
110111 onClickShop = {
111112 if (! hasSeenShopIntro) {
112- rootNavController.navigate (Routes .ShopIntro )
113+ rootNavController.navigateIfNotCurrent (Routes .ShopIntro )
113114 } else {
114- rootNavController.navigate (Routes .ShopDiscover )
115+ rootNavController.navigateIfNotCurrent (Routes .ShopDiscover )
115116 }
116117 },
117118 )
@@ -141,7 +142,11 @@ private fun Menu(
141142 label = stringResource(R .string.wallet__drawer__wallet),
142143 iconRes = R .drawable.ic_coins,
143144 onClick = {
144- rootNavController.navigateToHome()
145+ val isOnHome = rootNavController.currentBackStackEntry
146+ ?.destination?.hasRoute<Routes .Home >() ? : false
147+ if (! isOnHome) {
148+ rootNavController.navigateToHome()
149+ }
145150 scope.launch { drawerState.close() }
146151 },
147152 modifier = Modifier .testTag(" DrawerWallet" )
@@ -152,9 +157,9 @@ private fun Menu(
152157 iconRes = R .drawable.ic_heartbeat,
153158 onClick = {
154159 if (walletNavController != null ) {
155- walletNavController.navigate (HomeRoutes .AllActivity )
160+ walletNavController.navigateIfNotCurrent (HomeRoutes .AllActivity )
156161 } else {
157- rootNavController.navigate (Routes .Home )
162+ rootNavController.navigateIfNotCurrent (Routes .Home )
158163 }
159164 scope.launch { drawerState.close() }
160165 },
@@ -199,7 +204,7 @@ private fun Menu(
199204 label = stringResource(R .string.wallet__drawer__settings),
200205 iconRes = R .drawable.ic_settings,
201206 onClick = {
202- rootNavController.navigateToSettings( )
207+ rootNavController.navigateIfNotCurrent( Routes . Settings )
203208 scope.launch { drawerState.close() }
204209 },
205210 modifier = Modifier .testTag(" DrawerSettings" )
@@ -212,15 +217,17 @@ private fun Menu(
212217 modifier = Modifier
213218 .fillMaxWidth()
214219 .clickableAlpha {
215- rootNavController.navigate (Routes .AppStatus )
220+ rootNavController.navigateIfNotCurrent (Routes .AppStatus )
216221 scope.launch { drawerState.close() }
217222 }
218223 ) {
219224 AppStatus (
220225 showText = true ,
221226 showReady = true ,
222227 color = Colors .Black ,
223- modifier = Modifier .padding(vertical = 16 .dp).testTag(" DrawerAppStatus" )
228+ modifier = Modifier
229+ .padding(vertical = 16 .dp)
230+ .testTag(" DrawerAppStatus" )
224231 )
225232 }
226233 }
0 commit comments