all parameters are now required
This commit is contained in:
@@ -56,7 +56,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
ruleset: game.ruleset.name,
|
||||
description: game.description,
|
||||
color: game.color,
|
||||
icon: Value(game.icon),
|
||||
icon: game.icon,
|
||||
createdAt: game.createdAt,
|
||||
),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
@@ -82,7 +82,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
ruleset: game.ruleset.name,
|
||||
description: game.description,
|
||||
color: game.color,
|
||||
icon: Value(game.icon),
|
||||
icon: game.icon,
|
||||
createdAt: game.createdAt,
|
||||
),
|
||||
)
|
||||
@@ -153,7 +153,7 @@ class GameDao extends DatabaseAccessor<AppDatabase> with _$GameDaoMixin {
|
||||
/// Updates the icon of the game with the given [gameId].
|
||||
Future<void> updateGameIcon({
|
||||
required String gameId,
|
||||
required String? newIcon,
|
||||
required String newIcon,
|
||||
}) async {
|
||||
await (update(gameTable)..where((g) => g.id.equals(gameId))).write(
|
||||
GameTableCompanion(icon: Value(newIcon)),
|
||||
|
||||
@@ -58,7 +58,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
GroupTableCompanion.insert(
|
||||
id: group.id,
|
||||
name: group.name,
|
||||
description: Value(group.description),
|
||||
description: group.description,
|
||||
createdAt: group.createdAt,
|
||||
),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
@@ -108,7 +108,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
(group) => GroupTableCompanion.insert(
|
||||
id: group.id,
|
||||
name: group.name,
|
||||
description: Value(group.description),
|
||||
description: group.description,
|
||||
createdAt: group.createdAt,
|
||||
),
|
||||
)
|
||||
@@ -136,7 +136,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
(p) => PlayerTableCompanion.insert(
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
description: Value(p.description),
|
||||
description: p.description,
|
||||
createdAt: p.createdAt,
|
||||
),
|
||||
)
|
||||
@@ -196,7 +196,7 @@ class GroupDao extends DatabaseAccessor<AppDatabase> with _$GroupDaoMixin {
|
||||
/// Returns `true` if more than 0 rows were affected, otherwise `false`.
|
||||
Future<bool> updateGroupDescription({
|
||||
required String groupId,
|
||||
required String? newDescription,
|
||||
required String newDescription,
|
||||
}) async {
|
||||
final rowsAffected =
|
||||
await (update(groupTable)..where((g) => g.id.equals(groupId))).write(
|
||||
|
||||
@@ -36,7 +36,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
game: game,
|
||||
group: group,
|
||||
players: players,
|
||||
notes: row.notes,
|
||||
notes: row.notes ?? '',
|
||||
createdAt: row.createdAt,
|
||||
);
|
||||
}),
|
||||
@@ -66,7 +66,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
game: game,
|
||||
group: group,
|
||||
players: players,
|
||||
notes: result.notes,
|
||||
notes: result.notes ?? '',
|
||||
createdAt: result.createdAt,
|
||||
);
|
||||
}
|
||||
@@ -75,15 +75,11 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
/// This method assumes that the game and group (if any) are already present
|
||||
/// in the database.
|
||||
Future<void> addMatch({required Match match}) async {
|
||||
if (match.game == null) {
|
||||
throw ArgumentError('Match must have a game associated with it');
|
||||
}
|
||||
|
||||
await db.transaction(() async {
|
||||
await into(matchTable).insert(
|
||||
MatchTableCompanion.insert(
|
||||
id: match.id,
|
||||
gameId: match.game!.id,
|
||||
gameId: match.game.id,
|
||||
groupId: Value(match.group?.id),
|
||||
name: Value(match.name),
|
||||
notes: Value(match.notes),
|
||||
@@ -113,9 +109,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
// Add all games first (deduplicated)
|
||||
final uniqueGames = <String, Game>{};
|
||||
for (final match in matches) {
|
||||
if (match.game != null) {
|
||||
uniqueGames[match.game!.id] = match.game!;
|
||||
}
|
||||
uniqueGames[match.game.id] = match.game;
|
||||
}
|
||||
|
||||
if (uniqueGames.isNotEmpty) {
|
||||
@@ -130,7 +124,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
ruleset: game.ruleset.name,
|
||||
description: game.description,
|
||||
color: game.color,
|
||||
icon: Value(game.icon),
|
||||
icon: game.icon,
|
||||
createdAt: game.createdAt,
|
||||
),
|
||||
)
|
||||
@@ -150,7 +144,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
(match) => GroupTableCompanion.insert(
|
||||
id: match.group!.id,
|
||||
name: match.group!.name,
|
||||
description: Value(match.group!.description),
|
||||
description: match.group!.description,
|
||||
createdAt: match.group!.createdAt,
|
||||
),
|
||||
)
|
||||
@@ -164,11 +158,10 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
(b) => b.insertAll(
|
||||
matchTable,
|
||||
matches
|
||||
.where((match) => match.game != null)
|
||||
.map(
|
||||
(match) => MatchTableCompanion.insert(
|
||||
id: match.id,
|
||||
gameId: match.game!.id,
|
||||
gameId: match.game.id,
|
||||
groupId: Value(match.group?.id),
|
||||
name: Value(match.name),
|
||||
notes: Value(match.notes),
|
||||
@@ -205,7 +198,7 @@ class MatchDao extends DatabaseAccessor<AppDatabase> with _$MatchDaoMixin {
|
||||
(p) => PlayerTableCompanion.insert(
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
description: Value(p.description),
|
||||
description: p.description,
|
||||
createdAt: p.createdAt,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -46,7 +46,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
PlayerTableCompanion.insert(
|
||||
id: player.id,
|
||||
name: player.name,
|
||||
description: Value(player.description),
|
||||
description: player.description,
|
||||
createdAt: player.createdAt,
|
||||
),
|
||||
mode: InsertMode.insertOrReplace,
|
||||
@@ -70,7 +70,7 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
(player) => PlayerTableCompanion.insert(
|
||||
id: player.id,
|
||||
name: player.name,
|
||||
description: Value(player.description),
|
||||
description: player.description,
|
||||
createdAt: player.createdAt,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -34,9 +34,9 @@ class $PlayerTableTable extends PlayerTable
|
||||
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
||||
'description',
|
||||
aliasedName,
|
||||
true,
|
||||
false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _createdAtMeta = const VerificationMeta(
|
||||
'createdAt',
|
||||
@@ -84,6 +84,8 @@ class $PlayerTableTable extends PlayerTable
|
||||
_descriptionMeta,
|
||||
),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_descriptionMeta);
|
||||
}
|
||||
if (data.containsKey('created_at')) {
|
||||
context.handle(
|
||||
@@ -113,7 +115,7 @@ class $PlayerTableTable extends PlayerTable
|
||||
description: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}description'],
|
||||
),
|
||||
)!,
|
||||
createdAt: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}created_at'],
|
||||
@@ -130,12 +132,12 @@ class $PlayerTableTable extends PlayerTable
|
||||
class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
final String id;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String description;
|
||||
final DateTime createdAt;
|
||||
const PlayerTableData({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.description,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
});
|
||||
@override
|
||||
@@ -143,9 +145,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<String>(id);
|
||||
map['name'] = Variable<String>(name);
|
||||
if (!nullToAbsent || description != null) {
|
||||
map['description'] = Variable<String>(description);
|
||||
}
|
||||
map['description'] = Variable<String>(description);
|
||||
map['created_at'] = Variable<DateTime>(createdAt);
|
||||
return map;
|
||||
}
|
||||
@@ -154,9 +154,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
return PlayerTableCompanion(
|
||||
id: Value(id),
|
||||
name: Value(name),
|
||||
description: description == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
: Value(description),
|
||||
description: Value(description),
|
||||
createdAt: Value(createdAt),
|
||||
);
|
||||
}
|
||||
@@ -169,7 +167,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
return PlayerTableData(
|
||||
id: serializer.fromJson<String>(json['id']),
|
||||
name: serializer.fromJson<String>(json['name']),
|
||||
description: serializer.fromJson<String?>(json['description']),
|
||||
description: serializer.fromJson<String>(json['description']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
);
|
||||
}
|
||||
@@ -179,7 +177,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<String>(id),
|
||||
'name': serializer.toJson<String>(name),
|
||||
'description': serializer.toJson<String?>(description),
|
||||
'description': serializer.toJson<String>(description),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
};
|
||||
}
|
||||
@@ -187,12 +185,12 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
PlayerTableData copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
Value<String?> description = const Value.absent(),
|
||||
String? description,
|
||||
DateTime? createdAt,
|
||||
}) => PlayerTableData(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
description: description.present ? description.value : this.description,
|
||||
description: description ?? this.description,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
PlayerTableData copyWithCompanion(PlayerTableCompanion data) {
|
||||
@@ -232,7 +230,7 @@ class PlayerTableData extends DataClass implements Insertable<PlayerTableData> {
|
||||
class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
||||
final Value<String> id;
|
||||
final Value<String> name;
|
||||
final Value<String?> description;
|
||||
final Value<String> description;
|
||||
final Value<DateTime> createdAt;
|
||||
final Value<int> rowid;
|
||||
const PlayerTableCompanion({
|
||||
@@ -245,11 +243,12 @@ class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
||||
PlayerTableCompanion.insert({
|
||||
required String id,
|
||||
required String name,
|
||||
this.description = const Value.absent(),
|
||||
required String description,
|
||||
required DateTime createdAt,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
name = Value(name),
|
||||
description = Value(description),
|
||||
createdAt = Value(createdAt);
|
||||
static Insertable<PlayerTableData> custom({
|
||||
Expression<String>? id,
|
||||
@@ -270,7 +269,7 @@ class PlayerTableCompanion extends UpdateCompanion<PlayerTableData> {
|
||||
PlayerTableCompanion copyWith({
|
||||
Value<String>? id,
|
||||
Value<String>? name,
|
||||
Value<String?>? description,
|
||||
Value<String>? description,
|
||||
Value<DateTime>? createdAt,
|
||||
Value<int>? rowid,
|
||||
}) {
|
||||
@@ -348,9 +347,9 @@ class $GroupTableTable extends GroupTable
|
||||
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
||||
'description',
|
||||
aliasedName,
|
||||
true,
|
||||
false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _createdAtMeta = const VerificationMeta(
|
||||
'createdAt',
|
||||
@@ -398,6 +397,8 @@ class $GroupTableTable extends GroupTable
|
||||
_descriptionMeta,
|
||||
),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_descriptionMeta);
|
||||
}
|
||||
if (data.containsKey('created_at')) {
|
||||
context.handle(
|
||||
@@ -427,7 +428,7 @@ class $GroupTableTable extends GroupTable
|
||||
description: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}description'],
|
||||
),
|
||||
)!,
|
||||
createdAt: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}created_at'],
|
||||
@@ -444,12 +445,12 @@ class $GroupTableTable extends GroupTable
|
||||
class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
final String id;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String description;
|
||||
final DateTime createdAt;
|
||||
const GroupTableData({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.description,
|
||||
required this.description,
|
||||
required this.createdAt,
|
||||
});
|
||||
@override
|
||||
@@ -457,9 +458,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
final map = <String, Expression>{};
|
||||
map['id'] = Variable<String>(id);
|
||||
map['name'] = Variable<String>(name);
|
||||
if (!nullToAbsent || description != null) {
|
||||
map['description'] = Variable<String>(description);
|
||||
}
|
||||
map['description'] = Variable<String>(description);
|
||||
map['created_at'] = Variable<DateTime>(createdAt);
|
||||
return map;
|
||||
}
|
||||
@@ -468,9 +467,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
return GroupTableCompanion(
|
||||
id: Value(id),
|
||||
name: Value(name),
|
||||
description: description == null && nullToAbsent
|
||||
? const Value.absent()
|
||||
: Value(description),
|
||||
description: Value(description),
|
||||
createdAt: Value(createdAt),
|
||||
);
|
||||
}
|
||||
@@ -483,7 +480,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
return GroupTableData(
|
||||
id: serializer.fromJson<String>(json['id']),
|
||||
name: serializer.fromJson<String>(json['name']),
|
||||
description: serializer.fromJson<String?>(json['description']),
|
||||
description: serializer.fromJson<String>(json['description']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
);
|
||||
}
|
||||
@@ -493,7 +490,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
return <String, dynamic>{
|
||||
'id': serializer.toJson<String>(id),
|
||||
'name': serializer.toJson<String>(name),
|
||||
'description': serializer.toJson<String?>(description),
|
||||
'description': serializer.toJson<String>(description),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
};
|
||||
}
|
||||
@@ -501,12 +498,12 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
GroupTableData copyWith({
|
||||
String? id,
|
||||
String? name,
|
||||
Value<String?> description = const Value.absent(),
|
||||
String? description,
|
||||
DateTime? createdAt,
|
||||
}) => GroupTableData(
|
||||
id: id ?? this.id,
|
||||
name: name ?? this.name,
|
||||
description: description.present ? description.value : this.description,
|
||||
description: description ?? this.description,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
GroupTableData copyWithCompanion(GroupTableCompanion data) {
|
||||
@@ -546,7 +543,7 @@ class GroupTableData extends DataClass implements Insertable<GroupTableData> {
|
||||
class GroupTableCompanion extends UpdateCompanion<GroupTableData> {
|
||||
final Value<String> id;
|
||||
final Value<String> name;
|
||||
final Value<String?> description;
|
||||
final Value<String> description;
|
||||
final Value<DateTime> createdAt;
|
||||
final Value<int> rowid;
|
||||
const GroupTableCompanion({
|
||||
@@ -559,11 +556,12 @@ class GroupTableCompanion extends UpdateCompanion<GroupTableData> {
|
||||
GroupTableCompanion.insert({
|
||||
required String id,
|
||||
required String name,
|
||||
this.description = const Value.absent(),
|
||||
required String description,
|
||||
required DateTime createdAt,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
name = Value(name),
|
||||
description = Value(description),
|
||||
createdAt = Value(createdAt);
|
||||
static Insertable<GroupTableData> custom({
|
||||
Expression<String>? id,
|
||||
@@ -584,7 +582,7 @@ class GroupTableCompanion extends UpdateCompanion<GroupTableData> {
|
||||
GroupTableCompanion copyWith({
|
||||
Value<String>? id,
|
||||
Value<String>? name,
|
||||
Value<String?>? description,
|
||||
Value<String>? description,
|
||||
Value<DateTime>? createdAt,
|
||||
Value<int>? rowid,
|
||||
}) {
|
||||
@@ -691,9 +689,9 @@ class $GameTableTable extends GameTable
|
||||
late final GeneratedColumn<String> icon = GeneratedColumn<String>(
|
||||
'icon',
|
||||
aliasedName,
|
||||
true,
|
||||
false,
|
||||
type: DriftSqlType.string,
|
||||
requiredDuringInsert: false,
|
||||
requiredDuringInsert: true,
|
||||
);
|
||||
static const VerificationMeta _createdAtMeta = const VerificationMeta(
|
||||
'createdAt',
|
||||
@@ -773,6 +771,8 @@ class $GameTableTable extends GameTable
|
||||
_iconMeta,
|
||||
icon.isAcceptableOrUnknown(data['icon']!, _iconMeta),
|
||||
);
|
||||
} else if (isInserting) {
|
||||
context.missing(_iconMeta);
|
||||
}
|
||||
if (data.containsKey('created_at')) {
|
||||
context.handle(
|
||||
@@ -814,7 +814,7 @@ class $GameTableTable extends GameTable
|
||||
icon: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}icon'],
|
||||
),
|
||||
)!,
|
||||
createdAt: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}created_at'],
|
||||
@@ -834,7 +834,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
final String ruleset;
|
||||
final String description;
|
||||
final String color;
|
||||
final String? icon;
|
||||
final String icon;
|
||||
final DateTime createdAt;
|
||||
const GameTableData({
|
||||
required this.id,
|
||||
@@ -842,7 +842,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
required this.ruleset,
|
||||
required this.description,
|
||||
required this.color,
|
||||
this.icon,
|
||||
required this.icon,
|
||||
required this.createdAt,
|
||||
});
|
||||
@override
|
||||
@@ -853,9 +853,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
map['ruleset'] = Variable<String>(ruleset);
|
||||
map['description'] = Variable<String>(description);
|
||||
map['color'] = Variable<String>(color);
|
||||
if (!nullToAbsent || icon != null) {
|
||||
map['icon'] = Variable<String>(icon);
|
||||
}
|
||||
map['icon'] = Variable<String>(icon);
|
||||
map['created_at'] = Variable<DateTime>(createdAt);
|
||||
return map;
|
||||
}
|
||||
@@ -867,7 +865,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
ruleset: Value(ruleset),
|
||||
description: Value(description),
|
||||
color: Value(color),
|
||||
icon: icon == null && nullToAbsent ? const Value.absent() : Value(icon),
|
||||
icon: Value(icon),
|
||||
createdAt: Value(createdAt),
|
||||
);
|
||||
}
|
||||
@@ -883,7 +881,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
ruleset: serializer.fromJson<String>(json['ruleset']),
|
||||
description: serializer.fromJson<String>(json['description']),
|
||||
color: serializer.fromJson<String>(json['color']),
|
||||
icon: serializer.fromJson<String?>(json['icon']),
|
||||
icon: serializer.fromJson<String>(json['icon']),
|
||||
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
||||
);
|
||||
}
|
||||
@@ -896,7 +894,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
'ruleset': serializer.toJson<String>(ruleset),
|
||||
'description': serializer.toJson<String>(description),
|
||||
'color': serializer.toJson<String>(color),
|
||||
'icon': serializer.toJson<String?>(icon),
|
||||
'icon': serializer.toJson<String>(icon),
|
||||
'createdAt': serializer.toJson<DateTime>(createdAt),
|
||||
};
|
||||
}
|
||||
@@ -907,7 +905,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
String? ruleset,
|
||||
String? description,
|
||||
String? color,
|
||||
Value<String?> icon = const Value.absent(),
|
||||
String? icon,
|
||||
DateTime? createdAt,
|
||||
}) => GameTableData(
|
||||
id: id ?? this.id,
|
||||
@@ -915,7 +913,7 @@ class GameTableData extends DataClass implements Insertable<GameTableData> {
|
||||
ruleset: ruleset ?? this.ruleset,
|
||||
description: description ?? this.description,
|
||||
color: color ?? this.color,
|
||||
icon: icon.present ? icon.value : this.icon,
|
||||
icon: icon ?? this.icon,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
GameTableData copyWithCompanion(GameTableCompanion data) {
|
||||
@@ -968,7 +966,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
||||
final Value<String> ruleset;
|
||||
final Value<String> description;
|
||||
final Value<String> color;
|
||||
final Value<String?> icon;
|
||||
final Value<String> icon;
|
||||
final Value<DateTime> createdAt;
|
||||
final Value<int> rowid;
|
||||
const GameTableCompanion({
|
||||
@@ -987,7 +985,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
||||
required String ruleset,
|
||||
required String description,
|
||||
required String color,
|
||||
this.icon = const Value.absent(),
|
||||
required String icon,
|
||||
required DateTime createdAt,
|
||||
this.rowid = const Value.absent(),
|
||||
}) : id = Value(id),
|
||||
@@ -995,6 +993,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
||||
ruleset = Value(ruleset),
|
||||
description = Value(description),
|
||||
color = Value(color),
|
||||
icon = Value(icon),
|
||||
createdAt = Value(createdAt);
|
||||
static Insertable<GameTableData> custom({
|
||||
Expression<String>? id,
|
||||
@@ -1024,7 +1023,7 @@ class GameTableCompanion extends UpdateCompanion<GameTableData> {
|
||||
Value<String>? ruleset,
|
||||
Value<String>? description,
|
||||
Value<String>? color,
|
||||
Value<String?>? icon,
|
||||
Value<String>? icon,
|
||||
Value<DateTime>? createdAt,
|
||||
Value<int>? rowid,
|
||||
}) {
|
||||
@@ -2783,7 +2782,7 @@ typedef $$PlayerTableTableCreateCompanionBuilder =
|
||||
PlayerTableCompanion Function({
|
||||
required String id,
|
||||
required String name,
|
||||
Value<String?> description,
|
||||
required String description,
|
||||
required DateTime createdAt,
|
||||
Value<int> rowid,
|
||||
});
|
||||
@@ -2791,7 +2790,7 @@ typedef $$PlayerTableTableUpdateCompanionBuilder =
|
||||
PlayerTableCompanion Function({
|
||||
Value<String> id,
|
||||
Value<String> name,
|
||||
Value<String?> description,
|
||||
Value<String> description,
|
||||
Value<DateTime> createdAt,
|
||||
Value<int> rowid,
|
||||
});
|
||||
@@ -3133,7 +3132,7 @@ class $$PlayerTableTableTableManager
|
||||
({
|
||||
Value<String> id = const Value.absent(),
|
||||
Value<String> name = const Value.absent(),
|
||||
Value<String?> description = const Value.absent(),
|
||||
Value<String> description = const Value.absent(),
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) => PlayerTableCompanion(
|
||||
@@ -3147,7 +3146,7 @@ class $$PlayerTableTableTableManager
|
||||
({
|
||||
required String id,
|
||||
required String name,
|
||||
Value<String?> description = const Value.absent(),
|
||||
required String description,
|
||||
required DateTime createdAt,
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) => PlayerTableCompanion.insert(
|
||||
@@ -3274,7 +3273,7 @@ typedef $$GroupTableTableCreateCompanionBuilder =
|
||||
GroupTableCompanion Function({
|
||||
required String id,
|
||||
required String name,
|
||||
Value<String?> description,
|
||||
required String description,
|
||||
required DateTime createdAt,
|
||||
Value<int> rowid,
|
||||
});
|
||||
@@ -3282,7 +3281,7 @@ typedef $$GroupTableTableUpdateCompanionBuilder =
|
||||
GroupTableCompanion Function({
|
||||
Value<String> id,
|
||||
Value<String> name,
|
||||
Value<String?> description,
|
||||
Value<String> description,
|
||||
Value<DateTime> createdAt,
|
||||
Value<int> rowid,
|
||||
});
|
||||
@@ -3550,7 +3549,7 @@ class $$GroupTableTableTableManager
|
||||
({
|
||||
Value<String> id = const Value.absent(),
|
||||
Value<String> name = const Value.absent(),
|
||||
Value<String?> description = const Value.absent(),
|
||||
Value<String> description = const Value.absent(),
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) => GroupTableCompanion(
|
||||
@@ -3564,7 +3563,7 @@ class $$GroupTableTableTableManager
|
||||
({
|
||||
required String id,
|
||||
required String name,
|
||||
Value<String?> description = const Value.absent(),
|
||||
required String description,
|
||||
required DateTime createdAt,
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) => GroupTableCompanion.insert(
|
||||
@@ -3664,7 +3663,7 @@ typedef $$GameTableTableCreateCompanionBuilder =
|
||||
required String ruleset,
|
||||
required String description,
|
||||
required String color,
|
||||
Value<String?> icon,
|
||||
required String icon,
|
||||
required DateTime createdAt,
|
||||
Value<int> rowid,
|
||||
});
|
||||
@@ -3675,7 +3674,7 @@ typedef $$GameTableTableUpdateCompanionBuilder =
|
||||
Value<String> ruleset,
|
||||
Value<String> description,
|
||||
Value<String> color,
|
||||
Value<String?> icon,
|
||||
Value<String> icon,
|
||||
Value<DateTime> createdAt,
|
||||
Value<int> rowid,
|
||||
});
|
||||
@@ -3909,7 +3908,7 @@ class $$GameTableTableTableManager
|
||||
Value<String> ruleset = const Value.absent(),
|
||||
Value<String> description = const Value.absent(),
|
||||
Value<String> color = const Value.absent(),
|
||||
Value<String?> icon = const Value.absent(),
|
||||
Value<String> icon = const Value.absent(),
|
||||
Value<DateTime> createdAt = const Value.absent(),
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) => GameTableCompanion(
|
||||
@@ -3929,7 +3928,7 @@ class $$GameTableTableTableManager
|
||||
required String ruleset,
|
||||
required String description,
|
||||
required String color,
|
||||
Value<String?> icon = const Value.absent(),
|
||||
required String icon,
|
||||
required DateTime createdAt,
|
||||
Value<int> rowid = const Value.absent(),
|
||||
}) => GameTableCompanion.insert(
|
||||
|
||||
@@ -6,7 +6,7 @@ class GameTable extends Table {
|
||||
TextColumn get ruleset => text()();
|
||||
TextColumn get description => text()();
|
||||
TextColumn get color => text()();
|
||||
TextColumn get icon => text().nullable()();
|
||||
TextColumn get icon => text()();
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
|
||||
@override
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:drift/drift.dart';
|
||||
class GroupTable extends Table {
|
||||
TextColumn get id => text()();
|
||||
TextColumn get name => text()();
|
||||
TextColumn get description => text().nullable()();
|
||||
TextColumn get description => text()();
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
|
||||
@override
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:drift/drift.dart';
|
||||
class PlayerTable extends Table {
|
||||
TextColumn get id => text()();
|
||||
TextColumn get name => text()();
|
||||
TextColumn get description => text().nullable()();
|
||||
TextColumn get description => text()();
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
|
||||
@override
|
||||
|
||||
@@ -9,7 +9,7 @@ class Game {
|
||||
final Ruleset ruleset;
|
||||
final String description;
|
||||
final String color;
|
||||
final String? icon;
|
||||
final String icon;
|
||||
|
||||
Game({
|
||||
String? id,
|
||||
@@ -18,7 +18,7 @@ class Game {
|
||||
required this.ruleset,
|
||||
required this.description,
|
||||
required this.color,
|
||||
this.icon,
|
||||
required this.icon,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:uuid/uuid.dart';
|
||||
class Group {
|
||||
final String id;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String description;
|
||||
final DateTime createdAt;
|
||||
final List<Player> members;
|
||||
|
||||
@@ -13,7 +13,7 @@ class Group {
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
required this.name,
|
||||
this.description,
|
||||
required this.description,
|
||||
required this.members,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:clock/clock.dart';
|
||||
import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/data/dto/game.dart';
|
||||
import 'package:game_tracker/data/dto/group.dart';
|
||||
import 'package:game_tracker/data/dto/player.dart';
|
||||
@@ -8,20 +9,20 @@ class Match {
|
||||
final String id;
|
||||
final DateTime createdAt;
|
||||
final String name;
|
||||
final Game? game;
|
||||
final Game game;
|
||||
final Group? group;
|
||||
final List<Player>? players;
|
||||
final String? notes;
|
||||
final String notes;
|
||||
Player? winner;
|
||||
|
||||
Match({
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
required this.name,
|
||||
this.game,
|
||||
required this.game,
|
||||
this.group,
|
||||
this.players,
|
||||
this.notes,
|
||||
required this.notes,
|
||||
this.winner,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now();
|
||||
@@ -37,17 +38,17 @@ class Match {
|
||||
: id = json['id'],
|
||||
createdAt = DateTime.parse(json['createdAt']),
|
||||
name = json['name'],
|
||||
game = null, // Populated during import via DataTransferService
|
||||
game = Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''), // Populated during import via DataTransferService
|
||||
group = null, // Populated during import via DataTransferService
|
||||
players = [], // Populated during import via DataTransferService
|
||||
notes = json['notes'];
|
||||
notes = json['notes'] ?? '';
|
||||
|
||||
/// Converts the Match instance to a JSON object using normalized format (ID references only).
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'name': name,
|
||||
'gameId': game?.id,
|
||||
'gameId': game.id,
|
||||
'groupId': group?.id,
|
||||
'playerIds': (players ?? []).map((player) => player.id).toList(),
|
||||
'notes': notes,
|
||||
|
||||
@@ -5,13 +5,13 @@ class Player {
|
||||
final String id;
|
||||
final DateTime createdAt;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String description;
|
||||
|
||||
Player({
|
||||
String? id,
|
||||
DateTime? createdAt,
|
||||
required this.name,
|
||||
this.description,
|
||||
required this.description,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now();
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
||||
bool success = await db.groupDao.addGroup(
|
||||
group: Group(
|
||||
name: _groupNameController.text.trim(),
|
||||
description: '',
|
||||
members: selectedPlayers,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,8 @@ class _GroupsViewState extends State<GroupsView> {
|
||||
7,
|
||||
Group(
|
||||
name: 'Skeleton Group',
|
||||
members: List.filled(6, Player(name: 'Skeleton Player')),
|
||||
description: '',
|
||||
members: List.filled(6, Player(name: 'Skeleton Player', description: '')),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/adaptive_page_route.dart';
|
||||
import 'package:game_tracker/core/constants.dart';
|
||||
import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
import 'package:game_tracker/data/dto/game.dart';
|
||||
import 'package:game_tracker/data/dto/group.dart';
|
||||
import 'package:game_tracker/data/dto/match.dart';
|
||||
import 'package:game_tracker/data/dto/player.dart';
|
||||
@@ -40,13 +42,16 @@ class _HomeViewState extends State<HomeView> {
|
||||
2,
|
||||
Match(
|
||||
name: 'Skeleton Match',
|
||||
game: Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''),
|
||||
group: Group(
|
||||
name: 'Skeleton Group',
|
||||
description: '',
|
||||
members: [
|
||||
Player(name: 'Skeleton Player 1'),
|
||||
Player(name: 'Skeleton Player 2'),
|
||||
Player(name: 'Skeleton Player 1', description: ''),
|
||||
Player(name: 'Skeleton Player 2', description: ''),
|
||||
],
|
||||
),
|
||||
notes: '',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -114,7 +119,7 @@ class _HomeViewState extends State<HomeView> {
|
||||
MatchResultView(match: match),
|
||||
),
|
||||
);
|
||||
await updatedWinnerinRecentMatches(match.id);
|
||||
await updatedWinnerInRecentMatches(match.id);
|
||||
},
|
||||
),
|
||||
)
|
||||
@@ -214,7 +219,7 @@ class _HomeViewState extends State<HomeView> {
|
||||
}
|
||||
|
||||
/// Updates the winner information for a specific match in the recent matches list.
|
||||
Future<void> updatedWinnerinRecentMatches(String matchId) async {
|
||||
Future<void> updatedWinnerInRecentMatches(String matchId) async {
|
||||
final db = Provider.of<AppDatabase>(context, listen: false);
|
||||
final winner = await db.matchDao.getWinner(matchId: matchId);
|
||||
final matchIndex = recentMatches.indexWhere((match) => match.id == matchId);
|
||||
|
||||
@@ -203,6 +203,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
description: selectedGame.$2,
|
||||
ruleset: selectedGame.$3,
|
||||
color: '0xFF000000',
|
||||
icon: '',
|
||||
);
|
||||
} else {
|
||||
// Use the selected game from the list
|
||||
@@ -212,6 +213,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
description: selectedGame.$2,
|
||||
ruleset: selectedGame.$3,
|
||||
color: '0xFF000000',
|
||||
icon: '',
|
||||
);
|
||||
}
|
||||
// Add the game to the database if it doesn't exist
|
||||
@@ -225,6 +227,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
game: gameToUse,
|
||||
group: selectedGroup,
|
||||
players: selectedPlayers,
|
||||
notes: '',
|
||||
);
|
||||
await db.matchDao.addMatch(match: match);
|
||||
if (context.mounted) {
|
||||
|
||||
@@ -5,7 +5,9 @@ import 'package:fluttericon/rpg_awesome_icons.dart';
|
||||
import 'package:game_tracker/core/adaptive_page_route.dart';
|
||||
import 'package:game_tracker/core/constants.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
import 'package:game_tracker/data/dto/game.dart';
|
||||
import 'package:game_tracker/data/dto/group.dart';
|
||||
import 'package:game_tracker/data/dto/match.dart';
|
||||
import 'package:game_tracker/data/dto/player.dart';
|
||||
@@ -36,12 +38,15 @@ class _MatchViewState extends State<MatchView> {
|
||||
4,
|
||||
Match(
|
||||
name: 'Skeleton match name',
|
||||
game: Game(name: '', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''),
|
||||
group: Group(
|
||||
name: 'Group name',
|
||||
members: List.filled(5, Player(name: 'Player')),
|
||||
description: '',
|
||||
members: List.filled(5, Player(name: 'Player', description: '')),
|
||||
),
|
||||
winner: Player(name: 'Player'),
|
||||
players: [Player(name: 'Player')],
|
||||
winner: Player(name: 'Player', description: ''),
|
||||
players: [Player(name: 'Player', description: '')],
|
||||
notes: '',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
final playerId = winCounts[i].$1;
|
||||
final player = players.firstWhere(
|
||||
(p) => p.id == playerId,
|
||||
orElse: () => Player(id: playerId, name: loc.not_available),
|
||||
orElse: () => Player(id: playerId, name: loc.not_available, description: ''),
|
||||
);
|
||||
winCounts[i] = (player.name, winCounts[i].$2);
|
||||
}
|
||||
@@ -231,7 +231,7 @@ class _StatisticsViewState extends State<StatisticsView> {
|
||||
final playerId = matchCounts[i].$1;
|
||||
final player = players.firstWhere(
|
||||
(p) => p.id == playerId,
|
||||
orElse: () => Player(id: playerId, name: loc.not_available),
|
||||
orElse: () => Player(id: playerId, name: loc.not_available, description: ''),
|
||||
);
|
||||
matchCounts[i] = (player.name, matchCounts[i].$2);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
/// Skeleton data used while loading players.
|
||||
late final List<Player> skeletonData = List.filled(
|
||||
7,
|
||||
Player(name: 'Player 0'),
|
||||
Player(name: 'Player 0', description: ''),
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -260,7 +260,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
||||
final loc = AppLocalizations.of(context);
|
||||
final playerName = _searchBarController.text.trim();
|
||||
|
||||
final createdPlayer = Player(name: playerName);
|
||||
final createdPlayer = Player(name: playerName, description: '');
|
||||
final success = await db.playerDao.addPlayer(player: createdPlayer);
|
||||
|
||||
if (!context.mounted) return;
|
||||
|
||||
@@ -61,7 +61,7 @@ class DataTransferService {
|
||||
'id': m.id,
|
||||
'name': m.name,
|
||||
'createdAt': m.createdAt.toIso8601String(),
|
||||
'gameId': m.game?.id,
|
||||
'gameId': m.game.id,
|
||||
'groupId': m.group?.id,
|
||||
'playerIds': (m.players ?? []).map((p) => p.id).toList(),
|
||||
'notes': m.notes,
|
||||
@@ -160,7 +160,7 @@ class DataTransferService {
|
||||
return Group(
|
||||
id: map['id'] as String,
|
||||
name: map['name'] as String,
|
||||
description: map['description'] as String?,
|
||||
description: map['description'] as String,
|
||||
members: members,
|
||||
createdAt: DateTime.parse(map['createdAt'] as String),
|
||||
);
|
||||
@@ -192,11 +192,11 @@ class DataTransferService {
|
||||
final List<Match> importedMatches = matchesJson.map((m) {
|
||||
final map = m as Map<String, dynamic>;
|
||||
|
||||
final String? gameId = map['gameId'] as String?;
|
||||
final String gameId = map['gameId'] as String;
|
||||
final String? groupId = map['groupId'] as String?;
|
||||
final List<String> playerIds = (map['playerIds'] as List<dynamic>? ?? []).cast<String>();
|
||||
|
||||
final game = (gameId == null) ? null : gameById[gameId];
|
||||
final game = gameById[gameId];
|
||||
final group = (groupId == null) ? null : groupById[groupId];
|
||||
final players = playerIds
|
||||
.map((id) => playerById[id])
|
||||
@@ -206,11 +206,11 @@ class DataTransferService {
|
||||
return Match(
|
||||
id: map['id'] as String,
|
||||
name: map['name'] as String,
|
||||
game: game,
|
||||
game: game ?? Game(name: 'Unknown', ruleset: Ruleset.singleWinner, description: '', color: '', icon: ''),
|
||||
group: group,
|
||||
players: players.isNotEmpty ? players : null,
|
||||
createdAt: DateTime.parse(map['createdAt'] as String),
|
||||
notes: map['notes'] as String?,
|
||||
notes: map['notes'] as String? ?? '',
|
||||
);
|
||||
}).toList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user