Files
Tracker/lib/services/mock_data_service.dart
Sterlen b4b2bfe749 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.
2025-12-26 22:40:52 -06:00

99 lines
3.3 KiB
Dart

import 'dart:math';
import 'package:uuid/uuid.dart';
import '../models/cycle_entry.dart';
import '../models/user_profile.dart';
class MockDataService {
final Random _random = Random();
final Uuid _uuid = const Uuid();
UserProfile generateMockWifeProfile() {
return UserProfile(
id: _uuid.v4(),
name: 'Sarah',
relationshipStatus: RelationshipStatus.married,
averageCycleLength: 29,
averagePeriodLength: 5,
lastPeriodStartDate: DateTime.now().subtract(const Duration(days: 10)),
favoriteFoods: ['Chocolate', 'Ice Cream', 'Berries'],
isDataShared: true,
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
);
}
List<CycleEntry> generateMockCycleEntries({
int days = 90,
int cycleLength = 28,
int periodLength = 5,
}) {
final List<CycleEntry> entries = [];
final DateTime today = DateTime.now();
for (int i = 0; i < days; i++) {
final DateTime date = today.subtract(Duration(days: i));
final int dayOfCycle = (cycleLength - (i % cycleLength)) % cycleLength;
bool isPeriodDay = dayOfCycle < periodLength;
FlowIntensity? flow;
if (isPeriodDay) {
if (dayOfCycle < 2) {
flow = FlowIntensity.heavy;
} else if (dayOfCycle < 4) {
flow = FlowIntensity.medium;
} else {
flow = FlowIntensity.light;
}
}
final entry = CycleEntry(
id: _uuid.v4(),
date: date,
isPeriodDay: isPeriodDay,
flowIntensity: flow,
mood: MoodLevel.values[_random.nextInt(MoodLevel.values.length)],
energyLevel: _random.nextInt(5) + 1,
crampIntensity: isPeriodDay && _random.nextBool() ? _random.nextInt(4) + 1 : 0,
hasHeadache: !isPeriodDay && _random.nextDouble() < 0.2,
hasBloating: !isPeriodDay && _random.nextDouble() < 0.3,
hasBreastTenderness: dayOfCycle > 20 && _random.nextDouble() < 0.4,
hasFatigue: _random.nextDouble() < 0.3,
hasAcne: dayOfCycle > 18 && _random.nextDouble() < 0.25,
hasLowerBackPain: isPeriodDay && _random.nextDouble() < 0.4,
stressLevel: _random.nextInt(5) + 1,
notes: _getNoteForDay(dayOfCycle, cycleLength),
husbandNotes: _getHusbandNoteForDay(dayOfCycle),
createdAt: date,
updatedAt: date,
);
entries.add(entry);
}
return entries.reversed.toList();
}
String? _getNoteForDay(int dayOfCycle, int cycleLength) {
if (_random.nextDouble() < 0.3) { // 30% chance of having a note
if (dayOfCycle < 5) {
return "Feeling a bit tired and crampy today. Taking it easy.";
} else if (dayOfCycle > 10 && dayOfCycle < 16) {
return "Feeling energetic and positive! Productive day at work.";
} else if (dayOfCycle > cycleLength - 7) {
return "A bit irritable today, craving some chocolate.";
} else {
return "Just a regular day. Nothing much to report.";
}
}
return null;
}
String? _getHusbandNoteForDay(int dayOfCycle) {
if (_random.nextDouble() < 0.2) { // 20% chance of husband note
if (dayOfCycle < 5) {
return "She seems to be in a bit of pain. I'll make her some tea.";
} else if (dayOfCycle > 22) {
return "She mentioned feeling a little down. Extra hugs tonight.";
}
}
return null;
}
}