diff --git a/lib/data/models/game.dart b/lib/data/models/game.dart index 607db0a..42c3b33 100644 --- a/lib/data/models/game.dart +++ b/lib/data/models/game.dart @@ -10,6 +10,7 @@ class Game { final String description; final GameColor color; final String icon; + final bool deleted; Game({ String? id, @@ -19,6 +20,7 @@ class Game { String? description, required this.color, required this.icon, + this.deleted = false, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(), description = description ?? ''; @@ -39,7 +41,8 @@ class Game { ), description = json['description'], color = GameColor.values.firstWhere((e) => e.name == json['color']), - icon = json['icon']; + icon = json['icon'], + deleted = json['deleted'] ?? false; /// Converts the Game instance to a JSON object. Map toJson() => { @@ -50,5 +53,6 @@ class Game { 'description': description, 'color': color.name, 'icon': icon, + 'deleted': deleted, }; } diff --git a/lib/data/models/group.dart b/lib/data/models/group.dart index c684541..9433087 100644 --- a/lib/data/models/group.dart +++ b/lib/data/models/group.dart @@ -8,6 +8,7 @@ class Group { final String description; final DateTime createdAt; final List members; + final bool deleted; Group({ String? id, @@ -15,6 +16,7 @@ class Group { required this.name, String? description, required this.members, + this.deleted = false, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(), description = description ?? ''; @@ -31,7 +33,8 @@ class Group { createdAt = DateTime.parse(json['createdAt']), name = json['name'], description = json['description'], - members = []; + members = [], + deleted = json['deleted'] ?? false; /// Converts the Group instance to a JSON object. Related [Player] objects are /// represented by their IDs. @@ -41,5 +44,6 @@ class Group { 'name': name, 'description': description, 'memberIds': members.map((member) => member.id).toList(), + 'deleted': deleted, }; } diff --git a/lib/data/models/match.dart b/lib/data/models/match.dart index 2ff02d6..1cb8c60 100644 --- a/lib/data/models/match.dart +++ b/lib/data/models/match.dart @@ -16,6 +16,7 @@ class Match { final List players; final String notes; Map scores; + final bool deleted; Match({ required this.name, @@ -27,6 +28,7 @@ class Match { String? id, DateTime? createdAt, Map? scores, + this.deleted = false, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(), scores = scores ?? {for (Player p in players) p.id: null}; @@ -65,7 +67,8 @@ class Match { ), ) : {}, - notes = json['notes'] ?? ''; + notes = json['notes'] ?? '', + deleted = json['deleted'] ?? false; /// Converts the Match instance to a JSON object. Related objects are /// represented by their IDs, so the game, group, and players are not fully @@ -80,6 +83,7 @@ class Match { 'playerIds': players.map((player) => player.id).toList(), 'scores': scores.map((key, value) => MapEntry(key, value?.toJson())), 'notes': notes, + 'deleted': deleted, }; List get mvp { diff --git a/lib/data/models/player.dart b/lib/data/models/player.dart index 12d17f0..d7e5e33 100644 --- a/lib/data/models/player.dart +++ b/lib/data/models/player.dart @@ -7,6 +7,7 @@ class Player { final String name; int nameCount; final String description; + final bool deleted; Player({ String? id, @@ -14,6 +15,7 @@ class Player { required this.name, this.nameCount = 0, String? description, + this.deleted = false, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(), description = description ?? ''; @@ -29,7 +31,8 @@ class Player { createdAt = DateTime.parse(json['createdAt']), name = json['name'], nameCount = 0, - description = json['description']; + description = json['description'], + deleted = json['deleted'] ?? false; /// Converts the Player instance to a JSON object. Map toJson() => { @@ -37,5 +40,6 @@ class Player { 'createdAt': createdAt.toIso8601String(), 'name': name, 'description': description, + 'deleted': deleted, }; } diff --git a/lib/data/models/score_entry.dart b/lib/data/models/score_entry.dart index f9c5ff0..42924d3 100644 --- a/lib/data/models/score_entry.dart +++ b/lib/data/models/score_entry.dart @@ -2,8 +2,9 @@ class ScoreEntry { final int roundNumber; final int score; final int change; + final bool deleted; - ScoreEntry({required this.score, this.roundNumber = 0, this.change = 0}); + ScoreEntry({required this.score, this.roundNumber = 0, this.change = 0, this.deleted = false}); @override String toString() { @@ -13,11 +14,13 @@ class ScoreEntry { ScoreEntry.fromJson(Map json) : roundNumber = json['roundNumber'], score = json['score'], - change = json['change']; + change = json['change'], + deleted = json['deleted'] ?? false; Map toJson() => { 'roundNumber': roundNumber, 'score': score, 'change': change, + 'deleted': deleted, }; } diff --git a/lib/data/models/team.dart b/lib/data/models/team.dart index f5941c4..2dbe8dd 100644 --- a/lib/data/models/team.dart +++ b/lib/data/models/team.dart @@ -7,12 +7,14 @@ class Team { final String name; final DateTime createdAt; final List members; + final bool deleted; Team({ String? id, required this.name, DateTime? createdAt, required this.members, + this.deleted = false, }) : id = id ?? const Uuid().v4(), createdAt = createdAt ?? clock.now(); @@ -27,7 +29,8 @@ class Team { : id = json['id'], name = json['name'], createdAt = DateTime.parse(json['createdAt']), - members = []; // Populated during import via DataTransferService + members = [], + deleted = json['deleted'] ?? false; /// Converts the Team instance to a JSON object. Related objects are /// represented by their IDs. @@ -36,5 +39,6 @@ class Team { 'name': name, 'createdAt': createdAt.toIso8601String(), 'memberIds': members.map((member) => member.id).toList(), + 'deleted': deleted, }; }