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",
|
||||
"inputSearchTerm": "Input a search term.",
|
||||
"answers": "Answers",
|
||||
"copyDomainClipboard": "Copy domain to clipboard",
|
||||
"copyClipboard": "Copy to clipboard",
|
||||
"domainCopiedClipboard": "Domain copied to the clipboard",
|
||||
"clearDnsCache": "Clear DNS cache",
|
||||
"clearDnsCacheMessage": "Are you sure you want to clear the DNS cache?",
|
||||
|
|
|
@ -574,7 +574,7 @@
|
|||
"permissionNotGranted": "Permiso no concedido",
|
||||
"inputSearchTerm": "Introduce un término de búsqueda.",
|
||||
"answers": "Respuestas",
|
||||
"copyDomainClipboard": "Copiar dominio al portapapeles",
|
||||
"copyClipboard": "Copiar al portapapeles",
|
||||
"domainCopiedClipboard": "Dominio copiado al portapapeles",
|
||||
"clearDnsCache": "Borrar 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(
|
||||
context: context,
|
||||
builder: (context) => TopItemsOptionsModal(
|
||||
isBlocked: getIsBlocked(),
|
||||
changeStatus: (String status) => blockUnblock(domain, status),
|
||||
copyToClipboard: () => copyDomainClipboard(domain),
|
||||
type: type,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -137,22 +138,33 @@ class TopItems extends StatelessWidget {
|
|||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: type == 'topQueriedDomains' || type == 'topBlockedDomains'
|
||||
?() {
|
||||
logsProvider.setSearchText(item.keys.toList()[0]);
|
||||
logsProvider.setAppliedFilters(
|
||||
AppliedFiters(
|
||||
selectedResultStatus: 'all',
|
||||
searchText: item.keys.toList()[0],
|
||||
clients: null
|
||||
)
|
||||
);
|
||||
appConfigProvider.setSelectedScreen(2);
|
||||
}
|
||||
: null,
|
||||
onLongPress: type == 'topQueriedDomains' || type == 'topBlockedDomains'
|
||||
? () => openOptionsModal(item.keys.toList()[0])
|
||||
: null,
|
||||
onTap: () {
|
||||
if (type == 'topQueriedDomains' || type == 'topBlockedDomains') {
|
||||
logsProvider.setSearchText(item.keys.toList()[0]);
|
||||
logsProvider.setSelectedClients(null);
|
||||
logsProvider.setAppliedFilters(
|
||||
AppliedFiters(
|
||||
selectedResultStatus: 'all',
|
||||
searchText: item.keys.toList()[0],
|
||||
clients: null
|
||||
)
|
||||
);
|
||||
appConfigProvider.setSelectedScreen(2);
|
||||
}
|
||||
else if (type == 'topClients') {
|
||||
logsProvider.setSearchText(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(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 20,
|
||||
|
|
|
@ -7,12 +7,14 @@ class TopItemsOptionsModal extends StatelessWidget {
|
|||
final bool? isBlocked;
|
||||
final void Function(String status)? changeStatus;
|
||||
final void Function() copyToClipboard;
|
||||
final String type;
|
||||
|
||||
const TopItemsOptionsModal({
|
||||
Key? key,
|
||||
this.isBlocked,
|
||||
this.changeStatus,
|
||||
required this.copyToClipboard,
|
||||
required this.type
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -38,24 +40,26 @@ class TopItemsOptionsModal extends StatelessWidget {
|
|||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (isBlocked == true && changeStatus != null) CustomListTileDialog(
|
||||
title: AppLocalizations.of(context)!.unblock,
|
||||
icon: Icons.check,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
changeStatus!('unblock');
|
||||
},
|
||||
),
|
||||
if (isBlocked == false && changeStatus != null) CustomListTileDialog(
|
||||
title: AppLocalizations.of(context)!.block,
|
||||
icon: Icons.block,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
changeStatus!('block');
|
||||
},
|
||||
),
|
||||
if (type == 'topQueriedDomains' || type == 'topBlockedDomains') ...[
|
||||
if (isBlocked == true && changeStatus != null) CustomListTileDialog(
|
||||
title: AppLocalizations.of(context)!.unblock,
|
||||
icon: Icons.check,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
changeStatus!('unblock');
|
||||
},
|
||||
),
|
||||
if (isBlocked == false && changeStatus != null) CustomListTileDialog(
|
||||
title: AppLocalizations.of(context)!.block,
|
||||
icon: Icons.block,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
changeStatus!('block');
|
||||
},
|
||||
),
|
||||
],
|
||||
CustomListTileDialog(
|
||||
title: AppLocalizations.of(context)!.copyDomainClipboard,
|
||||
title: AppLocalizations.of(context)!.copyClipboard,
|
||||
icon: Icons.copy,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
|
|
|
@ -90,7 +90,8 @@ class LogTile extends StatelessWidget {
|
|||
context: context,
|
||||
value: log.question.name,
|
||||
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) {
|
||||
LogsData newLogsData = result['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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
void openOptionsModal(String domain) {
|
||||
void openOptionsModal(String domain, String type) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => TopItemsOptionsModal(
|
||||
|
@ -100,7 +100,8 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
context: context,
|
||||
value: domain,
|
||||
successMessage: AppLocalizations.of(context)!.domainCopiedClipboard
|
||||
)
|
||||
),
|
||||
type: type,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -197,23 +198,38 @@ class _TopItemsScreenState extends State<TopItemsScreen> {
|
|||
}
|
||||
|
||||
return CustomListTile(
|
||||
onTap: widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains'
|
||||
? () {
|
||||
logsProvider.setSearchText(screenData[index].keys.toList()[0]);
|
||||
logsProvider.setAppliedFilters(
|
||||
AppliedFiters(
|
||||
selectedResultStatus: 'all',
|
||||
searchText: screenData[index].keys.toList()[0],
|
||||
clients: null
|
||||
)
|
||||
);
|
||||
Navigator.pop(context);
|
||||
appConfigProvider.setSelectedScreen(2);
|
||||
}
|
||||
: null,
|
||||
onLongPress: widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains'
|
||||
? () => openOptionsModal(screenData[index].keys.toList()[0])
|
||||
: null,
|
||||
onTap: () {
|
||||
if (widget.type == 'topQueriedDomains' || widget.type == 'topBlockedDomains') {
|
||||
logsProvider.setSearchText(screenData[index].keys.toList()[0]);
|
||||
logsProvider.setSelectedClients(null);
|
||||
logsProvider.setAppliedFilters(
|
||||
AppliedFiters(
|
||||
selectedResultStatus: 'all',
|
||||
searchText: screenData[index].keys.toList()[0],
|
||||
clients: null
|
||||
)
|
||||
);
|
||||
appConfigProvider.setSelectedScreen(2);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
else if (widget.type == 'topClients') {
|
||||
logsProvider.setSearchText(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],
|
||||
trailing: Text(
|
||||
screenData[index].values.toList()[0].toString(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue