From b87784f5fc8ebb41702272ddc4c14dd18dbd4499 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Mon, 28 Mar 2022 22:11:31 +0200 Subject: [PATCH] Add an additional step when adding exercises --- lib/l10n/app_en.arb | 3 +- lib/screens/add_exercise_screen.dart | 70 +++++++++++++++++++--------- pubspec.lock | 24 ++++++++-- 3 files changed, 68 insertions(+), 29 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 83d4b747..17efed32 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -574,7 +574,8 @@ "images": "Images", "language": "Language", "addExercise": "Add exercise", - "baseData": "Base data", + "translation": "Translation", + "baseData": "Basics in English", "@baseData": { "description": "The base data for an exercise such as category, trained muscles, etc." } diff --git a/lib/screens/add_exercise_screen.dart b/lib/screens/add_exercise_screen.dart index 26e6d396..6348a477 100644 --- a/lib/screens/add_exercise_screen.dart +++ b/lib/screens/add_exercise_screen.dart @@ -21,7 +21,7 @@ class AddExerciseScreen extends StatefulWidget { const AddExerciseScreen({Key? key}) : super(key: key); static const routeName = '/exercises/add'; - static const STEPS_IN_FORM = 4; + static const STEPS_IN_FORM = 5; @override _AddExerciseScreenState createState() => _AddExerciseScreenState(); @@ -38,6 +38,7 @@ class _AddExerciseScreenState extends State { GlobalKey(), GlobalKey(), GlobalKey(), + GlobalKey(), GlobalKey() ]; @@ -83,14 +84,18 @@ class _AddExerciseScreenState extends State { title: Text(AppLocalizations.of(context).variations), content: _DuplicatesAndVariationsStepContent(formkey: _keys[1]), ), + Step( + title: Text(AppLocalizations.of(context).description), + content: _DescriptionStepContent(formkey: _keys[3]), + ), + Step( + title: Text(AppLocalizations.of(context).translation), + content: _DescriptionTranslationStepContent(formkey: _keys[4]), + ), Step( title: Text(AppLocalizations.of(context).images), content: _ImagesStepContent(formkey: _keys[2]), ), - Step( - title: Text(AppLocalizations.of(context).description), - content: _DescriptionStepContent(formkey: _keys[3]), - ) ], currentStep: _currentStep, onStepContinue: () { @@ -148,6 +153,22 @@ class _BasicStepContent extends StatelessWidget { key: formkey, child: Column( children: [ + const Text('All exercises need a base name in English'), + AddExerciseTextArea( + onChange: (value) => {}, + title: '${AppLocalizations.of(context).name}*', + isRequired: true, + validator: (name) => name?.isEmpty ?? true ? 'Name is required' : null, + onSaved: (String? name) => addExerciseProvider.exerciseNameEn = name!, + ), + AddExerciseTextArea( + onChange: (value) => {}, + title: AppLocalizations.of(context).alternativeNames, + isMultiline: true, + helperText: AppLocalizations.of(context).oneNamePerLine, + onSaved: (String? alternateName) => + addExerciseProvider.alternateNamesEn = alternateName!.split('\n'), + ), ExerciseCategoryInputWidget( categories: categories, title: AppLocalizations.of(context).category, @@ -279,23 +300,6 @@ class _DescriptionStepContent extends StatelessWidget { key: formkey, child: Column( children: [ - const Text('All exercises need a base name in English'), - const Text('*** Add flag here ***'), - AddExerciseTextArea( - onChange: (value) => {}, - title: '${AppLocalizations.of(context).name}*', - isRequired: true, - validator: (name) => name?.isEmpty ?? true ? 'Name is required' : null, - onSaved: (String? name) => addExerciseProvider.exerciseNameEn = name!, - ), - AddExerciseTextArea( - onChange: (value) => {}, - title: AppLocalizations.of(context).alternativeNames, - isMultiline: true, - helperText: AppLocalizations.of(context).oneNamePerLine, - onSaved: (String? alternateName) => - addExerciseProvider.alternateNamesEn = alternateName!.split('\n'), - ), AddExerciseTextArea( onChange: (value) => {}, title: '${AppLocalizations.of(context).description}*', @@ -304,7 +308,27 @@ class _DescriptionStepContent extends StatelessWidget { validator: (name) => name?.isEmpty ?? true ? 'Name is required' : null, onSaved: (String? description) => addExerciseProvider.descriptionEn = description!, ), - const Text('*** Add flag here ***'), + ], + ), + ); + } +} + +class _DescriptionTranslationStepContent extends StatelessWidget { + final GlobalKey formkey; + const _DescriptionTranslationStepContent({required this.formkey}); + + @override + Widget build(BuildContext context) { + final addExerciseProvider = context.read(); + final exerciseProvider = context.read(); + + final languages = exerciseProvider.languages; + + return Form( + key: formkey, + child: Column( + children: [ ExerciseCategoryInputWidget( categories: languages, title: AppLocalizations.of(context).language, diff --git a/pubspec.lock b/pubspec.lock index c41fbf77..04abb240 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -112,7 +112,7 @@ packages: name: camera url: "https://pub.dartlang.org" source: hosted - version: "0.9.4+14" + version: "0.9.4+17" camera_platform_interface: dependency: transitive description: @@ -383,7 +383,7 @@ packages: source: hosted version: "2.0.5" flutter_svg: - dependency: transitive + dependency: "direct main" description: name: flutter_svg url: "https://pub.dartlang.org" @@ -475,7 +475,7 @@ packages: name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.8.4+9" + version: "0.8.4+11" image_picker_for_web: dependency: transitive description: @@ -567,6 +567,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -588,6 +595,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.1.0" + multi_select_flutter: + dependency: "direct main" + description: + name: multi_select_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.2" nested: dependency: transitive description: @@ -879,7 +893,7 @@ packages: name: table_calendar url: "https://pub.dartlang.org" source: hosted - version: "3.0.3" + version: "3.0.5" term_glyph: dependency: transitive description: @@ -893,7 +907,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" timing: dependency: transitive description: