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.cart.CartScreen
|
||||||
import com.example.shawarma.screens.discount.DiscountScreen
|
import com.example.shawarma.screens.discount.DiscountScreen
|
||||||
import com.example.shawarma.screens.home.HomeScreen
|
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.screens.registration.RegistrationScreen
|
||||||
import com.example.shawarma.ui.theme.MyLightYellow
|
import com.example.shawarma.ui.theme.MyLightYellow
|
||||||
import com.example.shawarma.utils.ScreenPaths
|
import com.example.shawarma.utils.ScreenPaths
|
||||||
@ -52,6 +53,9 @@ fun MainNavBar() {
|
|||||||
composable(ScreenPaths.cart.name) {
|
composable(ScreenPaths.cart.name) {
|
||||||
CartScreen()
|
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 Home : BottomNavItem("Home", R.drawable.home_icon,ScreenPaths.home.name)
|
||||||
object Discount : BottomNavItem("Discount", R.drawable.discount_icon,ScreenPaths.discount.name)
|
object Discount : BottomNavItem("Discount", R.drawable.discount_icon,ScreenPaths.discount.name)
|
||||||
object Cart : BottomNavItem("Cart", R.drawable.cart_icon,ScreenPaths.cart.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
|
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.BottomNavigation
|
||||||
import androidx.compose.material.BottomNavigationItem
|
import androidx.compose.material.BottomNavigationItem
|
||||||
import androidx.compose.material.Icon
|
import androidx.compose.material.Icon
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
@ -16,24 +20,25 @@ import com.example.shawarma.utils.BottomNavItem
|
|||||||
@Composable
|
@Composable
|
||||||
fun BottomNavBar(navController: NavController) {
|
fun BottomNavBar(navController: NavController) {
|
||||||
val items = listOf(
|
val items = listOf(
|
||||||
BottomNavItem.Home,
|
|
||||||
BottomNavItem.Discount,
|
BottomNavItem.Discount,
|
||||||
|
BottomNavItem.Home,
|
||||||
BottomNavItem.Cart,
|
BottomNavItem.Cart,
|
||||||
|
BottomNavItem.Orders
|
||||||
)
|
)
|
||||||
BottomNavigation(
|
BottomNavigation(
|
||||||
backgroundColor = Color.Green,
|
backgroundColor = Color.White,
|
||||||
contentColor = Color.Cyan
|
contentColor = Color.Black,
|
||||||
|
modifier = Modifier.height(60.dp)
|
||||||
) {
|
) {
|
||||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||||
val currentRoute = navBackStackEntry?.destination?.route
|
val currentRoute = navBackStackEntry?.destination?.route
|
||||||
items.forEach { item ->
|
items.forEach { item ->
|
||||||
BottomNavigationItem(
|
BottomNavigationItem(
|
||||||
icon = { Icon(painterResource(id = item.icon), contentDescription = item.title) },
|
icon = {
|
||||||
label = {
|
Icon(
|
||||||
Text(
|
painterResource(id = item.icon),
|
||||||
text = item.title,
|
contentDescription = item.title,
|
||||||
fontSize = 9.sp
|
modifier = Modifier.size(42.dp)
|
||||||
) },
|
) },
|
||||||
selectedContentColor = Color.Black,
|
selectedContentColor = Color.Black,
|
||||||
unselectedContentColor = Color.Black.copy(0.4f),
|
unselectedContentColor = Color.Black.copy(0.4f),
|
||||||
@ -49,7 +54,8 @@ fun BottomNavBar(navController: NavController) {
|
|||||||
launchSingleTop = true
|
launchSingleTop = true
|
||||||
restoreState = 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