summaryrefslogtreecommitdiff
path: root/lib/data.dart
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-01-10 21:37:51 +0100
committerxengineering <me@xengineering.eu>2026-01-10 21:37:51 +0100
commitf8cf9dc0a8b7e67e4c0f7e2d40b0b4ab26a5ed0a (patch)
tree27155a68df1f20bbb4c25a4a86c1c5392bd32e89 /lib/data.dart
parentee38d5671e0d6b8d0e1d3708a37b43a65682329f (diff)
downloadsia-app-f8cf9dc0a8b7e67e4c0f7e2d40b0b4ab26a5ed0a.tar
sia-app-f8cf9dc0a8b7e67e4c0f7e2d40b0b4ab26a5ed0a.tar.zst
sia-app-f8cf9dc0a8b7e67e4c0f7e2d40b0b4ab26a5ed0a.zip
Re-introduce timer-based state toggling
This is now done with the refactored code organization and a strict UI / data split.
Diffstat (limited to 'lib/data.dart')
-rw-r--r--lib/data.dart25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/data.dart b/lib/data.dart
index 5cd59ec..4091bb3 100644
--- a/lib/data.dart
+++ b/lib/data.dart
@@ -1,3 +1,5 @@
+import 'dart:async';
+
import 'package:flutter/foundation.dart';
class AppState with ChangeNotifier {
@@ -7,6 +9,29 @@ class AppState with ChangeNotifier {
Contact(address: "Back Door", isOpen: false),
Contact(address: "Garage Window", isOpen: true),
];
+
+ Timer? _timer;
+
+ AppState() {
+ _timer = Timer.periodic(const Duration(seconds: 1), (_) {
+ toggleFirstContact();
+ });
+ }
+
+ void toggleFirstContact() {
+ if (contacts.isEmpty) {
+ return;
+ }
+
+ contacts[0].isOpen = !contacts[0].isOpen;
+ notifyListeners();
+ }
+
+ @override
+ void dispose() {
+ _timer?.cancel();
+ super.dispose();
+ }
}
class Contact {