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