diff options
Diffstat (limited to 'app/src/main/java/org/terst/feedreader/ui/MainActivity.kt')
| -rw-r--r-- | app/src/main/java/org/terst/feedreader/ui/MainActivity.kt | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/src/main/java/org/terst/feedreader/ui/MainActivity.kt b/app/src/main/java/org/terst/feedreader/ui/MainActivity.kt index f7ca043..9add10a 100644 --- a/app/src/main/java/org/terst/feedreader/ui/MainActivity.kt +++ b/app/src/main/java/org/terst/feedreader/ui/MainActivity.kt @@ -89,13 +89,23 @@ fun FeedReaderApp() { val feedId = decodeNavArg(backStackEntry.arguments?.getString("feedId") ?: UNREAD_FEED_ID) val articleId = decodeNavArg(backStackEntry.arguments?.getString("articleId") ?: "") // feedId here is the list the article was opened from (Unread/Saved/a specific - // feed) -- ReaderScreen uses it to build the swipe queue of sibling articles. + // feed) -- ReaderScreen uses it to look up the current article's neighbors. ReaderScreen( feedId = feedId, - initialArticleId = articleId, + articleId = articleId, onBack = { navController.popBackStack() }, onOpenLink = { url -> navController.navigate("linkReader/${encodeNavArg(url)}") }, - onOpenBrowser = { url -> navController.navigate("browser/${encodeNavArg(url)}") } + onOpenBrowser = { url -> navController.navigate("browser/${encodeNavArg(url)}") }, + // Replaces this screen's own back-stack entry rather than stacking a new + // one per article (same popUpTo-replace pattern linkReader's own link-chain + // navigation already uses below) -- so the stack is always exactly + // [list, this one reader entry], and back always returns to the list in a + // single press no matter how many articles were paged through via Next/Previous. + onNavigateToArticle = { nextArticleId -> + navController.navigate("reader/${encodeNavArg(feedId)}/${encodeNavArg(nextArticleId)}") { + popUpTo("reader/{feedId}/{articleId}") { inclusive = true } + } + } ) } composable( |
