Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/icons/nutrition-plan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"noNutritionalPlansSubtitle": "Erstelle deinen ersten Plan, um deine Ernährung zu verfolgen",
"@noNutritionalPlansSubtitle": {
"description": "Subtitle shown when the user has no nutritional plans"
},
"todaysWorkout": "Dein Training heute",
"@todaysWorkout": {},
"nrOfSets": "Sätze pro Übung: {nrOfSets}",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"noNutritionalPlansSubtitle": "Create your first plan to start tracking your nutrition",
"@noNutritionalPlansSubtitle": {
"description": "Subtitle shown when the user has no nutritional plans"
},
"onlyLogging": "Only track calories",
"onlyLoggingHelpText": "Check the box if you only want to log your calories and don't want to setup a detailed nutritional plan with specific meals",
"goalMacro": "Macro goals",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"noNutritionalPlansSubtitle": "Crea tu primer plan para comenzar a controlar tu nutrición",
"@noNutritionalPlansSubtitle": {
"description": "Subtitle shown when the user has no nutritional plans"
},
"nutritionalPlans": "Planes nutricionales",
"@nutritionalPlans": {},
"nutritionalDiary": "Diario nutricional",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"noNutritionalPlansSubtitle": "Créez votre premier plan pour commencer à suivre votre nutrition",
"@noNutritionalPlansSubtitle": {
"description": "Subtitle shown when the user has no nutritional plans"
},
"nutritionalPlans": "Programmes nutritionnels",
"@nutritionalPlans": {},
"nutritionalDiary": "Journal nutritionnel",
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"noNutritionalPlansSubtitle": "Utwórz swój pierwszy plan, aby zacząć śledzić odżywianie",
"@noNutritionalPlansSubtitle": {
"description": "Subtitle shown when the user has no nutritional plans"
},
"plateCalculator": "Obciążnik",
"@plateCalculator": {
"description": "Label used for the plate calculator in the gym mode"
Expand Down
4 changes: 4 additions & 0 deletions lib/l10n/app_pt.arb
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
"@noNutritionalPlans": {
"description": "Message shown when the user has no nutritional plans"
},
"noNutritionalPlansSubtitle": "Crie seu primeiro plano para começar a acompanhar sua nutrição",
"@noNutritionalPlansSubtitle": {
"description": "Subtitle shown when the user has no nutritional plans"
},
"goToDetailPage": "Ir para a página de detalhes",
"@goToDetailPage": {},
"anErrorOccurred": "Um erro ocorreu!",
Expand Down
1 change: 1 addition & 0 deletions lib/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Color wgerPrimaryColorLight = Color(0xff94B2DB);
const Color wgerSecondaryColor = Color(0xffe63946);
const Color wgerSecondaryColorLight = Color(0xffF6B4BA);
const Color wgerTertiaryColor = Color(0xFF6CA450);
const Color wgerAccentColor = Color(0xFF3B82F6);

const FlexSubThemesData wgerSubThemeData = FlexSubThemesData(
fabSchemeColor: SchemeColor.secondary,
Expand Down
255 changes: 166 additions & 89 deletions lib/widgets/dashboard/widgets/nutrition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@
*/

import 'package:flutter/material.dart';
import 'package:flutter_svg_icons/flutter_svg_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:wger/l10n/generated/app_localizations.dart';
import 'package:wger/models/nutrition/nutritional_plan.dart';
import 'package:wger/providers/nutrition.dart';
import 'package:wger/screens/form_screen.dart';
import 'package:wger/screens/log_meals_screen.dart';
import 'package:wger/screens/nutritional_plan_screen.dart';
import 'package:wger/widgets/dashboard/widgets/nothing_found.dart';
import 'package:wger/widgets/nutrition/charts.dart';
import 'package:wger/theme/theme.dart';
import 'package:wger/widgets/nutrition/nutrition_card.dart';
import 'package:wger/widgets/nutrition/forms.dart';

class DashboardNutritionWidget extends StatefulWidget {
Expand All @@ -50,100 +48,179 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {

@override
Widget build(BuildContext context) {
return Card(
child: Column(
children: [
ListTile(
title: Text(
_hasContent ? _plan!.description : AppLocalizations.of(context).nutritionalPlan,
style: Theme.of(context).textTheme.headlineSmall,
),
subtitle: Text(
_hasContent
? DateFormat.yMd(
Localizations.localeOf(context).languageCode,
).format(_plan!.creationDate)
: '',
),
leading: Icon(
Icons.restaurant,
color: Theme.of(context).textTheme.headlineSmall!.color,
),
return Padding(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave the card with the same color as the others, so it doesn't stand out (we can of course talk of changing this, but then we'd need to do it for all of them)

Image

padding: const EdgeInsets.all(4.0),
child: Material(
elevation: 0,
color: Colors.transparent,
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Theme.of(context).cardColor,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 20,
offset: const Offset(0, 4),
spreadRadius: 0,
),
BoxShadow(
color: Colors.black.withOpacity(0.04),
blurRadius: 10,
offset: const Offset(0, 2),
spreadRadius: 0,
),
],
),
if (_hasContent)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 15),
child: FlNutritionalPlanGoalWidget(nutritionalPlan: _plan!),
child: Column(
children: [
// Modern header with title and chevron
InkWell(
onTap: _hasContent
? () {
Navigator.of(context).pushNamed(
NutritionalPlanScreen.routeName,
arguments: _plan,
);
}
: null,
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
children: [
Expanded(
child: Text(
AppLocalizations.of(context).nutritionalPlan,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
if (_hasContent)
Icon(
Icons.chevron_right,
color: Colors.grey.shade400,
size: 28,
),
],
),
),
),
)
else
NothingFound(
AppLocalizations.of(context).noNutritionalPlans,
AppLocalizations.of(context).newNutritionalPlan,
PlanForm(),
),
if (_hasContent)
LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
child: Text(AppLocalizations.of(context).goToDetailPage),
onPressed: () {
Navigator.of(context).pushNamed(
NutritionalPlanScreen.routeName,
arguments: _plan,
);
},

// Progress indicators or empty state
if (_hasContent)
NutritionGoalsWidget(
nutritionalPlan: _plan!,
onLogIngredient: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).logIngredient,
getIngredientLogForm(_plan!),
hasListView: true,
),
);
},
onLogMeal: () {
Navigator.of(context).pushNamed(
LogMealsScreen.routeName,
arguments: _plan,
);
},
)
else
// Empty state - inviting the user to create their first nutritional plan
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 24),
child: Column(
children: [
const SizedBox(height: 16),
// 3D nutrition plan icon
Image.asset(
'assets/icons/nutrition-plan.png',
width: 120,
height: 120,
),
const SizedBox(height: 20),
// Inviting title
Text(
AppLocalizations.of(context).noNutritionalPlans,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey.shade300
: Colors.grey.shade800,
),
Row(
children: [
IconButton(
icon: const SvgIcon(
icon: SvgIconData('assets/icons/ingredient-diary.svg'),
textAlign: TextAlign.center,
),
const SizedBox(height: 8),
// Subtitle
Text(
AppLocalizations.of(context).noNutritionalPlansSubtitle,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey.shade400
: Colors.grey.shade600,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
// Modern button to create nutritional plan
Material(
color: wgerAccentColor,
borderRadius: BorderRadius.circular(12),
child: InkWell(
onTap: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).newNutritionalPlan,
hasListView: true,
PlanForm(),
),
tooltip: AppLocalizations.of(context).logIngredient,
onPressed: () {
Navigator.pushNamed(
context,
FormScreen.routeName,
arguments: FormScreenArguments(
AppLocalizations.of(context).logIngredient,
getIngredientLogForm(_plan!),
hasListView: true,
);
},
borderRadius: BorderRadius.circular(12),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.add_rounded,
color: Colors.white,
size: 20,
),
const SizedBox(width: 8),
Text(
AppLocalizations.of(context).newNutritionalPlan,
style: const TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w600,
),
);
},
),
],
),
IconButton(
icon: const SvgIcon(
icon: SvgIconData('assets/icons/meal-diary.svg'),
),
tooltip: AppLocalizations.of(context).logMeal,
onPressed: () {
Navigator.of(
context,
).pushNamed(LogMealsScreen.routeName, arguments: _plan);
},
),
],
),
),
],
),
),
const SizedBox(height: 8),
],
),
);
},
),
],
),
],
),
),
),
);
}

}
Loading