|
@@ -32,6 +32,7 @@ import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.filled.ArrowDropDown
|
|
|
import androidx.compose.material.icons.filled.DateRange
|
|
|
import androidx.compose.material.icons.filled.Home
|
|
|
+import androidx.compose.material.icons.filled.KeyboardArrowDown
|
|
|
import androidx.compose.material.icons.filled.Lock
|
|
|
import androidx.compose.material.icons.filled.MoreVert
|
|
|
import androidx.compose.material.icons.filled.ShoppingCart
|
|
@@ -56,6 +57,7 @@ import androidx.compose.ui.res.vectorResource
|
|
|
import androidx.compose.ui.text.font.FontFamily
|
|
|
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
+import androidx.navigation.NavController
|
|
|
import androidx.navigation.NavHostController
|
|
|
import coil.compose.rememberImagePainter
|
|
|
import com.example.eatwell.R
|
|
@@ -65,11 +67,13 @@ import com.example.eatwell.model.Category
|
|
|
import com.example.eatwell.model.Diets
|
|
|
import com.example.eatwell.model.Recipes
|
|
|
import com.example.eatwell.view.MainViewModel
|
|
|
+import com.example.eatwell.view.ui.theme.fon2
|
|
|
+import com.example.eatwell.view.ui.theme.knopka
|
|
|
import com.example.eatwell.view.ui.theme.text_1
|
|
|
import io.github.jan.supabase.gotrue.auth
|
|
|
|
|
|
-var dietId: Int = 0
|
|
|
-var categoryId: Int = 0
|
|
|
+var dietId: Int = 1
|
|
|
+var categoryId: Int = 1
|
|
|
var flag: Boolean = false;
|
|
|
|
|
|
|
|
@@ -77,14 +81,19 @@ var flag: Boolean = false;
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
//@Preview(showBackground = true)
|
|
|
@Composable
|
|
|
-fun home(navController: NavHostController) {
|
|
|
+fun home(navController: NavController) {
|
|
|
var categoryExpanded by remember { mutableStateOf(false) }
|
|
|
var expanded by remember { mutableStateOf(false) }
|
|
|
var expandedCat by remember { mutableStateOf(false) }
|
|
|
var selectedOption: String
|
|
|
+ var selectedCategory: String
|
|
|
|
|
|
- for (i in 0..Resources.recipes.size-1){
|
|
|
- Resources.chosenRecipes.add(Resources.recipes.get(i))
|
|
|
+ var list = remember { mutableStateListOf<Recipes>() }
|
|
|
+ if(!flag) {
|
|
|
+ for (i in 0..Resources.recipes.size - 1) {
|
|
|
+ list.add(Resources.recipes.get(i))
|
|
|
+ }
|
|
|
+ flag = true
|
|
|
}
|
|
|
|
|
|
Log.d("Диеты home: ", Resources.diets.toString())
|
|
@@ -103,22 +112,20 @@ fun home(navController: NavHostController) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.width(359.dp)
|
|
|
- .height(730.dp)
|
|
|
+ .height(800.dp)
|
|
|
.clip(RoundedCornerShape(30.dp))
|
|
|
.background(white)
|
|
|
.align(Alignment.TopCenter) // .shadow(elevation = 10.dp, shape = RoundedCornerShape(30.dp))
|
|
|
- .padding(16.dp)
|
|
|
-
|
|
|
-
|
|
|
+ .padding(1.dp)
|
|
|
) {
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
|
.fillMaxSize()
|
|
|
.background(white)
|
|
|
- .padding(top = 50.dp, start = 15.dp, end = 15.dp)
|
|
|
+ .padding(top = 15.dp, start = 15.dp, end = 15.dp)
|
|
|
) {
|
|
|
Row(
|
|
|
- modifier = Modifier.fillMaxWidth(),
|
|
|
+ modifier = Modifier.fillMaxWidth().padding(vertical = 15.dp),
|
|
|
horizontalArrangement = Arrangement.SpaceBetween,
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
@@ -142,9 +149,11 @@ fun home(navController: NavHostController) {
|
|
|
)
|
|
|
IconButton(onClick = { expanded = true }) {
|
|
|
Icon(
|
|
|
- painter = painterResource(id = R.drawable.img_5),
|
|
|
- contentDescription = "Показать меню",
|
|
|
- tint = text_1
|
|
|
+ imageVector = if (expanded) Icons.Default.KeyboardArrowDown else Icons.Default.ArrowDropDown, // Используем векторную иконку
|
|
|
+ contentDescription = "Показать/Скрыть меню",
|
|
|
+ tint = text_1,
|
|
|
+ modifier = Modifier.size(24.dp)
|
|
|
+
|
|
|
)
|
|
|
}
|
|
|
DropdownMenu(
|
|
@@ -156,11 +165,17 @@ fun home(navController: NavHostController) {
|
|
|
|
|
|
Resources.diets.forEach { diet ->
|
|
|
DropdownMenuItem(
|
|
|
- text = { Text(diet.name) },
|
|
|
+ text = { Text(diet.name) }, // Указываем текст через `text` параметр
|
|
|
onClick = {
|
|
|
- selectedOption = diet.name
|
|
|
+ selectedOption = diet.name // Устанавливаем выбранный элемент
|
|
|
dietId = diet.id
|
|
|
- defineRecipes()
|
|
|
+ list.clear()
|
|
|
+ for(i in 0..Resources.recipes.size-1){
|
|
|
+ if(Resources.recipes.get(i).diets == dietId && Resources.recipes.get(i).category == categoryId){
|
|
|
+ Log.d("Добавили: " ," ")
|
|
|
+ list.add(Resources.recipes.get(i))
|
|
|
+ }
|
|
|
+ }
|
|
|
expanded = false
|
|
|
}
|
|
|
)
|
|
@@ -190,20 +205,31 @@ fun home(navController: NavHostController) {
|
|
|
Spacer(modifier = Modifier.width(8.dp))
|
|
|
IconButton(onClick = { expandedCat = true }) {
|
|
|
Icon(
|
|
|
- painter = painterResource(id = R.drawable.img_5),
|
|
|
- contentDescription = "Показать меню",
|
|
|
- tint = text_1
|
|
|
+ imageVector = if (expandedCat) Icons.Default.KeyboardArrowDown else Icons.Default.ArrowDropDown, // Используем векторную иконку
|
|
|
+ contentDescription = "Показать/Скрыть меню",
|
|
|
+ tint = text_1,
|
|
|
+ modifier = Modifier.size(44.dp)
|
|
|
)
|
|
|
}
|
|
|
DropdownMenu(
|
|
|
expanded = expandedCat,
|
|
|
onDismissRequest = { expandedCat = false }
|
|
|
) {
|
|
|
- for (i in 0..Resources.categories.size - 1) {
|
|
|
- Text(
|
|
|
- text = Resources.categories.get(i).name,
|
|
|
- fontSize = 18.sp,
|
|
|
- modifier = Modifier.padding(10.dp)
|
|
|
+ Resources.categories.forEach { categories ->
|
|
|
+ DropdownMenuItem(
|
|
|
+ text = { Text(categories.name) }, // Указываем текст через `text` параметр
|
|
|
+ onClick = {
|
|
|
+ selectedCategory = categories.name // Устанавливаем выбранный элемент
|
|
|
+ categoryId = categories.id
|
|
|
+ list.clear()
|
|
|
+ for(i in 0..Resources.recipes.size-1){
|
|
|
+ if(Resources.recipes.get(i).diets == dietId && Resources.recipes.get(i).category == categoryId){
|
|
|
+ Log.d("Добавили: " ," ")
|
|
|
+ list.add(Resources.recipes.get(i))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ expandedCat = false
|
|
|
+ }
|
|
|
)
|
|
|
}
|
|
|
}
|
|
@@ -211,17 +237,26 @@ fun home(navController: NavHostController) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .width(359.dp)
|
|
|
+ .height(630.dp)
|
|
|
+ .clip(RoundedCornerShape(30.dp))
|
|
|
+ .background(fon2)
|
|
|
+ .padding(15.dp)
|
|
|
+
|
|
|
+ ) {
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
|
.size(width = 400.dp, height = 750.dp)
|
|
|
- .background(Color.LightGray)
|
|
|
+ .background(fon2)
|
|
|
+
|
|
|
) {
|
|
|
|
|
|
LazyColumn(
|
|
|
modifier = Modifier.fillMaxSize()
|
|
|
) {
|
|
|
- var list: MutableList<Recipes> = Resources.chosenRecipes
|
|
|
-
|
|
|
items(list.size) { itemId ->
|
|
|
Image(
|
|
|
painter = rememberImagePainter(
|
|
@@ -238,7 +273,9 @@ fun home(navController: NavHostController) {
|
|
|
end = 7.5.dp
|
|
|
)
|
|
|
.fillMaxWidth()
|
|
|
- .height(100.dp)
|
|
|
+ .height(150.dp)
|
|
|
+ .clip(RoundedCornerShape(50.dp))
|
|
|
+
|
|
|
)
|
|
|
Text(
|
|
|
modifier = Modifier
|
|
@@ -257,7 +294,7 @@ fun home(navController: NavHostController) {
|
|
|
.fillMaxWidth()
|
|
|
.padding(top = 7.5.dp),
|
|
|
text = list.get(itemId).calories,
|
|
|
- color = Color.Gray,
|
|
|
+ color = knopka,
|
|
|
fontSize = 15.sp,
|
|
|
fontWeight = FontWeight.Bold,
|
|
|
fontFamily = FontFamily.Monospace,
|
|
@@ -267,7 +304,7 @@ fun home(navController: NavHostController) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
+ }}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -283,7 +320,7 @@ fun home(navController: NavHostController) {
|
|
|
.clip(RoundedCornerShape(30.dp))
|
|
|
.background(white)
|
|
|
.align(Alignment.BottomCenter)
|
|
|
- .padding(bottom = 50.dp)
|
|
|
+ .padding(bottom = 20.dp)
|
|
|
) {
|
|
|
|
|
|
// Черная линия
|
|
@@ -319,7 +356,7 @@ fun home(navController: NavHostController) {
|
|
|
) {
|
|
|
IconButton(
|
|
|
onClick = {
|
|
|
- navController.navigate("MyPlan")
|
|
|
+ navController.navigate("MyPlan")
|
|
|
{
|
|
|
}
|
|
|
}, modifier = Modifier.size(32.dp)
|
|
@@ -379,12 +416,5 @@ fun home(navController: NavHostController) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fun defineRecipes(){
|
|
|
- Resources.chosenRecipes.clear()
|
|
|
- for(i in 0..Resources.recipes.size-1){
|
|
|
- if(Resources.recipes.get(i).diets == dietId && Resources.recipes.get(i).category == categoryId){
|
|
|
- Resources.chosenRecipes.add(Resources.recipes.get(i))
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
|