diff --git a/CHANGELOG.md b/CHANGELOG.md index 608d8798..35bea1e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Change submitter text to 'authored' when applicable - Unread comments now have a brighter background rather than a text badge -- Opening posts you have previously seen will show the number of new comments since last visit +- Opening posts you have previously seen will show the number of new comments since last visit +- Bottom navigation's visibility now interacts with the scroll behavior of the post lists ## [1.48.0] - 2024-06-05 diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/decorations/ClawNavigationBar.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/decorations/ClawNavigationBar.kt index 66fff5fd..1f1c04b1 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/decorations/ClawNavigationBar.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/decorations/ClawNavigationBar.kt @@ -13,8 +13,10 @@ import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.tween import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically +import androidx.compose.material3.BottomAppBar +import androidx.compose.material3.BottomAppBarScrollBehavior +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon -import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -29,11 +31,13 @@ import kotlinx.collections.immutable.ImmutableList const val AnimationDuration = 100 +@OptIn(ExperimentalMaterial3Api::class) @Composable fun ClawNavigationBar( navController: NavController, items: ImmutableList, isVisible: Boolean, + scrollBehavior: BottomAppBarScrollBehavior, modifier: Modifier = Modifier, ) { AnimatedVisibility( @@ -52,7 +56,7 @@ fun ClawNavigationBar( ), modifier = Modifier, ) { - NavigationBar(modifier = modifier) { + BottomAppBar(modifier = modifier, scrollBehavior = scrollBehavior) { val navBackStackEntry = navController.currentBackStackEntryAsState().value val currentDestination = navBackStackEntry?.destination items.forEach { navItem -> diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/LobstersPostsScreen.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/LobstersPostsScreen.kt index d9b2ebb6..f28bfc01 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/LobstersPostsScreen.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/ui/screens/LobstersPostsScreen.kt @@ -26,6 +26,7 @@ import androidx.compose.material.icons.filled.Whatshot import androidx.compose.material.icons.outlined.FavoriteBorder import androidx.compose.material.icons.outlined.NewReleases import androidx.compose.material.icons.outlined.Whatshot +import androidx.compose.material3.BottomAppBarDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -44,6 +45,7 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow +import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -110,6 +112,8 @@ fun LobstersPostsScreen( val snackbarHostState = remember { SnackbarHostState() } val postActions = rememberPostActions(context, urlLauncher, navController, viewModel) + val scrollBehavior = BottomAppBarDefaults.exitAlwaysScrollBehavior() + val hottestPosts = viewModel.hottestPosts.collectAsLazyPagingItems() val newestPosts = viewModel.newestPosts.collectAsLazyPagingItems() val savedPosts by viewModel.savedPostsByMonth.collectAsState(persistentMapOf()) @@ -205,11 +209,15 @@ fun LobstersPostsScreen( navController = navController, items = navItems, isVisible = currentDestination.any(navDestinations), + scrollBehavior = scrollBehavior, ) } }, snackbarHost = { SnackbarHost(snackbarHostState) }, - modifier = modifier.semantics { testTagsAsResourceId = true }, + modifier = + modifier.nestedScroll(scrollBehavior.nestedScrollConnection).semantics { + testTagsAsResourceId = true + }, ) { paddingValues -> Row(modifier = Modifier.padding(paddingValues)) { AnimatedVisibility(visible = navigationType == ClawNavigationType.NAVIGATION_RAIL) {