Files
GroundedHelper/frontend/lib/Grounded/about/external/data/GroupMember.dart
alvocool 1b5d105400 Show real photos for people instead of scene art
Your avatar is your photo, picked from the device by tapping it on Home or
from a new Profile photo row in Settings, shrunk to 256 px and kept on the
phone (there is no upload endpoint yet). Group members show the photo the
server sends in a new `photo` field, everywhere avatars appear. Without a
photo, an initial on a neutral disc. Mock mode bundles free Unsplash
portraits for the sample people.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
2026-11-09 08:22:41 +03:00

71 lines
1.6 KiB
Dart

/// Someone in a group, with the numbers the leaderboard ranks on.
class GroupMember {
String id;
String name;
/// Their profile photo (URL), or empty for none.
String photo;
/// "Owner" or "Member".
String role;
/// Share of their own commitments kept over the last seven days, 0..1.
double keptRate;
/// Kept days in a row.
int streak;
/// Their standing name — Good, Warned, Grounded, Lockdown.
String standing;
DateTime? lastCheckIn;
/// True for the signed-in user.
bool me;
GroupMember({
this.id = "",
this.name = "",
this.photo = "",
this.role = "Member",
this.keptRate = 0,
this.streak = 0,
this.standing = "Good",
this.lastCheckIn,
this.me = false,
});
bool get owner => role == "Owner";
factory GroupMember.fromJson(Map<String, dynamic> json) {
return GroupMember(
id: json['id'] ?? "",
name: json['name'] ?? "",
photo: json['photo'] ?? "",
role: json['role'] ?? "Member",
keptRate: (json['keptRate'] ?? 0).toDouble(),
streak: json['streak'] ?? 0,
standing: json['standing'] ?? "Good",
lastCheckIn: json['lastCheckIn'] == null
? null
: DateTime.tryParse(json['lastCheckIn']),
me: json['me'] ?? false,
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['name'] = name;
data['photo'] = photo;
data['role'] = role;
data['keptRate'] = keptRate;
data['streak'] = streak;
data['standing'] = standing;
data['lastCheckIn'] = lastCheckIn?.toIso8601String();
data['me'] = me;
return data;
}
}