make drawer gesture controllable via settings
This commit is contained in:
@@ -292,6 +292,12 @@ class BrowserScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final drawerGestureEnabled = ref.watch(
|
||||||
|
generalSettingsWithDefaultsProvider.select(
|
||||||
|
(value) => value.drawerGestureEnabled,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final displayAppBar = useValueNotifier(true);
|
final displayAppBar = useValueNotifier(true);
|
||||||
|
|
||||||
ref.listen(tabBarDismissableControllerProvider, (previous, next) {
|
ref.listen(tabBarDismissableControllerProvider, (previous, next) {
|
||||||
@@ -462,7 +468,7 @@ class BrowserScreen extends HookConsumerWidget {
|
|||||||
// Minimal scaffold - only for Material overlay support (SnackBars)
|
// Minimal scaffold - only for Material overlay support (SnackBars)
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
endDrawer: const BrowserNavigationDrawer(),
|
endDrawer: const BrowserNavigationDrawer(),
|
||||||
endDrawerEnableOpenDragGesture: false,
|
endDrawerEnableOpenDragGesture: drawerGestureEnabled,
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
// Layer 0: Browser content
|
// Layer 0: Browser content
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ class _GesturesSection extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
SettingSection(name: 'Gestures'),
|
SettingSection(name: 'Gestures'),
|
||||||
_PullToRefreshTile(),
|
_PullToRefreshTile(),
|
||||||
|
_DrawerGestureTile(),
|
||||||
_DoubleBackCloseTabTile(),
|
_DoubleBackCloseTabTile(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -470,6 +471,32 @@ class _PullToRefreshTile extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _DrawerGestureTile extends HookConsumerWidget {
|
||||||
|
const _DrawerGestureTile();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final drawerGestureEnabled = ref.watch(
|
||||||
|
generalSettingsWithDefaultsProvider.select((s) => s.drawerGestureEnabled),
|
||||||
|
);
|
||||||
|
|
||||||
|
return SwitchListTile.adaptive(
|
||||||
|
title: const Text('Drawer Swipe Gesture'),
|
||||||
|
subtitle: const Text('Swipe from screen edge to open navigation drawer'),
|
||||||
|
secondary: const Icon(MdiIcons.gestureSwipe),
|
||||||
|
value: drawerGestureEnabled,
|
||||||
|
onChanged: (value) async {
|
||||||
|
await ref
|
||||||
|
.read(saveGeneralSettingsControllerProvider.notifier)
|
||||||
|
.save(
|
||||||
|
(currentSettings) =>
|
||||||
|
currentSettings.copyWith.drawerGestureEnabled(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _DoubleBackCloseTabTile extends HookConsumerWidget {
|
class _DoubleBackCloseTabTile extends HookConsumerWidget {
|
||||||
const _DoubleBackCloseTabTile();
|
const _DoubleBackCloseTabTile();
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class GeneralSettings with FastEquatable {
|
|||||||
final bool allowClipboardAccess;
|
final bool allowClipboardAccess;
|
||||||
final bool tabListShowFavicons;
|
final bool tabListShowFavicons;
|
||||||
final bool quickTabSwitcherShowTitles;
|
final bool quickTabSwitcherShowTitles;
|
||||||
|
final bool drawerGestureEnabled;
|
||||||
|
|
||||||
GeneralSettings({
|
GeneralSettings({
|
||||||
required this.themeMode,
|
required this.themeMode,
|
||||||
@@ -118,6 +119,7 @@ class GeneralSettings with FastEquatable {
|
|||||||
required this.allowClipboardAccess,
|
required this.allowClipboardAccess,
|
||||||
required this.tabListShowFavicons,
|
required this.tabListShowFavicons,
|
||||||
required this.quickTabSwitcherShowTitles,
|
required this.quickTabSwitcherShowTitles,
|
||||||
|
required this.drawerGestureEnabled,
|
||||||
});
|
});
|
||||||
|
|
||||||
GeneralSettings.withDefaults({
|
GeneralSettings.withDefaults({
|
||||||
@@ -149,6 +151,7 @@ class GeneralSettings with FastEquatable {
|
|||||||
bool? allowClipboardAccess,
|
bool? allowClipboardAccess,
|
||||||
bool? tabListShowFavicons,
|
bool? tabListShowFavicons,
|
||||||
bool? quickTabSwitcherShowTitles,
|
bool? quickTabSwitcherShowTitles,
|
||||||
|
bool? drawerGestureEnabled,
|
||||||
}) : themeMode = themeMode ?? ThemeMode.dark,
|
}) : themeMode = themeMode ?? ThemeMode.dark,
|
||||||
enableReadability = enableReadability ?? true,
|
enableReadability = enableReadability ?? true,
|
||||||
enforceReadability = enforceReadability ?? false,
|
enforceReadability = enforceReadability ?? false,
|
||||||
@@ -180,7 +183,8 @@ class GeneralSettings with FastEquatable {
|
|||||||
maxSearchHistoryEntries = maxSearchHistoryEntries ?? 5,
|
maxSearchHistoryEntries = maxSearchHistoryEntries ?? 5,
|
||||||
allowClipboardAccess = allowClipboardAccess ?? true,
|
allowClipboardAccess = allowClipboardAccess ?? true,
|
||||||
tabListShowFavicons = tabListShowFavicons ?? false,
|
tabListShowFavicons = tabListShowFavicons ?? false,
|
||||||
quickTabSwitcherShowTitles = quickTabSwitcherShowTitles ?? true;
|
quickTabSwitcherShowTitles = quickTabSwitcherShowTitles ?? true,
|
||||||
|
drawerGestureEnabled = drawerGestureEnabled ?? false;
|
||||||
|
|
||||||
factory GeneralSettings.fromJson(Map<String, dynamic> json) =>
|
factory GeneralSettings.fromJson(Map<String, dynamic> json) =>
|
||||||
_$GeneralSettingsFromJson(json);
|
_$GeneralSettingsFromJson(json);
|
||||||
@@ -217,5 +221,6 @@ class GeneralSettings with FastEquatable {
|
|||||||
allowClipboardAccess,
|
allowClipboardAccess,
|
||||||
tabListShowFavicons,
|
tabListShowFavicons,
|
||||||
quickTabSwitcherShowTitles,
|
quickTabSwitcherShowTitles,
|
||||||
|
drawerGestureEnabled,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ abstract class _$GeneralSettingsCWProxy {
|
|||||||
|
|
||||||
GeneralSettings quickTabSwitcherShowTitles(bool quickTabSwitcherShowTitles);
|
GeneralSettings quickTabSwitcherShowTitles(bool quickTabSwitcherShowTitles);
|
||||||
|
|
||||||
|
GeneralSettings drawerGestureEnabled(bool drawerGestureEnabled);
|
||||||
|
|
||||||
/// Creates a new instance with the provided field values.
|
/// 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)`.
|
/// 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)`.
|
||||||
///
|
///
|
||||||
@@ -111,6 +113,7 @@ abstract class _$GeneralSettingsCWProxy {
|
|||||||
bool allowClipboardAccess,
|
bool allowClipboardAccess,
|
||||||
bool tabListShowFavicons,
|
bool tabListShowFavicons,
|
||||||
bool quickTabSwitcherShowTitles,
|
bool quickTabSwitcherShowTitles,
|
||||||
|
bool drawerGestureEnabled,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +241,10 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
|||||||
GeneralSettings quickTabSwitcherShowTitles(bool quickTabSwitcherShowTitles) =>
|
GeneralSettings quickTabSwitcherShowTitles(bool quickTabSwitcherShowTitles) =>
|
||||||
call(quickTabSwitcherShowTitles: quickTabSwitcherShowTitles);
|
call(quickTabSwitcherShowTitles: quickTabSwitcherShowTitles);
|
||||||
|
|
||||||
|
@override
|
||||||
|
GeneralSettings drawerGestureEnabled(bool drawerGestureEnabled) =>
|
||||||
|
call(drawerGestureEnabled: drawerGestureEnabled);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
/// Creates a new instance with the provided field values.
|
/// 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)`.
|
/// 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)`.
|
||||||
@@ -275,6 +282,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
|||||||
Object? allowClipboardAccess = const $CopyWithPlaceholder(),
|
Object? allowClipboardAccess = const $CopyWithPlaceholder(),
|
||||||
Object? tabListShowFavicons = const $CopyWithPlaceholder(),
|
Object? tabListShowFavicons = const $CopyWithPlaceholder(),
|
||||||
Object? quickTabSwitcherShowTitles = const $CopyWithPlaceholder(),
|
Object? quickTabSwitcherShowTitles = const $CopyWithPlaceholder(),
|
||||||
|
Object? drawerGestureEnabled = const $CopyWithPlaceholder(),
|
||||||
}) {
|
}) {
|
||||||
return GeneralSettings(
|
return GeneralSettings(
|
||||||
themeMode: themeMode == const $CopyWithPlaceholder() || themeMode == null
|
themeMode: themeMode == const $CopyWithPlaceholder() || themeMode == null
|
||||||
@@ -441,6 +449,12 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy {
|
|||||||
? _value.quickTabSwitcherShowTitles
|
? _value.quickTabSwitcherShowTitles
|
||||||
// ignore: cast_nullable_to_non_nullable
|
// ignore: cast_nullable_to_non_nullable
|
||||||
: quickTabSwitcherShowTitles as bool,
|
: quickTabSwitcherShowTitles as bool,
|
||||||
|
drawerGestureEnabled:
|
||||||
|
drawerGestureEnabled == const $CopyWithPlaceholder() ||
|
||||||
|
drawerGestureEnabled == null
|
||||||
|
? _value.drawerGestureEnabled
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: drawerGestureEnabled as bool,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,6 +533,7 @@ GeneralSettings _$GeneralSettingsFromJson(
|
|||||||
allowClipboardAccess: json['allowClipboardAccess'] as bool?,
|
allowClipboardAccess: json['allowClipboardAccess'] as bool?,
|
||||||
tabListShowFavicons: json['tabListShowFavicons'] as bool?,
|
tabListShowFavicons: json['tabListShowFavicons'] as bool?,
|
||||||
quickTabSwitcherShowTitles: json['quickTabSwitcherShowTitles'] as bool?,
|
quickTabSwitcherShowTitles: json['quickTabSwitcherShowTitles'] as bool?,
|
||||||
|
drawerGestureEnabled: json['drawerGestureEnabled'] as bool?,
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> _$GeneralSettingsToJson(
|
Map<String, dynamic> _$GeneralSettingsToJson(
|
||||||
@@ -561,6 +576,7 @@ Map<String, dynamic> _$GeneralSettingsToJson(
|
|||||||
'allowClipboardAccess': instance.allowClipboardAccess,
|
'allowClipboardAccess': instance.allowClipboardAccess,
|
||||||
'tabListShowFavicons': instance.tabListShowFavicons,
|
'tabListShowFavicons': instance.tabListShowFavicons,
|
||||||
'quickTabSwitcherShowTitles': instance.quickTabSwitcherShowTitles,
|
'quickTabSwitcherShowTitles': instance.quickTabSwitcherShowTitles,
|
||||||
|
'drawerGestureEnabled': instance.drawerGestureEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$ThemeModeEnumMap = {
|
const _$ThemeModeEnumMap = {
|
||||||
|
|||||||
@@ -151,6 +151,10 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository {
|
|||||||
),
|
),
|
||||||
'quickTabSwitcherShowTitles': settings['quickTabSwitcherShowTitles']
|
'quickTabSwitcherShowTitles': settings['quickTabSwitcherShowTitles']
|
||||||
?.readAs(DriftSqlType.bool, db.typeMapping),
|
?.readAs(DriftSqlType.bool, db.typeMapping),
|
||||||
|
'drawerGestureEnabled': settings['drawerGestureEnabled']?.readAs(
|
||||||
|
DriftSqlType.bool,
|
||||||
|
db.typeMapping,
|
||||||
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ final class GeneralSettingsRepositoryProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$generalSettingsRepositoryHash() =>
|
String _$generalSettingsRepositoryHash() =>
|
||||||
r'290fc9fb5dd79b94bb4a42a131184b385a1ecb4d';
|
r'33730ccb09471c1a7c187bd19760110f524e055b';
|
||||||
|
|
||||||
abstract class _$GeneralSettingsRepository
|
abstract class _$GeneralSettingsRepository
|
||||||
extends $StreamNotifier<GeneralSettings> {
|
extends $StreamNotifier<GeneralSettings> {
|
||||||
|
|||||||
Reference in New Issue
Block a user