164 lines
3.9 KiB
Dart
164 lines
3.9 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,
|
|
}
|
|
|
|
/// 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;
|
|
|
|
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,
|
|
});
|
|
|
|
/// 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,
|
|
}) {
|
|
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,
|
|
);
|
|
}
|
|
}
|
|
|
|
@HiveType(typeId: 8)
|
|
enum UserRole {
|
|
@HiveField(0)
|
|
wife,
|
|
@HiveField(1)
|
|
husband,
|
|
}
|