feat: Implement husband features and fix iOS Safari web startup
Implement initial features for husband's companion app, including mock data service and husband notes screen. Refactor scripture and cycle services for improved stability and testability. Address iOS Safari web app startup issue by removing deprecated initialization. - Implemented MockDataService and HusbandNotesScreen. - Converted _DashboardTab and DevotionalScreen to StatefulWidgets for robust scripture provider initialization. - Refactored CycleService to use immutable CycleInfo class, reducing UI rebuilds. - Removed deprecated window.flutterConfiguration from index.html, resolving Flutter web app startup failure on iOS Safari. - Updated and fixed related tests.
This commit is contained in:
@@ -1,16 +1,47 @@
|
||||
import '../models/user_profile.dart';
|
||||
import '../models/cycle_entry.dart';
|
||||
|
||||
class CycleInfo {
|
||||
final CyclePhase phase;
|
||||
final int dayOfCycle;
|
||||
final int daysUntilPeriod;
|
||||
final bool isPeriodExpected;
|
||||
|
||||
CycleInfo({
|
||||
required this.phase,
|
||||
required this.dayOfCycle,
|
||||
required this.daysUntilPeriod,
|
||||
required this.isPeriodExpected,
|
||||
});
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is CycleInfo &&
|
||||
runtimeType == other.runtimeType &&
|
||||
phase == other.phase &&
|
||||
dayOfCycle == other.dayOfCycle &&
|
||||
daysUntilPeriod == other.daysUntilPeriod &&
|
||||
isPeriodExpected == other.isPeriodExpected;
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
phase.hashCode ^
|
||||
dayOfCycle.hashCode ^
|
||||
daysUntilPeriod.hashCode ^
|
||||
isPeriodExpected.hashCode;
|
||||
}
|
||||
|
||||
class CycleService {
|
||||
/// Calculates the current cycle information based on user profile
|
||||
static Map<String, dynamic> calculateCycleInfo(UserProfile? user) {
|
||||
static CycleInfo calculateCycleInfo(UserProfile? user) {
|
||||
if (user?.lastPeriodStartDate == null) {
|
||||
return {
|
||||
'phase': CyclePhase.follicular,
|
||||
'dayOfCycle': 1,
|
||||
'daysUntilPeriod': user?.averageCycleLength ?? 28,
|
||||
'isPeriodExpected': false,
|
||||
};
|
||||
return CycleInfo(
|
||||
phase: CyclePhase.follicular,
|
||||
dayOfCycle: 1,
|
||||
daysUntilPeriod: user?.averageCycleLength ?? 28,
|
||||
isPeriodExpected: false,
|
||||
);
|
||||
}
|
||||
|
||||
final lastPeriod = user!.lastPeriodStartDate!;
|
||||
@@ -38,12 +69,12 @@ class CycleService {
|
||||
phase = CyclePhase.luteal;
|
||||
}
|
||||
|
||||
return {
|
||||
'phase': phase,
|
||||
'dayOfCycle': dayOfCycle,
|
||||
'daysUntilPeriod': daysUntilPeriod,
|
||||
'isPeriodExpected': daysUntilPeriod <= 0 || dayOfCycle <= 5,
|
||||
};
|
||||
return CycleInfo(
|
||||
phase: phase,
|
||||
dayOfCycle: dayOfCycle,
|
||||
daysUntilPeriod: daysUntilPeriod,
|
||||
isPeriodExpected: daysUntilPeriod <= 0 || dayOfCycle <= 5,
|
||||
);
|
||||
}
|
||||
|
||||
/// Format cycle day for display
|
||||
|
||||
Reference in New Issue
Block a user