mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-11 22:53:51 +01:00
Both platforms gain a calendar tab/screen (green/yellow/red/not-logged day coloring, logging/adherence streaks, year-to-date tally), and tapping a day drills into that day's logged entries. This requires the daily budget to become a normal, freely-editable value synced between devices like the food log — replaces the previous chattr +i seal (deliberately, per user decision) with plain last-edit-wins sync via a new budget.json alongside food_log.json. The budget field defaults to 2200 kcal, starts read-only, and unlocks via an Edit/Save toggle on both the PC gate's History tab and the phone app's Calendar screen. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dHac1iYQKTMZEtL7xDJvA
58 lines
1.5 KiB
Dart
58 lines
1.5 KiB
Dart
/// Per-day budget-adherence status and year-to-date tally value types.
|
|
library;
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
/// Qualitative per-day budget-adherence state, worst to best.
|
|
///
|
|
/// Kept in sync with `diet_guard/_daystatus.py`'s `DayStatus`: not-logged is
|
|
/// considered worse than red, since an unlogged day carries no information
|
|
/// about whether it went well or badly.
|
|
enum DayStatus {
|
|
/// No valid, non-tombstoned entries were logged for the day.
|
|
notLogged,
|
|
|
|
/// Logged, and more than 20% over budget.
|
|
red,
|
|
|
|
/// Logged, and up to 20% over budget.
|
|
yellow,
|
|
|
|
/// Logged, and at or under budget.
|
|
green,
|
|
}
|
|
|
|
/// Year-to-date logging/adherence counts.
|
|
@immutable
|
|
class YtdTally {
|
|
/// Creates a tally from its three component counts.
|
|
const YtdTally({
|
|
required this.loggedDays,
|
|
required this.elapsedDays,
|
|
required this.adherentDays,
|
|
});
|
|
|
|
/// Days this year with at least one valid log entry.
|
|
final int loggedDays;
|
|
|
|
/// Days from Jan 1 through the reference date, inclusive.
|
|
final int elapsedDays;
|
|
|
|
/// Of [loggedDays], how many were green or yellow.
|
|
final int adherentDays;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is YtdTally &&
|
|
other.loggedDays == loggedDays &&
|
|
other.elapsedDays == elapsedDays &&
|
|
other.adherentDays == adherentDays;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(loggedDays, elapsedDays, adherentDays);
|
|
|
|
@override
|
|
String toString() =>
|
|
'YtdTally(logged: $loggedDays/$elapsedDays, adherent: $adherentDays)';
|
|
}
|