mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-14 05:52:51 +00:00
New tab list on clients
This commit is contained in:
parent
a5f38915b4
commit
1508c49536
10 changed files with 440 additions and 351 deletions
109
lib/widgets/tab_content_list.dart
Normal file
109
lib/widgets/tab_content_list.dart
Normal file
|
@ -0,0 +1,109 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adguard_home_manager/constants/enums.dart';
|
||||
|
||||
class CustomTabContentList extends StatelessWidget {
|
||||
final Widget Function() loadingGenerator;
|
||||
final int itemsCount;
|
||||
final Widget Function(int index) contentWidget;
|
||||
final Widget noData;
|
||||
final Widget Function() errorGenerator;
|
||||
final LoadStatus loadStatus;
|
||||
final Future<void> Function() onRefresh;
|
||||
|
||||
const CustomTabContentList({
|
||||
Key? key,
|
||||
required this.loadingGenerator,
|
||||
required this.itemsCount,
|
||||
required this.contentWidget,
|
||||
required this.noData,
|
||||
required this.errorGenerator,
|
||||
required this.loadStatus,
|
||||
required this.onRefresh,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (loadStatus) {
|
||||
case LoadStatus.loading:
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) => CustomScrollView(
|
||||
slivers: [
|
||||
SliverOverlapInjector(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
),
|
||||
SliverFillRemaining(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: loadingGenerator()
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
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),
|
||||
),
|
||||
if (itemsCount > 0) SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => contentWidget(index),
|
||||
childCount: itemsCount
|
||||
),
|
||||
),
|
||||
if (itemsCount == 0) SliverFillRemaining(
|
||||
child: noData,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
case LoadStatus.error:
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) => CustomScrollView(
|
||||
slivers: [
|
||||
SliverOverlapInjector(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
),
|
||||
SliverFillRemaining(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 95,
|
||||
left: 16,
|
||||
right: 16
|
||||
),
|
||||
child: errorGenerator()
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
default:
|
||||
return const SizedBox();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue