A fork of Simple Time Tracker with WearOS support. (Now integrated upstream)
0

Configure Feed

Select the types of activity you want to include in your feed.

fix: Block back navigation after TagsList

It was previously possible to navigate back to a closed tag list
by swiping back.

This was a poor UX for two reasons:
1. Swiping back doesn't indicate the Activity for which the user is
now picking tags.
2. To close the app via the back action, the user has to swipe back
through **everything**.

Now, swiping back on the ActivitiesScreen will always close the
app.

closes thehale/SimpleTimeTracker-WearOS#14

Joseph Hale (Feb 26, 2024, 10:27 PM -0700) a0f8ab58 2ff34e48

+12 -1
+12 -1
wear/src/main/java/com/example/util/simpletimetracker/presentation/screens/TagsScreen.kt
··· 8 8 import androidx.compose.runtime.Composable 9 9 import androidx.compose.runtime.rememberCoroutineScope 10 10 import androidx.navigation.NavController 11 + import androidx.navigation.NavHostController 11 12 import com.example.util.simpletimetracker.presentation.components.TagList 12 13 import com.example.util.simpletimetracker.presentation.components.TagSelectionMode 13 14 import com.example.util.simpletimetracker.presentation.mediators.CurrentActivitiesMediator ··· 17 18 import com.example.util.simpletimetracker.presentation.remember.rememberTags 18 19 import kotlinx.coroutines.Dispatchers 19 20 import kotlinx.coroutines.launch 21 + 22 + fun NavHostController.navigateAndReplaceStartRoute(newHomeRoute: String) { 23 + popBackStack(graph.startDestinationId, true) 24 + graph.setStartDestination(newHomeRoute) 25 + navigate(newHomeRoute) 26 + } 20 27 21 28 @Composable 22 29 fun TagsScreen(activityId: Long, navigation: NavController) { ··· 38 45 coroutineScope.launch(Dispatchers.Default) { 39 46 currentActivitiesMediator.start(activityId, it) 40 47 coroutineScope.launch(Dispatchers.Main) { 41 - navigation.navigate("activities") 48 + // Inspired by: https://stackoverflow.com/a/72856761/14765128 49 + navigation.navigate("activities") { 50 + popUpTo(navigation.graph.startDestinationId) { inclusive = true } 51 + navigation.graph.setStartDestination("activities") 52 + } 42 53 } 43 54 } 44 55 },