mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +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
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue