Files
Tracker/lib/providers/sync_notification_provider.dart
2026-01-10 12:50:52 -06:00

44 lines
1.1 KiB
Dart

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<SyncNotificationState> {
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<SyncNotificationNotifier, SyncNotificationState>(
(ref) {
return SyncNotificationNotifier();
});