mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
Added scaffold on each screen
This commit is contained in:
parent
b93928173e
commit
429ad636b0
10 changed files with 887 additions and 672 deletions
|
@ -17,11 +17,13 @@ import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
|||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||
|
||||
class AddedList extends StatelessWidget {
|
||||
final int loadStatus;
|
||||
final List<Client> data;
|
||||
final Future Function() fetchClients;
|
||||
|
||||
const AddedList({
|
||||
Key? key,
|
||||
required this.loadStatus,
|
||||
required this.data,
|
||||
required this.fetchClients
|
||||
}) : super(key: key);
|
||||
|
@ -133,94 +135,144 @@ class AddedList extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
if (data.isNotEmpty) RefreshIndicator(
|
||||
onRefresh: () async {},
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
isThreeLine: true,
|
||||
onLongPress: () => openOptionsModal(data[index]),
|
||||
onTap: () => openClientModal(data[index]),
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5),
|
||||
child: Text(data[index].name),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(data[index].ids.toString().replaceAll(RegExp(r'^\[|\]$'), '')),
|
||||
const SizedBox(height: 7),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.filter_list_rounded,
|
||||
size: 19,
|
||||
color: data[index].filteringEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.vpn_lock_rounded,
|
||||
size: 18,
|
||||
color: data[index].safebrowsingEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.block,
|
||||
size: 18,
|
||||
color: data[index].parentalEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.search_rounded,
|
||||
size: 19,
|
||||
color: data[index].safesearchEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
if (data.isEmpty) SizedBox(
|
||||
switch (loadStatus) {
|
||||
case 0:
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noClientsList,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 20,
|
||||
right: 20,
|
||||
child: ClientsFab(tab: 1),
|
||||
),
|
||||
],
|
||||
);
|
||||
);
|
||||
|
||||
case 1:
|
||||
return Stack(
|
||||
children: [
|
||||
if (data.isNotEmpty) ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
isThreeLine: true,
|
||||
onLongPress: () => openOptionsModal(data[index]),
|
||||
onTap: () => openClientModal(data[index]),
|
||||
title: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5),
|
||||
child: Text(data[index].name),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(data[index].ids.toString().replaceAll(RegExp(r'^\[|\]$'), '')),
|
||||
const SizedBox(height: 7),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.filter_list_rounded,
|
||||
size: 19,
|
||||
color: data[index].filteringEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.vpn_lock_rounded,
|
||||
size: 18,
|
||||
color: data[index].safebrowsingEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.block,
|
||||
size: 18,
|
||||
color: data[index].parentalEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
Icons.search_rounded,
|
||||
size: 19,
|
||||
color: data[index].safesearchEnabled == true
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
if (data.isEmpty) SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noClientsList,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 20,
|
||||
right: 20,
|
||||
child: ClientsFab(tab: 1),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
case 2:
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
size: 50,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.errorLoadServerStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -14,11 +14,13 @@ import 'package:adguard_home_manager/services/http_requests.dart';
|
|||
import 'package:adguard_home_manager/classes/process_modal.dart';
|
||||
|
||||
class BlockedList extends StatelessWidget {
|
||||
final int loadStatus;
|
||||
final List<String> data;
|
||||
final Future Function() fetchClients;
|
||||
|
||||
const BlockedList({
|
||||
Key? key,
|
||||
required this.loadStatus,
|
||||
required this.data,
|
||||
required this.fetchClients
|
||||
}) : super(key: key);
|
||||
|
@ -71,54 +73,107 @@ class BlockedList extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
if (data.isNotEmpty) ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
title: Text(data[index]),
|
||||
trailing: IconButton(
|
||||
onPressed: () => {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RemoveDomainModal(
|
||||
onConfirm: () => confirmRemoveDomain(data[index]),
|
||||
)
|
||||
)
|
||||
},
|
||||
icon: const Icon(Icons.delete_rounded)
|
||||
),
|
||||
)
|
||||
),
|
||||
if (data.isEmpty) SizedBox(
|
||||
switch (loadStatus) {
|
||||
case 0:
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noCustomFilters,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 20,
|
||||
right: 20,
|
||||
child: ClientsFab(tab: 2),
|
||||
),
|
||||
]
|
||||
);
|
||||
);
|
||||
|
||||
case 1:
|
||||
return Stack(
|
||||
children: [
|
||||
if (data.isNotEmpty) ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
title: Text(data[index]),
|
||||
trailing: IconButton(
|
||||
onPressed: () => {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => RemoveDomainModal(
|
||||
onConfirm: () => confirmRemoveDomain(data[index]),
|
||||
)
|
||||
)
|
||||
},
|
||||
icon: const Icon(Icons.delete_rounded)
|
||||
),
|
||||
)
|
||||
),
|
||||
if (data.isEmpty) SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noCustomFilters,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 20,
|
||||
right: 20,
|
||||
child: ClientsFab(tab: 2),
|
||||
),
|
||||
]
|
||||
);
|
||||
|
||||
case 2:
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
size: 50,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.errorLoadServerStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -89,144 +89,146 @@ class _ClientsWidgetState extends State<ClientsWidget> with TickerProviderStateM
|
|||
Widget build(BuildContext context) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
|
||||
switch (serversProvider.clients.loadStatus) {
|
||||
Widget generateBody() {
|
||||
switch (serversProvider.clients.loadStatus) {
|
||||
case 0:
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.clients),
|
||||
centerTitle: true,
|
||||
),
|
||||
SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
case 1:
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder: ((context, innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverAppBar(
|
||||
title: Text(AppLocalizations.of(context)!.clients),
|
||||
centerTitle: true,
|
||||
pinned: true,
|
||||
floating: true,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
bottom: TabBar(
|
||||
controller: tabController,
|
||||
tabs: [
|
||||
Tab(
|
||||
icon: const Icon(Icons.devices),
|
||||
text: AppLocalizations.of(context)!.activeClients,
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
Tab(
|
||||
icon: const Icon(Icons.add),
|
||||
text: AppLocalizations.of(context)!.added,
|
||||
),
|
||||
Tab(
|
||||
icon: const Icon(Icons.block),
|
||||
text: AppLocalizations.of(context)!.blocked,
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
];
|
||||
}),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? const Color.fromRGBO(220, 220, 220, 1)
|
||||
: const Color.fromRGBO(50, 50, 50, 1)
|
||||
)
|
||||
)
|
||||
),
|
||||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: ClientsList(
|
||||
data: serversProvider.clients.data!.autoClientsData,
|
||||
fetchClients: fetchClients,
|
||||
),
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: AddedList(
|
||||
data: serversProvider.clients.data!.clients,
|
||||
fetchClients: fetchClients,
|
||||
)
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: BlockedList(
|
||||
data: serversProvider.clients.data!.clientsAllowedBlocked!.disallowedClients,
|
||||
fetchClients: fetchClients,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
],
|
||||
);
|
||||
|
||||
case 2:
|
||||
return Column(
|
||||
children: [
|
||||
AppBar(
|
||||
case 1:
|
||||
return Container();
|
||||
|
||||
case 2:
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
size: 50,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.errorLoadServerStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder: ((context, innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverAppBar(
|
||||
title: Text(AppLocalizations.of(context)!.clients),
|
||||
centerTitle: true,
|
||||
),
|
||||
SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
size: 50,
|
||||
pinned: true,
|
||||
floating: true,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
bottom: TabBar(
|
||||
controller: tabController,
|
||||
tabs: [
|
||||
Tab(
|
||||
icon: const Icon(Icons.devices),
|
||||
text: AppLocalizations.of(context)!.activeClients,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.errorLoadServerStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
Tab(
|
||||
icon: const Icon(Icons.add),
|
||||
text: AppLocalizations.of(context)!.added,
|
||||
),
|
||||
Tab(
|
||||
icon: const Icon(Icons.block),
|
||||
text: AppLocalizations.of(context)!.blocked,
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
];
|
||||
}),
|
||||
body: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(
|
||||
color: Theme.of(context).brightness == Brightness.light
|
||||
? const Color.fromRGBO(220, 220, 220, 1)
|
||||
: const Color.fromRGBO(50, 50, 50, 1)
|
||||
)
|
||||
)
|
||||
),
|
||||
child: TabBarView(
|
||||
controller: tabController,
|
||||
children: [
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: ClientsList(
|
||||
loadStatus: serversProvider.clients.loadStatus,
|
||||
data: serversProvider.clients.loadStatus == 1
|
||||
? serversProvider.clients.data!.autoClientsData : [],
|
||||
fetchClients: fetchClients,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: AddedList(
|
||||
loadStatus: serversProvider.clients.loadStatus,
|
||||
data: serversProvider.clients.loadStatus == 1
|
||||
? serversProvider.clients.data!.clients : [],
|
||||
fetchClients: fetchClients,
|
||||
)
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchClients,
|
||||
child: BlockedList(
|
||||
loadStatus: serversProvider.clients.loadStatus,
|
||||
data: serversProvider.clients.loadStatus == 1
|
||||
? serversProvider.clients.data!.clientsAllowedBlocked!.disallowedClients : [],
|
||||
fetchClients: fetchClients,
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,59 +4,113 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|||
import 'package:adguard_home_manager/models/clients.dart';
|
||||
|
||||
class ClientsList extends StatelessWidget {
|
||||
final int loadStatus;
|
||||
final List<AutoClient> data;
|
||||
final Future Function() fetchClients;
|
||||
|
||||
const ClientsList({
|
||||
Key? key,
|
||||
required this.loadStatus,
|
||||
required this.data,
|
||||
required this.fetchClients
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (data.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
title: Text(
|
||||
data[index].name != ''
|
||||
? data[index].name!
|
||||
: data[index].ip
|
||||
),
|
||||
subtitle: data[index].name != ''
|
||||
? Text(
|
||||
data[index].ip
|
||||
switch (loadStatus) {
|
||||
case 0:
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
trailing: Text(data[index].source),
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noClientsList,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
case 1:
|
||||
if (data.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 0),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
title: Text(
|
||||
data[index].name != ''
|
||||
? data[index].name!
|
||||
: data[index].ip
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh)
|
||||
subtitle: data[index].name != ''
|
||||
? Text(
|
||||
data[index].ip
|
||||
)
|
||||
: null,
|
||||
trailing: Text(data[index].source),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
else {
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.noClientsList,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: fetchClients,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh)
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
case 2:
|
||||
return SizedBox(
|
||||
width: double.maxFinite,
|
||||
height: MediaQuery.of(context).size.height-171,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
size: 50,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.errorLoadServerStatus,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue