mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 08:17:04 +05:30
android: hide NavigationBar in comments screen
This commit is contained in:
parent
15da824d3e
commit
2b638fcc29
4 changed files with 40 additions and 13 deletions
|
@ -106,6 +106,7 @@ fun LobstersApp(
|
|||
ClawNavigationBar(
|
||||
navController = navController,
|
||||
items = navItems,
|
||||
isVisible = navItems.any { it.route == currentDestination },
|
||||
)
|
||||
},
|
||||
) {
|
||||
|
|
|
@ -15,10 +15,9 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import dev.msfjarvis.claw.android.R
|
||||
import dev.msfjarvis.claw.android.ui.AnimationDuration
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private const val AnimationDuration = 100
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
fun ClawFab(
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package dev.msfjarvis.claw.android.ui.decorations
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.FastOutLinearInEasing
|
||||
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.Icon
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
|
@ -12,26 +18,45 @@ import androidx.compose.runtime.setValue
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.navigation.NavController
|
||||
import dev.msfjarvis.claw.android.ui.AnimationDuration
|
||||
|
||||
@Composable
|
||||
fun ClawNavigationBar(
|
||||
navController: NavController,
|
||||
items: List<NavigationItem>,
|
||||
isVisible: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var selectedIndex by remember { mutableStateOf(0) }
|
||||
|
||||
NavigationBar(modifier = modifier) {
|
||||
items.forEachIndexed { index, navItem ->
|
||||
NavigationBarItem(
|
||||
icon = { Icon(painter = navItem.icon, contentDescription = navItem.label) },
|
||||
label = { Text(text = navItem.label) },
|
||||
selected = selectedIndex == index,
|
||||
onClick = {
|
||||
selectedIndex = index
|
||||
navController.navigate(navItem.route)
|
||||
}
|
||||
)
|
||||
AnimatedVisibility(
|
||||
visible = isVisible,
|
||||
enter =
|
||||
slideInVertically(
|
||||
// Enters by sliding up from offset 0 to fullHeight.
|
||||
initialOffsetY = { fullHeight -> fullHeight },
|
||||
animationSpec = tween(durationMillis = AnimationDuration, easing = LinearOutSlowInEasing),
|
||||
),
|
||||
exit =
|
||||
slideOutVertically(
|
||||
// Exits by sliding up from offset 0 to -fullHeight.
|
||||
targetOffsetY = { fullHeight -> fullHeight },
|
||||
animationSpec = tween(durationMillis = AnimationDuration, easing = FastOutLinearInEasing),
|
||||
),
|
||||
modifier = Modifier,
|
||||
) {
|
||||
NavigationBar(modifier = modifier) {
|
||||
items.forEachIndexed { index, navItem ->
|
||||
NavigationBarItem(
|
||||
icon = { Icon(painter = navItem.icon, contentDescription = navItem.label) },
|
||||
label = { Text(text = navItem.label) },
|
||||
selected = selectedIndex == index,
|
||||
onClick = {
|
||||
selectedIndex = index
|
||||
navController.navigate(navItem.route)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
|||
import dev.msfjarvis.claw.database.local.SavedPost
|
||||
import kotlin.math.ln
|
||||
|
||||
const val AnimationDuration = 100
|
||||
|
||||
// The destination needs to be tracked like this rather than used directly since
|
||||
// `NavController#currentDestination` is not a Composable state.
|
||||
@Composable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue