mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-25 00:06:07 +00:00
Added condition ipv4
This commit is contained in:
parent
a753774cae
commit
b48c2a8d3b
1 changed files with 94 additions and 92 deletions
|
@ -219,7 +219,7 @@ class _DhcpWidgetState extends State<DhcpWidget> {
|
||||||
final result = await saveDhcpConfig(server: serversProvider.selectedServer!, data: {
|
final result = await saveDhcpConfig(server: serversProvider.selectedServer!, data: {
|
||||||
"enabled": enabled,
|
"enabled": enabled,
|
||||||
"interface_name": selectedInterface!.name,
|
"interface_name": selectedInterface!.name,
|
||||||
"v4": {
|
if (selectedInterface!.ipv4Addresses.isNotEmpty) "v4": {
|
||||||
"gateway_ip": ipv4GatewayController.text,
|
"gateway_ip": ipv4GatewayController.text,
|
||||||
"subnet_mask": ipv4SubnetMaskController.text,
|
"subnet_mask": ipv4SubnetMaskController.text,
|
||||||
"range_start": ipv4StartRangeController.text,
|
"range_start": ipv4StartRangeController.text,
|
||||||
|
@ -391,110 +391,112 @@ class _DhcpWidgetState extends State<DhcpWidget> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SectionLabel(
|
if (selectedInterface!.ipv4Addresses.isNotEmpty) ...[
|
||||||
label: AppLocalizations.of(context)!.ipv4settings,
|
SectionLabel(
|
||||||
),
|
label: AppLocalizations.of(context)!.ipv4settings,
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
|
||||||
child: TextFormField(
|
|
||||||
controller: ipv4StartRangeController,
|
|
||||||
onChanged: (value) => validateIpV4(value, 'ipv4StartRangeError', AppLocalizations.of(context)!.ipNotValid),
|
|
||||||
decoration: InputDecoration(
|
|
||||||
prefixIcon: const Icon(Icons.skip_next_rounded),
|
|
||||||
border: const OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.all(
|
|
||||||
Radius.circular(10)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
errorText: ipv4StartRangeError,
|
|
||||||
labelText: AppLocalizations.of(context)!.startOfRange,
|
|
||||||
),
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
const SizedBox(height: 30),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
Padding(
|
child: TextFormField(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
controller: ipv4StartRangeController,
|
||||||
child: TextFormField(
|
onChanged: (value) => validateIpV4(value, 'ipv4StartRangeError', AppLocalizations.of(context)!.ipNotValid),
|
||||||
controller: ipv4EndRangeController,
|
decoration: InputDecoration(
|
||||||
onChanged: (value) => validateIpV4(value, 'ipv4EndRangeError', AppLocalizations.of(context)!.ipNotValid),
|
prefixIcon: const Icon(Icons.skip_previous_rounded),
|
||||||
decoration: InputDecoration(
|
border: const OutlineInputBorder(
|
||||||
prefixIcon: const Icon(Icons.skip_previous_rounded),
|
borderRadius: BorderRadius.all(
|
||||||
border: const OutlineInputBorder(
|
Radius.circular(10)
|
||||||
borderRadius: BorderRadius.all(
|
)
|
||||||
Radius.circular(10)
|
),
|
||||||
)
|
errorText: ipv4StartRangeError,
|
||||||
|
labelText: AppLocalizations.of(context)!.startOfRange,
|
||||||
),
|
),
|
||||||
errorText: ipv4EndRangeError,
|
keyboardType: TextInputType.number,
|
||||||
labelText: AppLocalizations.of(context)!.endOfRange,
|
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
const SizedBox(height: 30),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
child: TextFormField(
|
||||||
child: TextFormField(
|
controller: ipv4EndRangeController,
|
||||||
controller: ipv4SubnetMaskController,
|
onChanged: (value) => validateIpV4(value, 'ipv4EndRangeError', AppLocalizations.of(context)!.ipNotValid),
|
||||||
onChanged: (value) => validateIpV4(value, 'ipv4SubnetMaskError', AppLocalizations.of(context)!.subnetMaskNotValid),
|
decoration: InputDecoration(
|
||||||
decoration: InputDecoration(
|
prefixIcon: const Icon(Icons.skip_next_rounded),
|
||||||
prefixIcon: const Icon(Icons.hub_rounded),
|
border: const OutlineInputBorder(
|
||||||
border: const OutlineInputBorder(
|
borderRadius: BorderRadius.all(
|
||||||
borderRadius: BorderRadius.all(
|
Radius.circular(10)
|
||||||
Radius.circular(10)
|
)
|
||||||
)
|
),
|
||||||
|
errorText: ipv4EndRangeError,
|
||||||
|
labelText: AppLocalizations.of(context)!.endOfRange,
|
||||||
),
|
),
|
||||||
errorText: ipv4SubnetMaskError,
|
keyboardType: TextInputType.number,
|
||||||
labelText: AppLocalizations.of(context)!.subnetMask,
|
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
const SizedBox(height: 30),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
child: TextFormField(
|
||||||
child: TextFormField(
|
controller: ipv4SubnetMaskController,
|
||||||
controller: ipv4GatewayController,
|
onChanged: (value) => validateIpV4(value, 'ipv4SubnetMaskError', AppLocalizations.of(context)!.subnetMaskNotValid),
|
||||||
onChanged: (value) => validateIpV4(value, 'ipv4GatewayError', AppLocalizations.of(context)!.gatewayNotValid),
|
decoration: InputDecoration(
|
||||||
decoration: InputDecoration(
|
prefixIcon: const Icon(Icons.hub_rounded),
|
||||||
prefixIcon: const Icon(Icons.router_rounded),
|
border: const OutlineInputBorder(
|
||||||
border: const OutlineInputBorder(
|
borderRadius: BorderRadius.all(
|
||||||
borderRadius: BorderRadius.all(
|
Radius.circular(10)
|
||||||
Radius.circular(10)
|
)
|
||||||
)
|
),
|
||||||
|
errorText: ipv4SubnetMaskError,
|
||||||
|
labelText: AppLocalizations.of(context)!.subnetMask,
|
||||||
),
|
),
|
||||||
errorText: ipv4GatewayError,
|
keyboardType: TextInputType.number,
|
||||||
labelText: AppLocalizations.of(context)!.gateway,
|
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
const SizedBox(height: 30),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
child: TextFormField(
|
||||||
child: TextFormField(
|
controller: ipv4GatewayController,
|
||||||
controller: ipv4LeaseTimeController,
|
onChanged: (value) => validateIpV4(value, 'ipv4GatewayError', AppLocalizations.of(context)!.gatewayNotValid),
|
||||||
onChanged: (value) {
|
decoration: InputDecoration(
|
||||||
if (int.tryParse(value).runtimeType == int) {
|
prefixIcon: const Icon(Icons.router_rounded),
|
||||||
setState(() => ipv4LeaseTimeError = null);
|
border: const OutlineInputBorder(
|
||||||
}
|
borderRadius: BorderRadius.all(
|
||||||
else {
|
Radius.circular(10)
|
||||||
setState(() => ipv4LeaseTimeError = AppLocalizations.of(context)!.leaseTimeNotValid);
|
)
|
||||||
}
|
),
|
||||||
},
|
errorText: ipv4GatewayError,
|
||||||
decoration: InputDecoration(
|
labelText: AppLocalizations.of(context)!.gateway,
|
||||||
prefixIcon: const Icon(Icons.timer),
|
|
||||||
border: const OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.all(
|
|
||||||
Radius.circular(10)
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
errorText: ipv4LeaseTimeError,
|
keyboardType: TextInputType.number,
|
||||||
labelText: AppLocalizations.of(context)!.leaseTime,
|
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: ipv4LeaseTimeController,
|
||||||
|
onChanged: (value) {
|
||||||
|
if (int.tryParse(value).runtimeType == int) {
|
||||||
|
setState(() => ipv4LeaseTimeError = null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() => ipv4LeaseTimeError = AppLocalizations.of(context)!.leaseTimeNotValid);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
prefixIcon: const Icon(Icons.timer),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(10)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
errorText: ipv4LeaseTimeError,
|
||||||
|
labelText: AppLocalizations.of(context)!.leaseTime,
|
||||||
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
if (selectedInterface!.ipv6Addresses.isNotEmpty) ...[
|
if (selectedInterface!.ipv6Addresses.isNotEmpty) ...[
|
||||||
SectionLabel(
|
SectionLabel(
|
||||||
label: AppLocalizations.of(context)!.ipv6settings,
|
label: AppLocalizations.of(context)!.ipv6settings,
|
||||||
|
|
Loading…
Add table
Reference in a new issue