|
@@ -0,0 +1,103 @@
|
|
|
+package com.example.wabi.view.common_elements.bars.bottom
|
|
|
+
|
|
|
+import androidx.compose.foundation.BorderStroke
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.PaddingValues
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.height
|
|
|
+import androidx.compose.foundation.layout.offset
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
+import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
+import androidx.compose.material3.Button
|
|
|
+import androidx.compose.material3.ButtonDefaults
|
|
|
+import androidx.compose.material3.Icon
|
|
|
+import androidx.compose.material3.NavigationBar
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.getValue
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.draw.clip
|
|
|
+import androidx.compose.ui.graphics.vector.ImageVector
|
|
|
+import androidx.compose.ui.res.vectorResource
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.navigation.NavHostController
|
|
|
+import androidx.navigation.compose.currentBackStackEntryAsState
|
|
|
+import com.example.wabi.domain.navigation.NavigationFun
|
|
|
+import com.example.wabi.ui.theme.WabiTheme
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun BottomBar(
|
|
|
+ navController: NavHostController, modifier: Modifier = Modifier
|
|
|
+) {
|
|
|
+ val screens = listOf(
|
|
|
+ DestinationsBB.Catalog, DestinationsBB.Basket, DestinationsBB.Profile
|
|
|
+ )
|
|
|
+
|
|
|
+ NavigationBar(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .height(70.dp)
|
|
|
+ .clip(shape = RoundedCornerShape(topEnd = 15.dp, topStart = 15.dp))
|
|
|
+ ) {
|
|
|
+
|
|
|
+ val navBackStackEntry by navController.currentBackStackEntryAsState()
|
|
|
+ val currentRoute = navBackStackEntry?.destination?.route
|
|
|
+ val nav = NavigationFun()
|
|
|
+
|
|
|
+ screens.forEach { screen ->
|
|
|
+ if (screen.route == currentRoute) {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .offset(y = 0.dp)
|
|
|
+ .offset(y = -10.dp),
|
|
|
+ ) {
|
|
|
+ Button(
|
|
|
+ onClick = {
|
|
|
+ nav.NextScreen(
|
|
|
+ navController = navController,
|
|
|
+ whereFrom = currentRoute,
|
|
|
+ where = screen.route
|
|
|
+ )
|
|
|
+ },
|
|
|
+ contentPadding = PaddingValues(10.dp),
|
|
|
+ modifier = Modifier.size(70.dp),
|
|
|
+ colors = ButtonDefaults.buttonColors(
|
|
|
+ contentColor = WabiTheme.colors.backgroundColor,
|
|
|
+ containerColor = WabiTheme.colors.mainColor
|
|
|
+ ),
|
|
|
+ border = BorderStroke(
|
|
|
+ width = 3.dp, color = WabiTheme.colors.backgroundColor
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ imageVector = ImageVector.vectorResource(screen.iconId),
|
|
|
+ contentDescription = screen.route,
|
|
|
+ modifier = Modifier.size(35.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Button(
|
|
|
+ onClick = {
|
|
|
+ nav.NextScreen(
|
|
|
+ navController = navController,
|
|
|
+ whereFrom = currentRoute!!,
|
|
|
+ where = screen.route
|
|
|
+ )
|
|
|
+ },
|
|
|
+ contentPadding = PaddingValues(10.dp),
|
|
|
+ modifier = Modifier.size(70.dp),
|
|
|
+ colors = ButtonDefaults.buttonColors(
|
|
|
+ contentColor = WabiTheme.colors.backgroundColor,
|
|
|
+ containerColor = WabiTheme.colors.mainColor
|
|
|
+ ),
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ imageVector = ImageVector.vectorResource(screen.iconId),
|
|
|
+ contentDescription = screen.route,
|
|
|
+ modifier = Modifier.size(35.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|