Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/alarm/logic/alarm_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ void stopTimer(int scheduleId, AlarmStopAction action) async {
RingtonePlayer.playAlarm(alarm);
}
}
// One-shot timer: delete from storage on dismiss
if (timer.shouldDeleteAfterFinishing) {
List<ClockTimer> timers = await loadList("timers");
timers.removeWhere((t) => t.id == scheduleId);
await saveList("timers", timers);
// Notify UI isolate that timers list changed
SendPort? updatePort = IsolateNameServer.lookupPortByName(updatePortName);
updatePort?.send("updateTimers");
}
}
RingingManager.stopAllTimers();
}
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@
"@startMelodyAtRandomPosDescription": {},
"vibrationSetting": "Vibration",
"@vibrationSetting": {},
"timerDeleteAfterFinishingSetting": "Delete After Finishing",
"@timerDeleteAfterFinishingSetting": {},
"audioChannelSetting": "Audio Channel",
"@audioChannelSetting": {},
"audioChannelAlarm": "Alarm",
Expand Down
2 changes: 2 additions & 0 deletions lib/timer/data/timer_settings_schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ SettingGroup timerSettingsSchema = SettingGroup(
"Vibration",
],
),
SwitchSetting("Delete After Finishing",
(context) => AppLocalizations.of(context)!.timerDeleteAfterFinishingSetting, false),
SliderSetting("Add Length",
(context) => AppLocalizations.of(context)!.addLengthSetting, 1, 30, 1,
unit: "minutes", snapLength: 1),
Expand Down
2 changes: 2 additions & 0 deletions lib/timer/types/timer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ClockTimer extends CustomizableListItem {
? _settings.getSetting("Time To Full Volume").value
: TimeDuration.zero;
double get addLength => _settings.getSetting("Add Length").value;
bool get shouldDeleteAfterFinishing =>
_settings.getSetting("Delete After Finishing").value;
List<Tag> get tags => _settings.getSetting("Tags").value;
TimeDuration get duration => _duration;
TimeDuration get currentDuration => _currentDuration;
Expand Down
9 changes: 9 additions & 0 deletions lib/timer/widgets/timer_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ class _TimerCardState extends State<TimerCard> {
],
),
),
if (widget.timer.shouldDeleteAfterFinishing)
SizedBox(
width: 24,
child: Icon(
Icons.delete_outline_rounded,
size: 18,
color: colorScheme.onSurface.withOpacity(0.4),
),
),
const Spacer(),
CardEditMenu(actions: [
if (!widget.timer.isStopped)
Expand Down