Rebuild Home around a forest header with streak, score and water
Home now opens on a deep green header: greeting, a Today / Weekly toggle, a seven-day streak with a leaf on every kept day, minutes held with a + ring, plan thumbnails, the report-card letter as the score, and one bar per commitment class (weekly view swaps in per-day bars and class rates). The + opens an "Add to today" sheet over the blurred day. A water tracker sits below the header, kept on the device. The nav marks the selected tab as a filled block and drops the side action button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import '../../about/external/data/Commitment.dart';
|
||||
import '../../about/external/data/ExcuseCluster.dart';
|
||||
import '../../about/external/data/ReportCard.dart';
|
||||
import '../../about/external/data/RoutineChain.dart';
|
||||
import '../../about/external/data/pages/request/CommitmentsRequest.dart';
|
||||
import '../../about/external/data/pages/request/HistoryRequest.dart';
|
||||
@@ -34,9 +35,40 @@ class ViewHome extends ParentViewModel {
|
||||
|
||||
loadTodos();
|
||||
|
||||
loadWater();
|
||||
|
||||
loadWeek();
|
||||
|
||||
loadPlan();
|
||||
}
|
||||
|
||||
/// The last seven days. Quiet on failure: the header falls back to today.
|
||||
void loadWeek() async {
|
||||
try {
|
||||
final DateTime now = DateTime.now();
|
||||
final DateTime start = DateTime(now.year, now.month, now.day)
|
||||
.subtract(const Duration(days: 6));
|
||||
|
||||
final response =
|
||||
await getDataManager().getWeeklyReportCard(ReportCardRequest(
|
||||
periodStart: start.toIso8601String(),
|
||||
periodEnd: now.toIso8601String(),
|
||||
));
|
||||
|
||||
connection.onWeekLoaded(ReportCard.fromJson(response.data));
|
||||
} catch (e) {
|
||||
connection.onWeekLoaded(null);
|
||||
}
|
||||
}
|
||||
|
||||
void loadWater() async {
|
||||
connection.onWaterLoaded(await getDataManager().getWaterToday());
|
||||
}
|
||||
|
||||
void saveWater(int ml) async {
|
||||
await getDataManager().setWaterToday(ml);
|
||||
}
|
||||
|
||||
void loadTodos() async {
|
||||
connection.onTodosLoaded(await getDataManager().getTodos());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user