Groups let people keep each other honest: create one or join with a six-letter invite code. Each group has shared goals split into measurable objectives (km, sessions, words) that every member logs toward, a leaderboard of kept rate and streak with nudges, and a group chat where check-ins and nudges appear as cards beside the talk. The open chat polls for new messages. Reached from a new Groups tab (Training moves into the day rail), a Home "Your groups" rail that opens the chat, and a Group tile in the add sheet. Mock mode seeds two groups, a joinable one and members who reply. The water tracker is removed; it did not fit the app. Bottom sheets are now square app-wide via the theme. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
59 lines
1.3 KiB
Dart
59 lines
1.3 KiB
Dart
/// One measurable part of a shared goal — "Run 100 km", "20 sessions" — that
|
|
/// every member logs toward.
|
|
class GroupObjective {
|
|
String id;
|
|
|
|
String title;
|
|
|
|
/// km, sessions, pages, hours…
|
|
String unit;
|
|
|
|
double target;
|
|
|
|
/// The group's total so far.
|
|
double current;
|
|
|
|
/// What the signed-in user has put in.
|
|
double mine;
|
|
|
|
GroupObjective({
|
|
this.id = "",
|
|
this.title = "",
|
|
this.unit = "",
|
|
this.target = 0,
|
|
this.current = 0,
|
|
this.mine = 0,
|
|
});
|
|
|
|
double get progress {
|
|
if (target <= 0) {
|
|
return 0;
|
|
}
|
|
return (current / target).clamp(0.0, 1.0);
|
|
}
|
|
|
|
bool get complete => target > 0 && current >= target;
|
|
|
|
factory GroupObjective.fromJson(Map<String, dynamic> json) {
|
|
return GroupObjective(
|
|
id: json['id'] ?? "",
|
|
title: json['title'] ?? "",
|
|
unit: json['unit'] ?? "",
|
|
target: (json['target'] ?? 0).toDouble(),
|
|
current: (json['current'] ?? 0).toDouble(),
|
|
mine: (json['mine'] ?? 0).toDouble(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['id'] = id;
|
|
data['title'] = title;
|
|
data['unit'] = unit;
|
|
data['target'] = target;
|
|
data['current'] = current;
|
|
data['mine'] = mine;
|
|
return data;
|
|
}
|
|
}
|