Преглед изворни кода

Календарь и навигация

Anastasia пре 4 дана
родитељ
комит
43074e45cf

+ 45 - 17
EatWell/app/src/main/java/com/example/eatwell/view/mainActivity/Dish.kt

@@ -40,6 +40,7 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.compose.material3.Text
 import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
 import androidx.compose.ui.graphics.vector.ImageVector
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.painterResource
@@ -146,23 +147,41 @@ fun dish(navController: NavController) {
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img),
-                                    contentDescription = "Home",
-                                    tint = text_1
-                                )
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Home")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img),
+                                        contentDescription = "HOME",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("HOME", color = text_1)
                             }
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_1),
-                                    contentDescription = "My Plan",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("MyPlan")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_1),
+                                        contentDescription = "My Plan",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("MY PLAN", color = text_1)
                             }
                             Column(
@@ -180,12 +199,21 @@ fun dish(navController: NavController) {
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_3),
-                                    contentDescription = "Log Out",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Auth")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_3),
+                                        contentDescription = "Log Out",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("LOG OUT", color = text_1)
                             }
                         }

+ 46 - 20
EatWell/app/src/main/java/com/example/eatwell/view/mainActivity/Fridge.kt

@@ -42,6 +42,7 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.compose.material3.Text
 import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
 import androidx.compose.ui.graphics.vector.ImageVector
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.painterResource
@@ -254,32 +255,48 @@ fun fridge(navController: NavController) {
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img),
-                                    contentDescription = "Home",
-                                    tint = text_1
-                                )
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Home")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img),
+                                        contentDescription = "HOME",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("HOME", color = text_1)
                             }
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_1),
-                                    contentDescription = "My Plan",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("MyPlan")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_1),
+                                        contentDescription = "My Plan",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("MY PLAN", color = text_1)
                             }
-
-                            // Элемент "FRIGE"
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
                                 Icon(
-                                    painter = painterResource(id = R.drawable.img_2),
+                                    painter = painterResource(id = R.drawable.img_4),
                                     contentDescription = "Fridge",
                                     tint = Color.Black
                                 )
@@ -290,12 +307,21 @@ fun fridge(navController: NavController) {
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_3),
-                                    contentDescription = "Log Out",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Auth")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_3),
+                                        contentDescription = "Log Out",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("LOG OUT", color = text_1)
                             }
                         }

+ 47 - 18
EatWell/app/src/main/java/com/example/eatwell/view/mainActivity/Ingredients.kt

@@ -44,6 +44,7 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.compose.material3.Text
 import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
 import androidx.compose.ui.graphics.vector.ImageVector
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.painterResource
@@ -198,45 +199,73 @@ fun ingredients(navController: NavController) {
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img),
-                                    contentDescription = "Home",
-                                    tint = text_1
-                                )
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Home")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img),
+                                        contentDescription = "HOME",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("HOME", color = text_1)
                             }
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_1),
-                                    contentDescription = "My Plan",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("MyPlan")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_1),
+                                        contentDescription = "My Plan",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("MY PLAN", color = text_1)
                             }
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
                                 Icon(
-                                    painter = painterResource(id = R.drawable.img_2),
+                                    painter = painterResource(id = R.drawable.img_4),
                                     contentDescription = "Fridge",
                                     tint = Color.Black
                                 )
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("FRIGE", color = Color.Black)
                             }
+
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_3),
-                                    contentDescription = "Log Out",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Auth")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_3),
+                                        contentDescription = "Log Out",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("LOG OUT", color = text_1)
                             }
                         }

+ 60 - 37
EatWell/app/src/main/java/com/example/eatwell/view/mainActivity/MyPlan.kt

@@ -1,6 +1,8 @@
 package com.example.eatwell.view.mainActivity
 
 import android.graphics.drawable.Drawable
+import android.os.Build
+import androidx.annotation.RequiresApi
 import androidx.compose.foundation.background
 import androidx.compose.foundation.layout.Box
 import androidx.compose.foundation.layout.Column
@@ -101,14 +103,16 @@ import androidx.compose.ui.res.vectorResource
 import androidx.core.content.ContextCompat
 import androidx.core.graphics.drawable.toBitmap
 import androidx.navigation.NavController
+import androidx.navigation.NavHostController
 import com.example.eatwell.view.ui.theme.knopka
 import com.example.eatwell.view.ui.theme.text_1
 import io.github.jan.supabase.gotrue.auth
 
+@RequiresApi(Build.VERSION_CODES.O)
 @OptIn(ExperimentalMaterial3Api::class)
 //@Preview
 @Composable
-fun myplan(navController: NavController) {
+fun myplan(navController: NavHostController) {
     var selectedDates by remember { mutableStateOf(mutableSetOf<LocalDate>()) }
     var currentMonth by remember { mutableStateOf(LocalDate.now().monthValue) }
 
@@ -153,7 +157,7 @@ fun myplan(navController: NavController) {
                 )
                 Text(
                     text = "Отметьте дни, когда вы следуете своему плану  ",
-                    fontSize = 18.sp,
+                    fontSize = 20.sp,
                     fontWeight = FontWeight.Bold,
                     color = black,
                     textAlign = TextAlign.Left,
@@ -216,28 +220,19 @@ fun myplan(navController: NavController) {
                             val isSelected = selectedDates.contains(date)
 
 
-                            val drawable: Drawable? = ContextCompat.getDrawable(
-                                LocalContext.current,
-                                R.drawable.rounded_item
-                            )
-                            // val painter = drawable?.toBitmap()?.let { BitmapPainter(it) }
-
                             Box(
                                 modifier = Modifier
                                     .fillMaxWidth()
                                     .padding(4.dp)
                                     .clip(CircleShape)
-                                    // .background(painter = drawable)
-
-                                    //.size(36.dp)
                                     .clickable {
-
                                         selectedDates = if (isSelected) {
                                             selectedDates - date
                                         } else {
                                             selectedDates + date
                                         }.toMutableSet()
-                                    },
+                                    }
+                                    .then(if (isSelected) Modifier.background(knopka) else Modifier),
                                 contentAlignment = Alignment.Center
                             ) {
                                 Text(text = day.toString())
@@ -250,10 +245,10 @@ fun myplan(navController: NavController) {
                 Row(
                     modifier = Modifier
                         .fillMaxWidth()
-                        .padding(1.dp),
+                        .padding(10.dp),
                     horizontalArrangement = Arrangement.SpaceBetween
                 ) {
-                    repeat(5) { index ->
+                    repeat(12) { index ->
                         Box(
                             modifier = Modifier
                                 .size(5.dp)
@@ -261,15 +256,14 @@ fun myplan(navController: NavController) {
                                 .clickable { currentMonth = (index + 1) }
                         )
                     }
-                }
+                }}
 
 
                 //вот
                 Column(
                     modifier = Modifier
                         .fillMaxSize()
-                        .background(white)
-                        .padding(top = 670.dp, start = 15.dp, end = 15.dp)
+                        .padding(top = 710.dp, start = 15.dp, end = 15.dp)
                 ) {
                     Box(
                         modifier = Modifier
@@ -292,11 +286,20 @@ fun myplan(navController: NavController) {
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img),
-                                    contentDescription = "Home",
-                                    tint = text_1
-                                )
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Home")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img),
+                                        contentDescription = "HOME",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("HOME", color = text_1)
                             }
@@ -307,32 +310,50 @@ fun myplan(navController: NavController) {
                                 Icon(
                                     painter = painterResource(id = R.drawable.img_1),
                                     contentDescription = "My Plan",
-                                    tint = Color.Black
+                                    tint = Color.Black,
+                                            modifier = Modifier.size(25.dp)
                                 )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("MY PLAN", color = Color.Black)
                             }
 
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_2),
-                                    contentDescription = "Fridge",
-                                    tint = text_1
-                                )
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Fridge")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_2),
+                                        contentDescription = "Fridge",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("FRIGE", color = text_1)
                             }
-
                             Column(
                                 horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_3),
-                                    contentDescription = "Log Out",
-                                    tint = text_1
-                                )
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Auth")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_3),
+                                        contentDescription = "Log Out",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
                                 Spacer(modifier = Modifier.height(4.dp))
                                 Text("LOG OUT", color = text_1)
                             }
@@ -342,14 +363,16 @@ fun myplan(navController: NavController) {
             }
         }
     }
-}
+
 
 
 // Функция для получения количества дней в месяце
+@RequiresApi(Build.VERSION_CODES.O)
 fun getDaysInMonth(month: Int, year: Int): Int {
     return LocalDate.of(year, month, 1).lengthOfMonth()
 }
 
+@RequiresApi(Build.VERSION_CODES.O)
 @Composable
 fun CalendarDay(date: LocalDate, isSelected: Boolean, onDateClick: (LocalDate) -> Unit) {
     Button(

+ 55 - 36
EatWell/app/src/main/java/com/example/eatwell/view/mainActivity/Recept.kt

@@ -38,6 +38,7 @@ import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
 import androidx.compose.material3.Text
 import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
 import androidx.compose.ui.graphics.vector.ImageVector
 import androidx.compose.ui.platform.LocalContext
 import androidx.compose.ui.res.painterResource
@@ -119,59 +120,77 @@ fun recept(navController: NavHostController) {
                             verticalAlignment = Alignment.CenterVertically
                         ) {
                             Column(
-                                horizontalAlignment = Alignment.CenterHorizontally
-                            ) {
+                                horizontalAlignment = Alignment.CenterHorizontally,
+
+                                ) {
                                 Icon(
                                     painter = painterResource(id = R.drawable.img),
                                     contentDescription = "Home",
-                                    tint = Color.Black
+                                    tint = Color.Black,
+                                    modifier = Modifier.size(25.dp)
                                 )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("HOME", color = Color.Black)
                             }
 
                             Column(
-                                horizontalAlignment = Alignment.CenterHorizontally,
-                                modifier = Modifier.clickable {
-                                    navController.navigate("MyPlan")
-                                }
+                                horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_1),
-                                    contentDescription = "My Plan",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("MyPlan")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_1),
+                                        contentDescription = "My Plan",
+                                        tint = text_1,
+                                        modifier = Modifier.size(25.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("MY PLAN", color = text_1)
                             }
-
                             Column(
-                                horizontalAlignment = Alignment.CenterHorizontally,
-                                modifier = Modifier.clickable {
-                                    navController.navigate("Frige")
-                                }
+                                horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_2),
-                                    contentDescription = "Fridge",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Fridge")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_2),
+                                        contentDescription = "Fridge",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("FRIGE", color = text_1)
                             }
-
                             Column(
-                                horizontalAlignment = Alignment.CenterHorizontally,
-                                modifier = Modifier.clickable {
-                                    navController.navigate("auth")
-                                }
+                                horizontalAlignment = Alignment.CenterHorizontally
                             ) {
-                                Icon(
-                                    painter = painterResource(id = R.drawable.img_3),
-                                    contentDescription = "Log Out",
-                                    tint = text_1
-                                )
-                                Spacer(modifier = Modifier.height(4.dp))
+                                IconButton(
+                                    onClick = {
+                                        navController.navigate("Auth")
+                                        {
+                                        }
+                                    }, modifier = Modifier.size(32.dp)
+                                ) {
+                                    Icon(
+                                        painter = painterResource(id = R.drawable.img_3),
+                                        contentDescription = "Log Out",
+                                        tint = text_1,
+                                        modifier = Modifier.size(28.dp)
+                                    )
+                                }
+                                Spacer(modifier = Modifier.height(9.dp))
                                 Text("LOG OUT", color = text_1)
                             }
                         }

+ 1 - 1
EatWell/app/src/main/res/drawable/ic_launcher_background.xml

@@ -5,7 +5,7 @@
     android:viewportWidth="108"
     android:viewportHeight="108">
     <path
-        android:fillColor="#3DDC84"
+        android:fillColor="#FF6F00"
         android:pathData="M0,0h108v108h-108z" />
     <path
         android:fillColor="#00000000"