setting to control swipe to refresh
This commit is contained in:
+17
@@ -61,6 +61,23 @@ class EngineSettingsReplicationService
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
fireImmediately: true,
|
||||
generalSettingsWithDefaultsProvider.select(
|
||||
(settings) => settings.pullToRefreshEnabled,
|
||||
),
|
||||
(previous, next) async {
|
||||
await _service.setPullToRefreshEnabled(next);
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
logger.e(
|
||||
'Error listening to pullToRefreshEnabled',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
fireImmediately: true,
|
||||
engineSettingsRepositoryProvider,
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ final class EngineSettingsReplicationServiceProvider
|
||||
}
|
||||
|
||||
String _$engineSettingsReplicationServiceHash() =>
|
||||
r'7583ebc8ca9c11377486ff5a3e763493dcdc903a';
|
||||
r'0a9539e19946028f525de64ed5f33e2483e7abc2';
|
||||
|
||||
abstract class _$EngineSettingsReplicationService extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
@@ -66,6 +66,7 @@ class GeneralSettingsScreen extends StatelessWidget {
|
||||
_AutoHideTabBarTile(),
|
||||
_BottomSheetTabViewTile(),
|
||||
_TabBarSwipeBehaviorSection(),
|
||||
_PullToRefreshTile(),
|
||||
_IconCacheTile(),
|
||||
],
|
||||
);
|
||||
@@ -840,6 +841,32 @@ class _TabBarSwipeBehaviorSection extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class _PullToRefreshTile extends HookConsumerWidget {
|
||||
const _PullToRefreshTile();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final pullToRefreshEnabled = ref.watch(
|
||||
generalSettingsWithDefaultsProvider.select((s) => s.pullToRefreshEnabled),
|
||||
);
|
||||
|
||||
return SwitchListTile.adaptive(
|
||||
title: const Text('Pull to Refresh'),
|
||||
subtitle: const Text('Swipe down on pages to reload them'),
|
||||
secondary: const Icon(MdiIcons.gestureSwipeDown),
|
||||
value: pullToRefreshEnabled,
|
||||
onChanged: (value) async {
|
||||
await ref
|
||||
.read(saveGeneralSettingsControllerProvider.notifier)
|
||||
.save(
|
||||
(currentSettings) =>
|
||||
currentSettings.copyWith.pullToRefreshEnabled(value),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _IconCacheTile extends HookConsumerWidget {
|
||||
const _IconCacheTile();
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ class GeneralSettings with FastEquatable {
|
||||
final bool tabBarShowQuickTabSwitcherBar;
|
||||
final TabBarPosition tabBarPosition;
|
||||
final QuickTabSwitcherMode quickTabSwitcherMode;
|
||||
final bool pullToRefreshEnabled;
|
||||
|
||||
GeneralSettings({
|
||||
required this.themeMode,
|
||||
@@ -102,6 +103,7 @@ class GeneralSettings with FastEquatable {
|
||||
required this.tabBarShowQuickTabSwitcherBar,
|
||||
required this.tabBarPosition,
|
||||
required this.quickTabSwitcherMode,
|
||||
required this.pullToRefreshEnabled,
|
||||
});
|
||||
|
||||
GeneralSettings.withDefaults({
|
||||
@@ -125,6 +127,7 @@ class GeneralSettings with FastEquatable {
|
||||
bool? tabBarShowQuickTabSwitcherBar,
|
||||
TabBarPosition? tabBarPosition,
|
||||
QuickTabSwitcherMode? quickTabSwitcherMode,
|
||||
bool? pullToRefreshEnabled,
|
||||
}) : themeMode = themeMode ?? ThemeMode.dark,
|
||||
enableReadability = enableReadability ?? true,
|
||||
enforceReadability = enforceReadability ?? false,
|
||||
@@ -147,7 +150,8 @@ class GeneralSettings with FastEquatable {
|
||||
tabBarShowQuickTabSwitcherBar = tabBarShowQuickTabSwitcherBar ?? true,
|
||||
tabBarPosition = tabBarPosition ?? TabBarPosition.bottom,
|
||||
quickTabSwitcherMode =
|
||||
quickTabSwitcherMode ?? QuickTabSwitcherMode.lastUsedTabs;
|
||||
quickTabSwitcherMode ?? QuickTabSwitcherMode.lastUsedTabs,
|
||||
pullToRefreshEnabled = pullToRefreshEnabled ?? true;
|
||||
|
||||
factory GeneralSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$GeneralSettingsFromJson(json);
|
||||
@@ -176,5 +180,6 @@ class GeneralSettings with FastEquatable {
|
||||
tabBarShowQuickTabSwitcherBar,
|
||||
tabBarPosition,
|
||||
quickTabSwitcherMode,
|
||||
pullToRefreshEnabled,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ abstract class _$GeneralSettingsCWProxy {
|
||||
QuickTabSwitcherMode quickTabSwitcherMode,
|
||||
);
|
||||
|
||||
GeneralSettings pullToRefreshEnabled(bool pullToRefreshEnabled);
|
||||
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
@@ -85,6 +87,7 @@ abstract class _$GeneralSettingsCWProxy {
|
||||
bool tabBarShowQuickTabSwitcherBar,
|
||||
TabBarPosition tabBarPosition,
|
||||
QuickTabSwitcherMode quickTabSwitcherMode,
|
||||
bool pullToRefreshEnabled,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,6 +182,10 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
QuickTabSwitcherMode quickTabSwitcherMode,
|
||||
) => call(quickTabSwitcherMode: quickTabSwitcherMode);
|
||||
|
||||
@override
|
||||
GeneralSettings pullToRefreshEnabled(bool pullToRefreshEnabled) =>
|
||||
call(pullToRefreshEnabled: pullToRefreshEnabled);
|
||||
|
||||
@override
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `GeneralSettings(...).copyWith.fieldName(value)`.
|
||||
@@ -208,6 +215,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
Object? tabBarShowQuickTabSwitcherBar = const $CopyWithPlaceholder(),
|
||||
Object? tabBarPosition = const $CopyWithPlaceholder(),
|
||||
Object? quickTabSwitcherMode = const $CopyWithPlaceholder(),
|
||||
Object? pullToRefreshEnabled = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return GeneralSettings(
|
||||
themeMode: themeMode == const $CopyWithPlaceholder() || themeMode == null
|
||||
@@ -326,6 +334,12 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
||||
? _value.quickTabSwitcherMode
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: quickTabSwitcherMode as QuickTabSwitcherMode,
|
||||
pullToRefreshEnabled:
|
||||
pullToRefreshEnabled == const $CopyWithPlaceholder() ||
|
||||
pullToRefreshEnabled == null
|
||||
? _value.pullToRefreshEnabled
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: pullToRefreshEnabled as bool,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -390,6 +404,7 @@ GeneralSettings _$GeneralSettingsFromJson(
|
||||
_$QuickTabSwitcherModeEnumMap,
|
||||
json['quickTabSwitcherMode'],
|
||||
),
|
||||
pullToRefreshEnabled: json['pullToRefreshEnabled'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GeneralSettingsToJson(
|
||||
@@ -423,6 +438,7 @@ Map<String, dynamic> _$GeneralSettingsToJson(
|
||||
'tabBarPosition': _$TabBarPositionEnumMap[instance.tabBarPosition]!,
|
||||
'quickTabSwitcherMode':
|
||||
_$QuickTabSwitcherModeEnumMap[instance.quickTabSwitcherMode]!,
|
||||
'pullToRefreshEnabled': instance.pullToRefreshEnabled,
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
|
||||
@@ -122,6 +122,10 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
|
||||
DriftSqlType.string,
|
||||
db.typeMapping,
|
||||
),
|
||||
'pullToRefreshEnabled': settings['pullToRefreshEnabled']?.readAs(
|
||||
DriftSqlType.bool,
|
||||
db.typeMapping,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ final class GeneralSettingsRepositoryProvider
|
||||
}
|
||||
|
||||
String _$generalSettingsRepositoryHash() =>
|
||||
r'74db28f2adc4e35a4c00bb2b7f137ed05a3bc662';
|
||||
r'dceccac3a93e96907c7bd2b4c58f5021912553ac';
|
||||
|
||||
abstract class _$GeneralSettingsRepository
|
||||
extends $StreamNotifier<GeneralSettings> {
|
||||
|
||||
Reference in New Issue
Block a user