mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-24 07:46:06 +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
|
@ -35,9 +35,7 @@ List<AppScreen> screensServerConnected = [
|
||||||
const AppScreen(
|
const AppScreen(
|
||||||
name: "home",
|
name: "home",
|
||||||
icon: Icons.home_rounded,
|
icon: Icons.home_rounded,
|
||||||
appBar: HomeAppBar(),
|
|
||||||
body: Home(),
|
body: Home(),
|
||||||
fab: HomeFab()
|
|
||||||
),
|
),
|
||||||
const AppScreen(
|
const AppScreen(
|
||||||
name: "clients",
|
name: "clients",
|
||||||
|
@ -48,7 +46,6 @@ List<AppScreen> screensServerConnected = [
|
||||||
name: "logs",
|
name: "logs",
|
||||||
icon: Icons.list_alt_rounded,
|
icon: Icons.list_alt_rounded,
|
||||||
body: Logs(),
|
body: Logs(),
|
||||||
appBar: LogsAppBar()
|
|
||||||
),
|
),
|
||||||
const AppScreen(
|
const AppScreen(
|
||||||
name: "filters",
|
name: "filters",
|
||||||
|
|
|
@ -17,11 +17,13 @@ import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||||
|
|
||||||
class AddedList extends StatelessWidget {
|
class AddedList extends StatelessWidget {
|
||||||
|
final int loadStatus;
|
||||||
final List<Client> data;
|
final List<Client> data;
|
||||||
final Future Function() fetchClients;
|
final Future Function() fetchClients;
|
||||||
|
|
||||||
const AddedList({
|
const AddedList({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.loadStatus,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.fetchClients
|
required this.fetchClients
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
@ -133,94 +135,144 @@ class AddedList extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stack(
|
switch (loadStatus) {
|
||||||
children: [
|
case 0:
|
||||||
if (data.isNotEmpty) RefreshIndicator(
|
return SizedBox(
|
||||||
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(
|
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
|
height: MediaQuery.of(context).size.height-171,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
const CircularProgressIndicator(),
|
||||||
AppLocalizations.of(context)!.noClientsList,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
TextButton.icon(
|
Text(
|
||||||
onPressed: fetchClients,
|
AppLocalizations.of(context)!.loadingStatus,
|
||||||
icon: const Icon(Icons.refresh_rounded),
|
style: const TextStyle(
|
||||||
label: Text(AppLocalizations.of(context)!.refresh),
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
const Positioned(
|
|
||||||
bottom: 20,
|
case 1:
|
||||||
right: 20,
|
return Stack(
|
||||||
child: ClientsFab(tab: 1),
|
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';
|
import 'package:adguard_home_manager/classes/process_modal.dart';
|
||||||
|
|
||||||
class BlockedList extends StatelessWidget {
|
class BlockedList extends StatelessWidget {
|
||||||
|
final int loadStatus;
|
||||||
final List<String> data;
|
final List<String> data;
|
||||||
final Future Function() fetchClients;
|
final Future Function() fetchClients;
|
||||||
|
|
||||||
const BlockedList({
|
const BlockedList({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.loadStatus,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.fetchClients
|
required this.fetchClients
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
@ -71,54 +73,107 @@ class BlockedList extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stack(
|
switch (loadStatus) {
|
||||||
children: [
|
case 0:
|
||||||
if (data.isNotEmpty) ListView.builder(
|
return SizedBox(
|
||||||
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,
|
width: double.maxFinite,
|
||||||
|
height: MediaQuery.of(context).size.height-171,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
const CircularProgressIndicator(),
|
||||||
AppLocalizations.of(context)!.noCustomFilters,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
TextButton.icon(
|
Text(
|
||||||
onPressed: fetchClients,
|
AppLocalizations.of(context)!.loadingStatus,
|
||||||
icon: const Icon(Icons.refresh_rounded),
|
style: const TextStyle(
|
||||||
label: Text(AppLocalizations.of(context)!.refresh),
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
const Positioned(
|
|
||||||
bottom: 20,
|
case 1:
|
||||||
right: 20,
|
return Stack(
|
||||||
child: ClientsFab(tab: 2),
|
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) {
|
Widget build(BuildContext context) {
|
||||||
final serversProvider = Provider.of<ServersProvider>(context);
|
final serversProvider = Provider.of<ServersProvider>(context);
|
||||||
|
|
||||||
switch (serversProvider.clients.loadStatus) {
|
Widget generateBody() {
|
||||||
|
switch (serversProvider.clients.loadStatus) {
|
||||||
case 0:
|
case 0:
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
AppBar(
|
SizedBox(
|
||||||
title: Text(AppLocalizations.of(context)!.clients),
|
width: double.maxFinite,
|
||||||
centerTitle: true,
|
height: MediaQuery.of(context).size.height-171,
|
||||||
),
|
child: Column(
|
||||||
SizedBox(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
width: double.maxFinite,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
height: MediaQuery.of(context).size.height-171,
|
children: [
|
||||||
child: Column(
|
const CircularProgressIndicator(),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
const SizedBox(height: 30),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
Text(
|
||||||
children: [
|
AppLocalizations.of(context)!.loadingStatus,
|
||||||
const CircularProgressIndicator(),
|
style: const TextStyle(
|
||||||
const SizedBox(height: 30),
|
fontSize: 22,
|
||||||
Text(
|
color: Colors.grey,
|
||||||
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,
|
|
||||||
),
|
),
|
||||||
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:
|
case 1:
|
||||||
return Column(
|
return Container();
|
||||||
children: [
|
|
||||||
AppBar(
|
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),
|
title: Text(AppLocalizations.of(context)!.clients),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
pinned: true,
|
||||||
SizedBox(
|
floating: true,
|
||||||
width: double.maxFinite,
|
forceElevated: innerBoxIsScrolled,
|
||||||
height: MediaQuery.of(context).size.height-171,
|
bottom: TabBar(
|
||||||
child: Column(
|
controller: tabController,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
tabs: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
Tab(
|
||||||
children: [
|
icon: const Icon(Icons.devices),
|
||||||
const Icon(
|
text: AppLocalizations.of(context)!.activeClients,
|
||||||
Icons.error,
|
|
||||||
color: Colors.red,
|
|
||||||
size: 50,
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
Tab(
|
||||||
Text(
|
icon: const Icon(Icons.add),
|
||||||
AppLocalizations.of(context)!.errorLoadServerStatus,
|
text: AppLocalizations.of(context)!.added,
|
||||||
style: const TextStyle(
|
),
|
||||||
fontSize: 22,
|
Tab(
|
||||||
color: Colors.grey,
|
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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
RefreshIndicator(
|
||||||
],
|
onRefresh: fetchClients,
|
||||||
);
|
child: AddedList(
|
||||||
|
loadStatus: serversProvider.clients.loadStatus,
|
||||||
default:
|
data: serversProvider.clients.loadStatus == 1
|
||||||
return const SizedBox();
|
? 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';
|
import 'package:adguard_home_manager/models/clients.dart';
|
||||||
|
|
||||||
class ClientsList extends StatelessWidget {
|
class ClientsList extends StatelessWidget {
|
||||||
|
final int loadStatus;
|
||||||
final List<AutoClient> data;
|
final List<AutoClient> data;
|
||||||
final Future Function() fetchClients;
|
final Future Function() fetchClients;
|
||||||
|
|
||||||
const ClientsList({
|
const ClientsList({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.loadStatus,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.fetchClients
|
required this.fetchClients
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (data.isNotEmpty) {
|
switch (loadStatus) {
|
||||||
return ListView.builder(
|
case 0:
|
||||||
padding: const EdgeInsets.only(top: 0),
|
return SizedBox(
|
||||||
itemCount: data.length,
|
width: double.maxFinite,
|
||||||
itemBuilder: (context, index) => ListTile(
|
height: MediaQuery.of(context).size.height-171,
|
||||||
title: Text(
|
child: Column(
|
||||||
data[index].name != ''
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
? data[index].name!
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
: data[index].ip
|
children: [
|
||||||
),
|
const CircularProgressIndicator(),
|
||||||
subtitle: data[index].name != ''
|
const SizedBox(height: 30),
|
||||||
? Text(
|
Text(
|
||||||
data[index].ip
|
AppLocalizations.of(context)!.loadingStatus,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: null,
|
],
|
||||||
trailing: Text(data[index].source),
|
),
|
||||||
)
|
);
|
||||||
);
|
|
||||||
}
|
case 1:
|
||||||
else {
|
if (data.isNotEmpty) {
|
||||||
return SizedBox(
|
return ListView.builder(
|
||||||
width: double.maxFinite,
|
padding: const EdgeInsets.only(top: 0),
|
||||||
child: Column(
|
itemCount: data.length,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
itemBuilder: (context, index) => ListTile(
|
||||||
children: [
|
title: Text(
|
||||||
Text(
|
data[index].name != ''
|
||||||
AppLocalizations.of(context)!.noClientsList,
|
? data[index].name!
|
||||||
textAlign: TextAlign.center,
|
: data[index].ip
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
),
|
||||||
),
|
subtitle: data[index].name != ''
|
||||||
const SizedBox(height: 30),
|
? Text(
|
||||||
TextButton.icon(
|
data[index].ip
|
||||||
onPressed: fetchClients,
|
)
|
||||||
icon: const Icon(Icons.refresh_rounded),
|
: null,
|
||||||
label: Text(AppLocalizations.of(context)!.refresh)
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,12 +15,14 @@ import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||||
import 'package:adguard_home_manager/classes/process_modal.dart';
|
import 'package:adguard_home_manager/classes/process_modal.dart';
|
||||||
|
|
||||||
class CustomRulesList extends StatefulWidget {
|
class CustomRulesList extends StatefulWidget {
|
||||||
|
final int loadStatus;
|
||||||
final ScrollController scrollController;
|
final ScrollController scrollController;
|
||||||
final List<String> data;
|
final List<String> data;
|
||||||
final void Function() fetchData;
|
final void Function() fetchData;
|
||||||
|
|
||||||
const CustomRulesList({
|
const CustomRulesList({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.loadStatus,
|
||||||
required this.scrollController,
|
required this.scrollController,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.fetchData
|
required this.fetchData
|
||||||
|
@ -100,51 +102,104 @@ class _CustomRulesListState extends State<CustomRulesList> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stack(
|
switch (widget.loadStatus) {
|
||||||
children: [
|
case 0:
|
||||||
if (widget.data.isNotEmpty) ListView.builder(
|
return SizedBox(
|
||||||
padding: const EdgeInsets.only(top: 0),
|
|
||||||
itemCount: widget.data.length,
|
|
||||||
itemBuilder: (context, index) => ListTile(
|
|
||||||
title: Text(widget.data[index]),
|
|
||||||
trailing: IconButton(
|
|
||||||
onPressed: () => openRemoveCustomRuleModal(widget.data[index]),
|
|
||||||
icon: const Icon(Icons.delete)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
if (widget.data.isEmpty) SizedBox(
|
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
|
height: MediaQuery.of(context).size.height-171,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
const CircularProgressIndicator(),
|
||||||
AppLocalizations.of(context)!.noBlackLists,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
TextButton.icon(
|
Text(
|
||||||
onPressed: widget.fetchData,
|
AppLocalizations.of(context)!.loadingFilters,
|
||||||
icon: const Icon(Icons.refresh_rounded),
|
style: const TextStyle(
|
||||||
label: Text(AppLocalizations.of(context)!.refresh),
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
AnimatedPositioned(
|
|
||||||
duration: const Duration(milliseconds: 100),
|
case 1:
|
||||||
curve: Curves.easeInOut,
|
return Stack(
|
||||||
bottom: isVisible ? 20 : -70,
|
children: [
|
||||||
right: 20,
|
if (widget.data.isNotEmpty) ListView.builder(
|
||||||
child: const FiltersFab(
|
padding: const EdgeInsets.only(top: 0),
|
||||||
type: 'custom_rule',
|
itemCount: widget.data.length,
|
||||||
)
|
itemBuilder: (context, index) => ListTile(
|
||||||
)
|
title: Text(widget.data[index]),
|
||||||
],
|
trailing: IconButton(
|
||||||
);
|
onPressed: () => openRemoveCustomRuleModal(widget.data[index]),
|
||||||
|
icon: const Icon(Icons.delete)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
if (widget.data.isEmpty) SizedBox(
|
||||||
|
width: double.maxFinite,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.noBlackLists,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
color: Colors.grey
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: widget.fetchData,
|
||||||
|
icon: const Icon(Icons.refresh_rounded),
|
||||||
|
label: Text(AppLocalizations.of(context)!.refresh),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AnimatedPositioned(
|
||||||
|
duration: const Duration(milliseconds: 100),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
bottom: isVisible ? 20 : -70,
|
||||||
|
right: 20,
|
||||||
|
child: const FiltersFab(
|
||||||
|
type: 'custom_rule',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
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)!.filtersNotLoaded,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -80,150 +80,86 @@ class _FiltersWidgetState extends State<FiltersWidget> with TickerProviderStateM
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final serversProvider = Provider.of<ServersProvider>(context);
|
final serversProvider = Provider.of<ServersProvider>(context);
|
||||||
|
|
||||||
switch (serversProvider.filtering.loadStatus) {
|
return DefaultTabController(
|
||||||
case 0:
|
length: 3,
|
||||||
return Column(
|
child: NestedScrollView(
|
||||||
mainAxisSize: MainAxisSize.max,
|
headerSliverBuilder: ((context, innerBoxIsScrolled) {
|
||||||
children: [
|
return [
|
||||||
AppBar(
|
SliverAppBar(
|
||||||
title: Text(AppLocalizations.of(context)!.filters),
|
title: Text(AppLocalizations.of(context)!.filters),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
),
|
pinned: true,
|
||||||
SizedBox(
|
floating: true,
|
||||||
width: double.maxFinite,
|
forceElevated: innerBoxIsScrolled,
|
||||||
height: MediaQuery.of(context).size.height-171,
|
bottom: TabBar(
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const CircularProgressIndicator(),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.loadingFilters,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
return DefaultTabController(
|
|
||||||
length: 3,
|
|
||||||
child: NestedScrollView(
|
|
||||||
controller: scrollController,
|
|
||||||
headerSliverBuilder: ((context, innerBoxIsScrolled) {
|
|
||||||
return [
|
|
||||||
SliverAppBar(
|
|
||||||
title: Text(AppLocalizations.of(context)!.filters),
|
|
||||||
centerTitle: true,
|
|
||||||
pinned: true,
|
|
||||||
floating: true,
|
|
||||||
forceElevated: innerBoxIsScrolled,
|
|
||||||
bottom: TabBar(
|
|
||||||
controller: tabController,
|
|
||||||
tabs: [
|
|
||||||
Tab(
|
|
||||||
icon: const Icon(Icons.verified_user_rounded),
|
|
||||||
text: AppLocalizations.of(context)!.whitelists,
|
|
||||||
),
|
|
||||||
Tab(
|
|
||||||
icon: const Icon(Icons.gpp_bad_rounded),
|
|
||||||
text: AppLocalizations.of(context)!.blacklists,
|
|
||||||
),
|
|
||||||
Tab(
|
|
||||||
icon: const Icon(Icons.shield_rounded),
|
|
||||||
text: AppLocalizations.of(context)!.customRules,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
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,
|
controller: tabController,
|
||||||
children: [
|
tabs: [
|
||||||
RefreshIndicator(
|
Tab(
|
||||||
onRefresh: fetchFilters,
|
icon: const Icon(Icons.verified_user_rounded),
|
||||||
child: FiltersList(
|
text: AppLocalizations.of(context)!.whitelists,
|
||||||
scrollController: scrollController,
|
|
||||||
type: 'whitelist',
|
|
||||||
data: serversProvider.filtering.data!.whitelistFilters,
|
|
||||||
fetchData: fetchFilters,
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
RefreshIndicator(
|
Tab(
|
||||||
onRefresh: fetchFilters,
|
icon: const Icon(Icons.gpp_bad_rounded),
|
||||||
child: FiltersList(
|
text: AppLocalizations.of(context)!.blacklists,
|
||||||
scrollController: scrollController,
|
|
||||||
type: 'blacklist',
|
|
||||||
data: serversProvider.filtering.data!.filters,
|
|
||||||
fetchData: fetchFilters,
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
RefreshIndicator(
|
Tab(
|
||||||
onRefresh: fetchFilters,
|
icon: const Icon(Icons.shield_rounded),
|
||||||
child: CustomRulesList(
|
text: AppLocalizations.of(context)!.customRules,
|
||||||
scrollController: scrollController,
|
|
||||||
data: serversProvider.filtering.data!.userRules,
|
|
||||||
fetchData: fetchFilters,
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
),
|
)
|
||||||
)
|
)
|
||||||
)
|
];
|
||||||
);
|
}),
|
||||||
|
body: Container(
|
||||||
case 2:
|
decoration: BoxDecoration(
|
||||||
return Column(
|
border: Border(
|
||||||
children: [
|
top: BorderSide(
|
||||||
AppBar(
|
color: Theme.of(context).brightness == Brightness.light
|
||||||
title: Text(AppLocalizations.of(context)!.filters),
|
? const Color.fromRGBO(220, 220, 220, 1)
|
||||||
centerTitle: true,
|
: const Color.fromRGBO(50, 50, 50, 1)
|
||||||
),
|
)
|
||||||
SizedBox(
|
)
|
||||||
width: double.maxFinite,
|
),
|
||||||
height: MediaQuery.of(context).size.height-171,
|
child: TabBarView(
|
||||||
child: Column(
|
controller: tabController,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
RefreshIndicator(
|
||||||
children: [
|
onRefresh: fetchFilters,
|
||||||
const Icon(
|
child: FiltersList(
|
||||||
Icons.error,
|
loadStatus: serversProvider.filtering.loadStatus,
|
||||||
color: Colors.red,
|
scrollController: scrollController,
|
||||||
size: 50,
|
type: 'whitelist',
|
||||||
),
|
data: serversProvider.filtering.loadStatus == 1
|
||||||
const SizedBox(height: 30),
|
? serversProvider.filtering.data!.whitelistFilters : [],
|
||||||
Text(
|
fetchData: fetchFilters,
|
||||||
AppLocalizations.of(context)!.filtersNotLoaded,
|
)
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
RefreshIndicator(
|
||||||
],
|
onRefresh: fetchFilters,
|
||||||
);
|
child: FiltersList(
|
||||||
|
loadStatus: serversProvider.filtering.loadStatus,
|
||||||
default:
|
scrollController: scrollController,
|
||||||
return const SizedBox();
|
type: 'blacklist',
|
||||||
}
|
data: serversProvider.filtering.loadStatus == 1
|
||||||
|
? serversProvider.filtering.data!.filters : [],
|
||||||
|
fetchData: fetchFilters,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
RefreshIndicator(
|
||||||
|
onRefresh: fetchFilters,
|
||||||
|
child: CustomRulesList(
|
||||||
|
loadStatus: serversProvider.filtering.loadStatus,
|
||||||
|
scrollController: scrollController,
|
||||||
|
data: serversProvider.filtering.loadStatus == 1
|
||||||
|
? serversProvider.filtering.data!.userRules : [],
|
||||||
|
fetchData: fetchFilters,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,7 @@ import 'package:adguard_home_manager/functions/number_format.dart';
|
||||||
import 'package:adguard_home_manager/models/filtering.dart';
|
import 'package:adguard_home_manager/models/filtering.dart';
|
||||||
|
|
||||||
class FiltersList extends StatefulWidget {
|
class FiltersList extends StatefulWidget {
|
||||||
|
final int loadStatus;
|
||||||
final ScrollController scrollController;
|
final ScrollController scrollController;
|
||||||
final List<Filter> data;
|
final List<Filter> data;
|
||||||
final void Function() fetchData;
|
final void Function() fetchData;
|
||||||
|
@ -25,6 +26,7 @@ class FiltersList extends StatefulWidget {
|
||||||
|
|
||||||
const FiltersList({
|
const FiltersList({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
required this.loadStatus,
|
||||||
required this.scrollController,
|
required this.scrollController,
|
||||||
required this.data,
|
required this.data,
|
||||||
required this.fetchData,
|
required this.fetchData,
|
||||||
|
@ -127,94 +129,147 @@ class _FiltersListState extends State<FiltersList> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stack(
|
switch (widget.loadStatus) {
|
||||||
children: [
|
case 0:
|
||||||
if (widget.data.isNotEmpty) ListView.builder(
|
return SizedBox(
|
||||||
padding: const EdgeInsets.only(top: 0),
|
|
||||||
itemCount: widget.data.length,
|
|
||||||
itemBuilder: (context, index) => Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () => openDetailsModal(widget.data[index]),
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width-130,
|
|
||||||
child: Text(
|
|
||||||
widget.data[index].name,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 16
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 5),
|
|
||||||
Text(
|
|
||||||
"${intFormat(widget.data[index].rulesCount, Platform.localeName)} ${AppLocalizations.of(context)!.enabledRules}",
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
widget.data[index].enabled == true
|
|
||||||
? AppLocalizations.of(context)!.enabled
|
|
||||||
: AppLocalizations.of(context)!.disabled,
|
|
||||||
style: TextStyle(
|
|
||||||
color: widget.data[index].enabled == true
|
|
||||||
? Colors.green
|
|
||||||
: Colors.red,
|
|
||||||
fontWeight: FontWeight.w500
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.data.isEmpty) if (widget.data.isEmpty) SizedBox(
|
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
|
height: MediaQuery.of(context).size.height-171,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
const CircularProgressIndicator(),
|
||||||
widget.type == 'blacklist'
|
|
||||||
? AppLocalizations.of(context)!.noBlackLists
|
|
||||||
: AppLocalizations.of(context)!.noWhiteLists,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
TextButton.icon(
|
Text(
|
||||||
onPressed: widget.fetchData,
|
AppLocalizations.of(context)!.loadingFilters,
|
||||||
icon: const Icon(Icons.refresh_rounded),
|
style: const TextStyle(
|
||||||
label: Text(AppLocalizations.of(context)!.refresh),
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
AnimatedPositioned(
|
|
||||||
duration: const Duration(milliseconds: 100),
|
case 1:
|
||||||
curve: Curves.easeInOut,
|
return Stack(
|
||||||
bottom: isVisible ? 20 : -70,
|
children: [
|
||||||
right: 20,
|
if (widget.data.isNotEmpty) ListView.builder(
|
||||||
child: FiltersFab(
|
padding: const EdgeInsets.only(top: 0),
|
||||||
type: widget.type
|
itemCount: widget.data.length,
|
||||||
)
|
itemBuilder: (context, index) => Material(
|
||||||
)
|
color: Colors.transparent,
|
||||||
],
|
child: InkWell(
|
||||||
);
|
onTap: () => openDetailsModal(widget.data[index]),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width-130,
|
||||||
|
child: Text(
|
||||||
|
widget.data[index].name,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: 16
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 5),
|
||||||
|
Text(
|
||||||
|
"${intFormat(widget.data[index].rulesCount, Platform.localeName)} ${AppLocalizations.of(context)!.enabledRules}",
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: Colors.grey
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.data[index].enabled == true
|
||||||
|
? AppLocalizations.of(context)!.enabled
|
||||||
|
: AppLocalizations.of(context)!.disabled,
|
||||||
|
style: TextStyle(
|
||||||
|
color: widget.data[index].enabled == true
|
||||||
|
? Colors.green
|
||||||
|
: Colors.red,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.data.isEmpty) if (widget.data.isEmpty) SizedBox(
|
||||||
|
width: double.maxFinite,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.type == 'blacklist'
|
||||||
|
? AppLocalizations.of(context)!.noBlackLists
|
||||||
|
: AppLocalizations.of(context)!.noWhiteLists,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
color: Colors.grey
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: widget.fetchData,
|
||||||
|
icon: const Icon(Icons.refresh_rounded),
|
||||||
|
label: Text(AppLocalizations.of(context)!.refresh),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
AnimatedPositioned(
|
||||||
|
duration: const Duration(milliseconds: 100),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
bottom: isVisible ? 20 : -70,
|
||||||
|
right: 20,
|
||||||
|
child: FiltersFab(
|
||||||
|
type: widget.type
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
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)!.filtersNotLoaded,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/screens/home/server_status.dart';
|
import 'package:adguard_home_manager/screens/home/server_status.dart';
|
||||||
|
import 'package:adguard_home_manager/screens/home/appbar.dart';
|
||||||
import 'package:adguard_home_manager/screens/home/top_items.dart';
|
import 'package:adguard_home_manager/screens/home/top_items.dart';
|
||||||
import 'package:adguard_home_manager/screens/home/chart.dart';
|
import 'package:adguard_home_manager/screens/home/chart.dart';
|
||||||
|
|
||||||
|
@ -154,24 +155,27 @@ class Home extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return RefreshIndicator(
|
return Scaffold(
|
||||||
color: Theme.of(context).primaryColor,
|
appBar: const HomeAppBar(),
|
||||||
onRefresh: () async {
|
body: RefreshIndicator(
|
||||||
final result = await getServerStatus(serversProvider.selectedServer!);
|
color: Theme.of(context).primaryColor,
|
||||||
if (result['result'] == 'success') {
|
onRefresh: () async {
|
||||||
serversProvider.setServerStatusData(result['data']);
|
final result = await getServerStatus(serversProvider.selectedServer!);
|
||||||
}
|
if (result['result'] == 'success') {
|
||||||
else {
|
serversProvider.setServerStatusData(result['data']);
|
||||||
appConfigProvider.addLog(result['log']);
|
}
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
else {
|
||||||
SnackBar(
|
appConfigProvider.addLog(result['log']);
|
||||||
content: Text(AppLocalizations.of(context)!.serverStatusNotRefreshed),
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
backgroundColor: Colors.red,
|
SnackBar(
|
||||||
)
|
content: Text(AppLocalizations.of(context)!.serverStatusNotRefreshed),
|
||||||
);
|
backgroundColor: Colors.red,
|
||||||
}
|
)
|
||||||
},
|
);
|
||||||
child: status()
|
}
|
||||||
|
},
|
||||||
|
child: status()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,14 +5,12 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/screens/logs/log_tile.dart';
|
import 'package:adguard_home_manager/screens/logs/log_tile.dart';
|
||||||
|
import 'package:adguard_home_manager/screens/logs/appbar.dart';
|
||||||
|
|
||||||
import 'package:adguard_home_manager/providers/logs_provider.dart';
|
import 'package:adguard_home_manager/providers/logs_provider.dart';
|
||||||
import 'package:adguard_home_manager/models/filtering_status.dart';
|
|
||||||
import 'package:adguard_home_manager/models/app_log.dart';
|
|
||||||
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
import 'package:adguard_home_manager/providers/app_config_provider.dart';
|
||||||
import 'package:adguard_home_manager/services/http_requests.dart';
|
import 'package:adguard_home_manager/services/http_requests.dart';
|
||||||
import 'package:adguard_home_manager/models/logs.dart';
|
import 'package:adguard_home_manager/models/logs.dart';
|
||||||
import 'package:adguard_home_manager/models/server.dart';
|
|
||||||
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
import 'package:adguard_home_manager/providers/servers_provider.dart';
|
||||||
|
|
||||||
class Logs extends StatelessWidget {
|
class Logs extends StatelessWidget {
|
||||||
|
@ -132,114 +130,121 @@ class _LogsWidgetState extends State<LogsWidget> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final logsProvider = Provider.of<LogsProvider>(context);
|
final logsProvider = Provider.of<LogsProvider>(context);
|
||||||
|
|
||||||
switch (logsProvider.loadStatus) {
|
Widget generateBody() {
|
||||||
case 0:
|
switch (logsProvider.loadStatus) {
|
||||||
return SizedBox(
|
case 0:
|
||||||
width: double.maxFinite,
|
return SizedBox(
|
||||||
child: Column(
|
width: double.maxFinite,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
const CircularProgressIndicator(),
|
children: [
|
||||||
const SizedBox(height: 30),
|
const CircularProgressIndicator(),
|
||||||
Text(
|
const SizedBox(height: 30),
|
||||||
AppLocalizations.of(context)!.loadingLogs,
|
Text(
|
||||||
style: const TextStyle(
|
AppLocalizations.of(context)!.loadingLogs,
|
||||||
fontSize: 22,
|
style: const TextStyle(
|
||||||
color: Colors.grey,
|
fontSize: 22,
|
||||||
),
|
color: Colors.grey,
|
||||||
)
|
),
|
||||||
],
|
)
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
await fetchLogs(inOffset: 0);
|
await fetchLogs(inOffset: 0);
|
||||||
},
|
},
|
||||||
child: logsProvider.logsData!.data.isNotEmpty
|
child: logsProvider.logsData!.data.isNotEmpty
|
||||||
? ListView.builder(
|
? ListView.builder(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
padding: const EdgeInsets.only(top: 0),
|
padding: const EdgeInsets.only(top: 0),
|
||||||
itemCount: isLoadingMore == true
|
itemCount: isLoadingMore == true
|
||||||
? logsProvider.logsData!.data.length+1
|
? logsProvider.logsData!.data.length+1
|
||||||
: logsProvider.logsData!.data.length,
|
: logsProvider.logsData!.data.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (isLoadingMore == true && index == logsProvider.logsData!.data.length) {
|
if (isLoadingMore == true && index == logsProvider.logsData!.data.length) {
|
||||||
return const Padding(
|
return const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 20),
|
padding: EdgeInsets.symmetric(vertical: 20),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return LogTile(
|
||||||
|
log: logsProvider.logsData!.data[index],
|
||||||
|
index: index,
|
||||||
|
length: logsProvider.logsData!.data.length,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
)
|
||||||
return LogTile(
|
: Center(
|
||||||
log: logsProvider.logsData!.data[index],
|
child: Column(
|
||||||
index: index,
|
mainAxisSize: MainAxisSize.min,
|
||||||
length: logsProvider.logsData!.data.length,
|
children: [
|
||||||
);
|
Text(
|
||||||
}
|
AppLocalizations.of(context)!.noLogsDisplay,
|
||||||
}
|
|
||||||
)
|
|
||||||
: Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.noLogsDisplay,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 24,
|
|
||||||
color: Colors.grey
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (logsProvider.logsOlderThan != null) Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
top: 30,
|
|
||||||
left: 20,
|
|
||||||
right: 20
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
AppLocalizations.of(context)!.noLogsThatOld,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
fontSize: 24,
|
||||||
color: Colors.grey
|
color: Colors.grey
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (logsProvider.logsOlderThan != null) Padding(
|
||||||
]
|
padding: const EdgeInsets.only(
|
||||||
),
|
top: 30,
|
||||||
)
|
left: 20,
|
||||||
);
|
right: 20
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
AppLocalizations.of(context)!.noLogsThatOld,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: Colors.grey
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Icon(
|
const Icon(
|
||||||
Icons.error,
|
Icons.error,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
size: 50,
|
size: 50,
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.logsNotLoaded,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 22,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
),
|
||||||
)
|
const SizedBox(height: 30),
|
||||||
],
|
Text(
|
||||||
),
|
AppLocalizations.of(context)!.logsNotLoaded,
|
||||||
);
|
style: const TextStyle(
|
||||||
|
fontSize: 22,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: const LogsAppBar(),
|
||||||
|
body: generateBody(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue