@@ -26,6 +26,7 @@ import 'package:provider/provider.dart';
26
26
import 'package:wger/models/nutrition/nutritional_plan.dart' ;
27
27
import 'package:wger/models/workouts/workout_plan.dart' ;
28
28
import 'package:wger/providers/body_weight.dart' ;
29
+ import 'package:wger/providers/measurement.dart' ;
29
30
import 'package:wger/providers/nutrition.dart' ;
30
31
import 'package:wger/providers/workout_plans.dart' ;
31
32
import 'package:wger/screens/form_screen.dart' ;
@@ -37,19 +38,15 @@ import 'package:wger/theme/theme.dart';
37
38
import 'package:wger/widgets/core/charts.dart' ;
38
39
import 'package:wger/widgets/core/core.dart' ;
39
40
import 'package:wger/widgets/measurements/categories_card.dart' ;
41
+ import 'package:wger/widgets/measurements/forms.dart' ;
40
42
import 'package:wger/widgets/nutrition/charts.dart' ;
41
43
import 'package:wger/widgets/nutrition/forms.dart' ;
42
44
import 'package:wger/widgets/weight/forms.dart' ;
43
45
import 'package:wger/widgets/workouts/forms.dart' ;
44
46
45
- import '../../providers/measurement.dart' ;
46
- import '../../screens/measurement_entries_screen.dart' ;
47
- import '../measurements/forms.dart' ;
48
-
49
47
class DashboardNutritionWidget extends StatefulWidget {
50
48
@override
51
- _DashboardNutritionWidgetState createState () =>
52
- _DashboardNutritionWidgetState ();
49
+ _DashboardNutritionWidgetState createState () => _DashboardNutritionWidgetState ();
53
50
}
54
51
55
52
class _DashboardNutritionWidgetState extends State <DashboardNutritionWidget > {
@@ -60,8 +57,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
60
57
@override
61
58
void initState () {
62
59
super .initState ();
63
- _plan =
64
- Provider .of <NutritionPlansProvider >(context, listen: false ).currentPlan;
60
+ _plan = Provider .of <NutritionPlansProvider >(context, listen: false ).currentPlan;
65
61
_hasContent = _plan != null ;
66
62
}
67
63
@@ -104,8 +100,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
104
100
icon: const Icon (Icons .history_edu),
105
101
color: wgerPrimaryButtonColor,
106
102
onPressed: () {
107
- Provider .of <NutritionPlansProvider >(context, listen: false )
108
- .logMealToDiary (meal);
103
+ Provider .of <NutritionPlansProvider >(context, listen: false ).logMealToDiary (meal);
109
104
ScaffoldMessenger .of (context).showSnackBar (
110
105
SnackBar (
111
106
content: Text (
@@ -136,8 +131,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
136
131
),
137
132
),
138
133
const SizedBox (width: 5 ),
139
- Text (
140
- '${item .amount .toStringAsFixed (0 )} ${AppLocalizations .of (context ).g }' ),
134
+ Text ('${item .amount .toStringAsFixed (0 )} ${AppLocalizations .of (context ).g }' ),
141
135
],
142
136
),
143
137
],
@@ -157,9 +151,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
157
151
return const Text ('' );
158
152
}
159
153
160
- return _showDetail
161
- ? const Icon (Icons .expand_less)
162
- : const Icon (Icons .expand_more);
154
+ return _showDetail ? const Icon (Icons .expand_less) : const Icon (Icons .expand_more);
163
155
}
164
156
165
157
@override
@@ -169,9 +161,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
169
161
children: [
170
162
ListTile (
171
163
title: Text (
172
- _hasContent
173
- ? _plan! .description
174
- : AppLocalizations .of (context).nutritionalPlan,
164
+ _hasContent ? _plan! .description : AppLocalizations .of (context).nutritionalPlan,
175
165
style: Theme .of (context).textTheme.headline4,
176
166
),
177
167
subtitle: Text (
@@ -200,8 +190,7 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
200
190
Container (
201
191
padding: const EdgeInsets .all (15 ),
202
192
height: 180 ,
203
- child:
204
- NutritionalPlanPieChartWidget (_plan! .nutritionalValues),
193
+ child: NutritionalPlanPieChartWidget (_plan! .nutritionalValues),
205
194
)
206
195
],
207
196
),
@@ -233,9 +222,8 @@ class _DashboardNutritionWidgetState extends State<DashboardNutritionWidget> {
233
222
TextButton (
234
223
child: Text (AppLocalizations .of (context).goToDetailPage),
235
224
onPressed: () {
236
- Navigator .of (context).pushNamed (
237
- NutritionalPlanScreen .routeName,
238
- arguments: _plan);
225
+ Navigator .of (context)
226
+ .pushNamed (NutritionalPlanScreen .routeName, arguments: _plan);
239
227
},
240
228
),
241
229
],
@@ -302,11 +290,9 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
302
290
mainAxisAlignment: MainAxisAlignment .end,
303
291
children: < Widget > [
304
292
TextButton (
305
- child: Text (
306
- AppLocalizations .of (context).goToDetailPage),
293
+ child: Text (AppLocalizations .of (context).goToDetailPage),
307
294
onPressed: () {
308
- Navigator .of (context)
309
- .pushNamed (WeightScreen .routeName);
295
+ Navigator .of (context).pushNamed (WeightScreen .routeName);
310
296
}),
311
297
],
312
298
),
@@ -327,14 +313,12 @@ class _DashboardWeightWidgetState extends State<DashboardWeightWidget> {
327
313
}
328
314
}
329
315
330
- class DashboardMeasurementsWidget extends StatefulWidget {
316
+ class DashboardMeasurementWidget extends StatefulWidget {
331
317
@override
332
- _DashboardMeasurementsWidgetState createState () =>
333
- _DashboardMeasurementsWidgetState ();
318
+ _DashboardMeasurementWidgetState createState () => _DashboardMeasurementWidgetState ();
334
319
}
335
320
336
- class _DashboardMeasurementsWidgetState
337
- extends State <DashboardMeasurementsWidget > {
321
+ class _DashboardMeasurementWidgetState extends State <DashboardMeasurementWidget > {
338
322
int _current = 0 ;
339
323
final CarouselController _controller = CarouselController ();
340
324
@@ -344,10 +328,13 @@ class _DashboardMeasurementsWidgetState
344
328
345
329
var items = _provider.categories
346
330
.map (
347
- (item) => CategoriesCard (item),
331
+ (item) => CategoriesCard (
332
+ item,
333
+ elevation: 0 ,
334
+ ),
348
335
)
349
336
.toList ();
350
- return Consumer <BodyWeightProvider >(
337
+ return Consumer <MeasurementProvider >(
351
338
builder: (context, workoutProvider, child) => Card (
352
339
child: Column (
353
340
mainAxisSize: MainAxisSize .min,
@@ -391,16 +378,13 @@ class _DashboardMeasurementsWidgetState
391
378
child: Container (
392
379
width: 12.0 ,
393
380
height: 12.0 ,
394
- margin: EdgeInsets .symmetric (
395
- vertical: 8.0 , horizontal: 4.0 ),
381
+ margin: EdgeInsets .symmetric (vertical: 8.0 , horizontal: 4.0 ),
396
382
decoration: BoxDecoration (
397
383
shape: BoxShape .circle,
398
- color: (Theme .of (context).brightness ==
399
- Brightness .dark
384
+ color: (Theme .of (context).brightness == Brightness .dark
400
385
? Colors .white
401
386
: wgerPrimaryColor)
402
- .withOpacity (
403
- _current == entry.key ? 0.9 : 0.4 )),
387
+ .withOpacity (_current == entry.key ? 0.9 : 0.4 )),
404
388
),
405
389
);
406
390
}).toList (),
@@ -409,9 +393,9 @@ class _DashboardMeasurementsWidgetState
409
393
])
410
394
else
411
395
NothingFound (
412
- AppLocalizations .of (context).noWeightEntries ,
396
+ AppLocalizations .of (context).noMeasurementEntries ,
413
397
AppLocalizations .of (context).newEntry,
414
- WeightForm (),
398
+ MeasurementCategoryForm (),
415
399
),
416
400
],
417
401
),
@@ -445,9 +429,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
445
429
return const Text ('' );
446
430
}
447
431
448
- return _showDetail
449
- ? const Icon (Icons .expand_less)
450
- : const Icon (Icons .expand_more);
432
+ return _showDetail ? const Icon (Icons .expand_less) : const Icon (Icons .expand_more);
451
433
}
452
434
453
435
List <Widget > getContent () {
@@ -479,8 +461,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
479
461
icon: const Icon (Icons .play_arrow),
480
462
color: wgerPrimaryButtonColor,
481
463
onPressed: () {
482
- Navigator .of (context)
483
- .pushNamed (GymModeScreen .routeName, arguments: day);
464
+ Navigator .of (context).pushNamed (GymModeScreen .routeName, arguments: day);
484
465
},
485
466
),
486
467
],
@@ -502,8 +483,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
502
483
children: [
503
484
Text (s.exerciseObj.name),
504
485
const SizedBox (width: 10 ),
505
- MutedText (
506
- set .getSmartRepr (s.exerciseObj).join ('\n ' )),
486
+ MutedText (set .getSmartRepr (s.exerciseObj).join ('\n ' )),
507
487
],
508
488
),
509
489
const SizedBox (height: 10 ),
@@ -528,9 +508,7 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
528
508
children: [
529
509
ListTile (
530
510
title: Text (
531
- _hasContent
532
- ? _workoutPlan! .name
533
- : AppLocalizations .of (context).labelWorkoutPlan,
511
+ _hasContent ? _workoutPlan! .name : AppLocalizations .of (context).labelWorkoutPlan,
534
512
style: Theme .of (context).textTheme.headline4,
535
513
),
536
514
subtitle: Text (
@@ -572,8 +550,8 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
572
550
TextButton (
573
551
child: Text (AppLocalizations .of (context).goToDetailPage),
574
552
onPressed: () {
575
- Navigator .of (context). pushNamed ( WorkoutPlanScreen .routeName,
576
- arguments: _workoutPlan);
553
+ Navigator .of (context)
554
+ . pushNamed ( WorkoutPlanScreen .routeName, arguments: _workoutPlan);
577
555
},
578
556
),
579
557
],
@@ -587,9 +565,10 @@ class _DashboardWorkoutWidgetState extends State<DashboardWorkoutWidget> {
587
565
class NothingFound extends StatelessWidget {
588
566
final String _title;
589
567
final String _titleForm;
590
- final Widget _form;
568
+ final Widget ? _form;
569
+ final VoidCallback ? onPressed;
591
570
592
- const NothingFound (this ._title, this ._titleForm, this ._form);
571
+ const NothingFound (this ._title, this ._titleForm, this ._form, { this .onPressed} );
593
572
594
573
@override
595
574
Widget build (BuildContext context) {
@@ -605,16 +584,19 @@ class NothingFound extends StatelessWidget {
605
584
Icons .add_box,
606
585
color: wgerPrimaryButtonColor,
607
586
),
608
- onPressed: () async {
609
- Navigator .pushNamed (
610
- context,
611
- FormScreen .routeName,
612
- arguments: FormScreenArguments (
613
- _titleForm,
614
- _form,
615
- ),
616
- );
617
- },
587
+ onPressed: onPressed ??
588
+ () async {
589
+ if (_form != null ) {
590
+ Navigator .pushNamed (
591
+ context,
592
+ FormScreen .routeName,
593
+ arguments: FormScreenArguments (
594
+ _titleForm,
595
+ _form! ,
596
+ ),
597
+ );
598
+ }
599
+ },
618
600
),
619
601
],
620
602
),
0 commit comments