mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-07-07 09:51:34 +00:00
refactor: update sleep timer settings handling
This commit is contained in:
parent
ff41bf2b4d
commit
e25692132d
11 changed files with 110 additions and 68 deletions
|
|
@ -11,20 +11,16 @@ part 'sleep_timer_provider.g.dart';
|
||||||
class SleepTimer extends _$SleepTimer {
|
class SleepTimer extends _$SleepTimer {
|
||||||
@override
|
@override
|
||||||
core.SleepTimer? build() {
|
core.SleepTimer? build() {
|
||||||
final appSettings = ref.watch(appSettingsProvider);
|
final sleepTimerSettings = ref.watch(sleepTimerSettingsProvider);
|
||||||
final sleepTimerSettings = appSettings.playerSettings.sleepTimerSettings;
|
if (!sleepTimerSettings.autoTurnOnTimer) {
|
||||||
bool isEnabled = sleepTimerSettings.autoTurnOnTimer;
|
|
||||||
if (!isEnabled) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!sleepTimerSettings.alwaysAutoTurnOnTimer) &&
|
if ((!sleepTimerSettings.alwaysAutoTurnOnTimer) &&
|
||||||
(sleepTimerSettings.autoTurnOnTime
|
!shouldBuildRightNow(
|
||||||
.toTimeOfDay()
|
sleepTimerSettings.autoTurnOnTime,
|
||||||
.isAfter(TimeOfDay.now()) &&
|
sleepTimerSettings.autoTurnOffTime,
|
||||||
sleepTimerSettings.autoTurnOffTime
|
)) {
|
||||||
.toTimeOfDay()
|
|
||||||
.isBefore(TimeOfDay.now()))) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,3 +64,9 @@ class SleepTimer extends _$SleepTimer {
|
||||||
state = null;
|
state = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool shouldBuildRightNow(Duration autoTurnOnTime, Duration autoTurnOffTime) {
|
||||||
|
final now = TimeOfDay.now();
|
||||||
|
return autoTurnOnTime.toTimeOfDay().isBefore(now) &&
|
||||||
|
autoTurnOffTime.toTimeOfDay().isAfter(now);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ part of 'sleep_timer_provider.dart';
|
||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$sleepTimerHash() => r'722bebfb7367acb84aacd98da66c5858b7e446cd';
|
String _$sleepTimerHash() => r'2679454a217d0630a833d730557ab4e4feac2e56';
|
||||||
|
|
||||||
/// See also [SleepTimer].
|
/// See also [SleepTimer].
|
||||||
@ProviderFor(SleepTimer)
|
@ProviderFor(SleepTimer)
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,7 @@ class SleepTimerBottomSheet extends HookConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final sleepTimer = ref.watch(sleepTimerProvider);
|
final sleepTimer = ref.watch(sleepTimerProvider);
|
||||||
final sleepTimerSettings =
|
final sleepTimerSettings = ref.watch(sleepTimerSettingsProvider);
|
||||||
ref.watch(appSettingsProvider).playerSettings.sleepTimerSettings;
|
|
||||||
|
|
||||||
final durationOptions = sleepTimerSettings.presetDurations;
|
final durationOptions = sleepTimerSettings.presetDurations;
|
||||||
final minDuration = Duration.zero;
|
final minDuration = Duration.zero;
|
||||||
|
|
|
||||||
|
|
@ -60,3 +60,19 @@ class AppSettings extends _$AppSettings {
|
||||||
state = const model.AppSettings();
|
state = const model.AppSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SleepTimerSettings provider but only rebuilds when the sleep timer settings change
|
||||||
|
@Riverpod(keepAlive: true)
|
||||||
|
class SleepTimerSettings extends _$SleepTimerSettings {
|
||||||
|
@override
|
||||||
|
model.SleepTimerSettings build() {
|
||||||
|
final settings = ref.read(appSettingsProvider).sleepTimerSettings;
|
||||||
|
state = settings;
|
||||||
|
ref.listen(appSettingsProvider, (a, b) {
|
||||||
|
if (a?.sleepTimerSettings != b.sleepTimerSettings) {
|
||||||
|
state = b.sleepTimerSettings;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,22 @@ final appSettingsProvider =
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef _$AppSettings = Notifier<model.AppSettings>;
|
typedef _$AppSettings = Notifier<model.AppSettings>;
|
||||||
|
String _$sleepTimerSettingsHash() =>
|
||||||
|
r'85bb3d3fb292b9a3a5b771d86e5fc57718519c69';
|
||||||
|
|
||||||
|
/// See also [SleepTimerSettings].
|
||||||
|
@ProviderFor(SleepTimerSettings)
|
||||||
|
final sleepTimerSettingsProvider =
|
||||||
|
NotifierProvider<SleepTimerSettings, model.SleepTimerSettings>.internal(
|
||||||
|
SleepTimerSettings.new,
|
||||||
|
name: r'sleepTimerSettingsProvider',
|
||||||
|
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||||
|
? null
|
||||||
|
: _$sleepTimerSettingsHash,
|
||||||
|
dependencies: null,
|
||||||
|
allTransitiveDependencies: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef _$SleepTimerSettings = Notifier<model.SleepTimerSettings>;
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ class AppSettings with _$AppSettings {
|
||||||
const factory AppSettings({
|
const factory AppSettings({
|
||||||
@Default(ThemeSettings()) ThemeSettings themeSettings,
|
@Default(ThemeSettings()) ThemeSettings themeSettings,
|
||||||
@Default(PlayerSettings()) PlayerSettings playerSettings,
|
@Default(PlayerSettings()) PlayerSettings playerSettings,
|
||||||
|
@Default(SleepTimerSettings()) SleepTimerSettings sleepTimerSettings,
|
||||||
@Default(DownloadSettings()) DownloadSettings downloadSettings,
|
@Default(DownloadSettings()) DownloadSettings downloadSettings,
|
||||||
@Default(NotificationSettings()) NotificationSettings notificationSettings,
|
@Default(NotificationSettings()) NotificationSettings notificationSettings,
|
||||||
@Default(ShakeDetectionSettings())
|
@Default(ShakeDetectionSettings())
|
||||||
|
|
@ -49,7 +50,6 @@ class PlayerSettings with _$PlayerSettings {
|
||||||
@Default(0.05) double speedIncrement,
|
@Default(0.05) double speedIncrement,
|
||||||
@Default(0.1) double minSpeed,
|
@Default(0.1) double minSpeed,
|
||||||
@Default(4) double maxSpeed,
|
@Default(4) double maxSpeed,
|
||||||
@Default(SleepTimerSettings()) SleepTimerSettings sleepTimerSettings,
|
|
||||||
@Default(Duration(seconds: 10)) Duration minimumPositionForReporting,
|
@Default(Duration(seconds: 10)) Duration minimumPositionForReporting,
|
||||||
@Default(Duration(seconds: 10)) Duration playbackReportInterval,
|
@Default(Duration(seconds: 10)) Duration playbackReportInterval,
|
||||||
@Default(Duration(seconds: 15)) Duration markCompleteWhenTimeLeft,
|
@Default(Duration(seconds: 15)) Duration markCompleteWhenTimeLeft,
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ AppSettings _$AppSettingsFromJson(Map<String, dynamic> json) {
|
||||||
mixin _$AppSettings {
|
mixin _$AppSettings {
|
||||||
ThemeSettings get themeSettings => throw _privateConstructorUsedError;
|
ThemeSettings get themeSettings => throw _privateConstructorUsedError;
|
||||||
PlayerSettings get playerSettings => throw _privateConstructorUsedError;
|
PlayerSettings get playerSettings => throw _privateConstructorUsedError;
|
||||||
|
SleepTimerSettings get sleepTimerSettings =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
DownloadSettings get downloadSettings => throw _privateConstructorUsedError;
|
DownloadSettings get downloadSettings => throw _privateConstructorUsedError;
|
||||||
NotificationSettings get notificationSettings =>
|
NotificationSettings get notificationSettings =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
|
|
@ -47,12 +49,14 @@ abstract class $AppSettingsCopyWith<$Res> {
|
||||||
$Res call(
|
$Res call(
|
||||||
{ThemeSettings themeSettings,
|
{ThemeSettings themeSettings,
|
||||||
PlayerSettings playerSettings,
|
PlayerSettings playerSettings,
|
||||||
|
SleepTimerSettings sleepTimerSettings,
|
||||||
DownloadSettings downloadSettings,
|
DownloadSettings downloadSettings,
|
||||||
NotificationSettings notificationSettings,
|
NotificationSettings notificationSettings,
|
||||||
ShakeDetectionSettings shakeDetectionSettings});
|
ShakeDetectionSettings shakeDetectionSettings});
|
||||||
|
|
||||||
$ThemeSettingsCopyWith<$Res> get themeSettings;
|
$ThemeSettingsCopyWith<$Res> get themeSettings;
|
||||||
$PlayerSettingsCopyWith<$Res> get playerSettings;
|
$PlayerSettingsCopyWith<$Res> get playerSettings;
|
||||||
|
$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings;
|
||||||
$DownloadSettingsCopyWith<$Res> get downloadSettings;
|
$DownloadSettingsCopyWith<$Res> get downloadSettings;
|
||||||
$NotificationSettingsCopyWith<$Res> get notificationSettings;
|
$NotificationSettingsCopyWith<$Res> get notificationSettings;
|
||||||
$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings;
|
$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings;
|
||||||
|
|
@ -75,6 +79,7 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? themeSettings = null,
|
Object? themeSettings = null,
|
||||||
Object? playerSettings = null,
|
Object? playerSettings = null,
|
||||||
|
Object? sleepTimerSettings = null,
|
||||||
Object? downloadSettings = null,
|
Object? downloadSettings = null,
|
||||||
Object? notificationSettings = null,
|
Object? notificationSettings = null,
|
||||||
Object? shakeDetectionSettings = null,
|
Object? shakeDetectionSettings = null,
|
||||||
|
|
@ -88,6 +93,10 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
||||||
? _value.playerSettings
|
? _value.playerSettings
|
||||||
: playerSettings // ignore: cast_nullable_to_non_nullable
|
: playerSettings // ignore: cast_nullable_to_non_nullable
|
||||||
as PlayerSettings,
|
as PlayerSettings,
|
||||||
|
sleepTimerSettings: null == sleepTimerSettings
|
||||||
|
? _value.sleepTimerSettings
|
||||||
|
: sleepTimerSettings // ignore: cast_nullable_to_non_nullable
|
||||||
|
as SleepTimerSettings,
|
||||||
downloadSettings: null == downloadSettings
|
downloadSettings: null == downloadSettings
|
||||||
? _value.downloadSettings
|
? _value.downloadSettings
|
||||||
: downloadSettings // ignore: cast_nullable_to_non_nullable
|
: downloadSettings // ignore: cast_nullable_to_non_nullable
|
||||||
|
|
@ -123,6 +132,17 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a copy of AppSettings
|
||||||
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings {
|
||||||
|
return $SleepTimerSettingsCopyWith<$Res>(_value.sleepTimerSettings,
|
||||||
|
(value) {
|
||||||
|
return _then(_value.copyWith(sleepTimerSettings: value) as $Val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a copy of AppSettings
|
/// Create a copy of AppSettings
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
@override
|
@override
|
||||||
|
|
@ -167,6 +187,7 @@ abstract class _$$AppSettingsImplCopyWith<$Res>
|
||||||
$Res call(
|
$Res call(
|
||||||
{ThemeSettings themeSettings,
|
{ThemeSettings themeSettings,
|
||||||
PlayerSettings playerSettings,
|
PlayerSettings playerSettings,
|
||||||
|
SleepTimerSettings sleepTimerSettings,
|
||||||
DownloadSettings downloadSettings,
|
DownloadSettings downloadSettings,
|
||||||
NotificationSettings notificationSettings,
|
NotificationSettings notificationSettings,
|
||||||
ShakeDetectionSettings shakeDetectionSettings});
|
ShakeDetectionSettings shakeDetectionSettings});
|
||||||
|
|
@ -176,6 +197,8 @@ abstract class _$$AppSettingsImplCopyWith<$Res>
|
||||||
@override
|
@override
|
||||||
$PlayerSettingsCopyWith<$Res> get playerSettings;
|
$PlayerSettingsCopyWith<$Res> get playerSettings;
|
||||||
@override
|
@override
|
||||||
|
$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings;
|
||||||
|
@override
|
||||||
$DownloadSettingsCopyWith<$Res> get downloadSettings;
|
$DownloadSettingsCopyWith<$Res> get downloadSettings;
|
||||||
@override
|
@override
|
||||||
$NotificationSettingsCopyWith<$Res> get notificationSettings;
|
$NotificationSettingsCopyWith<$Res> get notificationSettings;
|
||||||
|
|
@ -198,6 +221,7 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
||||||
$Res call({
|
$Res call({
|
||||||
Object? themeSettings = null,
|
Object? themeSettings = null,
|
||||||
Object? playerSettings = null,
|
Object? playerSettings = null,
|
||||||
|
Object? sleepTimerSettings = null,
|
||||||
Object? downloadSettings = null,
|
Object? downloadSettings = null,
|
||||||
Object? notificationSettings = null,
|
Object? notificationSettings = null,
|
||||||
Object? shakeDetectionSettings = null,
|
Object? shakeDetectionSettings = null,
|
||||||
|
|
@ -211,6 +235,10 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
||||||
? _value.playerSettings
|
? _value.playerSettings
|
||||||
: playerSettings // ignore: cast_nullable_to_non_nullable
|
: playerSettings // ignore: cast_nullable_to_non_nullable
|
||||||
as PlayerSettings,
|
as PlayerSettings,
|
||||||
|
sleepTimerSettings: null == sleepTimerSettings
|
||||||
|
? _value.sleepTimerSettings
|
||||||
|
: sleepTimerSettings // ignore: cast_nullable_to_non_nullable
|
||||||
|
as SleepTimerSettings,
|
||||||
downloadSettings: null == downloadSettings
|
downloadSettings: null == downloadSettings
|
||||||
? _value.downloadSettings
|
? _value.downloadSettings
|
||||||
: downloadSettings // ignore: cast_nullable_to_non_nullable
|
: downloadSettings // ignore: cast_nullable_to_non_nullable
|
||||||
|
|
@ -233,6 +261,7 @@ class _$AppSettingsImpl implements _AppSettings {
|
||||||
const _$AppSettingsImpl(
|
const _$AppSettingsImpl(
|
||||||
{this.themeSettings = const ThemeSettings(),
|
{this.themeSettings = const ThemeSettings(),
|
||||||
this.playerSettings = const PlayerSettings(),
|
this.playerSettings = const PlayerSettings(),
|
||||||
|
this.sleepTimerSettings = const SleepTimerSettings(),
|
||||||
this.downloadSettings = const DownloadSettings(),
|
this.downloadSettings = const DownloadSettings(),
|
||||||
this.notificationSettings = const NotificationSettings(),
|
this.notificationSettings = const NotificationSettings(),
|
||||||
this.shakeDetectionSettings = const ShakeDetectionSettings()});
|
this.shakeDetectionSettings = const ShakeDetectionSettings()});
|
||||||
|
|
@ -248,6 +277,9 @@ class _$AppSettingsImpl implements _AppSettings {
|
||||||
final PlayerSettings playerSettings;
|
final PlayerSettings playerSettings;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
|
final SleepTimerSettings sleepTimerSettings;
|
||||||
|
@override
|
||||||
|
@JsonKey()
|
||||||
final DownloadSettings downloadSettings;
|
final DownloadSettings downloadSettings;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
|
|
@ -258,7 +290,7 @@ class _$AppSettingsImpl implements _AppSettings {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings)';
|
return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -270,6 +302,8 @@ class _$AppSettingsImpl implements _AppSettings {
|
||||||
other.themeSettings == themeSettings) &&
|
other.themeSettings == themeSettings) &&
|
||||||
(identical(other.playerSettings, playerSettings) ||
|
(identical(other.playerSettings, playerSettings) ||
|
||||||
other.playerSettings == playerSettings) &&
|
other.playerSettings == playerSettings) &&
|
||||||
|
(identical(other.sleepTimerSettings, sleepTimerSettings) ||
|
||||||
|
other.sleepTimerSettings == sleepTimerSettings) &&
|
||||||
(identical(other.downloadSettings, downloadSettings) ||
|
(identical(other.downloadSettings, downloadSettings) ||
|
||||||
other.downloadSettings == downloadSettings) &&
|
other.downloadSettings == downloadSettings) &&
|
||||||
(identical(other.notificationSettings, notificationSettings) ||
|
(identical(other.notificationSettings, notificationSettings) ||
|
||||||
|
|
@ -280,8 +314,14 @@ class _$AppSettingsImpl implements _AppSettings {
|
||||||
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(runtimeType, themeSettings, playerSettings,
|
int get hashCode => Object.hash(
|
||||||
downloadSettings, notificationSettings, shakeDetectionSettings);
|
runtimeType,
|
||||||
|
themeSettings,
|
||||||
|
playerSettings,
|
||||||
|
sleepTimerSettings,
|
||||||
|
downloadSettings,
|
||||||
|
notificationSettings,
|
||||||
|
shakeDetectionSettings);
|
||||||
|
|
||||||
/// Create a copy of AppSettings
|
/// Create a copy of AppSettings
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
/// with the given fields replaced by the non-null parameter values.
|
||||||
|
|
@ -303,6 +343,7 @@ abstract class _AppSettings implements AppSettings {
|
||||||
const factory _AppSettings(
|
const factory _AppSettings(
|
||||||
{final ThemeSettings themeSettings,
|
{final ThemeSettings themeSettings,
|
||||||
final PlayerSettings playerSettings,
|
final PlayerSettings playerSettings,
|
||||||
|
final SleepTimerSettings sleepTimerSettings,
|
||||||
final DownloadSettings downloadSettings,
|
final DownloadSettings downloadSettings,
|
||||||
final NotificationSettings notificationSettings,
|
final NotificationSettings notificationSettings,
|
||||||
final ShakeDetectionSettings shakeDetectionSettings}) = _$AppSettingsImpl;
|
final ShakeDetectionSettings shakeDetectionSettings}) = _$AppSettingsImpl;
|
||||||
|
|
@ -315,6 +356,8 @@ abstract class _AppSettings implements AppSettings {
|
||||||
@override
|
@override
|
||||||
PlayerSettings get playerSettings;
|
PlayerSettings get playerSettings;
|
||||||
@override
|
@override
|
||||||
|
SleepTimerSettings get sleepTimerSettings;
|
||||||
|
@override
|
||||||
DownloadSettings get downloadSettings;
|
DownloadSettings get downloadSettings;
|
||||||
@override
|
@override
|
||||||
NotificationSettings get notificationSettings;
|
NotificationSettings get notificationSettings;
|
||||||
|
|
@ -552,8 +595,6 @@ mixin _$PlayerSettings {
|
||||||
double get speedIncrement => throw _privateConstructorUsedError;
|
double get speedIncrement => throw _privateConstructorUsedError;
|
||||||
double get minSpeed => throw _privateConstructorUsedError;
|
double get minSpeed => throw _privateConstructorUsedError;
|
||||||
double get maxSpeed => throw _privateConstructorUsedError;
|
double get maxSpeed => throw _privateConstructorUsedError;
|
||||||
SleepTimerSettings get sleepTimerSettings =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
Duration get minimumPositionForReporting =>
|
Duration get minimumPositionForReporting =>
|
||||||
throw _privateConstructorUsedError;
|
throw _privateConstructorUsedError;
|
||||||
Duration get playbackReportInterval => throw _privateConstructorUsedError;
|
Duration get playbackReportInterval => throw _privateConstructorUsedError;
|
||||||
|
|
@ -585,7 +626,6 @@ abstract class $PlayerSettingsCopyWith<$Res> {
|
||||||
double speedIncrement,
|
double speedIncrement,
|
||||||
double minSpeed,
|
double minSpeed,
|
||||||
double maxSpeed,
|
double maxSpeed,
|
||||||
SleepTimerSettings sleepTimerSettings,
|
|
||||||
Duration minimumPositionForReporting,
|
Duration minimumPositionForReporting,
|
||||||
Duration playbackReportInterval,
|
Duration playbackReportInterval,
|
||||||
Duration markCompleteWhenTimeLeft,
|
Duration markCompleteWhenTimeLeft,
|
||||||
|
|
@ -593,7 +633,6 @@ abstract class $PlayerSettingsCopyWith<$Res> {
|
||||||
|
|
||||||
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
||||||
$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings;
|
$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings;
|
||||||
$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
@ -619,7 +658,6 @@ class _$PlayerSettingsCopyWithImpl<$Res, $Val extends PlayerSettings>
|
||||||
Object? speedIncrement = null,
|
Object? speedIncrement = null,
|
||||||
Object? minSpeed = null,
|
Object? minSpeed = null,
|
||||||
Object? maxSpeed = null,
|
Object? maxSpeed = null,
|
||||||
Object? sleepTimerSettings = null,
|
|
||||||
Object? minimumPositionForReporting = null,
|
Object? minimumPositionForReporting = null,
|
||||||
Object? playbackReportInterval = null,
|
Object? playbackReportInterval = null,
|
||||||
Object? markCompleteWhenTimeLeft = null,
|
Object? markCompleteWhenTimeLeft = null,
|
||||||
|
|
@ -658,10 +696,6 @@ class _$PlayerSettingsCopyWithImpl<$Res, $Val extends PlayerSettings>
|
||||||
? _value.maxSpeed
|
? _value.maxSpeed
|
||||||
: maxSpeed // ignore: cast_nullable_to_non_nullable
|
: maxSpeed // ignore: cast_nullable_to_non_nullable
|
||||||
as double,
|
as double,
|
||||||
sleepTimerSettings: null == sleepTimerSettings
|
|
||||||
? _value.sleepTimerSettings
|
|
||||||
: sleepTimerSettings // ignore: cast_nullable_to_non_nullable
|
|
||||||
as SleepTimerSettings,
|
|
||||||
minimumPositionForReporting: null == minimumPositionForReporting
|
minimumPositionForReporting: null == minimumPositionForReporting
|
||||||
? _value.minimumPositionForReporting
|
? _value.minimumPositionForReporting
|
||||||
: minimumPositionForReporting // ignore: cast_nullable_to_non_nullable
|
: minimumPositionForReporting // ignore: cast_nullable_to_non_nullable
|
||||||
|
|
@ -702,17 +736,6 @@ class _$PlayerSettingsCopyWithImpl<$Res, $Val extends PlayerSettings>
|
||||||
return _then(_value.copyWith(expandedPlayerSettings: value) as $Val);
|
return _then(_value.copyWith(expandedPlayerSettings: value) as $Val);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a copy of PlayerSettings
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings {
|
|
||||||
return $SleepTimerSettingsCopyWith<$Res>(_value.sleepTimerSettings,
|
|
||||||
(value) {
|
|
||||||
return _then(_value.copyWith(sleepTimerSettings: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
@ -732,7 +755,6 @@ abstract class _$$PlayerSettingsImplCopyWith<$Res>
|
||||||
double speedIncrement,
|
double speedIncrement,
|
||||||
double minSpeed,
|
double minSpeed,
|
||||||
double maxSpeed,
|
double maxSpeed,
|
||||||
SleepTimerSettings sleepTimerSettings,
|
|
||||||
Duration minimumPositionForReporting,
|
Duration minimumPositionForReporting,
|
||||||
Duration playbackReportInterval,
|
Duration playbackReportInterval,
|
||||||
Duration markCompleteWhenTimeLeft,
|
Duration markCompleteWhenTimeLeft,
|
||||||
|
|
@ -742,8 +764,6 @@ abstract class _$$PlayerSettingsImplCopyWith<$Res>
|
||||||
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
$MinimizedPlayerSettingsCopyWith<$Res> get miniPlayerSettings;
|
||||||
@override
|
@override
|
||||||
$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings;
|
$ExpandedPlayerSettingsCopyWith<$Res> get expandedPlayerSettings;
|
||||||
@override
|
|
||||||
$SleepTimerSettingsCopyWith<$Res> get sleepTimerSettings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
|
|
@ -767,7 +787,6 @@ class __$$PlayerSettingsImplCopyWithImpl<$Res>
|
||||||
Object? speedIncrement = null,
|
Object? speedIncrement = null,
|
||||||
Object? minSpeed = null,
|
Object? minSpeed = null,
|
||||||
Object? maxSpeed = null,
|
Object? maxSpeed = null,
|
||||||
Object? sleepTimerSettings = null,
|
|
||||||
Object? minimumPositionForReporting = null,
|
Object? minimumPositionForReporting = null,
|
||||||
Object? playbackReportInterval = null,
|
Object? playbackReportInterval = null,
|
||||||
Object? markCompleteWhenTimeLeft = null,
|
Object? markCompleteWhenTimeLeft = null,
|
||||||
|
|
@ -806,10 +825,6 @@ class __$$PlayerSettingsImplCopyWithImpl<$Res>
|
||||||
? _value.maxSpeed
|
? _value.maxSpeed
|
||||||
: maxSpeed // ignore: cast_nullable_to_non_nullable
|
: maxSpeed // ignore: cast_nullable_to_non_nullable
|
||||||
as double,
|
as double,
|
||||||
sleepTimerSettings: null == sleepTimerSettings
|
|
||||||
? _value.sleepTimerSettings
|
|
||||||
: sleepTimerSettings // ignore: cast_nullable_to_non_nullable
|
|
||||||
as SleepTimerSettings,
|
|
||||||
minimumPositionForReporting: null == minimumPositionForReporting
|
minimumPositionForReporting: null == minimumPositionForReporting
|
||||||
? _value.minimumPositionForReporting
|
? _value.minimumPositionForReporting
|
||||||
: minimumPositionForReporting // ignore: cast_nullable_to_non_nullable
|
: minimumPositionForReporting // ignore: cast_nullable_to_non_nullable
|
||||||
|
|
@ -842,7 +857,6 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
this.speedIncrement = 0.05,
|
this.speedIncrement = 0.05,
|
||||||
this.minSpeed = 0.1,
|
this.minSpeed = 0.1,
|
||||||
this.maxSpeed = 4,
|
this.maxSpeed = 4,
|
||||||
this.sleepTimerSettings = const SleepTimerSettings(),
|
|
||||||
this.minimumPositionForReporting = const Duration(seconds: 10),
|
this.minimumPositionForReporting = const Duration(seconds: 10),
|
||||||
this.playbackReportInterval = const Duration(seconds: 10),
|
this.playbackReportInterval = const Duration(seconds: 10),
|
||||||
this.markCompleteWhenTimeLeft = const Duration(seconds: 15),
|
this.markCompleteWhenTimeLeft = const Duration(seconds: 15),
|
||||||
|
|
@ -884,9 +898,6 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
final double maxSpeed;
|
final double maxSpeed;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
final SleepTimerSettings sleepTimerSettings;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final Duration minimumPositionForReporting;
|
final Duration minimumPositionForReporting;
|
||||||
@override
|
@override
|
||||||
@JsonKey()
|
@JsonKey()
|
||||||
|
|
@ -900,7 +911,7 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, speedIncrement: $speedIncrement, minSpeed: $minSpeed, maxSpeed: $maxSpeed, sleepTimerSettings: $sleepTimerSettings, minimumPositionForReporting: $minimumPositionForReporting, playbackReportInterval: $playbackReportInterval, markCompleteWhenTimeLeft: $markCompleteWhenTimeLeft, configurePlayerForEveryBook: $configurePlayerForEveryBook)';
|
return 'PlayerSettings(miniPlayerSettings: $miniPlayerSettings, expandedPlayerSettings: $expandedPlayerSettings, preferredDefaultVolume: $preferredDefaultVolume, preferredDefaultSpeed: $preferredDefaultSpeed, speedOptions: $speedOptions, speedIncrement: $speedIncrement, minSpeed: $minSpeed, maxSpeed: $maxSpeed, minimumPositionForReporting: $minimumPositionForReporting, playbackReportInterval: $playbackReportInterval, markCompleteWhenTimeLeft: $markCompleteWhenTimeLeft, configurePlayerForEveryBook: $configurePlayerForEveryBook)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -924,8 +935,6 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
other.minSpeed == minSpeed) &&
|
other.minSpeed == minSpeed) &&
|
||||||
(identical(other.maxSpeed, maxSpeed) ||
|
(identical(other.maxSpeed, maxSpeed) ||
|
||||||
other.maxSpeed == maxSpeed) &&
|
other.maxSpeed == maxSpeed) &&
|
||||||
(identical(other.sleepTimerSettings, sleepTimerSettings) ||
|
|
||||||
other.sleepTimerSettings == sleepTimerSettings) &&
|
|
||||||
(identical(other.minimumPositionForReporting,
|
(identical(other.minimumPositionForReporting,
|
||||||
minimumPositionForReporting) ||
|
minimumPositionForReporting) ||
|
||||||
other.minimumPositionForReporting ==
|
other.minimumPositionForReporting ==
|
||||||
|
|
@ -953,7 +962,6 @@ class _$PlayerSettingsImpl implements _PlayerSettings {
|
||||||
speedIncrement,
|
speedIncrement,
|
||||||
minSpeed,
|
minSpeed,
|
||||||
maxSpeed,
|
maxSpeed,
|
||||||
sleepTimerSettings,
|
|
||||||
minimumPositionForReporting,
|
minimumPositionForReporting,
|
||||||
playbackReportInterval,
|
playbackReportInterval,
|
||||||
markCompleteWhenTimeLeft,
|
markCompleteWhenTimeLeft,
|
||||||
|
|
@ -986,7 +994,6 @@ abstract class _PlayerSettings implements PlayerSettings {
|
||||||
final double speedIncrement,
|
final double speedIncrement,
|
||||||
final double minSpeed,
|
final double minSpeed,
|
||||||
final double maxSpeed,
|
final double maxSpeed,
|
||||||
final SleepTimerSettings sleepTimerSettings,
|
|
||||||
final Duration minimumPositionForReporting,
|
final Duration minimumPositionForReporting,
|
||||||
final Duration playbackReportInterval,
|
final Duration playbackReportInterval,
|
||||||
final Duration markCompleteWhenTimeLeft,
|
final Duration markCompleteWhenTimeLeft,
|
||||||
|
|
@ -1012,8 +1019,6 @@ abstract class _PlayerSettings implements PlayerSettings {
|
||||||
@override
|
@override
|
||||||
double get maxSpeed;
|
double get maxSpeed;
|
||||||
@override
|
@override
|
||||||
SleepTimerSettings get sleepTimerSettings;
|
|
||||||
@override
|
|
||||||
Duration get minimumPositionForReporting;
|
Duration get minimumPositionForReporting;
|
||||||
@override
|
@override
|
||||||
Duration get playbackReportInterval;
|
Duration get playbackReportInterval;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ _$AppSettingsImpl _$$AppSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||||
? const PlayerSettings()
|
? const PlayerSettings()
|
||||||
: PlayerSettings.fromJson(
|
: PlayerSettings.fromJson(
|
||||||
json['playerSettings'] as Map<String, dynamic>),
|
json['playerSettings'] as Map<String, dynamic>),
|
||||||
|
sleepTimerSettings: json['sleepTimerSettings'] == null
|
||||||
|
? const SleepTimerSettings()
|
||||||
|
: SleepTimerSettings.fromJson(
|
||||||
|
json['sleepTimerSettings'] as Map<String, dynamic>),
|
||||||
downloadSettings: json['downloadSettings'] == null
|
downloadSettings: json['downloadSettings'] == null
|
||||||
? const DownloadSettings()
|
? const DownloadSettings()
|
||||||
: DownloadSettings.fromJson(
|
: DownloadSettings.fromJson(
|
||||||
|
|
@ -34,6 +38,7 @@ Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{
|
||||||
'themeSettings': instance.themeSettings,
|
'themeSettings': instance.themeSettings,
|
||||||
'playerSettings': instance.playerSettings,
|
'playerSettings': instance.playerSettings,
|
||||||
|
'sleepTimerSettings': instance.sleepTimerSettings,
|
||||||
'downloadSettings': instance.downloadSettings,
|
'downloadSettings': instance.downloadSettings,
|
||||||
'notificationSettings': instance.notificationSettings,
|
'notificationSettings': instance.notificationSettings,
|
||||||
'shakeDetectionSettings': instance.shakeDetectionSettings,
|
'shakeDetectionSettings': instance.shakeDetectionSettings,
|
||||||
|
|
@ -77,10 +82,6 @@ _$PlayerSettingsImpl _$$PlayerSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||||
speedIncrement: (json['speedIncrement'] as num?)?.toDouble() ?? 0.05,
|
speedIncrement: (json['speedIncrement'] as num?)?.toDouble() ?? 0.05,
|
||||||
minSpeed: (json['minSpeed'] as num?)?.toDouble() ?? 0.1,
|
minSpeed: (json['minSpeed'] as num?)?.toDouble() ?? 0.1,
|
||||||
maxSpeed: (json['maxSpeed'] as num?)?.toDouble() ?? 4,
|
maxSpeed: (json['maxSpeed'] as num?)?.toDouble() ?? 4,
|
||||||
sleepTimerSettings: json['sleepTimerSettings'] == null
|
|
||||||
? const SleepTimerSettings()
|
|
||||||
: SleepTimerSettings.fromJson(
|
|
||||||
json['sleepTimerSettings'] as Map<String, dynamic>),
|
|
||||||
minimumPositionForReporting: json['minimumPositionForReporting'] == null
|
minimumPositionForReporting: json['minimumPositionForReporting'] == null
|
||||||
? const Duration(seconds: 10)
|
? const Duration(seconds: 10)
|
||||||
: Duration(
|
: Duration(
|
||||||
|
|
@ -109,7 +110,6 @@ Map<String, dynamic> _$$PlayerSettingsImplToJson(
|
||||||
'speedIncrement': instance.speedIncrement,
|
'speedIncrement': instance.speedIncrement,
|
||||||
'minSpeed': instance.minSpeed,
|
'minSpeed': instance.minSpeed,
|
||||||
'maxSpeed': instance.maxSpeed,
|
'maxSpeed': instance.maxSpeed,
|
||||||
'sleepTimerSettings': instance.sleepTimerSettings,
|
|
||||||
'minimumPositionForReporting':
|
'minimumPositionForReporting':
|
||||||
instance.minimumPositionForReporting.inMicroseconds,
|
instance.minimumPositionForReporting.inMicroseconds,
|
||||||
'playbackReportInterval': instance.playbackReportInterval.inMicroseconds,
|
'playbackReportInterval': instance.playbackReportInterval.inMicroseconds,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class AppSettingsPage extends HookConsumerWidget {
|
||||||
final registeredServersAsList = registeredServers.toList();
|
final registeredServersAsList = registeredServers.toList();
|
||||||
final availableUsers = ref.watch(authenticatedUserProvider);
|
final availableUsers = ref.watch(authenticatedUserProvider);
|
||||||
final serverURIController = useTextEditingController();
|
final serverURIController = useTextEditingController();
|
||||||
final sleepTimerSettings = appSettings.playerSettings.sleepTimerSettings;
|
final sleepTimerSettings = appSettings.sleepTimerSettings;
|
||||||
|
|
||||||
return SimpleSettingsPage(
|
return SimpleSettingsPage(
|
||||||
title: const Text('App Settings'),
|
title: const Text('App Settings'),
|
||||||
|
|
@ -99,7 +99,7 @@ class AppSettingsPage extends HookConsumerWidget {
|
||||||
value: sleepTimerSettings.autoTurnOnTimer,
|
value: sleepTimerSettings.autoTurnOnTimer,
|
||||||
onToggle: (value) {
|
onToggle: (value) {
|
||||||
ref.read(appSettingsProvider.notifier).update(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings.sleepTimerSettings(
|
appSettings.copyWith.sleepTimerSettings(
|
||||||
autoTurnOnTimer: value,
|
autoTurnOnTimer: value,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final appSettings = ref.watch(appSettingsProvider);
|
final appSettings = ref.watch(appSettingsProvider);
|
||||||
final sleepTimerSettings = appSettings.playerSettings.sleepTimerSettings;
|
final sleepTimerSettings = appSettings.sleepTimerSettings;
|
||||||
|
|
||||||
return SimpleSettingsPage(
|
return SimpleSettingsPage(
|
||||||
title: const Text('Auto Sleep Timer Settings'),
|
title: const Text('Auto Sleep Timer Settings'),
|
||||||
|
|
@ -35,7 +35,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
: const Icon(Icons.timer_off),
|
: const Icon(Icons.timer_off),
|
||||||
onToggle: (value) {
|
onToggle: (value) {
|
||||||
ref.read(appSettingsProvider.notifier).update(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings.sleepTimerSettings(
|
appSettings.copyWith.sleepTimerSettings(
|
||||||
autoTurnOnTimer: value,
|
autoTurnOnTimer: value,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -57,7 +57,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
ref.read(appSettingsProvider.notifier).update(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings.sleepTimerSettings(
|
appSettings.copyWith.sleepTimerSettings(
|
||||||
autoTurnOnTime: selected.toDuration(),
|
autoTurnOnTime: selected.toDuration(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -81,7 +81,7 @@ class AutoSleepTimerSettingsPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
ref.read(appSettingsProvider.notifier).update(
|
ref.read(appSettingsProvider.notifier).update(
|
||||||
appSettings.copyWith.playerSettings.sleepTimerSettings(
|
appSettings.copyWith.sleepTimerSettings(
|
||||||
autoTurnOffTime: selected.toDuration(),
|
autoTurnOffTime: selected.toDuration(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
extension ToTimeOfDay on Duration {
|
extension ToTimeOfDay on Duration {
|
||||||
TimeOfDay toTimeOfDay() {
|
TimeOfDay toTimeOfDay() {
|
||||||
return TimeOfDay(hour: inHours, minute: inMinutes % 60);
|
return TimeOfDay(
|
||||||
|
hour: inHours % 24,
|
||||||
|
minute: inMinutes % 60,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue