mirror of
https://github.com/bleackstorm/satiea.git
synced 2026-12-03 07:41:56 +01:00
feat: add recipe management support
- Add `LocalRecipeEntity` and database migration 3->4 - Update `LocalCustomFoodEntity` with category support - Include DAO methods for recipe persistence
This commit is contained in:
1 parent
097d4b521e
commit
d4d5d77d71
41 files changed
+5264
-1901
No files matched your search
@@ -1,8 +1,5 @@
|
||||
package com.example.ui.journal
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.foundation.Image
|
||||
import coil.compose.AsyncImage
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
@@ -33,7 +30,6 @@ import androidx.compose.material.icons.filled.FileDownload
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.Restaurant
|
||||
import androidx.compose.material.icons.filled.TableChart
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
@@ -55,16 +51,22 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import coil.compose.AsyncImage
|
||||
import com.example.data.model.CustomFoodEntry
|
||||
import com.example.data.model.FoodCategory
|
||||
import com.example.data.model.HungerSatietyScale
|
||||
import com.example.data.model.MealEntry
|
||||
import com.example.data.model.MealType
|
||||
import com.example.util.ImageUtils
|
||||
import com.example.ui.common.FoodCategoryBadge
|
||||
import com.example.ui.journal.components.DailyBenchmarksCard
|
||||
import com.example.ui.journal.components.DietaryGuideSheet
|
||||
import java.time.Instant
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
@@ -74,6 +76,7 @@ import java.util.Locale
|
||||
@Composable
|
||||
fun JournalScreen(
|
||||
mealsUiState: MealsUiState,
|
||||
customFoods: List<CustomFoodEntry> = emptyList(),
|
||||
onAddMealClick: () -> Unit,
|
||||
onEditMeal: (MealEntry) -> Unit,
|
||||
onDeleteMeal: (String) -> Unit,
|
||||
@@ -81,6 +84,12 @@ fun JournalScreen(
|
||||
onSyncSheetsClick: (() -> Unit)? = null,
|
||||
spreadsheetUrl: String? = null
|
||||
) {
|
||||
var showDietaryGuide by remember { mutableStateOf(false) }
|
||||
|
||||
val customCategoryLookup = remember(customFoods) {
|
||||
customFoods.associate { it.name.lowercase(Locale.FRENCH).trim() to it.resolvedCategory() }
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@@ -139,6 +148,14 @@ fun JournalScreen(
|
||||
DailyOverviewCard(todayMeals = todayMeals)
|
||||
}
|
||||
|
||||
item {
|
||||
DailyBenchmarksCard(
|
||||
todayMeals = todayMeals,
|
||||
customCategoryLookup = customCategoryLookup,
|
||||
onOpenGuideClick = { showDietaryGuide = true }
|
||||
)
|
||||
}
|
||||
|
||||
if (meals.isEmpty()) {
|
||||
item {
|
||||
EmptyMealsView(onAddMealClick = onAddMealClick)
|
||||
@@ -167,13 +184,13 @@ fun JournalScreen(
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.TableChart,
|
||||
contentDescription = "Synchroniser vers Google Sheets",
|
||||
contentDescription = "Sauvegarder sur Google Sheets",
|
||||
modifier = Modifier.size(18.dp),
|
||||
tint = Color(0xFF0F9D58)
|
||||
)
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = "Sheets",
|
||||
text = "Drive",
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = Color(0xFF0F9D58)
|
||||
)
|
||||
@@ -204,6 +221,7 @@ fun JournalScreen(
|
||||
items(meals, key = { it.id.ifEmpty { it.mealTimestamp.toString() } }) { meal ->
|
||||
MealCardItem(
|
||||
meal = meal,
|
||||
customCategoryLookup = customCategoryLookup,
|
||||
onEdit = { onEditMeal(meal) },
|
||||
onDelete = { onDeleteMeal(meal.id) }
|
||||
)
|
||||
@@ -230,6 +248,10 @@ fun JournalScreen(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (showDietaryGuide) {
|
||||
DietaryGuideSheet(onDismiss = { showDietaryGuide = false })
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -331,6 +353,7 @@ private fun DailyOverviewCard(todayMeals: List<MealEntry>) {
|
||||
@Composable
|
||||
private fun MealCardItem(
|
||||
meal: MealEntry,
|
||||
customCategoryLookup: Map<String, FoodCategory>,
|
||||
onEdit: () -> Unit,
|
||||
onDelete: () -> Unit
|
||||
) {
|
||||
@@ -511,7 +534,7 @@ private fun MealCardItem(
|
||||
}
|
||||
}
|
||||
|
||||
// Food Items Badges (with optional weights)
|
||||
// Color-Coded Food Items Badges
|
||||
if (parsedFoods.isNotEmpty()) {
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
Text(
|
||||
@@ -526,18 +549,10 @@ private fun MealCardItem(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
parsedFoods.forEach { food ->
|
||||
Surface(
|
||||
shape = RoundedCornerShape(10.dp),
|
||||
color = MaterialTheme.colorScheme.primary.copy(alpha = 0.14f)
|
||||
) {
|
||||
Text(
|
||||
text = food.displayBadge(),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontWeight = FontWeight.Medium,
|
||||
modifier = Modifier.padding(horizontal = 10.dp, vertical = 5.dp)
|
||||
)
|
||||
}
|
||||
FoodCategoryBadge(
|
||||
text = food.displayBadge(),
|
||||
category = food.resolvedCategory(customCategoryLookup)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -568,7 +583,7 @@ private fun MealCardItem(
|
||||
text = "Note globale : « ${meal.note} »",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.9f),
|
||||
fontStyle = androidx.compose.ui.text.font.FontStyle.Italic
|
||||
fontStyle = FontStyle.Italic
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -578,7 +593,7 @@ private fun MealCardItem(
|
||||
AlertDialog(
|
||||
onDismissRequest = { showDeleteDialog = false },
|
||||
title = { Text("Supprimer ce repas ?") },
|
||||
text = { Text("Cette action est irréversible et supprimera le repas de votre historique synchronisé.") },
|
||||
text = { Text("Cette action supprimera ce repas de votre journal local.") },
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
@@ -633,7 +648,7 @@ private fun EmptyMealsView(onAddMealClick: () -> Unit) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Text(
|
||||
text = "Prenez 15 secondes pour noter vos aliments (avec ou sans poids), votre faim et votre satiété sur 10.",
|
||||
text = "Prenez 15 secondes pour noter vos aliments (avec leur code couleur), votre faim et votre satiété sur 10.",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.7f),
|
||||
textAlign = TextAlign.Center
|
||||
|
||||
Reference in new issue
Block a user