[READ-ONLY] Mirror of https://github.com/probablykasper/notifier. Android app for scheduling notifications
android app flutter notifications
0

Configure Feed

Select the types of activity you want to include in your feed.

UI will show one-time notifications being disabled when they're fired

A loop that checks if any one-time notifications were fired, and if they were, make them be disabled

+31 -5
+30 -4
lib/models/list.dart
··· 33 33 return listOfItems; 34 34 } 35 35 36 - ListModel() { 36 + ListModel({bool checkForDisabledNotifications: false}) { 37 37 print('[notifier] ListModel constructor'); 38 - _load(); 38 + _load(checkForDisabledNotifications: checkForDisabledNotifications); 39 39 // initialize notification plugin: 40 40 flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); 41 41 var initializationSettingsAndroid = AndroidInitializationSettings('app_icon'); ··· 47 47 flutterLocalNotificationsPlugin.initialize(initializationSettings); 48 48 } 49 49 50 - _load() async { 50 + checkForDisabledNotifications() async { 51 + print('Starting checkForDisabledNotifications()'); 52 + Timer.periodic( 53 + Duration(milliseconds: 500), 54 + (timer) { 55 + bool changedWereMade = false; 56 + _notificationItems.forEach((id, notificationItem) { 57 + if (notificationItem['willDisable'] == true) { 58 + if (notificationItem['date'] < DateTime.now().millisecondsSinceEpoch) { 59 + notificationItem['status'] = 'disabled'; 60 + notificationItem['willDisable'] = false; 61 + changedWereMade = true; 62 + } 63 + } 64 + }); 65 + if (changedWereMade) { 66 + print('changedWereMade'); 67 + _save(); 68 + rebuild(); 69 + } 70 + }, 71 + ); 72 + } 73 + 74 + _load({bool checkForDisabledNotifications: false}) async { 51 75 print('[notifier] listModel _load()'); 52 76 SharedPreferences prefs = await SharedPreferences.getInstance(); 53 77 String notificationItems = prefs.getString('notificationItems') ?? '{}'; ··· 60 84 61 85 print('[notifier] ListModel _load'); 62 86 notifyListeners(); 87 + if (checkForDisabledNotifications) this.checkForDisabledNotifications(); 88 + rebuild(); 63 89 } 64 90 65 91 rebuild() async { ··· 157 183 } 158 184 159 185 setNotifications({@required bool appIsOpen}) async { 160 - print('[notifier] _setNotification'); 186 + print('[notifier] _setNotifications'); 161 187 162 188 var androidPlatformChannelSpecifics = AndroidNotificationDetails( 163 189 'scheduled_notifications',
+1 -1
lib/views/list.dart
··· 7 7 import 'package:scoped_model/scoped_model.dart'; 8 8 import 'package:notifier/models/list.dart'; 9 9 10 - ListModel listModel = ListModel(); 10 + ListModel listModel = ListModel(checkForDisabledNotifications: true); 11 11 12 12 class ListPage extends StatelessWidget { 13 13 @override