checkpoint: focus seed 1.0.1 localized dev switch
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import '../core/date_keys.dart';
|
||||
import 'app_state.dart';
|
||||
import 'growth_stage.dart';
|
||||
|
||||
class TodayProgress {
|
||||
const TodayProgress({
|
||||
required this.dateKey,
|
||||
required this.intention,
|
||||
required this.focusMinutes,
|
||||
required this.completedHabits,
|
||||
required this.totalHabits,
|
||||
required this.hasReflection,
|
||||
required this.growthStage,
|
||||
});
|
||||
|
||||
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),
|
||||
growthStage: growthStageFor(state, dateKey),
|
||||
);
|
||||
}
|
||||
|
||||
final String dateKey;
|
||||
final String intention;
|
||||
final int focusMinutes;
|
||||
final int completedHabits;
|
||||
final int totalHabits;
|
||||
final bool hasReflection;
|
||||
final GrowthStage growthStage;
|
||||
|
||||
bool get hasIntention => intention.isNotEmpty;
|
||||
bool get hasFocus => focusMinutes > 0;
|
||||
bool get hasHabits => completedHabits > 0;
|
||||
int get completedSteps =>
|
||||
[
|
||||
hasIntention,
|
||||
hasFocus,
|
||||
hasHabits,
|
||||
hasReflection,
|
||||
].where((complete) => complete).length;
|
||||
}
|
||||
Reference in New Issue
Block a user