refactor: enhance sleep timer functionality and improve duration formatting

This commit is contained in:
Dr-Blank 2024-10-02 06:05:10 -04:00
parent 4c5dc53169
commit ff41bf2b4d
No known key found for this signature in database
GPG key ID: 7452CC63F210A266
11 changed files with 565 additions and 298 deletions

View file

@ -81,22 +81,17 @@ class MinimizedPlayerSettings with _$MinimizedPlayerSettings {
_$MinimizedPlayerSettingsFromJson(json);
}
enum SleepTimerShakeSenseMode { never, always, nearEnds }
@freezed
class SleepTimerSettings with _$SleepTimerSettings {
const factory SleepTimerSettings({
@Default(Duration(minutes: 15)) Duration defaultDuration,
@Default(SleepTimerShakeSenseMode.always)
SleepTimerShakeSenseMode shakeSenseMode,
/// the duration in which the shake is detected before the end of the timer and after the timer ends
/// only used if [shakeSenseMode] is [SleepTimerShakeSenseMode.nearEnds]
@Default(Duration(seconds: 30)) Duration shakeSenseDuration,
@Default(true) bool vibrateWhenReset,
@Default(false) bool beepWhenReset,
@Default(
[Duration(minutes: 5), Duration(minutes: 15), Duration(minutes: 30)],
)
List<Duration> presetDurations,
@Default(Duration(minutes: 100)) Duration maxDuration,
@Default(false) bool fadeOutAudio,
@Default(0.5) double shakeDetectThreshold,
@Default(Duration(seconds: 20)) Duration fadeOutDuration,
/// if true, the player will automatically rewind the audio when the sleep timer is stopped
@Default(false) bool autoRewindWhenStopped,