mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-29 01:18:35 +01:00
Add models for workouts
This commit is contained in:
13
lib/models/workouts/day.dart
Normal file
13
lib/models/workouts/day.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class Muscle {
|
||||
final int id;
|
||||
final String description;
|
||||
final List<int> daysOfWeek;
|
||||
|
||||
Muscle({
|
||||
@required this.id,
|
||||
@required this.description,
|
||||
@required this.daysOfWeek,
|
||||
});
|
||||
}
|
||||
30
lib/models/workouts/log.dart
Normal file
30
lib/models/workouts/log.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
import 'package:wger/providers/workout_plan.dart';
|
||||
|
||||
class Log {
|
||||
final int id;
|
||||
final Exercise exercise;
|
||||
final WorkoutPlan workoutPlan;
|
||||
|
||||
final int reps;
|
||||
final RepetitionUnit repetitionUnit;
|
||||
|
||||
final double weight;
|
||||
final WeightUnit weightUnit;
|
||||
|
||||
final DateTime date;
|
||||
|
||||
Log({
|
||||
@required this.id,
|
||||
@required this.exercise,
|
||||
@required this.workoutPlan,
|
||||
@required this.repetitionUnit,
|
||||
@required this.reps,
|
||||
@required this.weight,
|
||||
@required this.weightUnit,
|
||||
@required this.date,
|
||||
});
|
||||
}
|
||||
11
lib/models/workouts/repetition_unit.dart
Normal file
11
lib/models/workouts/repetition_unit.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class RepetitionUnit {
|
||||
final int id;
|
||||
final String name;
|
||||
|
||||
RepetitionUnit({
|
||||
@required this.id,
|
||||
@required this.name,
|
||||
});
|
||||
}
|
||||
25
lib/models/workouts/session.dart
Normal file
25
lib/models/workouts/session.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class Impression {
|
||||
static const bad = 1;
|
||||
static const neutral = 2;
|
||||
static const good = 3;
|
||||
}
|
||||
|
||||
class WorkoutSession {
|
||||
final int id;
|
||||
final DateTime date;
|
||||
final Impression impression;
|
||||
final String notes;
|
||||
final DateTime timeStart;
|
||||
final DateTime timeEnd;
|
||||
|
||||
WorkoutSession({
|
||||
@required this.id,
|
||||
@required this.date,
|
||||
@required this.impression,
|
||||
@required this.notes,
|
||||
this.timeStart,
|
||||
this.timeEnd,
|
||||
});
|
||||
}
|
||||
14
lib/models/workouts/set.dart
Normal file
14
lib/models/workouts/set.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
|
||||
class Set {
|
||||
final int id;
|
||||
final int sets;
|
||||
final List<Exercise> exercises;
|
||||
|
||||
Set({
|
||||
@required this.id,
|
||||
@required this.sets,
|
||||
@required this.exercises,
|
||||
});
|
||||
}
|
||||
24
lib/models/workouts/setting.dart
Normal file
24
lib/models/workouts/setting.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:wger/models/exercises/exercise.dart';
|
||||
import 'package:wger/models/workouts/repetition_unit.dart';
|
||||
import 'package:wger/models/workouts/weight_unit.dart';
|
||||
|
||||
class Setting {
|
||||
final int id;
|
||||
final Exercise exercise;
|
||||
final RepetitionUnit repetitionUnit;
|
||||
final int reps;
|
||||
final double weight;
|
||||
final WeightUnit weightUnit;
|
||||
final String comment;
|
||||
|
||||
Setting({
|
||||
@required this.id,
|
||||
@required this.exercise,
|
||||
@required this.repetitionUnit,
|
||||
@required this.reps,
|
||||
@required this.weight,
|
||||
@required this.weightUnit,
|
||||
@required this.comment,
|
||||
});
|
||||
}
|
||||
11
lib/models/workouts/weight_unit.dart
Normal file
11
lib/models/workouts/weight_unit.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class WeightUnit {
|
||||
final int id;
|
||||
final String name;
|
||||
|
||||
WeightUnit({
|
||||
@required this.id,
|
||||
@required this.name,
|
||||
});
|
||||
}
|
||||
@@ -2,12 +2,12 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class WorkoutPlan with ChangeNotifier {
|
||||
final int id;
|
||||
final DateTime creation_date;
|
||||
final DateTime creationDate;
|
||||
final String description;
|
||||
|
||||
WorkoutPlan({
|
||||
@required this.id,
|
||||
@required this.description,
|
||||
@required this.creation_date,
|
||||
@required this.creationDate,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class WorkoutPlans with ChangeNotifier {
|
||||
loadedWorkoutPlans.add(WorkoutPlan(
|
||||
id: entry['id'],
|
||||
description: entry['comment'],
|
||||
creation_date: DateTime.parse(entry['creation_date']),
|
||||
creationDate: DateTime.parse(entry['creation_date']),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class WorkoutPlans with ChangeNotifier {
|
||||
);
|
||||
final newProduct = WorkoutPlan(
|
||||
id: json.decode(response.body)['name'],
|
||||
creation_date: json.decode(response.body)['creation_date'],
|
||||
creationDate: json.decode(response.body)['creation_date'],
|
||||
description: product.description,
|
||||
);
|
||||
_entries.add(newProduct);
|
||||
|
||||
@@ -15,7 +15,7 @@ class WorkoutPlansDetail extends StatelessWidget {
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Text(
|
||||
'Workout ${DateFormat('dd.MM.yyyy').format(_workoutPlan.creation_date)}',
|
||||
'Workout ${DateFormat('dd.MM.yyyy').format(_workoutPlan.creationDate)}',
|
||||
style: Theme.of(context).textTheme.headline2,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -20,7 +20,7 @@ class WorkoutPlansList extends StatelessWidget {
|
||||
leading: FlutterLogo(size: 56.0),
|
||||
title: Text(
|
||||
DateFormat('dd.MM.yyyy')
|
||||
.format(workoutPlansData.items[index].creation_date)
|
||||
.format(workoutPlansData.items[index].creationDate)
|
||||
.toString(),
|
||||
),
|
||||
subtitle: Text(workoutPlansData.items[index].description),
|
||||
|
||||
Reference in New Issue
Block a user