From c751c6fe1575199652d4ffb58f04d9ddd1d0f4fa Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Wed, 11 Mar 2026 15:54:18 +0100 Subject: [PATCH] setting to control modal barrier --- .../routing/widgets/bottom_sheet_page.dart | 2 ++ app/lib/core/routing/widgets/dialog_page.dart | 2 +- .../browser/presentation/screens/browser.dart | 2 +- .../screens/appearance_display_settings.dart | 29 +++++++++++++++++++ .../user/data/models/general_settings.dart | 5 ++++ .../user/data/models/general_settings.g.dart | 16 ++++++++++ .../domain/repositories/general_settings.dart | 4 +++ .../repositories/general_settings.g.dart | 2 +- app/lib/main.dart | 17 +++++++++++ 9 files changed, 76 insertions(+), 3 deletions(-) diff --git a/app/lib/core/routing/widgets/bottom_sheet_page.dart b/app/lib/core/routing/widgets/bottom_sheet_page.dart index 053a1454..0c269425 100644 --- a/app/lib/core/routing/widgets/bottom_sheet_page.dart +++ b/app/lib/core/routing/widgets/bottom_sheet_page.dart @@ -54,6 +54,8 @@ class BottomSheetPage extends Page { shape: Theme.of(context).bottomSheetTheme.shape, clipBehavior: Clip.antiAlias, constraints: Theme.of(context).bottomSheetTheme.constraints, + modalBarrierColor: + barrierColor ?? Theme.of(context).bottomSheetTheme.modalBarrierColor, isScrollControlled: isScrollControlled, isDismissible: barrierDismissible, useSafeArea: useSafeArea, diff --git a/app/lib/core/routing/widgets/dialog_page.dart b/app/lib/core/routing/widgets/dialog_page.dart index a2cd1d3d..5faef544 100644 --- a/app/lib/core/routing/widgets/dialog_page.dart +++ b/app/lib/core/routing/widgets/dialog_page.dart @@ -33,7 +33,7 @@ class DialogPage extends Page { const DialogPage({ required this.builder, this.anchorPoint, - this.barrierColor = Colors.black54, + this.barrierColor, this.barrierDismissible = true, this.barrierLabel, this.useSafeArea = true, diff --git a/app/lib/features/geckoview/features/browser/presentation/screens/browser.dart b/app/lib/features/geckoview/features/browser/presentation/screens/browser.dart index 92becfb5..12c6140a 100644 --- a/app/lib/features/geckoview/features/browser/presentation/screens/browser.dart +++ b/app/lib/features/geckoview/features/browser/presentation/screens/browser.dart @@ -505,7 +505,7 @@ class BrowserScreen extends HookConsumerWidget { // Theme with dynamic snackbar margin to position above bottom toolbar final themeData = Theme.of(context).copyWith( - bottomSheetTheme: BottomSheetThemeData( + bottomSheetTheme: Theme.of(context).bottomSheetTheme.copyWith( constraints: BoxConstraints( maxWidth: MediaQuery.of(context).size.width - diff --git a/app/lib/features/settings/presentation/screens/appearance_display_settings.dart b/app/lib/features/settings/presentation/screens/appearance_display_settings.dart index 7def9881..5b9fa831 100644 --- a/app/lib/features/settings/presentation/screens/appearance_display_settings.dart +++ b/app/lib/features/settings/presentation/screens/appearance_display_settings.dart @@ -69,6 +69,7 @@ class _VisualSection extends StatelessWidget { SettingSection(name: 'Visual'), _UiZoomSection(), _DisableAnimationsTile(), + _ShowModalBarrierTile(), _ThemeSection(), ], ); @@ -177,6 +178,34 @@ class _DisableAnimationsTile extends HookConsumerWidget { } } +class _ShowModalBarrierTile extends HookConsumerWidget { + const _ShowModalBarrierTile(); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final showModalBarrier = ref.watch( + generalSettingsWithDefaultsProvider.select((s) => s.showModalBarrier), + ); + + return SwitchListTile.adaptive( + title: const Text('Show Modal Barrier'), + subtitle: const Text( + 'Dim the background behind dialogs and bottom sheets', + ), + secondary: const Icon(Icons.layers), + value: showModalBarrier, + onChanged: (value) async { + await ref + .read(saveGeneralSettingsControllerProvider.notifier) + .save( + (currentSettings) => + currentSettings.copyWith.showModalBarrier(value), + ); + }, + ); + } +} + class _TabBarSection extends StatelessWidget { const _TabBarSection(); diff --git a/app/lib/features/user/data/models/general_settings.dart b/app/lib/features/user/data/models/general_settings.dart index 73b4073a..1ccd7cfc 100644 --- a/app/lib/features/user/data/models/general_settings.dart +++ b/app/lib/features/user/data/models/general_settings.dart @@ -69,6 +69,7 @@ class GeneralSettings with FastEquatable { final ThemeMode themeMode; final double uiScaleFactor; final bool disableAnimations; + final bool showModalBarrier; final bool enableReadability; final bool enforceReadability; final Set? deleteBrowsingDataOnQuit; @@ -119,6 +120,7 @@ class GeneralSettings with FastEquatable { required this.themeMode, required this.uiScaleFactor, required this.disableAnimations, + required this.showModalBarrier, required this.enableReadability, required this.enforceReadability, required this.deleteBrowsingDataOnQuit, @@ -168,6 +170,7 @@ class GeneralSettings with FastEquatable { ThemeMode? themeMode, double? uiScaleFactor, bool? disableAnimations, + bool? showModalBarrier, bool? enableReadability, bool? enforceReadability, this.deleteBrowsingDataOnQuit, @@ -214,6 +217,7 @@ class GeneralSettings with FastEquatable { }) : themeMode = themeMode ?? ThemeMode.dark, uiScaleFactor = uiScaleFactor ?? defaultUiScaleFactor, disableAnimations = disableAnimations ?? false, + showModalBarrier = showModalBarrier ?? true, enableReadability = enableReadability ?? true, enforceReadability = enforceReadability ?? false, defaultSearchProvider = defaultSearchProvider ?? _fallbackSearchProvider, @@ -293,6 +297,7 @@ class GeneralSettings with FastEquatable { themeMode, uiScaleFactor, disableAnimations, + showModalBarrier, enableReadability, enforceReadability, deleteBrowsingDataOnQuit, diff --git a/app/lib/features/user/data/models/general_settings.g.dart b/app/lib/features/user/data/models/general_settings.g.dart index 05f82084..c91eed57 100644 --- a/app/lib/features/user/data/models/general_settings.g.dart +++ b/app/lib/features/user/data/models/general_settings.g.dart @@ -13,6 +13,8 @@ abstract class _$GeneralSettingsCWProxy { GeneralSettings disableAnimations(bool disableAnimations); + GeneralSettings showModalBarrier(bool showModalBarrier); + GeneralSettings enableReadability(bool enableReadability); GeneralSettings enforceReadability(bool enforceReadability); @@ -128,6 +130,7 @@ abstract class _$GeneralSettingsCWProxy { ThemeMode themeMode, double uiScaleFactor, bool disableAnimations, + bool showModalBarrier, bool enableReadability, bool enforceReadability, Set? deleteBrowsingDataOnQuit, @@ -192,6 +195,10 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy { GeneralSettings disableAnimations(bool disableAnimations) => call(disableAnimations: disableAnimations); + @override + GeneralSettings showModalBarrier(bool showModalBarrier) => + call(showModalBarrier: showModalBarrier); + @override GeneralSettings enableReadability(bool enableReadability) => call(enableReadability: enableReadability); @@ -389,6 +396,7 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy { Object? themeMode = const $CopyWithPlaceholder(), Object? uiScaleFactor = const $CopyWithPlaceholder(), Object? disableAnimations = const $CopyWithPlaceholder(), + Object? showModalBarrier = const $CopyWithPlaceholder(), Object? enableReadability = const $CopyWithPlaceholder(), Object? enforceReadability = const $CopyWithPlaceholder(), Object? deleteBrowsingDataOnQuit = const $CopyWithPlaceholder(), @@ -450,6 +458,12 @@ class _$GeneralSettingsCWProxyImpl implements _$GeneralSettingsCWProxy { ? _value.disableAnimations // ignore: cast_nullable_to_non_nullable : disableAnimations as bool, + showModalBarrier: + showModalBarrier == const $CopyWithPlaceholder() || + showModalBarrier == null + ? _value.showModalBarrier + // ignore: cast_nullable_to_non_nullable + : showModalBarrier as bool, enableReadability: enableReadability == const $CopyWithPlaceholder() || enableReadability == null @@ -726,6 +740,7 @@ GeneralSettings _$GeneralSettingsFromJson( themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']), uiScaleFactor: (json['uiScaleFactor'] as num?)?.toDouble(), disableAnimations: json['disableAnimations'] as bool?, + showModalBarrier: json['showModalBarrier'] as bool?, enableReadability: json['enableReadability'] as bool?, enforceReadability: json['enforceReadability'] as bool?, deleteBrowsingDataOnQuit: (json['deleteBrowsingDataOnQuit'] as List?) @@ -815,6 +830,7 @@ Map _$GeneralSettingsToJson( 'themeMode': _$ThemeModeEnumMap[instance.themeMode]!, 'uiScaleFactor': instance.uiScaleFactor, 'disableAnimations': instance.disableAnimations, + 'showModalBarrier': instance.showModalBarrier, 'enableReadability': instance.enableReadability, 'enforceReadability': instance.enforceReadability, 'deleteBrowsingDataOnQuit': instance.deleteBrowsingDataOnQuit diff --git a/app/lib/features/user/domain/repositories/general_settings.dart b/app/lib/features/user/domain/repositories/general_settings.dart index e4f3f7f3..748440fe 100644 --- a/app/lib/features/user/domain/repositories/general_settings.dart +++ b/app/lib/features/user/domain/repositories/general_settings.dart @@ -56,6 +56,10 @@ class GeneralSettingsRepository extends _$GeneralSettingsRepository { DriftSqlType.bool, db.typeMapping, ), + 'showModalBarrier': settings['showModalBarrier']?.readAs( + DriftSqlType.bool, + db.typeMapping, + ), 'enableReadability': settings['enableReadability']?.readAs( DriftSqlType.bool, db.typeMapping, diff --git a/app/lib/features/user/domain/repositories/general_settings.g.dart b/app/lib/features/user/domain/repositories/general_settings.g.dart index aa8679c5..31a880ff 100644 --- a/app/lib/features/user/domain/repositories/general_settings.g.dart +++ b/app/lib/features/user/domain/repositories/general_settings.g.dart @@ -35,7 +35,7 @@ final class GeneralSettingsRepositoryProvider } String _$generalSettingsRepositoryHash() => - r'12e49ad38ff25c6bad1680b3eb3a01274ebfb35f'; + r'7a30fefa2cdc934232e08e8809c62a83e99635fd'; abstract class _$GeneralSettingsRepository extends $StreamNotifier { diff --git a/app/lib/main.dart b/app/lib/main.dart index f7e26673..03c3d436 100644 --- a/app/lib/main.dart +++ b/app/lib/main.dart @@ -163,6 +163,11 @@ class _MainWidget extends HookConsumerWidget { (value) => value.disableAnimations, ), ); + final showModalBarrier = ref.watch( + generalSettingsWithDefaultsProvider.select( + (value) => value.showModalBarrier, + ), + ); useOnInitialization(() async { await CountryCodes.init(); @@ -286,6 +291,12 @@ class _MainWidget extends HookConsumerWidget { pageTransitionsTheme: disableAnimations ? _noAnimationPageTransitionsTheme : null, + dialogTheme: DialogThemeData( + barrierColor: showModalBarrier ? null : Colors.transparent, + ), + bottomSheetTheme: BottomSheetThemeData( + modalBarrierColor: showModalBarrier ? null : Colors.transparent, + ), extensions: const >[AppColors.light], ), darkTheme: ThemeData( @@ -294,6 +305,12 @@ class _MainWidget extends HookConsumerWidget { pageTransitionsTheme: disableAnimations ? _noAnimationPageTransitionsTheme : null, + dialogTheme: DialogThemeData( + barrierColor: showModalBarrier ? null : Colors.transparent, + ), + bottomSheetTheme: BottomSheetThemeData( + modalBarrierColor: showModalBarrier ? null : Colors.transparent, + ), extensions: const >[AppColors.dark], ), themeMode: themeMode,