diff --git a/lib/alarm/data/alarm_settings_schema.dart b/lib/alarm/data/alarm_settings_schema.dart index 84e19fe0..46928399 100644 --- a/lib/alarm/data/alarm_settings_schema.dart +++ b/lib/alarm/data/alarm_settings_schema.dart @@ -121,7 +121,7 @@ SettingGroup alarmSettingsSchema = SettingGroup( DateTimeSetting( "Date Range", (context) => AppLocalizations.of(context)!.alarmRangeSetting, - [], + [DateTime.now(), DateTime.now().add(const Duration(days: 2))], rangeOnly: true, enableConditions: [ ValueCondition(["Type"], (value) => value == RangeAlarmSchedule) diff --git a/lib/alarm/types/schedules/range_alarm_schedule.dart b/lib/alarm/types/schedules/range_alarm_schedule.dart index 8af5bd44..e5b00105 100644 --- a/lib/alarm/types/schedules/range_alarm_schedule.dart +++ b/lib/alarm/types/schedules/range_alarm_schedule.dart @@ -10,7 +10,7 @@ class RangeAlarmSchedule extends AlarmSchedule { late final AlarmRunner _alarmRunner; late final DateTimeSetting _datesRangeSetting; late final SelectSetting _intervalSetting; - bool _isFinished = true; + bool _isFinished = false; RangeInterval get interval => _intervalSetting.value; DateTime get startDate => _datesRangeSetting.value.first; @@ -42,21 +42,23 @@ class RangeAlarmSchedule extends AlarmSchedule { } @override - Future schedule(Time time,String description) async { + Future schedule(Time time, String description) async { // All the dates are not scheduled at once // Instead we schedule the next date after the current one is finished DateTime alarmDate = getDailyAlarmDate(time, scheduledDate: startDate); - if (alarmDate.day <= endDate.day) { - await _alarmRunner.schedule(alarmDate,description); - _isFinished = false; - } else { + print('$alarmDate $startDate $endDate'); + if (alarmDate.isAfter(endDate)) { _isFinished = true; + } else { + print("_____________"); + await _alarmRunner.schedule(alarmDate, description); + _isFinished = false; } } @override - Future cancel()async { + Future cancel() async { await _alarmRunner.cancel(); } diff --git a/lib/common/widgets/fields/date_picker_field.dart b/lib/common/widgets/fields/date_picker_field.dart index 1d8a7681..04d89d94 100644 --- a/lib/common/widgets/fields/date_picker_field.dart +++ b/lib/common/widgets/fields/date_picker_field.dart @@ -7,13 +7,13 @@ import 'package:intl/intl.dart'; class DatePickerField extends StatefulWidget { const DatePickerField({ - Key? key, + super.key, required this.title, this.description, required this.onChanged, required this.value, this.rangeOnly = false, - }) : super(key: key); + }); final List value; final String title;