New tab list filters

This commit is contained in:
Juan Gilsanz Polo 2023-04-06 18:27:57 +02:00
parent 1508c49536
commit b599debb3c
8 changed files with 376 additions and 402 deletions

View file

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:adguard_home_manager/providers/app_config_provider.dart';
import 'package:adguard_home_manager/constants/enums.dart';
class CustomTabContentList extends StatelessWidget {
@ -10,6 +12,8 @@ class CustomTabContentList extends StatelessWidget {
final Widget Function() errorGenerator;
final LoadStatus loadStatus;
final Future<void> Function() onRefresh;
final Widget? fab;
final bool? fabVisible;
const CustomTabContentList({
Key? key,
@ -20,10 +24,14 @@ class CustomTabContentList extends StatelessWidget {
required this.errorGenerator,
required this.loadStatus,
required this.onRefresh,
this.fab,
this.fabVisible
}) : super(key: key);
@override
Widget build(BuildContext context) {
final appConfigProvider = Provider.of<AppConfigProvider>(context);
switch (loadStatus) {
case LoadStatus.loading:
return SafeArea(
@ -48,33 +56,47 @@ class CustomTabContentList extends StatelessWidget {
case LoadStatus.loaded:
return SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) {
return RefreshIndicator(
onRefresh: onRefresh,
edgeOffset: 95,
child: CustomScrollView(
slivers: <Widget>[
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
return Stack(
children: [
SafeArea(
top: false,
bottom: false,
child: Builder(
builder: (BuildContext context) {
return RefreshIndicator(
onRefresh: onRefresh,
edgeOffset: 95,
child: CustomScrollView(
slivers: <Widget>[
SliverOverlapInjector(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
if (itemsCount > 0) SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => contentWidget(index),
childCount: itemsCount
),
),
if (itemsCount == 0) SliverFillRemaining(
child: noData,
)
],
),
if (itemsCount > 0) SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => contentWidget(index),
childCount: itemsCount
),
),
if (itemsCount == 0) SliverFillRemaining(
child: noData,
)
],
),
);
},
),
);
},
),
),
if (fab != null) AnimatedPositioned(
duration: const Duration(milliseconds: 100),
curve: Curves.easeInOut,
bottom: fabVisible != null && fabVisible == true ?
appConfigProvider.showingSnackbar
? 70 : 20
: -70,
right: 20,
child: fab!
),
],
);
case LoadStatus.error: