add support for badges and notifications, adjust nav pages
All checks were successful
All checks were successful
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user