mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Children at the bottom + consistent variable names + BuildContext async gaps
This commit is contained in:
@@ -49,8 +49,8 @@ class _AddExerciseDropdownButtonState extends State<AddExerciseDropdownButton> {
|
||||
items: widget.items
|
||||
.map(
|
||||
(item) => DropdownMenuItem<String>(
|
||||
child: Text(item),
|
||||
value: item,
|
||||
child: Text(item),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
|
||||
@@ -192,8 +192,8 @@ class MealItemForm extends StatelessWidget {
|
||||
),
|
||||
if (_listMealItems.isNotEmpty) const SizedBox(height: 10.0),
|
||||
Container(
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -320,8 +320,8 @@ class IngredientLogForm extends StatelessWidget {
|
||||
),
|
||||
if (diaryEntries.isNotEmpty) const SizedBox(height: 10.0),
|
||||
Container(
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Text(AppLocalizations.of(context).recentlyUsedIngredients),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -392,16 +392,21 @@ class PlanForm extends StatelessWidget {
|
||||
|
||||
// Save to DB
|
||||
try {
|
||||
final navigator = Navigator.of(context);
|
||||
if (_plan.id != null) {
|
||||
await Provider.of<NutritionPlansProvider>(context, listen: false).editPlan(_plan);
|
||||
Navigator.of(context).pop();
|
||||
if (context.mounted) {
|
||||
navigator.pop();
|
||||
}
|
||||
} else {
|
||||
_plan = await Provider.of<NutritionPlansProvider>(context, listen: false)
|
||||
.addPlan(_plan);
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
if (context.mounted) {
|
||||
navigator.pushReplacementNamed(
|
||||
NutritionalPlanScreen.routeName,
|
||||
arguments: _plan,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Saving was successful, reset the data
|
||||
|
||||
@@ -223,37 +223,6 @@ class DismissibleMealHeader extends StatelessWidget {
|
||||
return Dismissible(
|
||||
key: Key(_meal.id.toString()),
|
||||
direction: DismissDirection.startToEnd,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: const BoxDecoration(color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (_meal.name != '')
|
||||
Text(
|
||||
_meal.name,
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
_meal.time!.format(context),
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: _expanded ? const Icon(Icons.unfold_less) : const Icon(Icons.unfold_more),
|
||||
onPressed: () {
|
||||
_toggle();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor, //Theme.of(context).primaryColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
@@ -287,6 +256,37 @@ class DismissibleMealHeader extends StatelessWidget {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: const BoxDecoration(color: Colors.white),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (_meal.name != '')
|
||||
Text(
|
||||
_meal.name,
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
_meal.time!.format(context),
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: _expanded ? const Icon(Icons.unfold_less) : const Icon(Icons.unfold_more),
|
||||
onPressed: () {
|
||||
_toggle();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ class SettingWidget extends StatelessWidget {
|
||||
return ListTile(
|
||||
leading: InkWell(
|
||||
child: SizedBox(
|
||||
child: ExerciseImageWidget(image: setting.exerciseBaseObj.getMainImage),
|
||||
width: 45,
|
||||
child: ExerciseImageWidget(image: setting.exerciseBaseObj.getMainImage),
|
||||
),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
@@ -224,19 +224,19 @@ class _WorkoutDayWidgetState extends State<WorkoutDayWidget> {
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
buildDefaultDragHandles: false,
|
||||
onReorder: (_oldIndex, _newIndex) async {
|
||||
int _startIndex = 0;
|
||||
if (_oldIndex < _newIndex) {
|
||||
_newIndex -= 1;
|
||||
_startIndex = _oldIndex;
|
||||
onReorder: (oldIndex, newIndex) async {
|
||||
int startIndex = 0;
|
||||
if (oldIndex < newIndex) {
|
||||
newIndex -= 1;
|
||||
startIndex = oldIndex;
|
||||
} else {
|
||||
_startIndex = _newIndex;
|
||||
startIndex = newIndex;
|
||||
}
|
||||
setState(() {
|
||||
_sets.insert(_newIndex, _sets.removeAt(_oldIndex));
|
||||
_sets.insert(newIndex, _sets.removeAt(oldIndex));
|
||||
});
|
||||
_sets = await Provider.of<WorkoutPlansProvider>(context, listen: false)
|
||||
.reorderSets(_sets, _startIndex);
|
||||
.reorderSets(_sets, startIndex);
|
||||
},
|
||||
children: [
|
||||
for (var i = 0; i < widget._day.sets.length; i++) getSetRow(widget._day.sets[i], i),
|
||||
@@ -283,6 +283,31 @@ class DayHeaderDismissible extends StatelessWidget {
|
||||
return Dismissible(
|
||||
key: Key(_day.id.toString()),
|
||||
direction: DismissDirection.startToEnd,
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor, //Theme.of(context).primaryColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).gymMode,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
confirmDismiss: (direction) async {
|
||||
// Delete day
|
||||
if (direction == DismissDirection.startToEnd) {
|
||||
Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: _day);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: const BoxDecoration(color: Colors.white),
|
||||
@@ -311,31 +336,6 @@ class DayHeaderDismissible extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
background: Container(
|
||||
color: wgerPrimaryButtonColor, //Theme.of(context).primaryColor,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.only(left: 10),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context).gymMode,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
const Icon(
|
||||
Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
confirmDismiss: (direction) async {
|
||||
// Delete day
|
||||
if (direction == DismissDirection.startToEnd) {
|
||||
Navigator.of(context).pushNamed(GymModeScreen.routeName, arguments: _day);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,15 +466,6 @@ class _LogPageState extends State<LogPage> {
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: (!_isSaving)
|
||||
? Text(AppLocalizations.of(context).save)
|
||||
: const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
),
|
||||
),
|
||||
onPressed: _isSaving
|
||||
? null
|
||||
: () async {
|
||||
@@ -512,6 +503,15 @@ class _LogPageState extends State<LogPage> {
|
||||
_isSaving = false;
|
||||
}
|
||||
},
|
||||
child: (!_isSaving)
|
||||
? Text(AppLocalizations.of(context).save)
|
||||
: const SizedBox(
|
||||
height: 20,
|
||||
width: 20,
|
||||
child: CircularProgressIndicator(
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -781,17 +781,6 @@ class _SessionPageState extends State<SessionPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ToggleButtons(
|
||||
children: const <Widget>[
|
||||
Icon(
|
||||
Icons.sentiment_very_dissatisfied,
|
||||
),
|
||||
Icon(
|
||||
Icons.sentiment_neutral,
|
||||
),
|
||||
Icon(
|
||||
Icons.sentiment_very_satisfied,
|
||||
),
|
||||
],
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
setState(() {
|
||||
@@ -809,6 +798,17 @@ class _SessionPageState extends State<SessionPage> {
|
||||
});
|
||||
},
|
||||
isSelected: selectedImpression,
|
||||
children: const <Widget>[
|
||||
Icon(
|
||||
Icons.sentiment_very_dissatisfied,
|
||||
),
|
||||
Icon(
|
||||
Icons.sentiment_neutral,
|
||||
),
|
||||
Icon(
|
||||
Icons.sentiment_very_satisfied,
|
||||
),
|
||||
],
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
|
||||
@@ -45,6 +45,13 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
return Column(
|
||||
children: [
|
||||
ToggleButtons(
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
if (index == 0) {
|
||||
widget._changeMode(WorkoutScreenMode.workout);
|
||||
}
|
||||
},
|
||||
isSelected: const [false, true],
|
||||
children: const <Widget>[
|
||||
Icon(
|
||||
Icons.table_chart_outlined,
|
||||
@@ -53,13 +60,6 @@ class _WorkoutLogsState extends State<WorkoutLogs> {
|
||||
Icons.show_chart,
|
||||
),
|
||||
],
|
||||
renderBorder: false,
|
||||
onPressed: (int index) {
|
||||
if (index == 0) {
|
||||
widget._changeMode(WorkoutScreenMode.workout);
|
||||
}
|
||||
},
|
||||
isSelected: const [false, true],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
|
||||
Reference in New Issue
Block a user