Conversation
tenshiAMD
left a comment
There was a problem hiding this comment.
@dinurymomshad hi, can you rebase and check if all works fine? thanks
| required this.setExerciseName, | ||
| }); | ||
|
|
||
| final Function(String) setExerciseName; |
There was a problem hiding this comment.
Add return type and name of the parameter, so final void Function(String name) setExerciseName;
| // set up the AlertDialog | ||
| RedoWorkoutAlert alert = RedoWorkoutAlert(viewButton, redoButton); | ||
| Future<void> _showViewOrRedoAlertDialog(BuildContext context) async { | ||
| if (await showViewOrRedoAlertDialog(context)) { |
There was a problem hiding this comment.
Maybe work with an enum here that is returned instead of a bool, because now its not entirely clear when "true" is returned for example if this means a redo or a view.
There was a problem hiding this comment.
Work with guard clauses when you can to make code less cluttered and more readable, here for example:
Future<void> _showViewOrRedoAlertDialog(BuildContext context) async {
if (!await showViewOrRedoAlertDialog(context)) return addExercises(widget.workout);
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => WorkoutPage(widget.workout),
),
);
}
| ); | ||
| /// Alert Dialogs | ||
| void _showAddNewExerciseDialog(BuildContext context) async { | ||
| ExerciseInputField exerciseNameSelectionWidget = |
There was a problem hiding this comment.
Use final for fields that don't change + guard clause, also be consistent when you want to declare variables, exerciseNameSelection widget gets stored into a variable before being used in the dialog, but the SaveWorkoutContent widget just gets send directly to the dialog.
void _showAddNewExerciseDialog(BuildContext context) async {
final exerciseNameSelectionWidget = ExerciseInputField(setExerciseName: setExerciseName);
if (!await showAddNewExerciseDialog(context, exerciseNameSelectionWidget)) return;
addExercise();
}
| required this.title, | ||
| this.subtitle, | ||
| this.content, | ||
| required this.buttons, |
There was a problem hiding this comment.
Put required parameters first
| final Map<String, T> buttons; | ||
| } | ||
|
|
||
| extension Present<T> on AlertDialogModel<T> { |
There was a problem hiding this comment.
Name it something like PresentExtension so you know its an extension from the name.
| return ThemeProvider(builder: (context, AppTheme theme) { | ||
| return AlertDialog( | ||
| backgroundColor: theme.colorTheme.backgroundColorVariation, | ||
| titleTextStyle: Theme.of(context) |
There was a problem hiding this comment.
Store the theme in a variable at the top of this method so you don't have to call .of(context) every time.
| backgroundColor: theme.colorTheme.backgroundColorVariation, | ||
| titleTextStyle: Theme.of(context) | ||
| .textTheme | ||
| .headline6 |
There was a problem hiding this comment.
Maybe not for this PR immediately, but we should store the different textThemes in the theme provided by themeProvider ass well so we don't have 2 themes.
| context: context, | ||
| barrierDismissible: barrierDismissible, | ||
| builder: (context) { | ||
| return ThemeProvider(builder: (context, AppTheme theme) { |
There was a problem hiding this comment.
Defining the type of theme here isn't necessary .
| } | ||
|
|
||
| Future<bool> showDeleteWorkoutDialog(BuildContext context) { | ||
| return const _DeleteDialog(objName: 'workout').present(context).then( |
There was a problem hiding this comment.
Personally I think using await is clearer and looks better than using then + const isn't needed here since you're not storing the dialog. Same for the rest of the dialogs (the await not the const)
Future<bool> showDeleteWorkoutDialog(BuildContext context) async {
final result = await _DeleteDialog(objName: 'workout').present(context);
return result ?? false;
}
Or maybe better
Future<bool> showDeleteWorkoutDialog(BuildContext context) async => await _DeleteDialog(objName: 'workout').present(context) ?? false;
|
|
||
| Future<bool> showAddNewExerciseDialog(BuildContext context, Widget? content) { | ||
| return _AddNewExerciseDialog( | ||
| objName: 'Exercise', |
There was a problem hiding this comment.
I would maybe have the objName as an optional parameter to the showAddNewExerciesDialog method because otherwise I don't really see the reason it isn't just hardcoded in the constructor above, same for the rest of the dialogs.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
|
Lines of code have too many changes. It should be under 500 lines of addtions and deletions. |
1 similar comment
|
Lines of code have too many changes. It should be under 500 lines of addtions and deletions. |
Summary
This MR aims to close #84 .
Other Information
Some unused code was removed.