import '../core/date_keys.dart'; import 'app_state.dart'; class TodayProgress { const TodayProgress({ required this.dateKey, required this.intention, required this.focusMinutes, required this.completedHabits, required this.totalHabits, required this.hasReflection, }); factory TodayProgress.fromState(AppState state, String dateKey) { return TodayProgress( dateKey: dateKey, intention: state.activeAnchor(dateKey), focusMinutes: minutesForDate(state.sessions, dateKey), completedHabits: state.habits .where((habit) => habit.completedDates.contains(dateKey)) .length, totalHabits: state.habits.length, hasReflection: state.reflections.any((entry) => entry.dateKey == dateKey) || state.progressNotes.any( (entry) => entry.dateKey == dateKey && entry.hasContent, ), ); } final String dateKey; final String intention; final int focusMinutes; final int completedHabits; final int totalHabits; final bool hasReflection; bool get hasIntention => intention.isNotEmpty; bool get hasFocus => focusMinutes > 0; bool get hasHabits => completedHabits > 0; bool get isLoopClosed => hasIntention && hasFocus && hasReflection; int get completedSteps => [ hasIntention, hasFocus, hasReflection, ].where((complete) => complete).length; }