diff --git a/lib/screens/settings/safe_search_settings.dart b/lib/screens/settings/safe_search_settings.dart index 8334bcf..1d8a31e 100644 --- a/lib/screens/settings/safe_search_settings.dart +++ b/lib/screens/settings/safe_search_settings.dart @@ -8,6 +8,7 @@ import 'package:adguard_home_manager/widgets/custom_switch_list_tile.dart'; import 'package:adguard_home_manager/classes/process_modal.dart'; import 'package:adguard_home_manager/functions/snackbar.dart'; +import 'package:adguard_home_manager/widgets/custom_checkbox_list_tile.dart'; import 'package:adguard_home_manager/models/server_status.dart'; import 'package:adguard_home_manager/services/http_requests.dart'; import 'package:adguard_home_manager/providers/app_config_provider.dart'; @@ -216,7 +217,7 @@ class _SafeSearchSettingsScreenWidgetState extends State setState(() => bingEnabled = value), title: "Bing", @@ -225,7 +226,7 @@ class _SafeSearchSettingsScreenWidgetState extends State setState(() => duckduckgoEnabled = value), title: "DuckDuckGo", @@ -234,7 +235,7 @@ class _SafeSearchSettingsScreenWidgetState extends State setState(() => googleEnabled = value), title: "Google", @@ -243,7 +244,7 @@ class _SafeSearchSettingsScreenWidgetState extends State setState(() => pixabayEnabled = value), title: "Pixabay", @@ -252,7 +253,7 @@ class _SafeSearchSettingsScreenWidgetState extends State setState(() => yandexEnabled = value), title: "Yandex", @@ -261,7 +262,7 @@ class _SafeSearchSettingsScreenWidgetState extends State setState(() => youtubeEnabled = value), title: "YouTube", diff --git a/lib/widgets/custom_checkbox_list_tile.dart b/lib/widgets/custom_checkbox_list_tile.dart new file mode 100644 index 0000000..be14a3c --- /dev/null +++ b/lib/widgets/custom_checkbox_list_tile.dart @@ -0,0 +1,95 @@ +import 'package:flutter/material.dart'; + +class CustomCheckboxListTile extends StatelessWidget { + final bool value; + final void Function(bool) onChanged; + final String title; + final String? subtitle; + final bool? disabled; + final EdgeInsets? padding; + + const CustomCheckboxListTile({ + Key? key, + required this.value, + required this.onChanged, + required this.title, + this.disabled, + this.subtitle, + this.padding + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Material( + color: Colors.transparent, + child: InkWell( + onTap: disabled != null && disabled == true + ? null + : () => onChanged(!value), + child: Padding( + padding: padding ?? const EdgeInsets.only( + top: 12, left: 16, right: 18, bottom: 16 + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + fontSize: 16, + color: disabled != null && disabled == true + ? Theme.of(context).colorScheme.onSurface.withOpacity(0.38) + : Theme.of(context).colorScheme.onSurface, + ), + ), + if (subtitle != null) ... [ + const SizedBox(height: 5), + SizedBox( + width: MediaQuery.of(context).size.width-110, + child: Text( + subtitle!, + style: TextStyle( + fontSize: 14, + color: disabled != null && disabled == true + ? Theme.of(context).listTileTheme.textColor!.withOpacity(0.38) + : Theme.of(context).listTileTheme.textColor + ), + ), + ), + ] + ], + ), + ), + const SizedBox(width: 16), + Theme( + data: ThemeData( + unselectedWidgetColor: disabled == true + ? Colors.grey + : Theme.of(context).colorScheme.onSurface, + disabledColor: Colors.grey + ), + child: Checkbox( + value: value, + onChanged: (value) => disabled != null && disabled == true && value != null + ? null + : onChanged(value!), + tristate: false, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + activeColor: disabled == true + ? Colors.grey + : Theme.of(context).colorScheme.primary, + ), + ) + ], + ), + ), + ), + ); + } +} \ No newline at end of file