Слава КПСС, Соня Мармеладова, Гнойный и Овсянкин, 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.Scaffold
|
||||||
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.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import com.example.shawarma.screens.authorization.AuthorizationScreen
|
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.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
|
||||||
|
import com.example.shawarma.widgets.BottomNavBar
|
||||||
|
|
||||||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
|
||||||
@Composable
|
@Composable
|
||||||
@ -21,7 +27,14 @@ fun MainNavBar() {
|
|||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
Scaffold(
|
Scaffold(
|
||||||
backgroundColor = MyLightYellow,
|
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 ->
|
) {scaffoldPadding ->
|
||||||
NavHost(navController = navController, startDestination = ScreenPaths.authorization.name) {
|
NavHost(navController = navController, startDestination = ScreenPaths.authorization.name) {
|
||||||
composable(ScreenPaths.authorization.name) {
|
composable(ScreenPaths.authorization.name) {
|
||||||
@ -30,6 +43,15 @@ fun MainNavBar() {
|
|||||||
composable(ScreenPaths.registration.name) {
|
composable(ScreenPaths.registration.name) {
|
||||||
RegistrationScreen(navController)
|
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
|
singleLine = true
|
||||||
)
|
)
|
||||||
Button(
|
Button(
|
||||||
onClick = { /*TODO*/ },
|
onClick = {
|
||||||
|
navHostController.navigate(ScreenPaths.home.name) {
|
||||||
|
popUpTo(ScreenPaths.home.name) {
|
||||||
|
inclusive = true
|
||||||
|
}
|
||||||
|
}},
|
||||||
colors = ButtonDefaults.buttonColors(MyLightRed, Color.White),
|
colors = ButtonDefaults.buttonColors(MyLightRed, Color.White),
|
||||||
shape = RoundedCornerShape(20.dp),
|
shape = RoundedCornerShape(20.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
Loading…
Reference in New Issue
Block a user