mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-19 13:29:12 +00:00
Added search button to added clients
This commit is contained in:
parent
cce54c8ba5
commit
a8cbed5ca0
3 changed files with 46 additions and 16 deletions
|
@ -794,5 +794,6 @@
|
||||||
"disallowingClient": "Disallowing client...",
|
"disallowingClient": "Disallowing client...",
|
||||||
"clientIpCopied": "Client IP copied to the clipboard",
|
"clientIpCopied": "Client IP copied to the clipboard",
|
||||||
"clientNameCopied": "Client name copied to the clipboard",
|
"clientNameCopied": "Client name copied to the clipboard",
|
||||||
"dnsServerAddressCopied": "DNS server address copied to the clipboard"
|
"dnsServerAddressCopied": "DNS server address copied to the clipboard",
|
||||||
|
"select": "Select"
|
||||||
}
|
}
|
|
@ -794,5 +794,6 @@
|
||||||
"disallowingClient": "No permitiendo cliente...",
|
"disallowingClient": "No permitiendo cliente...",
|
||||||
"clientIpCopied": "Dirección IP del cliente copiada al portapapeles",
|
"clientIpCopied": "Dirección IP del cliente copiada al portapapeles",
|
||||||
"clientNameCopied": "Nombre del cliente copiado al portapapeles",
|
"clientNameCopied": "Nombre del cliente copiado al portapapeles",
|
||||||
"dnsServerAddressCopied": "Dirección del servidor DNS copiada al portapapeles"
|
"dnsServerAddressCopied": "Dirección del servidor DNS copiada al portapapeles",
|
||||||
|
"select": "Seleccionar"
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:adguard_home_manager/widgets/custom_checkbox_list_tile.dart';
|
import 'package:adguard_home_manager/widgets/custom_checkbox_list_tile.dart';
|
||||||
import 'package:adguard_home_manager/functions/is_ip.dart';
|
import 'package:adguard_home_manager/functions/is_ip.dart';
|
||||||
import 'package:adguard_home_manager/widgets/list_bottom_sheet.dart';
|
import 'package:adguard_home_manager/widgets/list_bottom_sheet.dart';
|
||||||
|
import 'package:adguard_home_manager/widgets/custom_list_tile.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/providers/status_provider.dart';
|
import 'package:adguard_home_manager/providers/status_provider.dart';
|
||||||
import 'package:adguard_home_manager/providers/clients_provider.dart';
|
import 'package:adguard_home_manager/providers/clients_provider.dart';
|
||||||
|
@ -80,9 +81,9 @@ class _ClientsModalState extends State<ClientsModal> {
|
||||||
// ---- //
|
// ---- //
|
||||||
}
|
}
|
||||||
return _ClientLog(
|
return _ClientLog(
|
||||||
ip: isIpAddress(e.ids[0]) ? e.ids[0] : '"${e.ids[0]}"',
|
ip: e.ids[0],
|
||||||
name: name,
|
name: name,
|
||||||
ids: e.ids.map((i) => isIpAddress(i) ? i : '"$i"').toList()
|
ids: e.ids
|
||||||
);
|
);
|
||||||
}).where(
|
}).where(
|
||||||
(c) => c.ip.contains(value.toLowerCase()) || (c.name != null && c.name!.toLowerCase().contains(value.toLowerCase()))
|
(c) => c.ip.contains(value.toLowerCase()) || (c.name != null && c.name!.toLowerCase().contains(value.toLowerCase()))
|
||||||
|
@ -112,6 +113,13 @@ class _ClientsModalState extends State<ClientsModal> {
|
||||||
onSearch(value: _searchController.text, selectedList: list);
|
onSearch(value: _searchController.text, selectedList: list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void searchAddedClient(_ClientLog client) {
|
||||||
|
final notIps = client.ids?.where((e) => isIpAddress(e) == false).toList();
|
||||||
|
if (notIps == null) return;
|
||||||
|
logsProvider.setSearchText('"${notIps[0]}"');
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.dialog == true) {
|
if (widget.dialog == true) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
|
@ -193,6 +201,8 @@ class _ClientsModalState extends State<ClientsModal> {
|
||||||
title: _filteredClients[index].ip,
|
title: _filteredClients[index].ip,
|
||||||
subtitle: _selectedList == 0 ? _filteredClients[index].name : _filteredClients[index].ids?.join(", "),
|
subtitle: _selectedList == 0 ? _filteredClients[index].name : _filteredClients[index].ids?.join(", "),
|
||||||
checkboxActive: logsProvider.selectedClients.contains(_filteredClients[index].ip),
|
checkboxActive: logsProvider.selectedClients.contains(_filteredClients[index].ip),
|
||||||
|
isAddedClient: _selectedList == 0,
|
||||||
|
onSearchAddedClient: () => searchAddedClient(_filteredClients[index]),
|
||||||
onChanged: (isSelected) {
|
onChanged: (isSelected) {
|
||||||
if (isSelected == true) {
|
if (isSelected == true) {
|
||||||
logsProvider.setSelectedClients([
|
logsProvider.setSelectedClients([
|
||||||
|
@ -278,6 +288,8 @@ class _ClientsModalState extends State<ClientsModal> {
|
||||||
title: _selectedList == 0 ? _filteredClients[index].ip : _filteredClients[index].name ?? "",
|
title: _selectedList == 0 ? _filteredClients[index].ip : _filteredClients[index].name ?? "",
|
||||||
subtitle: _selectedList == 0 ? _filteredClients[index].name : _filteredClients[index].ids?.join(", "),
|
subtitle: _selectedList == 0 ? _filteredClients[index].name : _filteredClients[index].ids?.join(", "),
|
||||||
checkboxActive: logsProvider.selectedClients.contains(_filteredClients[index].ip),
|
checkboxActive: logsProvider.selectedClients.contains(_filteredClients[index].ip),
|
||||||
|
isAddedClient: _selectedList == 1,
|
||||||
|
onSearchAddedClient: () => searchAddedClient(_filteredClients[index]),
|
||||||
onChanged: (isSelected) {
|
onChanged: (isSelected) {
|
||||||
if (isSelected == true) {
|
if (isSelected == true) {
|
||||||
logsProvider.setSelectedClients([
|
logsProvider.setSelectedClients([
|
||||||
|
@ -350,27 +362,43 @@ class _ListItem extends StatelessWidget {
|
||||||
final String? subtitle;
|
final String? subtitle;
|
||||||
final bool checkboxActive;
|
final bool checkboxActive;
|
||||||
final void Function(bool) onChanged;
|
final void Function(bool) onChanged;
|
||||||
|
final bool isAddedClient;
|
||||||
|
final void Function() onSearchAddedClient;
|
||||||
|
|
||||||
const _ListItem({
|
const _ListItem({
|
||||||
required this.title,
|
required this.title,
|
||||||
this.subtitle,
|
this.subtitle,
|
||||||
required this.checkboxActive,
|
required this.checkboxActive,
|
||||||
required this.onChanged,
|
required this.onChanged,
|
||||||
|
required this.isAddedClient,
|
||||||
|
required this.onSearchAddedClient,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomCheckboxListTile(
|
if (isAddedClient == true) {
|
||||||
value: checkboxActive,
|
return CustomListTile(
|
||||||
onChanged: (v) => onChanged(v),
|
title: title,
|
||||||
title: title,
|
subtitle: subtitle,
|
||||||
subtitle: subtitle,
|
trailing: TextButton(
|
||||||
padding: const EdgeInsets.only(
|
onPressed: onSearchAddedClient,
|
||||||
left: 24,
|
child: Text(AppLocalizations.of(context)!.select)
|
||||||
top: 8,
|
),
|
||||||
right: 12,
|
);
|
||||||
bottom: 8
|
}
|
||||||
),
|
else {
|
||||||
);
|
return CustomCheckboxListTile(
|
||||||
|
value: checkboxActive,
|
||||||
|
onChanged: (v) => onChanged(v),
|
||||||
|
title: title,
|
||||||
|
subtitle: subtitle,
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 24,
|
||||||
|
top: 8,
|
||||||
|
right: 12,
|
||||||
|
bottom: 8
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue