mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 14:02:48 +00:00
Adapted options modal top items
This commit is contained in:
parent
a4a7840e55
commit
eebcec329b
7 changed files with 101 additions and 57 deletions
|
@ -574,7 +574,7 @@
|
||||||
"permissionNotGranted": "Permission not granted",
|
"permissionNotGranted": "Permission not granted",
|
||||||
"inputSearchTerm": "Input a search term.",
|
"inputSearchTerm": "Input a search term.",
|
||||||
"answers": "Answers",
|
"answers": "Answers",
|
||||||
"copyDomainClipboard": "Copy domain to clipboard",
|
"copyClipboard": "Copy to clipboard",
|
||||||
"domainCopiedClipboard": "Domain copied to the clipboard",
|
"domainCopiedClipboard": "Domain copied to the clipboard",
|
||||||
"clearDnsCache": "Clear DNS cache",
|
"clearDnsCache": "Clear DNS cache",
|
||||||
"clearDnsCacheMessage": "Are you sure you want to clear the DNS cache?",
|
"clearDnsCacheMessage": "Are you sure you want to clear the DNS cache?",
|
||||||
|
|
|
@ -574,7 +574,7 @@
|
||||||
"permissionNotGranted": "Permiso no concedido",
|
"permissionNotGranted": "Permiso no concedido",
|
||||||
"inputSearchTerm": "Introduce un término de búsqueda.",
|
"inputSearchTerm": "Introduce un término de búsqueda.",
|
||||||
"answers": "Respuestas",
|
"answers": "Respuestas",
|
||||||
"copyDomainClipboard": "Copiar dominio al portapapeles",
|
"copyClipboard": "Copiar al portapapeles",
|
||||||
"domainCopiedClipboard": "Dominio copiado al portapapeles",
|
"domainCopiedClipboard": "Dominio copiado al portapapeles",
|
||||||
"clearDnsCache": "Borrar caché de DNS",
|
"clearDnsCache": "Borrar caché de DNS",
|
||||||
"clearDnsCacheMessage": "¿Estás seguro que deseas eliminar la caché de DNS?",
|
"clearDnsCacheMessage": "¿Estás seguro que deseas eliminar la caché de DNS?",
|
||||||
|
|
|
@ -113,13 +113,14 @@ class TopItems extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openOptionsModal(String domain) {
|
void openOptionsModal(String domain, String type) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => TopItemsOptionsModal(
|
builder: (context) => TopItemsOptionsModal(
|
||||||
isBlocked: getIsBlocked(),
|
isBlocked: getIsBlocked(),
|
||||||
changeStatus: (String status) => blockUnblock(domain, status),
|
changeStatus: (String status) => blockUnblock(domain, status),
|
||||||
copyToClipboard: () => copyDomainClipboard(domain),
|
copyToClipboard: () => copyDomainClipboard(domain),
|
||||||
|
type: type,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -137,22 +138,33 @@ class TopItems extends StatelessWidget {
|
||||||
return Material(
|
return Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: type == 'topQueriedDomains' || type == 'topBlockedDomains'
|
onTap: () {
|
||||||
?() {
|
if (type == 'topQueriedDomains' || type == 'topBlockedDomains') {
|
||||||
logsProvider.setSearchText(item.keys.toList()[0]);
|
logsProvider.setSearchText(item.keys.toList()[0]);
|
||||||
logsProvider.setAppliedFilters(
|
logsProvider.setSelectedClients(null);
|
||||||
AppliedFiters(
|
logsProvider.setAppliedFilters(
|
||||||
selectedResultStatus: 'all',
|
AppliedFiters(
|
||||||
searchText: item.keys.toList()[0],
|
selectedResultStatus: 'all',
|
||||||
clients: null
|
searchText: item.keys.toList()[0],
|
||||||
)
|
clients: null
|
||||||
);
|
)
|
||||||
appConfigProvider.setSelectedScreen(2);
|
);
|
||||||
}
|
appConfigProvider.setSelectedScreen(2);
|
||||||
: null,
|
}
|
||||||
onLongPress: type == 'topQueriedDomains' || type == 'topBlockedDomains'
|
else if (type == 'topClients') {
|
||||||
? () => openOptionsModal(item.keys.toList()[0])
|
logsProvider.setSearchText(null);
|
||||||
: null,
|
logsProvider.setSelectedClients([item.keys.toList()[0]]);
|
||||||
|
logsProvider.setAppliedFilters(
|
||||||
|
AppliedFiters(
|
||||||
|
selectedResultStatus: 'all',
|
||||||
|
searchText: null,
|
||||||
|
clients: [item.keys.toList()[0]]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
appConfigProvider.setSelectedScreen(2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () => openOptionsModal(item.keys.toList()[0], type),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 20,
|
horizontal: 20,
|
||||||
|
|
|
@ -7,12 +7,14 @@ class TopItemsOptionsModal extends StatelessWidget {
|
||||||
final bool? isBlocked;
|
final bool? isBlocked;
|
||||||
final void Function(String status)? changeStatus;
|
final void Function(String status)? changeStatus;
|
||||||
final void Function() copyToClipboard;
|
final void Function() copyToClipboard;
|
||||||
|
final String type;
|
||||||
|
|
||||||
const TopItemsOptionsModal({
|
const TopItemsOptionsModal({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.isBlocked,
|
this.isBlocked,
|
||||||
this.changeStatus,
|
this.changeStatus,
|
||||||
required this.copyToClipboard,
|
required this.copyToClipboard,
|
||||||
|
required this.type
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -38,24 +40,26 @@ class TopItemsOptionsModal extends StatelessWidget {
|
||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
if (isBlocked == true && changeStatus != null) CustomListTileDialog(
|
if (type == 'topQueriedDomains' || type == 'topBlockedDomains') ...[
|
||||||
title: AppLocalizations.of(context)!.unblock,
|
if (isBlocked == true && changeStatus != null) CustomListTileDialog(
|
||||||
icon: Icons.check,
|
title: AppLocalizations.of(context)!.unblock,
|
||||||
onTap: () {
|
icon: Icons.check,
|
||||||
Navigator.pop(context);
|
onTap: () {
|
||||||
changeStatus!('unblock');
|
Navigator.pop(context);
|
||||||
},
|
changeStatus!('unblock');
|
||||||
),
|
},
|
||||||
if (isBlocked == false && changeStatus != null) CustomListTileDialog(
|
),
|
||||||
title: AppLocalizations.of(context)!.block,
|
if (isBlocked == false && changeStatus != null) CustomListTileDialog(
|
||||||
icon: Icons.block,
|
title: AppLocalizations.of(context)!.block,
|
||||||
onTap: () {
|
icon: Icons.block,
|
||||||
Navigator.pop(context);
|
onTap: () {
|
||||||
changeStatus!('block');
|
Navigator.pop(context);
|
||||||
},
|
changeStatus!('block');
|
||||||
),
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
CustomListTileDialog(
|
CustomListTileDialog(
|
||||||
title: AppLocalizations.of(context)!.copyDomainClipboard,
|
title: AppLocalizations.of(context)!.copyClipboard,
|
||||||
icon: Icons.copy,
|
icon: Icons.copy,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
|
@ -90,7 +90,8 @@ class LogTile extends StatelessWidget {
|
||||||
context: context,
|
context: context,
|
||||||
value: log.question.name,
|
value: log.question.name,
|
||||||
successMessage: AppLocalizations.of(context)!.domainCopiedClipboard
|
successMessage: AppLocalizations.of(context)!.domainCopiedClipboard
|
||||||
)
|
),
|
||||||
|
type: 'topQueriedDomains', // topQueriedDomains can also be used here. It's the same
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,21 @@ class _LogsWidgetState extends State<LogsWidget> {
|
||||||
if (loadingMore != null && loadingMore == true && widget.logsProvider.logsData != null) {
|
if (loadingMore != null && loadingMore == true && widget.logsProvider.logsData != null) {
|
||||||
LogsData newLogsData = result['data'];
|
LogsData newLogsData = result['data'];
|
||||||
newLogsData.data = [...widget.logsProvider.logsData!.data, ...result['data'].data];
|
newLogsData.data = [...widget.logsProvider.logsData!.data, ...result['data'].data];
|
||||||
|
if (widget.logsProvider.selectedClients != null) {
|
||||||
|
newLogsData.data = newLogsData.data.where(
|
||||||
|
(item) => widget.logsProvider.selectedClients!.contains(item.clientInfo!.name)
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
widget.logsProvider.setLogsData(newLogsData);
|
widget.logsProvider.setLogsData(newLogsData);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
widget.logsProvider.setLogsData(result['data']);
|
LogsData newLogsData = result['data'];
|
||||||
|
if (widget.logsProvider.selectedClients != null) {
|
||||||
|
newLogsData.data = newLogsData.data.where(
|
||||||
|
(item) => widget.logsProvider.selectedClients!.contains(item.clientInfo!.name)
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
|
widget.logsProvider.setLogsData(newLogsData);
|
||||||
}
|
}
|
||||||
widget.logsProvider.setLoadStatus(1);
|
widget.logsProvider.setLoadStatus(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openOptionsModal(String domain) {
|
void openOptionsModal(String domain, String type) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => TopItemsOptionsModal(
|
builder: (context) => TopItemsOptionsModal(
|
||||||
|
@ -100,7 +100,8 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
context: context,
|
context: context,
|
||||||
value: domain,
|
value: domain,
|
||||||
successMessage: AppLocalizations.of(context)!.domainCopiedClipboard
|
successMessage: AppLocalizations.of(context)!.domainCopiedClipboard
|
||||||
)
|
),
|
||||||
|
type: type,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -197,23 +198,38 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
||||||
}
|
}
|
||||||
|
|
||||||
return CustomListTile(
|
return CustomListTile(
|
||||||
onTap: widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains'
|
onTap: () {
|
||||||
? () {
|
if (widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains') {
|
||||||
logsProvider.setSearchText(screenData[index].keys.toList()[0]);
|
logsProvider.setSearchText(screenData[index].keys.toList()[0]);
|
||||||
logsProvider.setAppliedFilters(
|
logsProvider.setSelectedClients(null);
|
||||||
AppliedFiters(
|
logsProvider.setAppliedFilters(
|
||||||
selectedResultStatus: 'all',
|
AppliedFiters(
|
||||||
searchText: screenData[index].keys.toList()[0],
|
selectedResultStatus: 'all',
|
||||||
clients: null
|
searchText: screenData[index].keys.toList()[0],
|
||||||
)
|
clients: null
|
||||||
);
|
)
|
||||||
Navigator.pop(context);
|
);
|
||||||
appConfigProvider.setSelectedScreen(2);
|
appConfigProvider.setSelectedScreen(2);
|
||||||
}
|
Navigator.pop(context);
|
||||||
: null,
|
}
|
||||||
onLongPress: widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains'
|
else if (widget.type == 'topClients') {
|
||||||
? () => openOptionsModal(screenData[index].keys.toList()[0])
|
logsProvider.setSearchText(null);
|
||||||
: null,
|
logsProvider.setSelectedClients([screenData[index].keys.toList()[0]]);
|
||||||
|
logsProvider.setAppliedFilters(
|
||||||
|
AppliedFiters(
|
||||||
|
selectedResultStatus: 'all',
|
||||||
|
searchText: null,
|
||||||
|
clients: [screenData[index].keys.toList()[0]]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
appConfigProvider.setSelectedScreen(2);
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () => openOptionsModal(
|
||||||
|
screenData[index].keys.toList()[0],
|
||||||
|
widget.type
|
||||||
|
),
|
||||||
title: screenData[index].keys.toList()[0],
|
title: screenData[index].keys.toList()[0],
|
||||||
trailing: Text(
|
trailing: Text(
|
||||||
screenData[index].values.toList()[0].toString(),
|
screenData[index].values.toList()[0].toString(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue