mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-15 14:32:48 +00:00
Added load dns info data
This commit is contained in:
parent
45946ddc1a
commit
ea1cb6165c
11 changed files with 540 additions and 90 deletions
|
@ -5,8 +5,15 @@ import 'package:adguard_home_manager/widgets/custom_radio_list_tile.dart';
|
|||
import 'package:adguard_home_manager/screens/settings/section_label.dart';
|
||||
import 'package:adguard_home_manager/widgets/custom_switch_list_tile.dart';
|
||||
|
||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||
|
||||
class DnsServerSettingsScreen extends StatefulWidget {
|
||||
const DnsServerSettingsScreen({Key? key}) : super(key: key);
|
||||
final ServersProvider serversProvider;
|
||||
|
||||
const DnsServerSettingsScreen({
|
||||
Key? key,
|
||||
required this.serversProvider
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DnsServerSettingsScreen> createState() => _DnsServerSettingsScreenState();
|
||||
|
@ -21,8 +28,36 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
|
|||
|
||||
String blockingMode = "default";
|
||||
|
||||
final TextEditingController ipv4controller = TextEditingController();
|
||||
String? ipv4error;
|
||||
final TextEditingController ipv6controller = TextEditingController();
|
||||
String? ipv6error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
limitRequestsController.text = widget.serversProvider.dnsInfo.data!.ratelimit.toString();
|
||||
enableEdns = widget.serversProvider.dnsInfo.data!.ednsCsEnabled;
|
||||
enableDnssec = widget.serversProvider.dnsInfo.data!.dnssecEnabled;
|
||||
disableIpv6Resolving = widget.serversProvider.dnsInfo.data!.disableIpv6;
|
||||
blockingMode = widget.serversProvider.dnsInfo.data!.blockingMode;
|
||||
ipv4controller.text = widget.serversProvider.dnsInfo.data!.blockingIpv4;
|
||||
ipv6controller.text = widget.serversProvider.dnsInfo.data!.blockingIpv6;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
void updateBlockingMode(String mode) {
|
||||
if (mode != 'custom_ip') {
|
||||
ipv4controller.text = '';
|
||||
ipv4error = null;
|
||||
ipv6controller.text = '';
|
||||
ipv6error = null;
|
||||
}
|
||||
setState(() => blockingMode = mode);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.dnsServerSettings),
|
||||
|
@ -81,7 +116,7 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
|
|||
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
|
||||
title: AppLocalizations.of(context)!.defaultMode,
|
||||
subtitle: AppLocalizations.of(context)!.defaultDescription,
|
||||
onChanged: (value) => setState(() => blockingMode = value),
|
||||
onChanged: updateBlockingMode,
|
||||
),
|
||||
CustomRadioListTile(
|
||||
groupValue: blockingMode,
|
||||
|
@ -89,7 +124,7 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
|
|||
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
|
||||
title: "REFUSED",
|
||||
subtitle: AppLocalizations.of(context)!.refusedDescription,
|
||||
onChanged: (value) => setState(() => blockingMode = value),
|
||||
onChanged: updateBlockingMode,
|
||||
),
|
||||
CustomRadioListTile(
|
||||
groupValue: blockingMode,
|
||||
|
@ -97,7 +132,7 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
|
|||
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
|
||||
title: "NXDOMAIN",
|
||||
subtitle: AppLocalizations.of(context)!.nxdomainDescription,
|
||||
onChanged: (value) => setState(() => blockingMode = value),
|
||||
onChanged: updateBlockingMode,
|
||||
),
|
||||
CustomRadioListTile(
|
||||
groupValue: blockingMode,
|
||||
|
@ -105,7 +140,7 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
|
|||
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
|
||||
title: AppLocalizations.of(context)!.nullIp,
|
||||
subtitle: AppLocalizations.of(context)!.nullIpDescription,
|
||||
onChanged: (value) => setState(() => blockingMode = value),
|
||||
onChanged: updateBlockingMode,
|
||||
),
|
||||
CustomRadioListTile(
|
||||
groupValue: blockingMode,
|
||||
|
@ -113,8 +148,53 @@ class _DnsServerSettingsScreenState extends State<DnsServerSettingsScreen> {
|
|||
radioBackgroundColor: Theme.of(context).dialogBackgroundColor,
|
||||
title: AppLocalizations.of(context)!.customIp,
|
||||
subtitle: AppLocalizations.of(context)!.customIpDescription,
|
||||
onChanged: (value) => setState(() => blockingMode = value),
|
||||
onChanged: updateBlockingMode,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (blockingMode == 'custom_ip') ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: TextFormField(
|
||||
controller: ipv4controller,
|
||||
// onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.link_rounded),
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10)
|
||||
)
|
||||
),
|
||||
errorText: ipv4error,
|
||||
helperText: AppLocalizations.of(context)!.blockingIpv4Description,
|
||||
helperMaxLines: 10,
|
||||
labelText: AppLocalizations.of(context)!.blockingIpv4,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: TextFormField(
|
||||
controller: ipv6controller,
|
||||
// onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.link_rounded),
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(10)
|
||||
)
|
||||
),
|
||||
errorText: ipv6error,
|
||||
helperText: AppLocalizations.of(context)!.blockingIpv6Description,
|
||||
helperMaxLines: 10,
|
||||
labelText: AppLocalizations.of(context)!.blockingIpv6,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30)
|
||||
]
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue