|
@@ -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(
|