mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Added refresh on clients
This commit is contained in:
parent
721316cf1b
commit
82079268d3
5 changed files with 84 additions and 45 deletions
|
@ -155,5 +155,6 @@
|
|||
"unselectAll": "Unselect all",
|
||||
"all": "All",
|
||||
"filtered": "Filtered",
|
||||
"checkAppLogs": "Check app logs"
|
||||
"checkAppLogs": "Check app logs",
|
||||
"refresh": "Refresh"
|
||||
}
|
|
@ -155,5 +155,6 @@
|
|||
"unselectAll": "Deseleccionar todo",
|
||||
"all": "Todas",
|
||||
"filtered": "Filtrada",
|
||||
"checkAppLogs": "Comprueba los logs de la app"
|
||||
"checkAppLogs": "Comprueba los logs de la app",
|
||||
"refresh": "Actualizar"
|
||||
}
|
|
@ -14,11 +14,13 @@ import 'package:adguard_home_manager/classes/process_modal.dart';
|
|||
class BlockedAllowedList extends StatelessWidget {
|
||||
final String type;
|
||||
final List<String> data;
|
||||
final Future Function() fetchClients;
|
||||
|
||||
const BlockedAllowedList({
|
||||
Key? key,
|
||||
required this.type,
|
||||
required this.data
|
||||
required this.data,
|
||||
required this.fetchClients
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -78,7 +80,9 @@ class BlockedAllowedList extends StatelessWidget {
|
|||
}
|
||||
|
||||
if (data.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {},
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
|
@ -95,13 +99,16 @@ class BlockedAllowedList extends StatelessWidget {
|
|||
icon: const Icon(Icons.delete_rounded)
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Center(
|
||||
child: Text(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noClientsList,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
|
@ -109,6 +116,13 @@ class BlockedAllowedList extends StatelessWidget {
|
|||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class ClientsWidget extends StatefulWidget {
|
|||
class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateMixin {
|
||||
late TabController tabController;
|
||||
|
||||
void fetchClients() async {
|
||||
Future fetchClients() async {
|
||||
widget.setLoadingStatus(0, false);
|
||||
final result = await getClients(widget.server);
|
||||
if (result['result'] == 'success') {
|
||||
|
@ -148,16 +148,28 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
|
|||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
ClientsList(
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: ClientsList(
|
||||
data: serversProvider.clients.data!.autoClientsData,
|
||||
fetchClients: fetchClients,
|
||||
),
|
||||
BlockedAllowedList(
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: BlockedAllowedList(
|
||||
type: 'allowed',
|
||||
data: serversProvider.clients.data!.clientsAllowedBlocked!.allowedClients,
|
||||
fetchClients: fetchClients,
|
||||
),
|
||||
BlockedAllowedList(
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: BlockedAllowedList(
|
||||
type: 'blocked',
|
||||
data: serversProvider.clients.data!.clientsAllowedBlocked!.disallowedClients,
|
||||
fetchClients: fetchClients,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -5,10 +5,12 @@ import 'package:adguard_home_manager/models/clients.dart';
|
|||
|
||||
class ClientsList extends StatelessWidget {
|
||||
final List<AutoClient> data;
|
||||
final Future Function() fetchClients;
|
||||
|
||||
const ClientsList({
|
||||
Key? key,
|
||||
required this.data
|
||||
required this.data,
|
||||
required this.fetchClients
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
@ -35,8 +37,10 @@ class ClientsList extends StatelessWidget {
|
|||
else {
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Center(
|
||||
child: Text(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noClientsList,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
|
@ -44,6 +48,13 @@ class ClientsList extends StatelessWidget {
|
|||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh)
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue