From d717623677966dcfa9361c6ea5b6f6c12fec26e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 26 Oct 2026 11:05:44 +0000 Subject: [PATCH] Nutrition becomes a tab; the coach moves into the Actions button Seeing what you ate and adding a meal to an earlier day were buried behind Today's tile or the Log sheet. Nutrition now takes the fifth tab, with its day arrows choosing the day a meal is saved to. The coach leaves the tab bar and becomes the first row of the floating button's sheet, renamed from "Log" to "Actions". It opens as a pushed screen with a back arrow in its header. The sheet also gains the two earlier-day paths: "For an earlier day" under Meal, and "Past workout". Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w --- AGENTS.md | 9 +++-- app/src/main/assets/i18n/pt-BR.json | 7 ++++ .../java/com/pulseloop/ui/PulseLoopApp.kt | 33 +++++++++++++------ .../com/pulseloop/ui/screens/CoachScreen.kt | 11 +++++-- .../java/com/pulseloop/ui/screens/LogSheet.kt | 20 ++++++++--- .../pulseloop/ui/screens/NutritionScreen.kt | 10 ++++-- 6 files changed, 70 insertions(+), 20 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d4582c9f..4c3712c0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1117,9 +1117,14 @@ sources: `docs/postpartum-breastfeeding-research.md`. clutter came from ignoring one of them: - **Where a thing lives follows what the user came to do.** Logging (meal, drink, dose, period, - tags, workout) is one job, so it has one door: the "+ Log" button on every tab but Coach + tags, workout) is one job, so it has one door: the "Actions" button on every tab (`LogSheet`, opened through `LaunchRequests.openLog`). Today's Meal/Drink chips open the same - sheet at a step; don't grow a second logging path on a new screen. Programs the user switched on + sheet at a step; don't grow a second logging path on a new screen. Earlier days belong to the + same door: "For an earlier day" sends a meal to the Nutrition tab's day arrows, "Past workout" + opens the past-activity form. +- **The tabs are Today, Vitals, Activity, Sleep, Nutrition.** Nutrition took the Coach's tab + because seeing and back-filling meals was buried; the coach is the first row of the Actions + sheet and a pushed screen with its own back arrow. Don't put it back on the bar to "restore" it. Programs the user switched on (cycle, meds, postpartum) surface on Today (`ProgramsRow`), and Rest Mode is offered where "I'm unwell" happens (`RestModeLine`), not only in a menu. - **Inside a screen, summary first, detail on tap.** A screen leads with one summary and its diff --git a/app/src/main/assets/i18n/pt-BR.json b/app/src/main/assets/i18n/pt-BR.json index d96db48b..e5dc0b78 100644 --- a/app/src/main/assets/i18n/pt-BR.json +++ b/app/src/main/assets/i18n/pt-BR.json @@ -102,6 +102,7 @@ "API key needed": "Chave de API necessária", "About": "Sobre", "About PulseLoop": "Sobre o PulseLoop", + "About your day, a plan, a meal idea": "Sobre o seu dia, um plano, uma ideia de refeição", "About {0} left": "Faltam cerca de {0}", "Above baseline": "Acima da linha de base", "Above goal": "Acima da meta", @@ -116,6 +117,7 @@ "Accuracy report": "Relatório de precisão", "Accuracy report ready · choose what to do with the paused export": "Relatório de precisão pronto · escolha o que fazer com a exportação pausada", "Across the year your tracked average is {0} over {1} nights. The long-term trend is still forming — as more months fill in, I'll be able to compare seasonal changes and consistency.": "Ao longo do ano, sua média registrada é {0} em {1} noites. A tendência de longo prazo ainda está se formando — conforme mais meses forem preenchidos, poderei comparar mudanças sazonais e consistência.", + "Actions": "Ações", "Active": "Ativo", "Active calories": "Calorias ativas", "Active every hour since {0}:00": "Ativo a cada hora desde {0}:00", @@ -186,6 +188,7 @@ "Around lunch and dinner, only when nothing is logged yet. Needs nutrition tracking on.": "Perto do almoço e do jantar, só quando ainda não há nada registrado. Requer o acompanhamento de nutrição ativado.", "Around your personal baseline.": "Perto da sua linha de base pessoal.", "Arroz branco": "Arroz branco", + "Ask the coach": "Perguntar ao coach", "Ask the coach about it": "Pergunte ao coach", "Ask the coach...": "Pergunte ao coach...", "Asleep {0}": "Dormindo {0}", @@ -603,6 +606,7 @@ "Folder: {0}": "Pasta: {0}", "Follicular": "Folicular", "Food the user logged themselves; totals are only as complete as the log.": "Alimentos que o usuário registrou; os totais são tão completos quanto o registro.", + "For an earlier day": "Para um dia anterior", "For drinks, money and calories saved": "Para bebidas, dinheiro e calorias economizados", "For my next meal ({0}) you suggested: ": "Para minha próxima refeição ({0}) você sugeriu: ", "For {0}h asleep before your usual {1}": "Para {0}h de sono antes do seu horário habitual {1}", @@ -1037,6 +1041,7 @@ "On. PulseLoop syncs your ring about every 30 minutes, even while the phone is idle.": "Ativado. O PulseLoop sincroniza seu anel a cada 30 minutos, mesmo com o celular ocioso.", "Once per dose, at its time, for what you add with + Log → Medication or supplement.": "Uma vez por dose, no horário, para o que você adicionar em + Registrar → Medicamento ou suplemento.", "One tap for the usual ones": "Um toque para as de sempre", + "One you already did, with its time and length": "Um que você já fez, com horário e duração", "Only needed if you started the server with --api-key. Leave blank otherwise.": "Só é necessário se você iniciou o servidor com --api-key. Caso contrário, deixe em branco.", "Only new data from now on": "Apenas dados novos daqui em diante", "Only providers that don't retain data": "Apenas provedores que não retêm dados", @@ -1081,6 +1086,7 @@ "Pair your ring first.": "Pareie seu anel primeiro.", "Pair your ring first: a check compares it against the other device.": "Pareie seu anel primeiro: a verificação o compara com o outro dispositivo.", "Past checks": "Verificações anteriores", + "Past workout": "Treino passado", "Patinho moído": "Patinho moído", "Pause": "Pausar", "Paused by the accuracy check": "Pausado pela verificação de precisão", @@ -1101,6 +1107,7 @@ "Photo": "Foto", "Photo, barcode or by hand": "Foto, código de barras ou à mão", "Physiology": "Fisiologia", + "Pick the day in Nutrition, then add it there": "Escolha o dia em Nutrição e adicione lá", "Pick the left and right PulseLoop metrics.": "Escolha as métricas do PulseLoop da esquerda e da direita.", "Pick the number before the first drink. It's easier to keep a number you chose beforehand.": "Escolha o número antes da primeira dose. É mais fácil cumprir um número que você definiu antes.", "Pick which PulseLoop metric this widget shows.": "Escolha qual métrica do PulseLoop este widget mostra.", diff --git a/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt b/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt index f6fe78d0..c7883978 100644 --- a/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt +++ b/app/src/main/java/com/pulseloop/ui/PulseLoopApp.kt @@ -306,8 +306,9 @@ fun PulseLoopApp() { } // ── Navigation ─────────────────────────────────────────────────── - // Tab order + icons mirror iOS MainTab (AppTheme.swift): Today (circle.circle), - // Vitals (heart), Activity (waveform.path.ecg), Sleep (moon), Coach (sparkles). + // Tabs: Today, Vitals, Activity, Sleep, Nutrition. Nutrition took the Coach's place: seeing + // what you ate, and adding a meal to an earlier day, used to be three taps deep. The coach + // is one tap from every tab instead, at the top of the Actions sheet. val navController = rememberNavController() // First-launch gate (iOS #48): show the onboarding flow until it's completed. @@ -341,7 +342,7 @@ fun PulseLoopApp() { Tab("vitals", tr("Vitals"), Icons.Filled.Favorite, Icons.Outlined.FavoriteBorder), Tab("activity", tr("Activity"), Icons.Filled.MonitorHeart, Icons.Outlined.MonitorHeart), Tab("sleep", tr("Sleep"), Icons.Filled.Bedtime, Icons.Outlined.Bedtime), - Tab("coach", tr("Coach"), Icons.Filled.AutoAwesome, Icons.Outlined.AutoAwesome), + Tab("nutrition", tr("Nutrition"), Icons.Filled.Restaurant, Icons.Outlined.Restaurant), ) // ── Self-update: release-only. Checked on every return to foreground (ON_START also @@ -394,10 +395,10 @@ fun PulseLoopApp() { noiseFactor = 0.02f, ) - // "+ Log" on every tab but Coach: recording something is the most frequent job in the - // app, so it sits in the same place whichever tab is open. + // "Actions" on every tab: recording something is the most frequent job in the app, so it + // sits in the same place whichever tab is open, and the coach is the sheet's first row. val fabEntry by navController.currentBackStackEntryAsState() - val showLogFab = fabEntry?.destination?.route.let { it in tabRoutes && it != "coach" } + val showLogFab = fabEntry?.destination?.route in tabRoutes Scaffold( containerColor = com.pulseloop.ui.theme.PulseColors.background, floatingActionButton = { @@ -411,7 +412,7 @@ fun PulseLoopApp() { ExtendedFloatingActionButton( onClick = { LaunchRequests.openLog.value = com.pulseloop.ui.screens.LogStep.MENU }, icon = { Icon(Icons.Filled.Add, contentDescription = null) }, - text = { Text(tr("Log"), maxLines = 1) }, + text = { Text(tr("Actions"), maxLines = 1) }, containerColor = com.pulseloop.ui.theme.PulseColors.accent, contentColor = com.pulseloop.ui.theme.PulseColors.onAccent, ) @@ -422,7 +423,8 @@ fun PulseLoopApp() { // routes only; pushed screens (settings, details, pairing) bring their own bars. val navBackStackEntry by navController.currentBackStackEntryAsState() val route = navBackStackEntry?.destination?.route - val onTabRoute = route in tabRoutes + // The coach is no longer a tab but keeps the frosted header it had as one. + val onTabRoute = route in tabRoutes || route == "coach" if (onTabRoute && !isLandscape) { Column( Modifier @@ -442,6 +444,7 @@ fun PulseLoopApp() { // (owner choice, issue #22). var showCoachUsage by remember { mutableStateOf(false) } CoachHeader( + onBack = { navController.popBackStack() }, onNewChat = { coachVM.newConversation() }, onOpenUsage = { showCoachUsage = true }, ) @@ -598,7 +601,7 @@ fun PulseLoopApp() { // bars as an opaque floor/ceiling via this per-route padding wrapper. val topPad = padding.calculateTopPadding() val barPad = padding.calculateBottomPadding() - // The four tabs with the "+ Log" button scroll their last card clear of it. + // The tabs scroll their last card clear of the Actions button. val tabPad = barPad + 72.dp fun androidx.navigation.NavGraphBuilder.paddedComposable( route: String, @@ -714,8 +717,9 @@ fun PulseLoopApp() { com.pulseloop.ui.LaunchRequests.coachMessage.value = msg navController.navigate("coach") { launchSingleTop = true } } else null + // A tab: the shared header above it, and no back arrow of its own. paddedComposable("nutrition") { - NutritionScreen(onBack = { navController.popBackStack() }, onDiscuss = discussMeal) + NutritionScreen(onBack = { navController.popBackStack() }, onDiscuss = discussMeal, asTab = true) } // Straight into a way of logging (Today's food card, the "Log meal" shortcut). listOf("photo", "barcode", "add").forEach { start -> @@ -872,7 +876,16 @@ fun PulseLoopApp() { db = db, start = step, onDismiss = ::close, + onCoach = { close(); navController.navigate("coach") { launchSingleTop = true } }, onMeal = { start -> close(); navController.navigate("nutrition/$start") }, + onEarlierMeal = { + close() + navController.navigate("nutrition") { + popUpTo(navController.graph.startDestinationId) + launchSingleTop = true + } + }, + onPastWorkout = { close(); navController.navigate("log_past_activity") }, onMoreDrinks = { close(); navController.navigate("drinks") }, onMeds = { close(); navController.navigate("meds") }, onPeriod = { close(); navController.navigate("cycle") }, diff --git a/app/src/main/java/com/pulseloop/ui/screens/CoachScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/CoachScreen.kt index 93a2acb7..7b7b07e4 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/CoachScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/CoachScreen.kt @@ -24,6 +24,7 @@ import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.ArrowUpward import androidx.compose.material.icons.filled.Close @@ -185,14 +186,20 @@ fun CoachScreen( * chat then scrolls under it. */ @Composable -fun CoachHeader(onNewChat: () -> Unit, onOpenUsage: (() -> Unit)? = null) { +fun CoachHeader(onNewChat: () -> Unit, onOpenUsage: (() -> Unit)? = null, onBack: (() -> Unit)? = null) { Row( Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 10.dp), + .padding(start = if (onBack != null) 4.dp else 16.dp, end = 16.dp, top = 10.dp, bottom = 10.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp), ) { + // The coach opens from the Actions sheet now, not a tab, so it needs a way back. + if (onBack != null) { + androidx.compose.material3.IconButton(onClick = onBack) { + Icon(Icons.AutoMirrored.Filled.ArrowBack, tr("Back"), tint = PulseColors.textPrimary) + } + } Box( Modifier .size(44.dp) diff --git a/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt b/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt index e0d43231..23f821f1 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/LogSheet.kt @@ -19,6 +19,8 @@ import androidx.compose.material.icons.filled.QrCodeScanner import androidx.compose.material.icons.filled.Restaurant import androidx.compose.material.icons.filled.WaterDrop import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.AutoAwesome +import androidx.compose.material.icons.filled.History import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.ModalBottomSheet @@ -43,14 +45,18 @@ import com.pulseloop.ui.theme.PulseColors import kotlinx.coroutines.launch /** - * Where a "+ Log" sheet opens. [MENU] lists everything; the others jump straight to one step, for + * Where the Actions sheet opens. [MENU] lists everything; the others jump straight to one step, for * the shortcuts on Today. */ enum class LogStep { MENU, MEAL, DRINK, TAGS } /** - * One place to record anything, reached the same way from every tab: logging is the most frequent - * thing people do in the app, and it used to live on six different screens. + * The Actions sheet: one place to record anything, or ask the coach, reached the same way from + * every tab. Logging is the most frequent thing people do in the app, and it used to live on six + * different screens; the coach moved here when Nutrition took its tab. + * + * An earlier day is part of the menu, not hidden in a screen: a meal goes to the Nutrition tab, + * whose day arrows choose the day it is saved to, and a past workout opens its own form. * * Meals, drinks and day tags are logged inside the sheet. Medications, periods and workouts open * their own screens, whose first block is the action, because they need more than one tap. @@ -61,7 +67,10 @@ fun LogSheet( db: PulseLoopDatabase, start: LogStep, onDismiss: () -> Unit, + onCoach: () -> Unit, onMeal: (start: String) -> Unit, + onEarlierMeal: () -> Unit, + onPastWorkout: () -> Unit, onMoreDrinks: () -> Unit, onMeds: () -> Unit, onPeriod: () -> Unit, @@ -93,19 +102,22 @@ fun LogSheet( Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { when (shownStep) { LogStep.MENU -> { - Text(tr("Log"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + Text(tr("Actions"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + SheetOption(tr("Ask the coach"), tr("About your day, a plan, a meal idea"), Icons.Filled.AutoAwesome, onCoach) SheetOption(tr("Meal"), tr("Photo, barcode or by hand"), Icons.Filled.Restaurant) { step = LogStep.MEAL } SheetOption(tr("Drink"), tr("One tap for the usual ones"), Icons.Filled.LocalBar) { step = LogStep.DRINK } SheetOption(tr("Medication or supplement"), tr("Mark today's doses"), Icons.Filled.Medication, onMeds) SheetOption(tr("Period"), tr("Started or ended today, or a past one"), Icons.Filled.WaterDrop, onPeriod) SheetOption(tr("Tag your day"), tr("Alcohol, stress, a late meal…"), Icons.Filled.LocalOffer) { step = LogStep.TAGS } SheetOption(tr("Workout"), tr("Start one now"), Icons.Filled.DirectionsRun, onWorkout) + SheetOption(tr("Past workout"), tr("One you already did, with its time and length"), Icons.Filled.History, onPastWorkout) } LogStep.MEAL -> { Text(tr("Log a meal"), fontSize = 18.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) SheetOption(tr("Photo"), tr("Snap your plate; the AI estimates it"), Icons.Filled.CameraAlt) { onMeal("photo") } SheetOption(tr("Barcode"), tr("Scan a packaged food"), Icons.Filled.QrCodeScanner) { onMeal("barcode") } SheetOption(tr("Add by hand"), tr("Type the name and calories"), Icons.Filled.Add) { onMeal("add") } + SheetOption(tr("For an earlier day"), tr("Pick the day in Nutrition, then add it there"), Icons.Filled.History, onEarlierMeal) } LogStep.DRINK -> QuickDrinks(db, onMoreDrinks) LogStep.TAGS -> JournalTagsCard(db, java.time.LocalDate.now(), tr("Tag your day"), allowYesterday = true) { diff --git a/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt b/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt index cad21d0d..0bcce289 100644 --- a/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt +++ b/app/src/main/java/com/pulseloop/ui/screens/NutritionScreen.kt @@ -53,6 +53,8 @@ fun NutritionScreen( start: String? = null, /** Opens the coach with a message, to discuss the next-meal idea. Null hides that button. */ onDiscuss: ((String) -> Unit)? = null, + /** Shown as a tab: the app header sits above it, so no bar or back arrow of its own. */ + asTab: Boolean = false, ) { val context = androidx.compose.ui.platform.LocalContext.current val scope = rememberCoroutineScope() @@ -117,7 +119,7 @@ fun NutritionScreen( // Insets are already applied by the route wrapper (see SettingsSubScreen). contentWindowInsets = WindowInsets(0, 0, 0, 0), topBar = { - TopAppBar( + if (!asTab) TopAppBar( title = { Text(tr("Nutrition")) }, navigationIcon = { IconButton(onClick = onBack) { @@ -132,8 +134,12 @@ fun NutritionScreen( LazyColumn( Modifier.fillMaxSize().padding(padding), verticalArrangement = Arrangement.spacedBy(12.dp), - contentPadding = PaddingValues(16.dp), + // As a tab, the last card scrolls clear of the Actions button. + contentPadding = PaddingValues(start = 16.dp, top = 16.dp, end = 16.dp, bottom = if (asTab) 88.dp else 16.dp), ) { + if (asTab) item { + Text(tr("Nutrition"), fontSize = 28.sp, fontWeight = FontWeight.Bold, color = PulseColors.textPrimary) + } // Day navigation — left goes to older dates (higher offset), right goes to today (offset 0). item { Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center, verticalAlignment = Alignment.CenterVertically) {