2022-09-30 02:24:49 +02:00
|
|
|
// ignore_for_file: use_build_context_synchronously
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
|
|
|
2022-10-21 02:06:53 +02:00
|
|
|
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
2022-09-30 02:24:49 +02:00
|
|
|
|
2023-10-29 02:47:14 +01:00
|
|
|
import 'package:adguard_home_manager/functions/desktop_mode.dart';
|
2023-05-21 23:21:03 +02:00
|
|
|
import 'package:adguard_home_manager/functions/snackbar.dart';
|
2022-09-30 02:24:49 +02:00
|
|
|
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
|
|
|
|
|
|
|
class AdvancedSettings extends StatelessWidget {
|
2023-12-09 04:04:14 +01:00
|
|
|
const AdvancedSettings({super.key});
|
2022-09-30 02:24:49 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final appConfigProvider = Provider.of<AppConfigProvider>(context);
|
2023-05-01 04:23:55 +02:00
|
|
|
|
2023-10-29 02:47:14 +01:00
|
|
|
final width = MediaQuery.of(context).size.width;
|
|
|
|
|
2023-05-21 23:21:03 +02:00
|
|
|
Future updateSettings({
|
|
|
|
required bool newStatus,
|
|
|
|
required Future Function(bool) function
|
|
|
|
}) async {
|
|
|
|
final result = await function(newStatus);
|
2023-11-15 18:16:43 +01:00
|
|
|
if (!context.mounted) return;
|
2022-09-30 02:24:49 +02:00
|
|
|
if (result == true) {
|
2024-09-11 18:13:26 +02:00
|
|
|
showSnackbar(
|
2023-05-21 23:21:03 +02:00
|
|
|
appConfigProvider: appConfigProvider,
|
|
|
|
label: AppLocalizations.of(context)!.settingsUpdatedSuccessfully,
|
|
|
|
color: Colors.green
|
2022-09-30 02:24:49 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
2024-09-11 18:13:26 +02:00
|
|
|
showSnackbar(
|
2023-05-21 23:21:03 +02:00
|
|
|
appConfigProvider: appConfigProvider,
|
|
|
|
label: AppLocalizations.of(context)!.cannotUpdateSettings,
|
|
|
|
color: Colors.red
|
2022-09-30 02:24:49 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
2023-05-21 23:21:03 +02:00
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(AppLocalizations.of(context)!.advancedSettings),
|
2023-10-29 02:47:14 +01:00
|
|
|
surfaceTintColor: isDesktop(width) ? Colors.transparent : null,
|
2023-05-21 23:21:03 +02:00
|
|
|
),
|
2023-12-09 04:04:14 +01:00
|
|
|
body: SafeArea(
|
|
|
|
child: ListView(
|
|
|
|
children: [
|
|
|
|
CustomListTile(
|
|
|
|
icon: Icons.lock,
|
|
|
|
title: AppLocalizations.of(context)!.dontCheckCertificate,
|
|
|
|
subtitle: AppLocalizations.of(context)!.dontCheckCertificateDescription,
|
|
|
|
trailing: Switch(
|
|
|
|
value: appConfigProvider.overrideSslCheck,
|
|
|
|
onChanged: (value) => updateSettings(
|
|
|
|
newStatus: value,
|
|
|
|
function: appConfigProvider.setOverrideSslCheck
|
|
|
|
),
|
|
|
|
),
|
|
|
|
onTap: () => updateSettings(
|
|
|
|
newStatus: !appConfigProvider.overrideSslCheck,
|
2023-05-21 23:21:03 +02:00
|
|
|
function: appConfigProvider.setOverrideSslCheck
|
|
|
|
),
|
2023-12-09 04:04:14 +01:00
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
top: 10,
|
|
|
|
bottom: 10,
|
|
|
|
left: 20,
|
|
|
|
right: 10
|
|
|
|
)
|
2023-05-21 23:21:03 +02:00
|
|
|
),
|
2023-12-09 04:04:14 +01:00
|
|
|
],
|
|
|
|
),
|
2023-05-18 13:54:50 +02:00
|
|
|
)
|
|
|
|
);
|
2022-09-30 02:24:49 +02:00
|
|
|
}
|
|
|
|
}
|