ui: better sleep timer ui in player and fix auto turn on settings (#43)

* refactor: enhance sleep timer functionality and improve duration formatting

* refactor: update sleep timer settings handling

* refactor: update cancel icon for sleep timer button

* refactor: implement isBetween method for TimeOfDay and simplify sleep timer logic

* refactor: update alwaysAutoTurnOnTimer default value and improve icon usage in settings

* refactor: remove unused IconButton and update sleep timer preset durations
This commit is contained in:
Dr.Blank 2024-10-02 09:18:06 -04:00 committed by GitHub
parent 933bfc5750
commit 12100ffbcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 755 additions and 383 deletions

View file

@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
extension ToTimeOfDay on Duration {
TimeOfDay toTimeOfDay() {
return TimeOfDay(hour: inHours, minute: inMinutes % 60);
return TimeOfDay(
hour: inHours % 24,
minute: inMinutes % 60,
);
}
}
@ -28,4 +31,16 @@ extension TimeOfDayExtension on TimeOfDay {
bool isBefore(TimeOfDay other) => this < other;
bool isAfter(TimeOfDay other) => this > other;
bool isBetween(TimeOfDay start, TimeOfDay end) {
// needs more logic to handle the case where start is after end
//but on the other day
if (start == end) {
return this == start;
}
if (start < end) {
return this >= start && this <= end;
}
return this >= start || this <= end;
}
}