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
|
@ -15,12 +15,14 @@ import 'package:adguard_home_manager/providers/servers_provider.dart';
|
|||
import 'package:adguard_home_manager/classes/process_modal.dart';
|
||||
|
||||
class CustomRulesList extends StatefulWidget {
|
||||
final int loadStatus;
|
||||
final ScrollController scrollController;
|
||||
final List<String> data;
|
||||
final void Function() fetchData;
|
||||
|
||||
const CustomRulesList({
|
||||
Key? key,
|
||||
required this.loadStatus,
|
||||
required this.scrollController,
|
||||
required this.data,
|
||||
required this.fetchData
|
||||
|
@ -100,51 +102,104 @@ class _CustomRulesListState extends State<CustomRulesList> {
|
|||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
if (widget.data.isNotEmpty) ListView.builder(
|
||||
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(
|
||||
switch (widget.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)!.noBlackLists,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: widget.fetchData,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingFilters,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
curve: Curves.easeInOut,
|
||||
bottom: isVisible ? 20 : -70,
|
||||
right: 20,
|
||||
child: const FiltersFab(
|
||||
type: 'custom_rule',
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
);
|
||||
|
||||
case 1:
|
||||
return Stack(
|
||||
children: [
|
||||
if (widget.data.isNotEmpty) ListView.builder(
|
||||
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,
|
||||
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) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
|
||||
switch (serversProvider.filtering.loadStatus) {
|
||||
case 0:
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
AppBar(
|
||||
return DefaultTabController(
|
||||
length: 3,
|
||||
child: NestedScrollView(
|
||||
headerSliverBuilder: ((context, innerBoxIsScrolled) {
|
||||
return [
|
||||
SliverAppBar(
|
||||
title: Text(AppLocalizations.of(context)!.filters),
|
||||
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)!.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(
|
||||
pinned: true,
|
||||
floating: true,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
bottom: TabBar(
|
||||
controller: tabController,
|
||||
children: [
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchFilters,
|
||||
child: FiltersList(
|
||||
scrollController: scrollController,
|
||||
type: 'whitelist',
|
||||
data: serversProvider.filtering.data!.whitelistFilters,
|
||||
fetchData: fetchFilters,
|
||||
)
|
||||
tabs: [
|
||||
Tab(
|
||||
icon: const Icon(Icons.verified_user_rounded),
|
||||
text: AppLocalizations.of(context)!.whitelists,
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchFilters,
|
||||
child: FiltersList(
|
||||
scrollController: scrollController,
|
||||
type: 'blacklist',
|
||||
data: serversProvider.filtering.data!.filters,
|
||||
fetchData: fetchFilters,
|
||||
)
|
||||
Tab(
|
||||
icon: const Icon(Icons.gpp_bad_rounded),
|
||||
text: AppLocalizations.of(context)!.blacklists,
|
||||
),
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchFilters,
|
||||
child: CustomRulesList(
|
||||
scrollController: scrollController,
|
||||
data: serversProvider.filtering.data!.userRules,
|
||||
fetchData: fetchFilters,
|
||||
)
|
||||
Tab(
|
||||
icon: const Icon(Icons.shield_rounded),
|
||||
text: AppLocalizations.of(context)!.customRules,
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
case 2:
|
||||
return Column(
|
||||
children: [
|
||||
AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.filters),
|
||||
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,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.filtersNotLoaded,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
];
|
||||
}),
|
||||
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: fetchFilters,
|
||||
child: FiltersList(
|
||||
loadStatus: serversProvider.filtering.loadStatus,
|
||||
scrollController: scrollController,
|
||||
type: 'whitelist',
|
||||
data: serversProvider.filtering.loadStatus == 1
|
||||
? serversProvider.filtering.data!.whitelistFilters : [],
|
||||
fetchData: fetchFilters,
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
RefreshIndicator(
|
||||
onRefresh: fetchFilters,
|
||||
child: FiltersList(
|
||||
loadStatus: serversProvider.filtering.loadStatus,
|
||||
scrollController: scrollController,
|
||||
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';
|
||||
|
||||
class FiltersList extends StatefulWidget {
|
||||
final int loadStatus;
|
||||
final ScrollController scrollController;
|
||||
final List<Filter> data;
|
||||
final void Function() fetchData;
|
||||
|
@ -25,6 +26,7 @@ class FiltersList extends StatefulWidget {
|
|||
|
||||
const FiltersList({
|
||||
Key? key,
|
||||
required this.loadStatus,
|
||||
required this.scrollController,
|
||||
required this.data,
|
||||
required this.fetchData,
|
||||
|
@ -127,94 +129,147 @@ class _FiltersListState extends State<FiltersList> {
|
|||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
if (widget.data.isNotEmpty) ListView.builder(
|
||||
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(
|
||||
switch (widget.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(
|
||||
widget.type == 'blacklist'
|
||||
? AppLocalizations.of(context)!.noBlackLists
|
||||
: AppLocalizations.of(context)!.noWhiteLists,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 24,
|
||||
color: Colors.grey
|
||||
),
|
||||
),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 30),
|
||||
TextButton.icon(
|
||||
onPressed: widget.fetchData,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
label: Text(AppLocalizations.of(context)!.refresh),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.loadingFilters,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
color: Colors.grey,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
curve: Curves.easeInOut,
|
||||
bottom: isVisible ? 20 : -70,
|
||||
right: 20,
|
||||
child: FiltersFab(
|
||||
type: widget.type
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
);
|
||||
|
||||
case 1:
|
||||
return Stack(
|
||||
children: [
|
||||
if (widget.data.isNotEmpty) ListView.builder(
|
||||
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,
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue