device transfer added in filters

main_design2.0
Sikander Saleem 2 years ago
parent cfa749ab74
commit 9101783703

@ -29,13 +29,13 @@ class AllRequestsProvider extends ChangeNotifier {
AllRequestsAndCount calendarRequests;
final pageItemNumber = 10;
int pageNum=1;
int pageNum = 1;
bool nextPage = true;
void reset() {
allRequestsAndCount?.requestsDetails?.clear();
allRequestsAndCount = null;
pageNum=1;
pageNum = 1;
nextPage = true;
stateCode = null;
}
@ -48,12 +48,21 @@ class AllRequestsProvider extends ChangeNotifier {
getCompletedRequests();
}
SearchAllRequestsModel searchedModel;
Future<int> getAllRequests(BuildContext context, {int typeTransaction, SearchAllRequestsModel search}) async {
if (isAllLoading == true) return -2;
isAllLoading = true;
if (allRequestsAndCount == null) notifyListeners();
Response response;
try {
if (search != null) {
searchedModel = search;
} else if (searchedModel != null) {
search = searchedModel;
} else {
searchedModel = null;
}
final type = typeTransaction == null
? search?.typeTransaction == null || search.typeTransaction.isEmpty
? [1, 2, 3, 4]
@ -65,8 +74,8 @@ class AllRequestsProvider extends ChangeNotifier {
"statusTransaction": status,
"priority": [0, 1],
"displayData": [],
"pageNumber" : pageNum++,
"pageSize" : pageItemNumber,
"pageNumber": pageNum++,
"pageSize": pageItemNumber,
if (search?.requestNumber?.value?.isNotEmpty ?? false) "requestNumber": search.requestNumber.value,
if (search?.assetName?.value?.isNotEmpty ?? false) "assetName": search.assetName.value,
if (search?.assetNo?.value?.isNotEmpty ?? false) "assetNumber": search.assetNo.value,
@ -82,7 +91,7 @@ class AllRequestsProvider extends ChangeNotifier {
if (response.statusCode >= 200 && response.statusCode < 300) {
if (allRequestsAndCount == null) {
allRequestsAndCount = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
} else{
} else {
allRequestsAndCount.requestsDetails.addAll(AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]).requestsDetails);
}
if (allRequestsAndCount.requestsDetails.length >= pageItemNumber) {
@ -140,7 +149,8 @@ class AllRequestsProvider extends ChangeNotifier {
Future<int> getHighPriorityRequests() async {
if (isHighPriorityLoading == true) return -2;
isHighPriorityLoading = true; notifyListeners();
isHighPriorityLoading = true;
notifyListeners();
if (highPriorityRequests == null) notifyListeners();
Response response;
try {
@ -183,7 +193,7 @@ class AllRequestsProvider extends ChangeNotifier {
stateCode = response.statusCode;
if (response.statusCode >= 200 && response.statusCode < 300) {
overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
overdueRequests = AllRequestsAndCount.fromJson(json.decode(response.body)["data"][0]);
notifyListeners();
}
isOverdueLoading = false;

@ -56,8 +56,9 @@ class _AllRequestsFilterPageState extends State<AllRequestsFilterPage> {
}
final types = {
context.translation.serviceRequest: 1,
context.translation.preventiveMaintenance: 4,
context.translation.gasRefill: 2,
context.translation.deviceTransfer: 3,
context.translation.preventiveMaintenance: 4,
};
final statuses = {
context.translation.allRequests: 0,
@ -78,6 +79,7 @@ class _AllRequestsFilterPageState extends State<AllRequestsFilterPage> {
context.translation.reset,
style: AppTextStyles.bodyText2.copyWith(color: AppColor.blueStatus(context)),
).paddingAll(8).onPress(() {
Provider.of<AllRequestsProvider>(context, listen: false).searchedModel = null;
setState(() {
search.statuses?.clear();
search.typeTransaction?.clear();
@ -164,6 +166,7 @@ class _AllRequestsFilterPageState extends State<AllRequestsFilterPage> {
if (search.startDate != null) search.endDate ??= DateTime.now();
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
requestsProvider.reset();
requestsProvider.searchedModel = search;
await requestsProvider.getAllRequests(context, search: search);
Navigator.pop(context);
Navigator.of(context).pop(search);

Loading…
Cancel
Save