summaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers')
-rw-r--r--lib/data/data_providers/app_provider.dart6
-rw-r--r--lib/data/data_providers/time_notifier.dart24
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/data/data_providers/app_provider.dart b/lib/data/data_providers/app_provider.dart
index c528a1a..80416a4 100644
--- a/lib/data/data_providers/app_provider.dart
+++ b/lib/data/data_providers/app_provider.dart
@@ -1,6 +1,7 @@
import 'package:flutter_ics_homescreen/data/data_providers/datetime_notifier.dart';
import 'package:flutter_ics_homescreen/data/data_providers/hybrid_notifier.dart';
import 'package:flutter_ics_homescreen/data/data_providers/signal_notifier.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/time_notifier.dart';
import 'package:flutter_ics_homescreen/data/data_providers/units_notifier.dart';
import 'package:flutter_ics_homescreen/data/data_providers/audio_notifier.dart';
import 'package:flutter_ics_homescreen/data/data_providers/users_notifier.dart';
@@ -61,3 +62,8 @@ final dateTimeStateProvider =
final hybridtateProvider = StateNotifierProvider<HybridNotifier, Hybrid>((ref) {
return HybridNotifier(const Hybrid.initial());
});
+
+final currentTimeProvider =
+ StateNotifierProvider<CurrentTimeNotifier, DateTime>((ref) {
+ return CurrentTimeNotifier();
+});
diff --git a/lib/data/data_providers/time_notifier.dart b/lib/data/data_providers/time_notifier.dart
new file mode 100644
index 0000000..9737b2b
--- /dev/null
+++ b/lib/data/data_providers/time_notifier.dart
@@ -0,0 +1,24 @@
+import 'dart:async';
+
+import 'package:flutter_ics_homescreen/export.dart';
+
+class CurrentTimeNotifier extends StateNotifier<DateTime> {
+ CurrentTimeNotifier() : super(DateTime.now()) {
+ if (!_hasInitialized) {
+ _initializeTimer();
+ _hasInitialized = true;
+ }
+ }
+
+ bool _hasInitialized = false;
+
+ void _initializeTimer() {
+ Timer.periodic(const Duration(seconds: 1), (timer) {
+ state = state.add(const Duration(seconds: 1));
+ });
+ }
+
+ void setCurrentTime(DateTime newTime) {
+ state = newTime;
+ }
+}