Files
Tracker/lib/models/user_profile.dart
2025-12-30 23:20:50 -06:00

281 lines
6.6 KiB
Dart

import 'package:hive/hive.dart';
part 'user_profile.g.dart';
/// User's relationship status
@HiveType(typeId: 0)
enum RelationshipStatus {
@HiveField(0)
single,
@HiveField(1)
engaged,
@HiveField(2)
married,
}
/// Fertility tracking goal for married users
@HiveType(typeId: 1)
enum FertilityGoal {
@HiveField(0)
tryingToConceive, // TTC
@HiveField(1)
tryingToAvoid, // TTA - NFP
@HiveField(2)
justTracking,
}
@HiveType(typeId: 9)
enum BibleTranslation {
@HiveField(0)
esv,
@HiveField(1)
niv,
@HiveField(2)
nkjv,
@HiveField(3)
nlt,
@HiveField(4)
nasb,
@HiveField(5)
kjv,
@HiveField(6)
msg,
}
@HiveType(typeId: 11)
enum AppThemeMode {
@HiveField(0)
system,
@HiveField(1)
light,
@HiveField(2)
dark,
}
/// User profile model
@HiveType(typeId: 2)
class UserProfile extends HiveObject {
@HiveField(0)
String id;
@HiveField(1)
String name;
@HiveField(2)
RelationshipStatus relationshipStatus;
@HiveField(3)
FertilityGoal? fertilityGoal;
@HiveField(4)
int averageCycleLength;
@HiveField(5)
int averagePeriodLength;
@HiveField(6)
DateTime? lastPeriodStartDate;
@HiveField(7)
bool notificationsEnabled;
@HiveField(8)
String? devotionalTime; // HH:mm format
@HiveField(9)
bool hasCompletedOnboarding;
@HiveField(10)
DateTime createdAt;
@HiveField(11)
DateTime updatedAt;
@HiveField(12)
String? partnerName; // For married users
@HiveField(14, defaultValue: UserRole.wife)
UserRole role;
@HiveField(15, defaultValue: false)
bool isIrregularCycle;
@HiveField(16, defaultValue: BibleTranslation.esv)
BibleTranslation bibleTranslation;
@HiveField(17)
List<String>? favoriteFoods;
@HiveField(18, defaultValue: false)
bool isDataShared;
@HiveField(19, defaultValue: AppThemeMode.system)
AppThemeMode themeMode;
@HiveField(20, defaultValue: '0xFFA8C5A8')
String accentColor;
// Sharing settings
@HiveField(21, defaultValue: true)
bool shareMoods;
@HiveField(22, defaultValue: true)
bool shareSymptoms;
@HiveField(23, defaultValue: true)
bool shareCravings;
@HiveField(24, defaultValue: true)
bool shareEnergyLevels;
@HiveField(25, defaultValue: true)
bool shareSleep;
@HiveField(26, defaultValue: true)
bool shareIntimacy;
UserProfile({
required this.id,
required this.name,
this.relationshipStatus = RelationshipStatus.single,
this.fertilityGoal,
this.averageCycleLength = 28,
this.averagePeriodLength = 5,
this.lastPeriodStartDate,
this.notificationsEnabled = true,
this.devotionalTime,
this.hasCompletedOnboarding = false,
required this.createdAt,
required this.updatedAt,
this.partnerName,
this.role = UserRole.wife,
this.isIrregularCycle = false,
this.bibleTranslation = BibleTranslation.esv,
this.favoriteFoods,
this.isDataShared = false,
this.themeMode = AppThemeMode.system,
this.accentColor = '0xFFA8C5A8',
this.shareMoods = true,
this.shareSymptoms = true,
this.shareCravings = true,
this.shareEnergyLevels = true,
this.shareSleep = true,
this.shareIntimacy = true,
});
/// Check if user is married
bool get isMarried => relationshipStatus == RelationshipStatus.married;
/// Check if user is trying to conceive
bool get isTTC => fertilityGoal == FertilityGoal.tryingToConceive;
/// Check if user is practicing NFP
bool get isNFP => fertilityGoal == FertilityGoal.tryingToAvoid;
/// Check if user is husband
bool get isHusband => role == UserRole.husband;
/// Should show fertility content
bool get showFertilityContent =>
!isHusband &&
isMarried &&
fertilityGoal != FertilityGoal.justTracking &&
fertilityGoal != null;
/// Should show intimacy recommendations
bool get showIntimacyContent => isMarried;
/// Copy with updated fields
UserProfile copyWith({
String? id,
String? name,
RelationshipStatus? relationshipStatus,
FertilityGoal? fertilityGoal,
int? averageCycleLength,
int? averagePeriodLength,
DateTime? lastPeriodStartDate,
bool? notificationsEnabled,
String? devotionalTime,
bool? hasCompletedOnboarding,
DateTime? createdAt,
DateTime? updatedAt,
String? partnerName,
UserRole? role,
bool? isIrregularCycle,
BibleTranslation? bibleTranslation,
List<String>? favoriteFoods,
bool? isDataShared,
AppThemeMode? themeMode,
String? accentColor,
bool? shareMoods,
bool? shareSymptoms,
bool? shareCravings,
bool? shareEnergyLevels,
bool? shareSleep,
bool? shareIntimacy,
}) {
return UserProfile(
id: id ?? this.id,
name: name ?? this.name,
relationshipStatus: relationshipStatus ?? this.relationshipStatus,
fertilityGoal: fertilityGoal ?? this.fertilityGoal,
averageCycleLength: averageCycleLength ?? this.averageCycleLength,
averagePeriodLength: averagePeriodLength ?? this.averagePeriodLength,
lastPeriodStartDate: lastPeriodStartDate ?? this.lastPeriodStartDate,
notificationsEnabled: notificationsEnabled ?? this.notificationsEnabled,
devotionalTime: devotionalTime ?? this.devotionalTime,
hasCompletedOnboarding:
hasCompletedOnboarding ?? this.hasCompletedOnboarding,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? DateTime.now(),
partnerName: partnerName ?? this.partnerName,
role: role ?? this.role,
isIrregularCycle: isIrregularCycle ?? this.isIrregularCycle,
bibleTranslation: bibleTranslation ?? this.bibleTranslation,
favoriteFoods: favoriteFoods ?? this.favoriteFoods,
isDataShared: isDataShared ?? this.isDataShared,
themeMode: themeMode ?? this.themeMode,
accentColor: accentColor ?? this.accentColor,
shareMoods: shareMoods ?? this.shareMoods,
shareSymptoms: shareSymptoms ?? this.shareSymptoms,
shareCravings: shareCravings ?? this.shareCravings,
shareEnergyLevels: shareEnergyLevels ?? this.shareEnergyLevels,
shareSleep: shareSleep ?? this.shareSleep,
shareIntimacy: shareIntimacy ?? this.shareIntimacy,
);
}
}
extension BibleTranslationExtension on BibleTranslation {
String get label {
switch (this) {
case BibleTranslation.esv:
return 'ESV';
case BibleTranslation.niv:
return 'NIV';
case BibleTranslation.nkjv:
return 'NKJV';
case BibleTranslation.nlt:
return 'NLT';
case BibleTranslation.nasb:
return 'NASB';
case BibleTranslation.kjv:
return 'KJV';
case BibleTranslation.msg:
return 'MSG';
}
}
}
@HiveType(typeId: 8)
enum UserRole {
@HiveField(0)
wife,
@HiveField(1)
husband,
}