diff --git a/lib/providers/sync_notification_provider.dart b/lib/providers/sync_notification_provider.dart new file mode 100644 index 0000000..ded1d66 --- /dev/null +++ b/lib/providers/sync_notification_provider.dart @@ -0,0 +1,43 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +class SyncNotificationState { + final bool hasNewLogData; + final bool hasNewPrayerData; + + const SyncNotificationState({ + this.hasNewLogData = false, + this.hasNewPrayerData = false, + }); + + SyncNotificationState copyWith({ + bool? hasNewLogData, + bool? hasNewPrayerData, + }) { + return SyncNotificationState( + hasNewLogData: hasNewLogData ?? this.hasNewLogData, + hasNewPrayerData: hasNewPrayerData ?? this.hasNewPrayerData, + ); + } +} + +class SyncNotificationNotifier extends StateNotifier { + SyncNotificationNotifier() : super(const SyncNotificationState()); + + void setHasNewLogData(bool value) { + if (state.hasNewLogData != value) { + state = state.copyWith(hasNewLogData: value); + } + } + + void setHasNewPrayerData(bool value) { + if (state.hasNewPrayerData != value) { + state = state.copyWith(hasNewPrayerData: value); + } + } +} + +final syncNotificationProvider = + StateNotifierProvider( + (ref) { + return SyncNotificationNotifier(); +});