mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 13:27:03 +05:30
android: add ClawNavigationBar
This commit is contained in:
parent
e8f9d88c68
commit
0e87507e63
1 changed files with 43 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
||||||
|
package dev.msfjarvis.claw.android.ui.decorations
|
||||||
|
|
||||||
|
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
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.painter.Painter
|
||||||
|
import androidx.navigation.NavController
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ClawNavigationBar(
|
||||||
|
navController: NavController,
|
||||||
|
items: List<NavigationItem>,
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NavigationItem(
|
||||||
|
val label: String,
|
||||||
|
val route: String,
|
||||||
|
val icon: Painter,
|
||||||
|
)
|
Loading…
Add table
Add a link
Reference in a new issue