Browse Source

update: end creating bottom bar

Bax 4 ngày trước cách đây
mục cha
commit
47cc17cde5

+ 1 - 1
mobile_app/wabi/.idea/deploymentTargetSelector.xml

@@ -4,7 +4,7 @@
     <selectionStates>
       <SelectionState runConfigName="app">
         <option name="selectionMode" value="DROPDOWN" />
-        <DropdownSelection timestamp="2024-11-19T23:23:16.885681600Z">
+        <DropdownSelection timestamp="2024-11-21T07:40:04.317590300Z">
           <Target type="DEFAULT_BOOT">
             <handle>
               <DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\bax\.android\avd\Medium_Phone_API_30.avd" />

+ 8 - 0
mobile_app/wabi/app/src/main/java/com/example/wabi/domain/repository/PrefManager.kt

@@ -14,4 +14,12 @@ object PrefManager {
     var onboard: Boolean
         get() = localDataSP.getBoolean("onboard", true)
         set(value) = localDataSP.edit().putBoolean("onboard", value).apply()
+
+    var userTheme: Int
+        get() = localDataSP.getInt("userTheme", 0)
+        set(value) = localDataSP.edit().putInt("userTheme", value).apply()
+
+    var currentUser: String?
+        get() = localDataSP.getString("currentUser", null)
+        set(value) = localDataSP.edit().putString("currentUser", value).apply()
 }

+ 7 - 4
mobile_app/wabi/app/src/main/java/com/example/wabi/view/MainActivity.kt

@@ -16,7 +16,6 @@ import androidx.navigation.compose.rememberNavController
 import com.example.wabi.domain.navigation.Navigation
 import com.example.wabi.domain.navigation.Routes
 import com.example.wabi.domain.repository.PrefManager
-import com.example.wabi.ui.theme.ThemeMode
 import com.example.wabi.ui.theme.WabiTheme
 import com.example.wabi.view.common_elements.bars.bottom.BottomBar
 import dagger.hilt.android.AndroidEntryPoint
@@ -30,18 +29,22 @@ class MainActivity : ComponentActivity() {
         installSplashScreen()
 
         setContent {
-            PrefManager.initPrefManager(LocalContext.current)
+            val context = LocalContext.current
+            PrefManager.initPrefManager(context)
 
             val navHostController = rememberNavController()
             val visibleBB = remember { mutableStateOf(false) }
             val visibleTB = remember { mutableStateOf(false) }
 
-            WabiTheme(themeState = ThemeMode.System) {
+            PrefManager.currentUser = "на логин"
+            PrefManager.userTheme = 0
+
+            WabiTheme(themeState = PrefManager.userTheme) {
                 Scaffold(modifier = Modifier.fillMaxSize(),
                     containerColor = WabiTheme.colors.backgroundColor,
                     bottomBar = {
                         if (visibleBB.value) {
-                            BottomBar(navController = navHostController)
+                            BottomBar(navController = navHostController, context = context)
                         }
                     }) { paddingValues ->
                     Box(

+ 38 - 35
mobile_app/wabi/app/src/main/java/com/example/wabi/view/common_elements/bars/bottom/BottomBar.kt

@@ -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)
-                    )
+                    }
                 }
             }
         }

+ 3 - 3
mobile_app/wabi/app/src/main/java/com/example/wabi/view/common_elements/bars/bottom/DestinationsBB.kt

@@ -4,14 +4,14 @@ import com.example.wabi.R
 import com.example.wabi.domain.navigation.Routes
 
 sealed class DestinationsBB(
-    val route: String, val anotherRoute: String? = "", val iconId: Int
+    val route: String, val anotherRoute: String, val iconId: Int
 ) {
     object Basket : DestinationsBB(
-        route = Routes.BASKET, iconId = R.drawable.user_basket_vector
+        route = Routes.BASKET, anotherRoute = Routes.BASKET, iconId = R.drawable.user_basket_vector
     )
 
     object Catalog : DestinationsBB(
-        route = Routes.CATALOG, iconId = R.drawable.catalog_vector
+        route = Routes.CATALOG, anotherRoute = Routes.CATALOG, iconId = R.drawable.catalog_vector
     )
 
     object Profile : DestinationsBB(