diff --git a/app/lib/features/geckoview/features/preferences/data/models/preference_setting.dart b/app/lib/features/geckoview/features/preferences/data/models/preference_setting.dart index 722f5550..6b2ba5a8 100644 --- a/app/lib/features/geckoview/features/preferences/data/models/preference_setting.dart +++ b/app/lib/features/geckoview/features/preferences/data/models/preference_setting.dart @@ -33,6 +33,10 @@ class PreferenceSettingGroup with FastEquatable { (setting) => setting.requireUserOptIn || setting.isActive, ); + bool get showMasterSwitch => + settings.values.length > + settings.values.where((setting) => setting.requireUserOptIn).length; + bool get isPartlyActive => settings.values.any((setting) => setting.isActive); bool get hasInactiveOptional => settings.values.any( diff --git a/app/lib/features/settings/presentation/screens/web_engine_hardening_group.dart b/app/lib/features/settings/presentation/screens/web_engine_hardening_group.dart index afcf916d..2439abe7 100644 --- a/app/lib/features/settings/presentation/screens/web_engine_hardening_group.dart +++ b/app/lib/features/settings/presentation/screens/web_engine_hardening_group.dart @@ -47,46 +47,47 @@ class WebEngineHardeningGroupScreen extends HookConsumerWidget { data: (group) { return Column( children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Card( - color: theme.colorScheme.primaryContainer, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: SwitchListTile( - value: group.isActiveOrOptional, - title: Text( - groupName, - style: TextStyle( - color: theme.colorScheme.onPrimaryContainer, - ), - ), - subtitle: group.description.mapNotNull( - (description) => Text( - description, + if (group.showMasterSwitch) + Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + color: theme.colorScheme.primaryContainer, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: SwitchListTile( + value: group.isActiveOrOptional, + title: Text( + groupName, style: TextStyle( color: theme.colorScheme.onPrimaryContainer, ), ), - ), - onChanged: (value) async { - final notifier = ref.read( - preferenceSettingsGroupRepositoryProvider( - PreferencePartition.user, - groupName, - ).notifier, - ); + subtitle: group.description.mapNotNull( + (description) => Text( + description, + style: TextStyle( + color: theme.colorScheme.onPrimaryContainer, + ), + ), + ), + onChanged: (value) async { + final notifier = ref.read( + preferenceSettingsGroupRepositoryProvider( + PreferencePartition.user, + groupName, + ).notifier, + ); - if (value) { - await notifier.apply(); - } else { - await notifier.reset(); - } - }, + if (value) { + await notifier.apply(); + } else { + await notifier.reset(); + } + }, + ), ), ), ), - ), Expanded( child: ListView( children: group.settings.entries.map((setting) {