Skip to content

Commit

Permalink
Merge pull request #141 from andreped/136-feat-alphabetic-sort-of-add…
Browse files Browse the repository at this point in the history
…-new-exercise

Sort exercises alphabetically in Select Exercise in log tab
  • Loading branch information
andreped authored Aug 11, 2024
2 parents 8abeb42 + 57658b3 commit b3613d7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/tabs/inputs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class _ExerciseSetterState extends State<ExerciseSetter> {

Future<void> _loadPredefinedExercises() async {
List<String> exercises = await _dbHelper.getPredefinedExercises();
exercises.sort(); // Sort alphabetically
setState(() {
_predefinedExercises = exercises;
_selectedExercise =
Expand Down Expand Up @@ -113,6 +114,7 @@ class _ExerciseSetterState extends State<ExerciseSetter> {
await _dbHelper.addPredefinedExercise(exerciseName);
setState(() {
_predefinedExercises.add(exerciseName);
_predefinedExercises.sort(); // Keep the list sorted
_selectedExercise = exerciseName;
});
} else {
Expand Down Expand Up @@ -281,6 +283,7 @@ class _ExerciseSetterState extends State<ExerciseSetter> {
final index = _predefinedExercises.indexOf(oldName);
if (index != -1) {
_predefinedExercises[index] = newName;
_predefinedExercises.sort(); // Keep the list sorted
if (_selectedExercise == oldName) {
_selectedExercise = newName;
}
Expand Down

0 comments on commit b3613d7

Please sign in to comment.