NavBar готов. Осталось всего-то сверстать 4 экрана!
This commit is contained in:
parent
68446fa3cf
commit
f568e491ea
@ -16,6 +16,7 @@ import com.example.shawarma.screens.authorization.AuthorizationScreen
|
||||
import com.example.shawarma.screens.cart.CartScreen
|
||||
import com.example.shawarma.screens.discount.DiscountScreen
|
||||
import com.example.shawarma.screens.home.HomeScreen
|
||||
import com.example.shawarma.screens.orders.OrdersScreen
|
||||
import com.example.shawarma.screens.registration.RegistrationScreen
|
||||
import com.example.shawarma.ui.theme.MyLightYellow
|
||||
import com.example.shawarma.utils.ScreenPaths
|
||||
@ -52,6 +53,9 @@ fun MainNavBar() {
|
||||
composable(ScreenPaths.cart.name) {
|
||||
CartScreen()
|
||||
}
|
||||
composable(ScreenPaths.orders.name) {
|
||||
OrdersScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.example.shawarma.screens.orders
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
|
||||
@Composable
|
||||
fun OrdersScreen() {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = "Orders"
|
||||
)
|
||||
}
|
||||
}
|
@ -6,4 +6,5 @@ sealed class BottomNavItem(var title:String, var icon:Int, var screen_route:Stri
|
||||
object Home : BottomNavItem("Home", R.drawable.home_icon,ScreenPaths.home.name)
|
||||
object Discount : BottomNavItem("Discount", R.drawable.discount_icon,ScreenPaths.discount.name)
|
||||
object Cart : BottomNavItem("Cart", R.drawable.cart_icon,ScreenPaths.cart.name)
|
||||
object Orders: BottomNavItem("Orders", R.drawable.orders_icon,ScreenPaths.orders.name)
|
||||
}
|
||||
|
@ -1,13 +1,17 @@
|
||||
package com.example.shawarma.widgets
|
||||
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.BottomNavigation
|
||||
import androidx.compose.material.BottomNavigationItem
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
@ -16,24 +20,25 @@ import com.example.shawarma.utils.BottomNavItem
|
||||
@Composable
|
||||
fun BottomNavBar(navController: NavController) {
|
||||
val items = listOf(
|
||||
BottomNavItem.Home,
|
||||
BottomNavItem.Discount,
|
||||
BottomNavItem.Home,
|
||||
BottomNavItem.Cart,
|
||||
BottomNavItem.Orders
|
||||
)
|
||||
BottomNavigation(
|
||||
backgroundColor = Color.Green,
|
||||
contentColor = Color.Cyan
|
||||
|
||||
backgroundColor = Color.White,
|
||||
contentColor = Color.Black,
|
||||
modifier = Modifier.height(60.dp)
|
||||
) {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
items.forEach { item ->
|
||||
BottomNavigationItem(
|
||||
icon = { Icon(painterResource(id = item.icon), contentDescription = item.title) },
|
||||
label = {
|
||||
Text(
|
||||
text = item.title,
|
||||
fontSize = 9.sp
|
||||
icon = {
|
||||
Icon(
|
||||
painterResource(id = item.icon),
|
||||
contentDescription = item.title,
|
||||
modifier = Modifier.size(42.dp)
|
||||
) },
|
||||
selectedContentColor = Color.Black,
|
||||
unselectedContentColor = Color.Black.copy(0.4f),
|
||||
@ -49,7 +54,8 @@ fun BottomNavBar(navController: NavController) {
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable/orders_icon.png
Normal file
BIN
app/src/main/res/drawable/orders_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 937 B |
Loading…
Reference in New Issue
Block a user