Remove hard coded strings from forms

This commit is contained in:
Roland Geider
2021-04-02 18:00:35 +02:00
parent bf9abea7aa
commit ba0fa896e1
2 changed files with 25 additions and 14 deletions

View File

@@ -97,6 +97,7 @@
"@rir": {
"description": "Shorthand for Repetitions In Reserve"
},
"sameRepetitions": "If you do the same repetitions for all sets you can just fill in one value: e.g. for 4 sets just enter one \"10\" for the repetitions, this automatically becomes \"4 x 10\".",
"comment": "Comment",
"@comment": {
"description": "Comment, additional information"
@@ -119,6 +120,7 @@
"@newSet": {
"description": "Header when adding a new set to a workout day"
},
"selectExercises": "You can search for more than one exercise, they will be grouped together for a superset.",
"gymMode": "Gym mode",
"@gymMode": {
"description": "Label when starting the gym mode"
@@ -260,6 +262,10 @@
"@enterValue": {
"description": "Error message when the user hasn't entered a value on a required field"
},
"selectExercise": "Please select an exercise",
"@selectExercise": {
"description": "Error message when the user hasn't selected an exercise in the form"
},
"enterCharacters": "Please enter between {min} and {max} characters",
"@enterCharacters": {
"description": "Error message when the user hasn't entered the correct number of characters in a form",
@@ -269,6 +275,14 @@
"max": {}
}
},
"nrOfSets": "Number of sets: {nrOfSets}",
"@nrOfSets": {
"description": "Label shown on the slider where the user selects the nr of sets",
"type": "text",
"placeholders": {
"nrOfSets": {}
}
},
"enterValidNumber": "Please enter a valid number",
"@enterValidNumber": {
"description": "Error message when the user has submitted an invalid number (e.g. '3,.,.,.')"

View File

@@ -160,7 +160,7 @@ class _DayFormWidgetState extends State<DayFormWidget> {
const minLength = 5;
const maxLength = 100;
if (value!.isEmpty || value.length < minLength || value.length > maxLength) {
return 'Please enter between $minLength and $maxLength characters.';
return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength);
}
return null;
},
@@ -257,8 +257,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
decoration: InputDecoration(
labelText: AppLocalizations.of(context)!.exercise,
helperMaxLines: 3,
helperText: 'You can search for more than one exercise, they will be grouped '
'together for a superset.'),
helperText: AppLocalizations.of(context)!.selectExercises),
),
suggestionsCallback: (pattern) async {
return await Provider.of<Exercises>(context, listen: false).searchExercise(pattern);
@@ -295,13 +294,13 @@ class _SetFormWidgetState extends State<SetFormWidget> {
},
validator: (value) {
if (value!.isEmpty) {
return 'Please select an exercise';
return AppLocalizations.of(context)!.selectExercise;
}
return null;
},
),
SizedBox(height: 10),
Text('Number of sets: ${_currentSetSliderValue.round()}'),
Text(AppLocalizations.of(context)!.nrOfSets(_currentSetSliderValue.round())),
Slider(
value: _currentSetSliderValue,
min: 1,
@@ -326,7 +325,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
},
),
SwitchListTile(
title: Text('More details'),
title: Text(AppLocalizations.of(context)!.toggleDetails),
value: _detailed,
onChanged: (value) {
setState(() {
@@ -334,9 +333,7 @@ class _SetFormWidgetState extends State<SetFormWidget> {
});
},
),
Text('If you do the same repetitions for all sets you can just enter '
'one value: e.g. for 4 sets just enter one "10" for the repetitions, '
'this automatically becomes "4 x 10".'),
Text(AppLocalizations.of(context)!.sameRepetitions),
...widget._set.exercisesObj.map((exercise) {
final settings =
widget._set.settings.where((e) => e.exerciseObj.id == exercise.id).toList();
@@ -450,11 +447,11 @@ class ExerciseSetting extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text('Reps'),
if (_detailed) Text('Unit'),
Text('Weight'),
if (_detailed) Text('Weight unit'),
if (_detailed) Text('RiR'),
Text(AppLocalizations.of(context)!.repetitions),
if (_detailed) Text(AppLocalizations.of(context)!.unit),
Text(AppLocalizations.of(context)!.weight),
if (_detailed) Text(AppLocalizations.of(context)!.unit),
if (_detailed) Text(AppLocalizations.of(context)!.rir),
],
),
getRow(),