This commit is contained in:
2025-12-30 23:20:50 -06:00
parent 9f8eab4a31
commit ec923c906e
26 changed files with 2234 additions and 53 deletions

View File

@@ -46,6 +46,16 @@ enum BibleTranslation {
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 {
@@ -103,6 +113,31 @@ class UserProfile extends HiveObject {
@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,
@@ -122,6 +157,14 @@ class UserProfile extends HiveObject {
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
@@ -166,6 +209,14 @@ class UserProfile extends HiveObject {
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,
@@ -187,6 +238,14 @@ class UserProfile extends HiveObject {
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,
);
}
}

View File

@@ -37,13 +37,22 @@ class UserProfileAdapter extends TypeAdapter<UserProfile> {
: fields[16] as BibleTranslation,
favoriteFoods: (fields[17] as List?)?.cast<String>(),
isDataShared: fields[18] == null ? false : fields[18] as bool,
themeMode:
fields[19] == null ? AppThemeMode.system : fields[19] as AppThemeMode,
accentColor: fields[20] == null ? '0xFFA8C5A8' : fields[20] as String,
shareMoods: fields[21] == null ? true : fields[21] as bool,
shareSymptoms: fields[22] == null ? true : fields[22] as bool,
shareCravings: fields[23] == null ? true : fields[23] as bool,
shareEnergyLevels: fields[24] == null ? true : fields[24] as bool,
shareSleep: fields[25] == null ? true : fields[25] as bool,
shareIntimacy: fields[26] == null ? true : fields[26] as bool,
);
}
@override
void write(BinaryWriter writer, UserProfile obj) {
writer
..writeByte(18)
..writeByte(26)
..writeByte(0)
..write(obj.id)
..writeByte(1)
@@ -79,7 +88,23 @@ class UserProfileAdapter extends TypeAdapter<UserProfile> {
..writeByte(17)
..write(obj.favoriteFoods)
..writeByte(18)
..write(obj.isDataShared);
..write(obj.isDataShared)
..writeByte(19)
..write(obj.themeMode)
..writeByte(20)
..write(obj.accentColor)
..writeByte(21)
..write(obj.shareMoods)
..writeByte(22)
..write(obj.shareSymptoms)
..writeByte(23)
..write(obj.shareCravings)
..writeByte(24)
..write(obj.shareEnergyLevels)
..writeByte(25)
..write(obj.shareSleep)
..writeByte(26)
..write(obj.shareIntimacy);
}
@override
@@ -245,6 +270,50 @@ class BibleTranslationAdapter extends TypeAdapter<BibleTranslation> {
typeId == other.typeId;
}
class AppThemeModeAdapter extends TypeAdapter<AppThemeMode> {
@override
final int typeId = 11;
@override
AppThemeMode read(BinaryReader reader) {
switch (reader.readByte()) {
case 0:
return AppThemeMode.system;
case 1:
return AppThemeMode.light;
case 2:
return AppThemeMode.dark;
default:
return AppThemeMode.system;
}
}
@override
void write(BinaryWriter writer, AppThemeMode obj) {
switch (obj) {
case AppThemeMode.system:
writer.writeByte(0);
break;
case AppThemeMode.light:
writer.writeByte(1);
break;
case AppThemeMode.dark:
writer.writeByte(2);
break;
}
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is AppThemeModeAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class UserRoleAdapter extends TypeAdapter<UserRole> {
@override
final int typeId = 8;