1.2.0 #6
+21
-4
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:alarm/utils/alarm_set.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -29,6 +30,7 @@ void main() async {
|
||||
|
||||
tz.initializeTimeZones();
|
||||
await Alarm.init();
|
||||
|
||||
runApp(const SunsetAlarmApp());
|
||||
}
|
||||
|
||||
@@ -93,13 +95,20 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
super.initState();
|
||||
_initNotifications();
|
||||
_loadPrefs();
|
||||
|
||||
// Reschedule alarm any time one goes off.
|
||||
Alarm.ringing.listen((AlarmSet alarmSet) {
|
||||
for (final alarm in alarmSet.alarms) {
|
||||
if (alarm.id == _alarmId) _scheduleAlarm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _initNotifications() async {
|
||||
const androidInit = AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||
const iosInit = DarwinInitializationSettings();
|
||||
const linuxInit = LinuxInitializationSettings(
|
||||
defaultActionName: 'Sunset Alarm',
|
||||
defaultActionName: 'Sunset Alarm ',
|
||||
);
|
||||
await _notifications.initialize(
|
||||
settings: const InitializationSettings(
|
||||
@@ -300,9 +309,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
androidScheduleMode: AndroidScheduleMode.alarmClock,
|
||||
);
|
||||
_showSnack('Alarm scheduled!');
|
||||
debugPrint('DEBUG: Alarm time: ${tzAlarm.toString()}');
|
||||
debugPrint('DEBUG: Current time: ${DateTime.now().toUtc().toString()}');
|
||||
debugPrint('DEBUG: ${_notifications.toString()}');
|
||||
_debug('Alarm time: ${tzAlarm.toString()}');
|
||||
_debug('Current time: ${DateTime.now().toUtc().toString()}');
|
||||
_debug('${_notifications.toString()}');
|
||||
}
|
||||
// End Notification Method ***/
|
||||
|
||||
@@ -366,6 +375,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg)));
|
||||
}
|
||||
|
||||
void _log(String tag, String msg) {
|
||||
debugPrint(tag + ": " + msg);
|
||||
}
|
||||
|
||||
void _debug(String msg) {
|
||||
_log("DEBUG", msg);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_savePrefs();
|
||||
|
||||
Reference in new issue
Block a user