Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration_test/3_gym_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Widget createGymModeResultsScreen({String locale = 'en'}) {
gymStateProvider.overrideWithValue(
GymModeState(
routine: routine,
dayId: routine.days.first.id!,
dayId: routine.days.first.id,
iteration: 1,
showExercisePages: true,
showTimerPages: true,
Expand Down
1 change: 1 addition & 0 deletions lib/helpers/i18n.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// This code is autogenerated in the backend repo in extract-i18n.py do not edit!
library;

/// Translate dynamic strings that are returned from the server
/// These strings such as categories or equipment are returned by the server
Expand Down
2 changes: 1 addition & 1 deletion lib/models/exercises/exercise.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Exercise extends Equatable {
(e) => e.languageObj.shortName == LANGUAGE_SHORT_ENGLISH,
orElse: () {
_logger.info(
'Could not find fallback english translation for exercise-ID ${id}, returning '
'Could not find fallback english translation for exercise-ID $id, returning '
'first language (${translations.first.languageObj.shortName}) instead.',
);
return translations.first;
Expand Down
4 changes: 2 additions & 2 deletions lib/models/measurements/measurement_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ class MeasurementCategory extends Equatable {
List<Object?> get props => [id, name, unit, entries];

// Helper function which makes the entries list of the toJson output null, as it isn't needed
//ignore: always_declare_return_types
static _nullValue(_) => null;
static List<MeasurementEntry>? _nullValue(_) => null;
}

2 changes: 1 addition & 1 deletion lib/models/workouts/base_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BaseConfig {
required this.value,
this.operation = 'r',
this.step = 'abs',
this.requirements = null,
this.requirements,
});

BaseConfig.firstIteration(this.value, this.slotEntryId) {
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/nutrition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class NutritionPlansProvider with ChangeNotifier {
(database.delete(database.ingredients)..where((i) => i.id.equals(ingredientId))).go();
}
} else {
_logger.info("Fetching ingredient ID $ingredientId from server");
_logger.info('Fetching ingredient ID $ingredientId from server');
final data = await baseProvider.fetch(
baseProvider.makeUrl(_ingredientInfoPath, id: ingredientId),
);
Expand Down
7 changes: 0 additions & 7 deletions lib/providers/plate_weights.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ class PlateCalculatorState {
final List<num> availablePlatesKg = const [0.5, 1, 1.25, 2, 2.5, 5, 10, 15, 20, 25];
final List<num> availablePlatesLb = const [2.5, 5, 10, 25, 35, 45];

final availableBarWeightsKg = [10, 15, 20];
final availableBarWeightsLb = [15, 20, 25, 33, 45];

PlateCalculatorState({
this.useColors = true,
num? barWeight,
Expand Down Expand Up @@ -106,10 +103,6 @@ class PlateCalculatorState {
return isMetric ? availablePlatesKg : availablePlatesLb;
}

List<num> get availableBarsWeights {
return isMetric ? availableBarWeightsKg : availableBarWeightsLb;
}

List<num> get platesList {
return plateCalculator(totalWeight, barWeight, selectedPlates);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/providers/routines.dart
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ class RoutinesProvider with ChangeNotifier {
}*/

Future<void> deleteLog(int logId, int routineId) async {
_logger.fine('Deleting log ${logId}');
_logger.fine('Deleting log $logId');
await baseProvider.deleteRequest(_logsUrlPath, logId);
await fetchAndSetRoutineFull(routineId);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/add_exercise/add_exercise_dropdown_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class _AddExerciseDropdownButtonState extends State<AddExerciseDropdownButton> {
});
widget.onChange(value);
},
value: _selectedItem,
initialValue: _selectedItem,
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
border: const OutlineInputBorder(
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/add_exercise/license_info_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:wger/l10n/generated/app_localizations.dart';
/// Being a separate widget allows Flutter to optimize rendering since
/// this content never changes.
class LicenseInfoWidget extends StatelessWidget {
const LicenseInfoWidget({Key? key}) : super(key: key);
const LicenseInfoWidget({super.key});

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/add_exercise/preview_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class PreviewExerciseImages extends StatelessWidget {
height: 120,
margin: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Theme.of(context).colorScheme.outline,
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/add_exercise/steps/step_2_variations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Step2Variations extends StatelessWidget {
),
),
Consumer<AddExerciseProvider>(
builder: (ctx, provider, __) => Switch(
builder: (ctx, provider, _) => Switch(
value: provider.variationId == key,
onChanged: (state) => provider.variationId = key,
),
Expand Down Expand Up @@ -83,7 +83,7 @@ class Step2Variations extends StatelessWidget {
),
),
Consumer<AddExerciseProvider>(
builder: (ctx, provider, __) => Switch(
builder: (ctx, provider, _) => Switch(
value: provider.variationConnectToExercise == base.id,
onChanged: (state) => provider.variationConnectToExercise = base.id,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/add_exercise/steps/step_4_translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _Step4TranslationState extends State<Step4Translation> {
AddExerciseTextArea(
title: '${i18n.name}*',
validator: (name) => validateName(name, context),
onSaved: (String? name) => addExerciseProvider.exerciseNameTrans = name!,
onSaved: (String? name) => addExerciseProvider.exerciseNameTrans = name,
),
AddExerciseTextArea(
title: i18n.alternativeNames,
Expand All @@ -86,14 +86,14 @@ class _Step4TranslationState extends State<Step4Translation> {
addExerciseProvider.alternateNamesTrans = alternateName!.split('\n'),
),
Consumer<AddExerciseProvider>(
builder: (ctx, provider, __) => AddExerciseTextArea(
builder: (ctx, provider, _) => AddExerciseTextArea(
onChange: (value) => {},
title: '${i18n.description}*',
helperText: i18n.enterTextInLanguage,
isMultiline: true,
validator: (name) => validateExerciseDescription(name, context),
onSaved: (String? description) =>
addExerciseProvider.descriptionTrans = description!,
addExerciseProvider.descriptionTrans = description,
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/add_exercise/steps/step_5_images.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class _Step5ImagesState extends State<Step5Images> with ExerciseImagePickerMixin
// Image picker or preview - shown when not entering metadata
if (_currentImageToAdd == null)
Consumer<AddExerciseProvider>(
builder: (ctx, provider, __) {
builder: (ctx, provider, _) {
if (provider.exerciseImages.isNotEmpty) {
// Show preview of images that have been added with metadata
return Column(
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/dashboard/widgets/measurements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class _DashboardMeasurementWidgetState extends State<DashboardMeasurementWidget>
);
}
return Consumer<MeasurementProvider>(
builder: (context, _, __) => Card(
builder: (context, _, _) => Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/exercises/forms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class _ExerciseCategoryInputWidgetState<T> extends State<ExerciseCategoryInputWi
padding: const EdgeInsets.all(8.0),
child: DropdownButtonFormField(
key: widget.key,
value: selectedEntry,
initialValue: selectedEntry,
decoration: InputDecoration(
labelText: widget._title,
contentPadding: const EdgeInsets.all(8.0),
Expand Down
3 changes: 1 addition & 2 deletions lib/widgets/measurements/charts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class MeasurementOverallChangeWidget extends StatelessWidget {

// ignore: prefer_interpolation_to_compose_strings
return Text(
AppLocalizations.of(context).overallChangeWeight +
' $prefix${delta.abs().toStringAsFixed(1)} $_unit',
'${AppLocalizations.of(context).overallChangeWeight} $prefix${delta.abs().toStringAsFixed(1)} $_unit',
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nutrition/charts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ class NutritionalDiaryChartWidgetFlState extends State<NutritionalDiaryChartWidg
child: BarChart(
BarChartData(
alignment: BarChartAlignment.center,
barTouchData: BarTouchData(enabled: false),
barTouchData: const BarTouchData(enabled: false),
titlesData: FlTitlesData(
show: true,
bottomTitles: AxisTitles(
Expand Down Expand Up @@ -532,7 +532,7 @@ class MealDiaryBarChartWidgetState extends State<MealDiaryBarChartWidget> {
return BarChart(
BarChartData(
alignment: BarChartAlignment.center,
barTouchData: BarTouchData(enabled: false),
barTouchData: const BarTouchData(enabled: false),
titlesData: FlTitlesData(
show: true,
bottomTitles: AxisTitles(
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/nutrition/nutrition_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class NutritionTile extends StatelessWidget {
Expanded(
child: Column(
children: [
if (title != null) title!,
if (subtitle != null) subtitle!,
?title,
?subtitle,
],
),
),
Expand Down
2 changes: 2 additions & 0 deletions lib/widgets/routines/forms/weight.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class _WeightInputWidgetState extends ConsumerState<WeightInputWidget> {
final base = currentWeight ?? 0;
final newValue = base - widget.valueChange;
if (newValue >= 0 && log != null) {
plateProvider.setWeight(newValue);
logProvider.setWeight(newValue);
}
},
Expand Down Expand Up @@ -181,6 +182,7 @@ class _WeightInputWidgetState extends ConsumerState<WeightInputWidget> {
final base = currentWeight ?? 0;
final newValue = base + widget.valueChange;
if (log != null) {
plateProvider.setWeight(newValue);
logProvider.setWeight(newValue);
}
},
Expand Down
31 changes: 21 additions & 10 deletions lib/widgets/routines/gym_mode/log_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ class LogPage extends ConsumerWidget {
}
final setConfigData = slotEntryPage.setConfigData!;

// Calculate weightRounding as 2 times the smallest available plate weight
final plateProvider = ref.read(plateCalculatorProvider.notifier);
final selectedPlates = plateProvider.state.selectedPlates;
final minPlate = selectedPlates.isNotEmpty ? selectedPlates.reduce((a, b) => a < b ? a : b) : 1.25;
final calculatedWeightRounding = 2 * minPlate;
Comment on lines +64 to +68
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could just move all this to within the plate provider and just expose a minWeightRounding


// Create a new SetConfigData with the calculated weightRounding
final updatedConfigData = setConfigData.copyWith(
weightRounding: calculatedWeightRounding,
);

final log = ref.read(gymLogProvider);

// Mark done sets
Expand All @@ -84,17 +95,17 @@ class LogPage extends ConsumerWidget {
children: [
Column(
children: [
Text(
setConfigData.textRepr,
textAlign: TextAlign.center,
Text(
updatedConfigData.textRepr,
textAlign: TextAlign.center,
style: theme.textTheme.headlineMedium?.copyWith(
color: Theme.of(context).colorScheme.primary,
decoration: decorationStyle,
),
),
if (setConfigData.type != SlotEntryType.normal)
),
),
if (updatedConfigData.type != SlotEntryType.normal)
Text(
setConfigData.type.name.toUpperCase(),
updatedConfigData.type.name.toUpperCase(),
textAlign: TextAlign.center,
style: theme.textTheme.headlineSmall?.copyWith(
color: Theme.of(context).colorScheme.primary,
Expand All @@ -115,8 +126,8 @@ class LogPage extends ConsumerWidget {
),
),
if (log.exercise.showPlateCalculator) const LogsPlatesWidget(),
if (slotEntryPage.setConfigData!.comment.isNotEmpty)
Text(slotEntryPage.setConfigData!.comment, textAlign: TextAlign.center),
if (updatedConfigData.comment.isNotEmpty)
Text(updatedConfigData.comment, textAlign: TextAlign.center),
const SizedBox(height: 10),
Expanded(
child: (gymState.routine.filterLogsByExercise(log.exerciseId).isNotEmpty)
Expand All @@ -135,7 +146,7 @@ class LogPage extends ConsumerWidget {
padding: const EdgeInsets.symmetric(vertical: 5),
child: LogFormWidget(
controller: _controller,
configData: setConfigData,
configData: updatedConfigData,
key: ValueKey('log-form-${slotEntryPage.uuid}'),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/routines/logs/session_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class _SessionInfoState extends State<SessionInfo> {
),
if (editMode)
SessionForm(
widget._session.routineId!,
widget._session.routineId,
onSaved: () => setState(() => editMode = false),
session: widget._session,
)
Expand Down
34 changes: 18 additions & 16 deletions lib/widgets/routines/plate_calculator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,26 @@ class _AddPlateWeightsState extends ConsumerState<ConfigureAvailablePlates> {
),
Padding(
padding: const EdgeInsets.all(10),
child: DropdownMenu<num>(
key: const ValueKey('barWeightDropdown'),
width: double.infinity,
initialSelection: plateWeightsState.barWeight,
requestFocusOnTap: true,
label: Text(i18n.barWeight),
onSelected: (num? value) {
if (value == null) {
return;
child: TextField(
key: const ValueKey('barWeightTextField'),
controller: TextEditingController(text: plateWeightsState.barWeight.toString()),
keyboardType: TextInputType.number,
decoration: InputDecoration(
labelText: i18n.barWeight,
suffix: Text(plateWeightsState.isMetric ? i18n.kg : i18n.lb),
),
onChanged: (text) {
final parsed = num.tryParse(text);
if (parsed != null) {
plateWeightsNotifier.setBarWeight(parsed);
}
},
onSubmitted: (text) {
final parsed = num.tryParse(text);
if (parsed != null) {
plateWeightsNotifier.setBarWeight(parsed);
}
plateWeightsNotifier.setBarWeight(value);
},
dropdownMenuEntries: plateWeightsState.availableBarsWeights.map((value) {
return DropdownMenuEntry<num>(
value: value,
label: value.toString(),
);
}).toList(),
),
),
SwitchListTile(
Expand Down
2 changes: 1 addition & 1 deletion test/exercises/contribute_exercise_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void main() {
await tester.pumpAndSettle();

// Verify initial step is 0
var stepper = tester.widget<Stepper>(find.byType(Stepper));
final stepper = tester.widget<Stepper>(find.byType(Stepper));
expect(stepper.currentStep, equals(0));

// Get localized text for UI elements
Expand Down
Loading