mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-20 22:09:11 +00:00
Added enable disable filtering on filters appbar
This commit is contained in:
parent
df8ebfcec1
commit
1e07b4e799
4 changed files with 83 additions and 2 deletions
|
@ -306,5 +306,10 @@
|
|||
"addingRule": "Adding rule...",
|
||||
"deletingRule": "Deleting rule...",
|
||||
"enablingList": "Enabling list...",
|
||||
"disablingList": "Disabling list..."
|
||||
"disablingList": "Disabling list...",
|
||||
"disableFiltering": "Disable filtering",
|
||||
"enablingFiltering": "Enabling filtering...",
|
||||
"disablingFiltering": "Disabling filtering...",
|
||||
"filteringStatusUpdated": "Filtering status updated successfully",
|
||||
"filteringStatusNotUpdated": "Filtering status couldn't be updated"
|
||||
}
|
|
@ -306,5 +306,10 @@
|
|||
"addingRule": "Añadiendo regla...",
|
||||
"deletingRule": "Eliminando regla...",
|
||||
"enablingList": "Habilitando lista...",
|
||||
"disablingList": "Deshabilitando lista..."
|
||||
"disablingList": "Deshabilitando lista...",
|
||||
"disableFiltering": "Deshabilitar filtrado",
|
||||
"enablingFiltering": "Habilitando filtrado...",
|
||||
"disablingFiltering": "Deshabilitando filtrado...",
|
||||
"filteringStatusUpdated": "Estado de filtrado actualizado correctamente",
|
||||
"filteringStatusNotUpdated": "El estado de filtrado no pudo ser actualizado"
|
||||
}
|
|
@ -118,6 +118,11 @@ class ServersProvider with ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void setFilteringProtectionStatus(bool status) {
|
||||
_serverStatus.data!.filteringEnabled = status;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<bool> createServer(Server server) async {
|
||||
final saved = await saveServerIntoDb(server);
|
||||
|
|
|
@ -147,6 +147,38 @@ class _FiltersWidgetState extends State<FiltersWidget> with TickerProviderStateM
|
|||
});
|
||||
}
|
||||
|
||||
void enableDisableFiltering() async {
|
||||
ProcessModal processModal = ProcessModal(context: context);
|
||||
processModal.open(
|
||||
serversProvider.serverStatus.data!.filteringEnabled == true
|
||||
? AppLocalizations.of(context)!.disableFiltering
|
||||
: AppLocalizations.of(context)!.enableFiltering
|
||||
);
|
||||
|
||||
final result = await updateFiltering(serversProvider.selectedServer!, !serversProvider.serverStatus.data!.filteringEnabled);
|
||||
|
||||
processModal.close();
|
||||
|
||||
if (result['result'] == 'success') {
|
||||
serversProvider.setFilteringProtectionStatus(!serversProvider.serverStatus.data!.filteringEnabled);
|
||||
|
||||
showSnacbkar(
|
||||
context: context,
|
||||
appConfigProvider: appConfigProvider,
|
||||
label: AppLocalizations.of(context)!.filteringStatusUpdated,
|
||||
color: Colors.green
|
||||
);
|
||||
}
|
||||
else {
|
||||
showSnacbkar(
|
||||
context: context,
|
||||
appConfigProvider: appConfigProvider,
|
||||
label: AppLocalizations.of(context)!.filteringStatusNotUpdated,
|
||||
color: Colors.red
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
child: NestedScrollView(
|
||||
|
@ -163,6 +195,40 @@ class _FiltersWidgetState extends State<FiltersWidget> with TickerProviderStateM
|
|||
floating: true,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: enableDisableFiltering,
|
||||
tooltip: serversProvider.serverStatus.data!.filteringEnabled == true
|
||||
? AppLocalizations.of(context)!.disableFiltering
|
||||
: AppLocalizations.of(context)!.enableFiltering,
|
||||
icon: Stack(
|
||||
children: [
|
||||
const Icon(Icons.power_settings_new_rounded),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: Colors.white
|
||||
),
|
||||
child: Icon(
|
||||
serversProvider.serverStatus.data!.filteringEnabled == true
|
||||
? Icons.check_circle_rounded
|
||||
: Icons.cancel,
|
||||
size: 12,
|
||||
color: serversProvider.serverStatus.data!.filteringEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
|
|
Loading…
Add table
Reference in a new issue