mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feature: Toggle wifi requirement for downloads (#110)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
0b0cd3a557
commit
cb4b416bfc
7 changed files with 46 additions and 6 deletions
|
|
@ -1115,5 +1115,7 @@
|
|||
"schemeSettingsExpressive": "Expressive",
|
||||
"schemeSettingsContent": "Content",
|
||||
"schemeSettingsRainbow": "Rainbow",
|
||||
"schemeSettingsFruitSalad": "Fruit salad"
|
||||
"schemeSettingsFruitSalad": "Fruit salad",
|
||||
"clientSettingsRequireWifiTitle": "Require Wi-Fi",
|
||||
"clientSettingsRequireWifiDesc": "Only download when connected to a Wi-Fi network"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ class ClientSettingsModel with _$ClientSettingsModel {
|
|||
@Default(ThemeMode.system) ThemeMode themeMode,
|
||||
ColorThemes? themeColor,
|
||||
@Default(false) bool amoledBlack,
|
||||
@Default(false) bool blurPlaceHolders,
|
||||
@Default(true) bool blurPlaceHolders,
|
||||
@Default(false) bool blurUpcomingEpisodes,
|
||||
@LocaleConvert() Locale? selectedLocale,
|
||||
@Default(true) bool enableMediaKeys,
|
||||
@Default(1.0) double posterSize,
|
||||
@Default(false) bool pinchPosterZoom,
|
||||
@Default(false) bool mouseDragSupport,
|
||||
@Default(true) bool requireWifi,
|
||||
@Default(DynamicSchemeVariant.tonalSpot) DynamicSchemeVariant schemeVariant,
|
||||
int? libraryPageSize,
|
||||
}) = _ClientSettingsModel;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ mixin _$ClientSettingsModel {
|
|||
double get posterSize => throw _privateConstructorUsedError;
|
||||
bool get pinchPosterZoom => throw _privateConstructorUsedError;
|
||||
bool get mouseDragSupport => throw _privateConstructorUsedError;
|
||||
bool get requireWifi => throw _privateConstructorUsedError;
|
||||
DynamicSchemeVariant get schemeVariant => throw _privateConstructorUsedError;
|
||||
int? get libraryPageSize => throw _privateConstructorUsedError;
|
||||
|
||||
|
|
@ -71,6 +72,7 @@ abstract class $ClientSettingsModelCopyWith<$Res> {
|
|||
double posterSize,
|
||||
bool pinchPosterZoom,
|
||||
bool mouseDragSupport,
|
||||
bool requireWifi,
|
||||
DynamicSchemeVariant schemeVariant,
|
||||
int? libraryPageSize});
|
||||
}
|
||||
|
|
@ -105,6 +107,7 @@ class _$ClientSettingsModelCopyWithImpl<$Res, $Val extends ClientSettingsModel>
|
|||
Object? posterSize = null,
|
||||
Object? pinchPosterZoom = null,
|
||||
Object? mouseDragSupport = null,
|
||||
Object? requireWifi = null,
|
||||
Object? schemeVariant = null,
|
||||
Object? libraryPageSize = freezed,
|
||||
}) {
|
||||
|
|
@ -169,6 +172,10 @@ class _$ClientSettingsModelCopyWithImpl<$Res, $Val extends ClientSettingsModel>
|
|||
? _value.mouseDragSupport
|
||||
: mouseDragSupport // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
requireWifi: null == requireWifi
|
||||
? _value.requireWifi
|
||||
: requireWifi // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
schemeVariant: null == schemeVariant
|
||||
? _value.schemeVariant
|
||||
: schemeVariant // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -205,6 +212,7 @@ abstract class _$$ClientSettingsModelImplCopyWith<$Res>
|
|||
double posterSize,
|
||||
bool pinchPosterZoom,
|
||||
bool mouseDragSupport,
|
||||
bool requireWifi,
|
||||
DynamicSchemeVariant schemeVariant,
|
||||
int? libraryPageSize});
|
||||
}
|
||||
|
|
@ -237,6 +245,7 @@ class __$$ClientSettingsModelImplCopyWithImpl<$Res>
|
|||
Object? posterSize = null,
|
||||
Object? pinchPosterZoom = null,
|
||||
Object? mouseDragSupport = null,
|
||||
Object? requireWifi = null,
|
||||
Object? schemeVariant = null,
|
||||
Object? libraryPageSize = freezed,
|
||||
}) {
|
||||
|
|
@ -301,6 +310,10 @@ class __$$ClientSettingsModelImplCopyWithImpl<$Res>
|
|||
? _value.mouseDragSupport
|
||||
: mouseDragSupport // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
requireWifi: null == requireWifi
|
||||
? _value.requireWifi
|
||||
: requireWifi // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
schemeVariant: null == schemeVariant
|
||||
? _value.schemeVariant
|
||||
: schemeVariant // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -326,13 +339,14 @@ class _$ClientSettingsModelImpl extends _ClientSettingsModel
|
|||
this.themeMode = ThemeMode.system,
|
||||
this.themeColor,
|
||||
this.amoledBlack = false,
|
||||
this.blurPlaceHolders = false,
|
||||
this.blurPlaceHolders = true,
|
||||
this.blurUpcomingEpisodes = false,
|
||||
@LocaleConvert() this.selectedLocale,
|
||||
this.enableMediaKeys = true,
|
||||
this.posterSize = 1.0,
|
||||
this.pinchPosterZoom = false,
|
||||
this.mouseDragSupport = false,
|
||||
this.requireWifi = true,
|
||||
this.schemeVariant = DynamicSchemeVariant.tonalSpot,
|
||||
this.libraryPageSize})
|
||||
: super._();
|
||||
|
|
@ -384,13 +398,16 @@ class _$ClientSettingsModelImpl extends _ClientSettingsModel
|
|||
final bool mouseDragSupport;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool requireWifi;
|
||||
@override
|
||||
@JsonKey()
|
||||
final DynamicSchemeVariant schemeVariant;
|
||||
@override
|
||||
final int? libraryPageSize;
|
||||
|
||||
@override
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'ClientSettingsModel(syncPath: $syncPath, position: $position, size: $size, timeOut: $timeOut, nextUpDateCutoff: $nextUpDateCutoff, themeMode: $themeMode, themeColor: $themeColor, amoledBlack: $amoledBlack, blurPlaceHolders: $blurPlaceHolders, blurUpcomingEpisodes: $blurUpcomingEpisodes, selectedLocale: $selectedLocale, enableMediaKeys: $enableMediaKeys, posterSize: $posterSize, pinchPosterZoom: $pinchPosterZoom, mouseDragSupport: $mouseDragSupport, schemeVariant: $schemeVariant, libraryPageSize: $libraryPageSize)';
|
||||
return 'ClientSettingsModel(syncPath: $syncPath, position: $position, size: $size, timeOut: $timeOut, nextUpDateCutoff: $nextUpDateCutoff, themeMode: $themeMode, themeColor: $themeColor, amoledBlack: $amoledBlack, blurPlaceHolders: $blurPlaceHolders, blurUpcomingEpisodes: $blurUpcomingEpisodes, selectedLocale: $selectedLocale, enableMediaKeys: $enableMediaKeys, posterSize: $posterSize, pinchPosterZoom: $pinchPosterZoom, mouseDragSupport: $mouseDragSupport, requireWifi: $requireWifi, schemeVariant: $schemeVariant, libraryPageSize: $libraryPageSize)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -413,6 +430,7 @@ class _$ClientSettingsModelImpl extends _ClientSettingsModel
|
|||
..add(DiagnosticsProperty('posterSize', posterSize))
|
||||
..add(DiagnosticsProperty('pinchPosterZoom', pinchPosterZoom))
|
||||
..add(DiagnosticsProperty('mouseDragSupport', mouseDragSupport))
|
||||
..add(DiagnosticsProperty('requireWifi', requireWifi))
|
||||
..add(DiagnosticsProperty('schemeVariant', schemeVariant))
|
||||
..add(DiagnosticsProperty('libraryPageSize', libraryPageSize));
|
||||
}
|
||||
|
|
@ -450,6 +468,8 @@ class _$ClientSettingsModelImpl extends _ClientSettingsModel
|
|||
other.pinchPosterZoom == pinchPosterZoom) &&
|
||||
(identical(other.mouseDragSupport, mouseDragSupport) ||
|
||||
other.mouseDragSupport == mouseDragSupport) &&
|
||||
(identical(other.requireWifi, requireWifi) ||
|
||||
other.requireWifi == requireWifi) &&
|
||||
(identical(other.schemeVariant, schemeVariant) ||
|
||||
other.schemeVariant == schemeVariant) &&
|
||||
(identical(other.libraryPageSize, libraryPageSize) ||
|
||||
|
|
@ -475,6 +495,7 @@ class _$ClientSettingsModelImpl extends _ClientSettingsModel
|
|||
posterSize,
|
||||
pinchPosterZoom,
|
||||
mouseDragSupport,
|
||||
requireWifi,
|
||||
schemeVariant,
|
||||
libraryPageSize);
|
||||
|
||||
|
|
@ -512,6 +533,7 @@ abstract class _ClientSettingsModel extends ClientSettingsModel {
|
|||
final double posterSize,
|
||||
final bool pinchPosterZoom,
|
||||
final bool mouseDragSupport,
|
||||
final bool requireWifi,
|
||||
final DynamicSchemeVariant schemeVariant,
|
||||
final int? libraryPageSize}) = _$ClientSettingsModelImpl;
|
||||
_ClientSettingsModel._() : super._();
|
||||
|
|
@ -551,6 +573,8 @@ abstract class _ClientSettingsModel extends ClientSettingsModel {
|
|||
@override
|
||||
bool get mouseDragSupport;
|
||||
@override
|
||||
bool get requireWifi;
|
||||
@override
|
||||
DynamicSchemeVariant get schemeVariant;
|
||||
@override
|
||||
int? get libraryPageSize;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ _$ClientSettingsModelImpl _$$ClientSettingsModelImplFromJson(
|
|||
ThemeMode.system,
|
||||
themeColor: $enumDecodeNullable(_$ColorThemesEnumMap, json['themeColor']),
|
||||
amoledBlack: json['amoledBlack'] as bool? ?? false,
|
||||
blurPlaceHolders: json['blurPlaceHolders'] as bool? ?? false,
|
||||
blurPlaceHolders: json['blurPlaceHolders'] as bool? ?? true,
|
||||
blurUpcomingEpisodes: json['blurUpcomingEpisodes'] as bool? ?? false,
|
||||
selectedLocale:
|
||||
const LocaleConvert().fromJson(json['selectedLocale'] as String?),
|
||||
|
|
@ -34,6 +34,7 @@ _$ClientSettingsModelImpl _$$ClientSettingsModelImplFromJson(
|
|||
posterSize: (json['posterSize'] as num?)?.toDouble() ?? 1.0,
|
||||
pinchPosterZoom: json['pinchPosterZoom'] as bool? ?? false,
|
||||
mouseDragSupport: json['mouseDragSupport'] as bool? ?? false,
|
||||
requireWifi: json['requireWifi'] as bool? ?? true,
|
||||
schemeVariant: $enumDecodeNullable(
|
||||
_$DynamicSchemeVariantEnumMap, json['schemeVariant']) ??
|
||||
DynamicSchemeVariant.tonalSpot,
|
||||
|
|
@ -58,6 +59,7 @@ Map<String, dynamic> _$$ClientSettingsModelImplToJson(
|
|||
'posterSize': instance.posterSize,
|
||||
'pinchPosterZoom': instance.pinchPosterZoom,
|
||||
'mouseDragSupport': instance.mouseDragSupport,
|
||||
'requireWifi': instance.requireWifi,
|
||||
'schemeVariant': _$DynamicSchemeVariantEnumMap[instance.schemeVariant]!,
|
||||
'libraryPageSize': instance.libraryPageSize,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,4 +56,6 @@ class ClientSettingsNotifier extends StateNotifier<ClientSettingsModel> {
|
|||
|
||||
void setSchemeVariant(DynamicSchemeVariant? type) =>
|
||||
state = state.copyWith(schemeVariant: type ?? state.schemeVariant);
|
||||
|
||||
void setRequireWifi(bool value) => state = state.copyWith(requireWifi: value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ class SyncNotifier extends StateNotifier<SyncSettingsModel> {
|
|||
filename: syncItem.videoFileName,
|
||||
updates: Updates.statusAndProgress,
|
||||
baseDirectory: BaseDirectory.root,
|
||||
requiresWiFi: true,
|
||||
requiresWiFi: ref.read(clientSettingsProvider.select((value) => value.requireWifi)),
|
||||
retries: 5,
|
||||
allowPause: true,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -145,6 +145,15 @@ class _ClientSettingsPageState extends ConsumerState<ClientSettingsPage> {
|
|||
);
|
||||
},
|
||||
),
|
||||
SettingsListTile(
|
||||
label: Text(context.localized.clientSettingsRequireWifiTitle),
|
||||
subLabel: Text(context.localized.clientSettingsRequireWifiDesc),
|
||||
onTap: () => ref.read(clientSettingsProvider.notifier).setRequireWifi(!clientSettings.requireWifi),
|
||||
trailing: Switch(
|
||||
value: clientSettings.requireWifi,
|
||||
onChanged: (value) => ref.read(clientSettingsProvider.notifier).setRequireWifi(value),
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
],
|
||||
SettingsLabelDivider(label: context.localized.lockscreen),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue