Skip to content

Commit 32c5aa2

Browse files
committed
feat(ui): add nutrition card to MealPlan screen for weekly protein tracking
1 parent f04ec5d commit 32c5aa2

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

mobile_app/lib/ui/screens/meal_plan_screen.dart

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../../state/user_provider.dart';
1717
import '../../models/user_profile_model.dart';
1818
import 'shopping_list_screen.dart';
1919
import 'optimize_plan_screen.dart';
20+
import '../widgets/weekly_nutrition_card.dart';
2021

2122
class MealPlanScreen extends StatefulWidget {
2223
const MealPlanScreen({super.key});
@@ -121,6 +122,7 @@ class _MealPlanScreenState extends State<MealPlanScreen> {
121122
child: Column(
122123
children: [
123124
_buildHeader(isDark),
125+
if (!_loading) _buildNutritionCard(isDark),
124126
_buildDaySelector(isDark),
125127
Expanded(
126128
child: _loading
@@ -175,19 +177,30 @@ class _MealPlanScreenState extends State<MealPlanScreen> {
175177
foregroundColor: AppTheme.primaryPurple,
176178
),
177179
),
178-
TextButton.icon(
179-
onPressed: _openAutoPlan,
180-
icon: const Icon(Icons.auto_awesome_rounded, size: 18),
181-
label: const Text('Auto-plan'),
182-
style: TextButton.styleFrom(
183-
foregroundColor: AppTheme.primaryPurple,
184-
),
185-
),
186180
],
187181
),
188182
);
189183
}
190184

185+
Widget _buildNutritionCard(bool isDark) {
186+
if (_plan == null) return const SizedBox.shrink();
187+
188+
// 350g/week matches the default floor on the auto-plan screen, keeps
189+
// the two views telling the same story instead of disagreeing
190+
const weeklyProteinTarget = 350.0;
191+
192+
return Padding(
193+
padding: const EdgeInsets.fromLTRB(20, 16, 20, 0),
194+
child: WeeklyNutritionCard(
195+
proteinAchieved: _plan!.weeklyProtein,
196+
proteinTarget: weeklyProteinTarget,
197+
mealsPlanned: _plan!.totalMeals,
198+
mealsTotal: 28, // 7 days x 4 slots
199+
onAutoPlan: _openAutoPlan,
200+
),
201+
);
202+
}
203+
191204
Widget _buildDaySelector(bool isDark) {
192205
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
193206
final today = DateTime.now().weekday - 1;

0 commit comments

Comments
 (0)