consolidated radio groups

This commit is contained in:
Fabian Freund
2025-10-05 10:35:24 +02:00
parent f1f03b1b5c
commit ddccf4cb73
4 changed files with 117 additions and 233 deletions
@@ -49,64 +49,29 @@ class DohSettingsScreen extends HookConsumerWidget {
); );
} }
}, },
child: const RadioListTile.adaptive( child: const Column(
value: DohSettingsMode.geckoDefault, children: [
title: Text('Default Protection'), RadioListTile.adaptive(
subtitle: Text('DoH used only when default DNS fails'), value: DohSettingsMode.geckoDefault,
), title: Text('Default Protection'),
), subtitle: Text('DoH used only when default DNS fails'),
RadioGroup( ),
groupValue: dohSettings.dohSettingsMode, RadioListTile.adaptive(
onChanged: (value) async { value: DohSettingsMode.increased,
if (value != null) { title: Text('Increased Protection'),
await ref subtitle: Text('DoH preferred, default DNS as fallback'),
.read(saveEngineSettingsControllerProvider.notifier) ),
.save( RadioListTile.adaptive(
(currentSettings) => value: DohSettingsMode.max,
currentSettings.copyWith.dohSettingsMode(value), title: Text('Max Protection'),
); subtitle: Text('DoH only, no fallback'),
} ),
}, RadioListTile.adaptive(
child: const RadioListTile.adaptive( value: DohSettingsMode.off,
value: DohSettingsMode.increased, title: Text('Off'),
title: Text('Increased Protection'), subtitle: Text('Use your default DNS resolver'),
subtitle: Text('DoH preferred, default DNS as fallback'), ),
), ],
),
RadioGroup(
groupValue: dohSettings.dohSettingsMode,
onChanged: (value) async {
if (value != null) {
await ref
.read(saveEngineSettingsControllerProvider.notifier)
.save(
(currentSettings) =>
currentSettings.copyWith.dohSettingsMode(value),
);
}
},
child: const RadioListTile.adaptive(
value: DohSettingsMode.max,
title: Text('Max Protection'),
subtitle: Text('DoH only, no fallback'),
),
),
RadioGroup(
groupValue: dohSettings.dohSettingsMode,
onChanged: (value) async {
if (value != null) {
await ref
.read(saveEngineSettingsControllerProvider.notifier)
.save(
(currentSettings) =>
currentSettings.copyWith.dohSettingsMode(value),
);
}
},
child: const RadioListTile.adaptive(
value: DohSettingsMode.off,
title: Text('Off'),
subtitle: Text('Use your default DNS resolver'),
), ),
), ),
const ListTile( const ListTile(
@@ -420,34 +420,23 @@ class GeneralSettingsScreen extends HookConsumerWidget {
); );
} }
}, },
child: const RadioListTile.adaptive( child: const Column(
value: TabBarSwipeAction.switchLastOpened, children: [
title: Text('Switch to Last Used Tab'), RadioListTile.adaptive(
subtitle: Text( value: TabBarSwipeAction.switchLastOpened,
'Swipe to toggle between current and previously opened tab', title: Text('Switch to Last Used Tab'),
), subtitle: Text(
), 'Swipe to toggle between current and previously opened tab',
), ),
RadioGroup( ),
groupValue: generalSettings.tabBarSwipeAction, RadioListTile.adaptive(
onChanged: (value) async { value: TabBarSwipeAction.navigateOrderedTabs,
if (value != null) { title: Text('Navigate Sequential Tabs'),
await ref subtitle: Text(
.read( 'Swipe left/right to move through tabs in order',
saveGeneralSettingsControllerProvider.notifier, ),
) ),
.save( ],
(currentSettings) => currentSettings.copyWith
.tabBarSwipeAction(value),
);
}
},
child: const RadioListTile.adaptive(
value: TabBarSwipeAction.navigateOrderedTabs,
title: Text('Navigate Sequential Tabs'),
subtitle: Text(
'Swipe left/right to move through tabs in order',
),
), ),
), ),
], ],
@@ -298,63 +298,35 @@ class WebEngineSettingsScreen extends HookConsumerWidget {
.trackingProtectionPolicy(value), .trackingProtectionPolicy(value),
); );
}, },
child: child: const Column(
const RadioListTile< children: [
TrackingProtectionPolicy RadioListTile<TrackingProtectionPolicy>.adaptive(
>.adaptive(
value: TrackingProtectionPolicy.none, value: TrackingProtectionPolicy.none,
title: Text('Disabled'), title: Text('Disabled'),
), ),
), RadioListTile<TrackingProtectionPolicy>.adaptive(
RadioGroup( value: TrackingProtectionPolicy.recommended,
groupValue: engineSettings.trackingProtectionPolicy, title: Text('Standard'),
onChanged: (value) async { subtitle: Text(
await ref 'Pages will load normally, but block fewer trackers.',
.read(saveEngineSettingsControllerProvider.notifier) ),
.save( ),
(currentSettings) => currentSettings.copyWith RadioListTile<TrackingProtectionPolicy>.adaptive(
.trackingProtectionPolicy(value), value: TrackingProtectionPolicy.strict,
); title: Text('Strict'),
}, subtitle: Text(
child: const RadioListTile<TrackingProtectionPolicy>.adaptive( 'Stronger tracking protection and faster performance, but some sites may not work properly.',
value: TrackingProtectionPolicy.recommended, ),
title: Text('Standard'), ),
subtitle: Text( RadioListTile<TrackingProtectionPolicy>.adaptive(
'Pages will load normally, but block fewer trackers.',
),
),
),
RadioGroup(
groupValue: engineSettings.trackingProtectionPolicy,
onChanged: (value) async {
await ref
.read(saveEngineSettingsControllerProvider.notifier)
.save(
(currentSettings) => currentSettings.copyWith
.trackingProtectionPolicy(value),
);
},
child: const RadioListTile<TrackingProtectionPolicy>.adaptive(
value: TrackingProtectionPolicy.strict,
title: Text('Strict'),
subtitle: Text(
'Stronger tracking protection and faster performance, but some sites may not work properly.',
),
),
),
RadioGroup(
groupValue: engineSettings.trackingProtectionPolicy,
onChanged: (_) {},
child:
const RadioListTile<
TrackingProtectionPolicy
>.adaptive(
value: TrackingProtectionPolicy.custom, value: TrackingProtectionPolicy.custom,
title: Text('Custom'), title: Text('Custom'),
subtitle: Text( subtitle: Text(
'Choose which trackers and scripts to block.', 'Choose which trackers and scripts to block.',
), ),
), ),
],
),
), ),
], ],
), ),
@@ -167,38 +167,26 @@ class TorProxyScreen extends HookConsumerWidget {
); );
} }
}, },
child: const RadioListTile.adaptive( child: const Column(
value: TorRegularTabProxyMode.container, children: [
title: Text('Container-Based Routing'), RadioListTile.adaptive(
subtitle: Text( value: TorRegularTabProxyMode.container,
'Route only tabs in Tor containers through the Tor network. Private tabs remain unaffected.', title: Text('Container-Based Routing'),
), subtitle: Text(
), 'Route only tabs in Tor containers through the Tor network. Private tabs remain unaffected.',
), ),
RadioGroup( ),
groupValue: torSettings.proxyRegularTabsMode, RadioListTile.adaptive(
onChanged: (value) async { value: TorRegularTabProxyMode.all,
if (value != null) { title: Text('Global Routing'),
await ref subtitle: Text(
.read( 'Route all regular tabs through the Tor network. Private tabs remain unaffected.',
saveTorSettingsControllerProvider ),
.notifier, ),
) ],
.save(
(currentSettings) => currentSettings
.copyWith
.proxyRegularTabsMode(value),
);
}
},
child: const RadioListTile.adaptive(
value: TorRegularTabProxyMode.all,
title: Text('Global Routing'),
subtitle: Text(
'Route all regular tabs through the Tor network. Private tabs remain unaffected.',
),
), ),
), ),
SwitchListTile.adaptive( SwitchListTile.adaptive(
inactiveThumbColor: Colors.white, inactiveThumbColor: Colors.white,
activeThumbColor: const Color(0xFF68B030), activeThumbColor: const Color(0xFF68B030),
@@ -337,75 +325,45 @@ class TorProxyScreen extends HookConsumerWidget {
); );
} }
}, },
child: RadioListTile.adaptive( child: Column(
value: TorConnectionConfig.direct, children: [
enabled: !torProxyPort.isLoading, RadioListTile.adaptive(
contentPadding: const EdgeInsets.only( value: TorConnectionConfig.direct,
left: 56, enabled: !torProxyPort.isLoading,
right: 24, contentPadding: const EdgeInsets.only(
), left: 56,
title: const Text('Direct Connection'), right: 24,
subtitle: const Text( ),
'The best way to connect to Tor if Tor is not blocked', title: const Text('Direct Connection'),
), subtitle: const Text(
), 'The best way to connect to Tor if Tor is not blocked',
), ),
RadioGroup( ),
groupValue: torSettings.config, RadioListTile.adaptive(
onChanged: (value) async { value: TorConnectionConfig.obfs4,
if (value != null) { enabled: !torProxyPort.isLoading,
await ref contentPadding: const EdgeInsets.only(
.read( left: 56,
saveTorSettingsControllerProvider right: 24,
.notifier, ),
) title: const Text('obfs4'),
.save( subtitle: const Text(
(currentSettings) => currentSettings 'Suitable for light censorship and high bandwidth needs',
.copyWith ),
.config(value), ),
); RadioListTile.adaptive(
} value: TorConnectionConfig.snowflake,
}, enabled: !torProxyPort.isLoading,
child: RadioListTile.adaptive( contentPadding: const EdgeInsets.only(
value: TorConnectionConfig.obfs4, left: 56,
enabled: !torProxyPort.isLoading, right: 24,
contentPadding: const EdgeInsets.only( ),
left: 56, title: const Text('Snowflake'),
right: 24, subtitle: const Text(
), 'Suitable for heavy censorship',
title: const Text('obfs4'), ),
subtitle: const Text( ),
'Suitable for light censorship and high bandwidth needs', ],
),
),
),
RadioGroup(
groupValue: torSettings.config,
onChanged: (value) async {
if (value != null) {
await ref
.read(
saveTorSettingsControllerProvider
.notifier,
)
.save(
(currentSettings) => currentSettings
.copyWith
.config(value),
);
}
},
child: RadioListTile.adaptive(
value: TorConnectionConfig.snowflake,
enabled: !torProxyPort.isLoading,
contentPadding: const EdgeInsets.only(
left: 56,
right: 24,
),
title: const Text('Snowflake'),
subtitle: const Text(
'Suitable for heavy censorship',
),
), ),
), ),
CheckboxListTile.adaptive( CheckboxListTile.adaptive(