add support for badges and notifications, adjust nav pages
All checks were successful
Release / meta (push) Successful in 7s
Release / linux-build (push) Successful in 6m49s
Release / android-build (push) Successful in 15m55s
Release / release-master (push) Successful in 24s
Release / release-dev (push) Successful in 26s

This commit is contained in:
2025-12-26 18:36:37 +00:00
parent 44d79e7c28
commit 4bd6f0bbed
16 changed files with 1161 additions and 144 deletions

View File

@@ -750,3 +750,80 @@ class EventField {
);
}
}
class UserNotification {
final int id;
final String title;
final String body;
final DateTime? createdAt;
final bool dismissed;
UserNotification({
required this.id,
required this.title,
required this.body,
required this.createdAt,
required this.dismissed,
});
factory UserNotification.fromJson(Map<String, dynamic> json) {
final created = json['created_at'] ?? json['createdAt'];
DateTime? createdAt;
if (created is String) {
createdAt = DateTime.tryParse(created);
} else if (created is DateTime) {
createdAt = created;
}
return UserNotification(
id: _asInt(json['notification_id'] ?? json['id']),
title: _asString(json['title']),
body: _asString(json['body']),
createdAt: createdAt,
dismissed: _asBool(json['dismissed'] ?? false, false),
);
}
}
class BadgeAward {
final int id;
final int badgeId;
final String badgeCode;
final String badgeTier;
final String? scopeValue;
final DateTime? awardedAt;
final LocoSummary? loco;
BadgeAward({
required this.id,
required this.badgeId,
required this.badgeCode,
required this.badgeTier,
this.scopeValue,
this.awardedAt,
this.loco,
});
factory BadgeAward.fromJson(Map<String, dynamic> json) {
final awarded = json['awarded_at'] ?? json['awardedAt'];
DateTime? awardedAt;
if (awarded is String) {
awardedAt = DateTime.tryParse(awarded);
} else if (awarded is DateTime) {
awardedAt = awarded;
}
final locoJson = json['loco'];
LocoSummary? loco;
if (locoJson is Map<String, dynamic>) {
loco = LocoSummary.fromJson(Map<String, dynamic>.from(locoJson));
}
return BadgeAward(
id: _asInt(json['award_id'] ?? json['id']),
badgeId: _asInt(json['badge_id'] ?? 0),
badgeCode: _asString(json['badge_code']),
badgeTier: _asString(json['badge_tier']),
scopeValue: _asString(json['scope_value']),
awardedAt: awardedAt,
loco: loco,
);
}
}