add pagination for pages

This commit is contained in:
tzw
2024-01-24 16:54:08 +06:30
parent 4b9dc7bdc2
commit 0dc32067b8
34 changed files with 399 additions and 2249 deletions

View File

@@ -15,6 +15,7 @@ import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:share/share.dart';
import '../../pagination/paginator_listview.dart';
import 'invitation_create.dart';
class CustomerList extends StatefulWidget {
@@ -27,6 +28,13 @@ class _CustomerListState extends State<CustomerList> {
final double dotSize = 15.0;
bool _isLoading = false;
@override
void initState() {
context.read<CustomerModel>().loadPaginationCustomers();
super.initState();
}
@override
Widget build(BuildContext context) {
var customerModel = Provider.of<CustomerModel>(context);
@@ -34,55 +42,40 @@ class _CustomerListState extends State<CustomerList> {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search, color: Colors.white),
onPressed: () => searchUser(context, onUserSelect: (u) {
_select(u);
})),
],
backgroundColor: primaryColor,
title: LocalText(
context,
"customer.list.title",
fontSize: 20,
color: Colors.white,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => InvitationCreate()));
},
icon: Icon(Icons.add),
label: LocalText(context, "invitation.new", color: Colors.white),
backgroundColor: primaryColor,
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.grey,
),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: customerModel.customers.length,
itemBuilder: (BuildContext context, int index) {
User customer = customerModel.customers[index];
return _item(customer);
}),
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
],
),
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.search, color: Colors.white),
onPressed: () => searchUser(context, onUserSelect: (u) {
_select(u);
})),
],
backgroundColor: primaryColor,
title: LocalText(
context,
"customer.list.title",
fontSize: 20,
color: Colors.white,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => InvitationCreate()));
},
icon: Icon(Icons.add),
label: LocalText(context, "invitation.new", color: Colors.white),
backgroundColor: primaryColor,
),
body: PaginatorListView<User>(
paginatorListener: customerModel.getCustomers!,
rowBuilder: (p) => _item(p),
color: primaryColor)),
);
}