Слава КПСС, Соня Мармеладова, Гнойный и Овсянкин, bottomNavBar заработал, Scaffold подчинен моей воле
This commit is contained in:
parent
c25ac4a9a9
commit
68446fa3cf
@ -6,14 +6,20 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Scaffold
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
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.registration.RegistrationScreen
|
||||
import com.example.shawarma.ui.theme.MyLightYellow
|
||||
import com.example.shawarma.utils.ScreenPaths
|
||||
import com.example.shawarma.widgets.BottomNavBar
|
||||
|
||||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
||||
@Composable
|
||||
@ -21,7 +27,14 @@ fun MainNavBar() {
|
||||
val navController = rememberNavController()
|
||||
Scaffold(
|
||||
backgroundColor = MyLightYellow,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
bottomBar = {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
if ( currentRoute != ScreenPaths.authorization.name && currentRoute != ScreenPaths.registration.name) {
|
||||
BottomNavBar(navController = navController)
|
||||
}
|
||||
}
|
||||
) {scaffoldPadding ->
|
||||
NavHost(navController = navController, startDestination = ScreenPaths.authorization.name) {
|
||||
composable(ScreenPaths.authorization.name) {
|
||||
@ -30,6 +43,15 @@ fun MainNavBar() {
|
||||
composable(ScreenPaths.registration.name) {
|
||||
RegistrationScreen(navController)
|
||||
}
|
||||
composable(ScreenPaths.home.name) {
|
||||
HomeScreen()
|
||||
}
|
||||
composable(ScreenPaths.discount.name) {
|
||||
DiscountScreen()
|
||||
}
|
||||
composable(ScreenPaths.cart.name) {
|
||||
CartScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -96,7 +96,12 @@ fun AuthorizationCard(navHostController: NavHostController) {
|
||||
singleLine = true
|
||||
)
|
||||
Button(
|
||||
onClick = { /*TODO*/ },
|
||||
onClick = {
|
||||
navHostController.navigate(ScreenPaths.home.name) {
|
||||
popUpTo(ScreenPaths.home.name) {
|
||||
inclusive = true
|
||||
}
|
||||
}},
|
||||
colors = ButtonDefaults.buttonColors(MyLightRed, Color.White),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
modifier = Modifier
|
||||
|
Loading…
Reference in New Issue
Block a user