|
@@ -1,8 +1,10 @@
|
|
|
package com.example.wabi.view.common_elements.bars.bottom
|
|
|
|
|
|
+import android.content.Context
|
|
|
import androidx.compose.foundation.BorderStroke
|
|
|
-import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
import androidx.compose.foundation.layout.height
|
|
|
import androidx.compose.foundation.layout.offset
|
|
@@ -22,11 +24,12 @@ 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.domain.repository.PrefManager
|
|
|
import com.example.wabi.ui.theme.WabiTheme
|
|
|
|
|
|
@Composable
|
|
|
fun BottomBar(
|
|
|
- navController: NavHostController, modifier: Modifier = Modifier
|
|
|
+ navController: NavHostController, modifier: Modifier = Modifier, context: Context
|
|
|
) {
|
|
|
val screens = listOf(
|
|
|
DestinationsBB.Catalog, DestinationsBB.Basket, DestinationsBB.Profile
|
|
@@ -34,22 +37,20 @@ fun BottomBar(
|
|
|
|
|
|
NavigationBar(
|
|
|
modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
.height(70.dp)
|
|
|
- .clip(shape = RoundedCornerShape(topEnd = 15.dp, topStart = 15.dp))
|
|
|
+ .clip(shape = RoundedCornerShape(topEnd = 15.dp, topStart = 15.dp)),
|
|
|
+ containerColor = WabiTheme.colors.mainColor
|
|
|
) {
|
|
|
-
|
|
|
+ PrefManager.initPrefManager(context)
|
|
|
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),
|
|
|
- ) {
|
|
|
+ Row(
|
|
|
+ modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceAround
|
|
|
+ ) {
|
|
|
+ screens.forEach { screen ->
|
|
|
+ if (screen.route == currentRoute || screen.anotherRoute == currentRoute) {
|
|
|
Button(
|
|
|
onClick = {
|
|
|
nav.NextScreen(
|
|
@@ -59,7 +60,9 @@ fun BottomBar(
|
|
|
)
|
|
|
},
|
|
|
contentPadding = PaddingValues(10.dp),
|
|
|
- modifier = Modifier.size(70.dp),
|
|
|
+ modifier = Modifier
|
|
|
+ .size(60.dp)
|
|
|
+ .offset(y = -8.dp),
|
|
|
colors = ButtonDefaults.buttonColors(
|
|
|
contentColor = WabiTheme.colors.backgroundColor,
|
|
|
containerColor = WabiTheme.colors.mainColor
|
|
@@ -71,31 +74,31 @@ fun BottomBar(
|
|
|
Icon(
|
|
|
imageVector = ImageVector.vectorResource(screen.iconId),
|
|
|
contentDescription = screen.route,
|
|
|
- modifier = Modifier.size(35.dp)
|
|
|
+ modifier = Modifier.size(30.dp)
|
|
|
)
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- Button(
|
|
|
- onClick = {
|
|
|
- nav.NextScreen(
|
|
|
- navController = navController,
|
|
|
- whereFrom = currentRoute!!,
|
|
|
- where = screen.route
|
|
|
+ } else {
|
|
|
+ Button(
|
|
|
+ onClick = {
|
|
|
+ nav.NextScreen(
|
|
|
+ navController = navController,
|
|
|
+ whereFrom = currentRoute!!,
|
|
|
+ where = if (PrefManager.currentUser == null) screen.anotherRoute else screen.route
|
|
|
+ )
|
|
|
+ },
|
|
|
+ contentPadding = PaddingValues(10.dp),
|
|
|
+ modifier = Modifier.size(60.dp),
|
|
|
+ colors = ButtonDefaults.buttonColors(
|
|
|
+ contentColor = WabiTheme.colors.backgroundColor,
|
|
|
+ containerColor = WabiTheme.colors.mainColor
|
|
|
+ ),
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ imageVector = ImageVector.vectorResource(screen.iconId),
|
|
|
+ contentDescription = screen.route,
|
|
|
+ modifier = Modifier.size(30.dp)
|
|
|
)
|
|
|
- },
|
|
|
- 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)
|
|
|
- )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|