dont show master switch if there are no required options
This commit is contained in:
@@ -33,6 +33,10 @@ class PreferenceSettingGroup with FastEquatable {
|
|||||||
(setting) => setting.requireUserOptIn || setting.isActive,
|
(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 isPartlyActive => settings.values.any((setting) => setting.isActive);
|
||||||
|
|
||||||
bool get hasInactiveOptional => settings.values.any(
|
bool get hasInactiveOptional => settings.values.any(
|
||||||
|
|||||||
@@ -47,46 +47,47 @@ class WebEngineHardeningGroupScreen extends HookConsumerWidget {
|
|||||||
data: (group) {
|
data: (group) {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
if (group.showMasterSwitch)
|
||||||
padding: const EdgeInsets.all(8.0),
|
Padding(
|
||||||
child: Card(
|
padding: const EdgeInsets.all(8.0),
|
||||||
color: theme.colorScheme.primaryContainer,
|
child: Card(
|
||||||
child: Padding(
|
color: theme.colorScheme.primaryContainer,
|
||||||
padding: const EdgeInsets.all(8.0),
|
child: Padding(
|
||||||
child: SwitchListTile(
|
padding: const EdgeInsets.all(8.0),
|
||||||
value: group.isActiveOrOptional,
|
child: SwitchListTile(
|
||||||
title: Text(
|
value: group.isActiveOrOptional,
|
||||||
groupName,
|
title: Text(
|
||||||
style: TextStyle(
|
groupName,
|
||||||
color: theme.colorScheme.onPrimaryContainer,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: group.description.mapNotNull(
|
|
||||||
(description) => Text(
|
|
||||||
description,
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: theme.colorScheme.onPrimaryContainer,
|
color: theme.colorScheme.onPrimaryContainer,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
subtitle: group.description.mapNotNull(
|
||||||
onChanged: (value) async {
|
(description) => Text(
|
||||||
final notifier = ref.read(
|
description,
|
||||||
preferenceSettingsGroupRepositoryProvider(
|
style: TextStyle(
|
||||||
PreferencePartition.user,
|
color: theme.colorScheme.onPrimaryContainer,
|
||||||
groupName,
|
),
|
||||||
).notifier,
|
),
|
||||||
);
|
),
|
||||||
|
onChanged: (value) async {
|
||||||
|
final notifier = ref.read(
|
||||||
|
preferenceSettingsGroupRepositoryProvider(
|
||||||
|
PreferencePartition.user,
|
||||||
|
groupName,
|
||||||
|
).notifier,
|
||||||
|
);
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
await notifier.apply();
|
await notifier.apply();
|
||||||
} else {
|
} else {
|
||||||
await notifier.reset();
|
await notifier.reset();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: group.settings.entries.map((setting) {
|
children: group.settings.entries.map((setting) {
|
||||||
|
|||||||
Reference in New Issue
Block a user