add pagination for invoice and update ui for material 3

This commit is contained in:
tzw
2024-01-26 16:56:20 +06:30
parent 93a5fe071a
commit 8d0f712bf4
32 changed files with 351 additions and 635 deletions

View File

@@ -21,30 +21,21 @@ class PackageModel extends BaseModel {
PaginatorListener<Package>? activePackages;
bool isLoading = false;
int _menuSelectedIndex = 1;
int selectedIndex = 1;
set menuSelectedIndex(int index) {
_menuSelectedIndex = index;
_loadPaginationPackages(_menuSelectedIndex == 2);
_loadPaginationCustomerPackages(_menuSelectedIndex == 2);
notifyListeners();
}
int get menuSelectedIndex => _menuSelectedIndex;
void privilegeChanged() {
if (user != null) {
_initData();
initData(int index, bool isCustomer) {
selectedIndex = index;
if (isCustomer) {
_loadPaginationCustomerPackages(selectedIndex == 2);
} else {
_loadPaginationPackages(selectedIndex == 2);
}
}
Future<void> _initData() async {
_menuSelectedIndex = 1;
_loadPaginationPackages(_menuSelectedIndex == 2);
_loadPaginationCustomerPackages(_menuSelectedIndex == 2);
_loadPaginationActivePackages();
void privilegeChanged() {
if (user != null) {
_loadPaginationActivePackages();
}
}
@override
@@ -54,6 +45,16 @@ class PackageModel extends BaseModel {
if (activePackages != null) activePackages!.close();
}
onChanged(int index, bool isCustomer) {
selectedIndex = index;
if (isCustomer) {
_loadPaginationCustomerPackages(selectedIndex == 2);
} else {
_loadPaginationPackages(selectedIndex == 2);
}
notifyListeners();
}
_loadPaginationPackages(bool isDelivered) {
if (user == null) return;
if (!((user!.hasPackages() ||
@@ -78,7 +79,6 @@ class PackageModel extends BaseModel {
_loadPaginationCustomerPackages(bool isDelivered) {
if (user == null) return;
String path = "/$packages_collection";
Query col = FirebaseFirestore.instance
.collection(path)
.where("is_delivered", isEqualTo: isDelivered)