trainlog-egu5j / lib /data /models /set_entry.dart
kuubson's picture
Zaprojektuj i wygeneruj kompletną aplikację Flutter (Dart) działającą na iOS, o nazwie TrainLog: dziennik treningu i śledzenie progresu siłowego/sylwetkowego. Aplikacja ma działać offline-first (bez b
afe1e75 verified
import 'package:isar/isar.dart';
import 'workout_exercise.dart';
part 'set_entry.g.dart';
@collection
class SetEntry {
Id id = Isar.autoIncrement;
double? weight;
int? reps;
double? rpe; // Rate of Perceived Exertion 6-10
String? tempo; // e.g., "3-1-2-0"
int? restSeconds;
final workoutExercise = IsarLink<WorkoutExercise>();
SetEntry({
this.weight,
this.reps,
this.rpe,
this.tempo,
this.restSeconds,
});
double? get volume => (weight != null && reps != null) ? weight! * reps! : null;
Map<String, dynamic> toJson() {
return {
'id': id,
'weight': weight,
'reps': reps,
'rpe': rpe,
'tempo': tempo,
'restSeconds': restSeconds,
};
}
factory SetEntry.fromJson(Map<String, dynamic> json) {
return SetEntry(
weight: json['weight'] != null ? (json['weight'] as num).toDouble() : null,
reps: json['reps'] as int?,
rpe: json['rpe'] != null ? (json['rpe'] as num).toDouble() : null,
tempo: json['tempo'] as String?,
restSeconds: json['restSeconds'] as int?,
)..id = json['id'] as int;
}
}