File size: 1,242 Bytes
afe1e75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import 'package:isar/isar.dart';
import 'package:uuid/uuid.dart';

part 'workout.g.dart';

@collection
class Workout {
  Id id = Isar.autoIncrement;
  
  @Index(unique: true)
  late String uuid;
  
  late DateTime date;
  
  @enumerated
  late WorkoutType type;
  
  String? note;
  
  /// 1-10 scale, optional
  int? mood;
  
  /// Duration in minutes
  int? duration;
  
  DateTime createdAt = DateTime.now();
  
  /// Backlink to exercises
  @Backlink(to: 'workout')
  final workoutExercises = IsarLinks<WorkoutExercise>();
  
  Workout() {
    uuid = const Uuid().v4();
  }
}

enum WorkoutType {
  strength,
  cardio,
  mixed,
  other
}

extension WorkoutTypeExtension on WorkoutType {
  String get displayName {
    switch (this) {
      case WorkoutType.strength:
        return 'Siłowy';
      case WorkoutType.cardio:
        return 'Cardio';
      case WorkoutType.mixed:
        return 'Mieszany';
      case WorkoutType.other:
        return 'Inny';
    }
  }
  
  String get icon {
    switch (this) {
      case WorkoutType.strength:
        return '💪';
      case WorkoutType.cardio:
        return '🏃';
      case WorkoutType.mixed:
        return '🔄';
      case WorkoutType.other:
        return '📝';
    }
  }
}