New
This commit is contained in:
@@ -26,12 +26,29 @@ class UserProfileNotifier extends StateNotifier<UserProfile?> {
|
||||
state = profile;
|
||||
}
|
||||
|
||||
Future<void> updateThemeMode(AppThemeMode themeMode) async {
|
||||
if (state != null) {
|
||||
await updateProfile(state!.copyWith(themeMode: themeMode));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateAccentColor(String accentColor) async {
|
||||
if (state != null) {
|
||||
await updateProfile(state!.copyWith(accentColor: accentColor));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateRelationshipStatus(RelationshipStatus relationshipStatus) async {
|
||||
if (state != null) {
|
||||
await updateProfile(state!.copyWith(relationshipStatus: relationshipStatus));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> clearProfile() async {
|
||||
final box = Hive.box<UserProfile>('user_profile');
|
||||
await box.clear();
|
||||
state = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Provider for cycle entries
|
||||
final cycleEntriesProvider = StateNotifierProvider<CycleEntriesNotifier, List<CycleEntry>>((ref) {
|
||||
@@ -67,6 +84,18 @@ class CycleEntriesNotifier extends StateNotifier<List<CycleEntry>> {
|
||||
_loadEntries();
|
||||
}
|
||||
|
||||
Future<void> deleteEntriesForMonth(int year, int month) async {
|
||||
final box = Hive.box<CycleEntry>('cycle_entries');
|
||||
final keysToDelete = <dynamic>[];
|
||||
for (var entry in box.values) {
|
||||
if (entry.date.year == year && entry.date.month == month) {
|
||||
keysToDelete.add(entry.key);
|
||||
}
|
||||
}
|
||||
await box.deleteAll(keysToDelete);
|
||||
_loadEntries();
|
||||
}
|
||||
|
||||
Future<void> clearEntries() async {
|
||||
final box = Hive.box<CycleEntry>('cycle_entries');
|
||||
await box.clear();
|
||||
|
||||
Reference in New Issue
Block a user