kettlebell-tracker/lib/providers/settings_provider.dart
2025-06-16 18:56:34 +02:00

51 lines
1.2 KiB
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
class SettingsState {
final int trainingTimeMinutes;
final double weightLeft;
final double weightRight;
final int repsPerSet;
final int goalSets;
final String notes;
SettingsState({
this.trainingTimeMinutes = 20,
this.weightLeft = 16.0,
this.weightRight = 16.0,
this.repsPerSet = 5,
this.goalSets = 5,
this.notes = "",
});
SettingsState copyWith({
int? trainingTimeMinutes,
double? weightLeft,
double? weightRight,
int? repsPerSet,
int? goalSets,
String? notes,
}) {
return SettingsState(
trainingTimeMinutes: trainingTimeMinutes ?? this.trainingTimeMinutes,
weightLeft: weightLeft ?? this.weightLeft,
weightRight: weightRight ?? this.weightRight,
repsPerSet: repsPerSet ?? this.repsPerSet,
goalSets: goalSets ?? this.goalSets,
notes: notes ?? this.notes,
);
}
}
class SettingsNotifier extends StateNotifier<SettingsState> {
SettingsNotifier() : super(SettingsState());
void updateSettings(SettingsState newSettings) {
state = newSettings;
}
}
final settingsProvider = StateNotifierProvider<SettingsNotifier, SettingsState>(
(ref) {
return SettingsNotifier();
},
);