Skip to content

Commit 9770d65

Browse files
author
code3-dev
committed
Fix navigation refresh issue: Prevent page refresh when switching between bottom nav and sidebar items
1 parent 9459a9c commit 9770d65

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

.kotlin/sessions/kotlin-compiler-11380051393043603248.salive

Whitespace-only changes.

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ android {
1818
// Android 7.x and below are not supported due to Jetpack Compose limitations
1919
minSdk = 26
2020
targetSdk = 36
21-
versionCode = 8
22-
versionName = "1.0.7"
21+
versionCode = 9
22+
versionName = "1.0.8"
2323

2424
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2525
}

app/src/main/java/com/pira/ccloud/navigation/AppNavigation.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ fun AppNavigation(
3535
SplashScreen(
3636
onTimeout = {
3737
navController.popBackStack()
38-
navController.navigate(AppScreens.Movies.route)
38+
navController.navigate(AppScreens.Movies.route) {
39+
// Prevent re-adding splash to back stack
40+
launchSingleTop = true
41+
}
3942
},
4043
backgroundColor = if (themeSettings.themeMode == com.pira.ccloud.ui.theme.ThemeMode.DARK) {
4144
androidx.compose.ui.graphics.Color(0xFF121212)

app/src/main/java/com/pira/ccloud/navigation/BottomNavigation.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,15 @@ fun BottomNavigationBar(navController: NavController) {
102102
label = null, // We're using custom label in icon
103103
selected = isSelected,
104104
onClick = {
105-
navController.navigate(screen.route) {
106-
// Pop up to the start destination of the graph to
107-
// avoid building up a large stack of destinations
108-
// on the back stack as users select items
109-
popUpTo(navController.graph.startDestinationId) {
110-
saveState = true
105+
// Only navigate if we're not already on the selected screen
106+
if (currentRoute != screen.route) {
107+
navController.navigate(screen.route) {
108+
// Avoid multiple copies of the same destination when
109+
// reselecting the same item
110+
launchSingleTop = true
111+
// Restore state when reselecting a previously selected item
112+
restoreState = true
111113
}
112-
// Avoid multiple copies of the same destination when
113-
// reselecting the same item
114-
launchSingleTop = true
115-
// Restore state when reselecting a previously selected item
116-
restoreState = true
117114
}
118115
},
119116
colors = NavigationBarItemDefaults.colors(

app/src/main/java/com/pira/ccloud/navigation/SidebarNavigation.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,15 @@ fun SidebarNavigation(navController: NavController) {
121121
label = null, // We're using custom label in icon
122122
selected = isSelected,
123123
onClick = {
124-
navController.navigate(screen.route) {
125-
// Pop up to the start destination of the graph to
126-
// avoid building up a large stack of destinations
127-
// on the back stack as users select items
128-
popUpTo(navController.graph.startDestinationId) {
129-
saveState = true
124+
// Only navigate if we're not already on the selected screen
125+
if (currentRoute != screen.route) {
126+
navController.navigate(screen.route) {
127+
// Avoid multiple copies of the same destination when
128+
// reselecting the same item
129+
launchSingleTop = true
130+
// Restore state when reselecting a previously selected item
131+
restoreState = true
130132
}
131-
// Avoid multiple copies of the same destination when
132-
// reselecting the same item
133-
launchSingleTop = true
134-
// Restore state when reselecting a previously selected item
135-
restoreState = true
136133
}
137134
},
138135
colors = NavigationRailItemDefaults.colors(

app/src/main/java/com/pira/ccloud/screens/AboutScreen.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ fun getArchitecture(): String {
241241
val supportedAbis = android.os.Build.SUPPORTED_ABIS
242242
if (supportedAbis.isNotEmpty()) {
243243
when (supportedAbis[0]) {
244-
"arm64-v8a" -> "ARM64"
245-
"armeabi-v7a" -> "ARM32"
244+
"arm64-v8a" -> "ARM64 (arm64-v8a)"
245+
"armeabi-v7a" -> "ARM32 (armeabi-v7a)"
246246
"x86_64" -> "x86_64"
247247
"x86" -> "x86"
248-
else -> supportedAbis[0]
248+
else -> "${supportedAbis[0]} (Unknown)"
249249
}
250250
} else {
251251
"Unknown"

0 commit comments

Comments
 (0)