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

@@ -9,6 +9,7 @@ import 'package:flutter_vector_icons/flutter_vector_icons.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../../pagination/paginator_listview.dart';
import 'staff_editor.dart';
class StaffList extends StatefulWidget {
@@ -21,6 +22,12 @@ class _StaffListState extends State<StaffList> {
final double dotSize = 15.0;
bool _isLoading = false;
@override
void initState() {
context.read<StaffModel>().loadPaginationStaffs();
super.initState();
}
@override
Widget build(BuildContext context) {
StaffModel staffModel = Provider.of<StaffModel>(context);
@@ -28,42 +35,33 @@ class _StaffListState extends State<StaffList> {
return LocalProgress(
inAsyncCall: _isLoading,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
appBar: AppBar(
centerTitle: true,
leading: new IconButton(
icon: new Icon(CupertinoIcons.back),
onPressed: () => Navigator.of(context).pop(),
),
backgroundColor: primaryColor,
title: LocalText(
context,
'staff.list.title',
color: Colors.white,
fontSize: 20,
),
),
backgroundColor: primaryColor,
title: LocalText(
context,
'staff.list.title',
color: Colors.white,
fontSize: 20,
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => StaffEditor()));
},
icon: Icon(Icons.add),
label: LocalText(context, "staff.new", color: Colors.white),
backgroundColor: primaryColor,
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => StaffEditor()));
},
icon: Icon(Icons.add),
label: LocalText(context, "staff.new", color: Colors.white),
backgroundColor: primaryColor,
),
body: new ListView.separated(
separatorBuilder: (context, index) => Divider(
color: Colors.black,
height: 1,
),
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: staffModel.employees.length,
itemBuilder: (BuildContext context, int index) {
User user = staffModel.employees[index];
return _item(user);
}),
),
body: PaginatorListView<User>(
paginatorListener: staffModel.getStaffs!,
rowBuilder: (p) => _item(p),
color: primaryColor)),
);
}