Move the action buttons in the dashboard to the side

This commit is contained in:
Roland Geider
2021-04-21 12:55:20 +02:00
parent deea1b1ed4
commit 6370df7b97
3 changed files with 64 additions and 15 deletions

View File

@@ -183,6 +183,8 @@
"@addMeal": {},
"mealLogged": "Meal logged to diary",
"@mealLogged": {},
"logMeal": "Log this meal",
"@logMeal": {},
"addIngredient": "Add ingredient",
"@addIngredient": {},
"nutritionalPlan": "Nutritional plan",

View File

@@ -60,9 +60,39 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
List<Widget> out = [];
if (hasContent) {
for (var meal in plan.meals) {
out.add(Text(
meal.time.format(context),
style: TextStyle(fontWeight: FontWeight.bold),
out.add(Container(
width: double.infinity,
child: Row(
children: [
Spacer(
flex: 1,
),
Expanded(
flex: 8,
child: Text(
meal.time.format(context),
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
Flexible(
child: IconButton(
icon: Icon(Icons.bar_chart),
onPressed: () {
Provider.of<Nutrition>(context, listen: false).logMealToDiary(meal);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.of(context)!.mealLogged,
textAlign: TextAlign.center,
),
),
);
},
),
)
],
),
));
out.add(Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
@@ -250,16 +280,33 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
List<Widget> out = [];
if (hasContent) {
for (var day in _workoutPlan.days) {
out.add(Text(
day.description,
style: TextStyle(fontWeight: FontWeight.bold),
));
out.add(IconButton(
icon: Icon(Icons.play_arrow),
onPressed: () {
Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: day);
},
out.add(Container(
width: double.infinity,
child: Row(
children: [
Spacer(
flex: 1,
),
Expanded(
flex: 8,
child: Text(
day.description,
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
Flexible(
child: IconButton(
icon: Icon(Icons.play_arrow),
onPressed: () {
Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: day);
},
),
)
],
),
));
if (showDetail) {
day.sets.forEach((set) {
out.add(Column(
@@ -269,14 +316,14 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
children: [
Text(s.exerciseObj.name),
Text(s.repsText),
SizedBox(height: 5),
],
);
}).toList(),
SizedBox(height: 15),
],
));
});
out.add(SizedBox(height: 10));
out.add(Divider());
}
}
}

View File

@@ -227,7 +227,7 @@ class DismissibleMealHeader extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Log this meal',
AppLocalizations.of(context)!.logMeal,
style: TextStyle(color: Colors.white),
),
Icon(