Fixing JIRA Issues
parent
d414327147
commit
7326886660
@ -1,27 +1,80 @@
|
|||||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
import 'package:mc_common_app/models/requests_models/request_model.dart';
|
|
||||||
import 'package:mc_common_app/utils/enums.dart';
|
import 'package:mc_common_app/utils/enums.dart';
|
||||||
|
|
||||||
class ShippingRequestModel {
|
class ShippingRequestModel {
|
||||||
int? id;
|
int? id;
|
||||||
int? requestID;
|
int? requestID;
|
||||||
RequestModel? request;
|
Request? request;
|
||||||
int? shippingStatus;
|
int? shippingStatus;
|
||||||
ShippingRequestStatusEnum? shippingStatusEnum;
|
ShippingRequestStatusEnum? shippingStatusEnum;
|
||||||
String? deliveredOn;
|
String? deliveredOn;
|
||||||
String? comment;
|
String? comment;
|
||||||
String? createdOn;
|
String? createdOn;
|
||||||
|
int? customerID;
|
||||||
|
String? customerName;
|
||||||
|
|
||||||
ShippingRequestModel({this.id, this.requestID, this.request, this.shippingStatus, this.deliveredOn, this.comment, this.createdOn});
|
ShippingRequestModel({this.id, this.requestID, this.request, this.shippingStatus, this.deliveredOn, this.comment, this.createdOn, this.customerID, this.customerName});
|
||||||
|
|
||||||
ShippingRequestModel.fromJson(Map<String, dynamic> json) {
|
ShippingRequestModel.fromJson(Map<String, dynamic> json) {
|
||||||
id = json['id'];
|
id = json['id'];
|
||||||
requestID = json['requestID'];
|
requestID = json['requestID'];
|
||||||
request = json['request'];
|
request = json['request'] != null ? Request.fromJson(json['request']) : null;
|
||||||
shippingStatus = json['shippingStatus'];
|
shippingStatus = json['shippingStatus'];
|
||||||
shippingStatusEnum = json['shippingStatus'] != null ? (json['shippingStatus'] as int).toShippingStatusEnum() : ShippingRequestStatusEnum.initiated;
|
shippingStatusEnum = json['shippingStatus'] != null ? (json['shippingStatus'] as int).toShippingStatusEnum() : ShippingRequestStatusEnum.initiated;
|
||||||
deliveredOn = json['deliveredOn'];
|
deliveredOn = json['deliveredOn'];
|
||||||
comment = json['comment'];
|
comment = json['comment'];
|
||||||
createdOn = json['createdOn'];
|
createdOn = json['createdOn'];
|
||||||
|
customerID = json['customerID'];
|
||||||
|
customerName = json['customerName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['id'] = id;
|
||||||
|
data['requestID'] = requestID;
|
||||||
|
if (request != null) {
|
||||||
|
data['request'] = request!.toJson();
|
||||||
|
}
|
||||||
|
data['shippingStatus'] = shippingStatus;
|
||||||
|
data['deliveredOn'] = deliveredOn;
|
||||||
|
data['comment'] = comment;
|
||||||
|
data['createdOn'] = createdOn;
|
||||||
|
data['customerID'] = customerID;
|
||||||
|
data['customerName'] = customerName;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Request {
|
||||||
|
int? requestType;
|
||||||
|
String? brand;
|
||||||
|
String? model;
|
||||||
|
int? year;
|
||||||
|
bool? isNew;
|
||||||
|
String? description;
|
||||||
|
double? price;
|
||||||
|
|
||||||
|
Request({this.requestType, this.brand, this.model, this.year, this.isNew, this.description, this.price});
|
||||||
|
|
||||||
|
Request.fromJson(Map<String, dynamic> json) {
|
||||||
|
requestType = json['requestType'];
|
||||||
|
brand = json['brand'];
|
||||||
|
model = json['model'];
|
||||||
|
year = json['year'];
|
||||||
|
isNew = json['isNew'];
|
||||||
|
description = json['description'];
|
||||||
|
price = json['price'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['requestType'] = requestType;
|
||||||
|
data['brand'] = brand;
|
||||||
|
data['model'] = model;
|
||||||
|
data['year'] = year;
|
||||||
|
data['isNew'] = isNew;
|
||||||
|
data['description'] = description;
|
||||||
|
data['price'] = price;
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,98 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:mc_common_app/classes/app_state.dart';
|
||||||
|
import 'package:mc_common_app/classes/consts.dart';
|
||||||
|
import 'package:mc_common_app/config/routes.dart';
|
||||||
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mc_common_app/utils/dialogs_and_bottomsheets.dart';
|
||||||
|
import 'package:mc_common_app/utils/navigator.dart';
|
||||||
|
import 'package:mc_common_app/view_models/requests_view_model.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mc_common_app/theme/colors.dart';
|
||||||
|
import 'package:mc_common_app/utils/enums.dart';
|
||||||
|
import 'package:mc_common_app/views/requests/widget/request_item.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||||
|
import 'package:mc_common_app/widgets/common_widgets/categories_list.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
|
||||||
|
class ProviderAcceptedRequestsView extends StatefulWidget {
|
||||||
|
const ProviderAcceptedRequestsView({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ProviderAcceptedRequestsView> createState() => _ProviderAcceptedRequestsViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProviderAcceptedRequestsViewState extends State<ProviderAcceptedRequestsView> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
scheduleMicrotask(() async => context.read<RequestsVM>().applyFilterOnProvidersAcceptedRequests(requestsTypeEnum: RequestsTypeEnum.specialCarRequest));
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer(builder: (BuildContext context, RequestsVM requestsVM, Widget? child) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: CustomAppBar(title: LocaleKeys.acceptedRequests.tr()),
|
||||||
|
body: Container(
|
||||||
|
color: MyColors.backgroundColor,
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
16.height,
|
||||||
|
FiltersList(
|
||||||
|
filterList: requestsVM.acceptedRequestsTypeFilterOptions,
|
||||||
|
onFilterTapped: (index, selectedFilterId) {
|
||||||
|
requestsVM.applyFilterOnProvidersAcceptedRequests(requestsTypeEnum: selectedFilterId.toRequestTypeEnum());
|
||||||
|
},
|
||||||
|
),
|
||||||
|
8.height,
|
||||||
|
Expanded(
|
||||||
|
child: RefreshIndicator(
|
||||||
|
onRefresh: () async => await requestsVM.getProvidersAcceptedRequests(),
|
||||||
|
child: requestsVM.state == ViewState.busy
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: requestsVM.providersAcceptedRequestsList.isEmpty
|
||||||
|
? Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.noRequeststoShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor),
|
||||||
|
if (requestsVM.requestsFiltersCounter > 0) ...[
|
||||||
|
8.height,
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
requestsVM.clearRequestsFilters();
|
||||||
|
await requestsVM.getRequestsBasedOnFilters();
|
||||||
|
},
|
||||||
|
child: LocaleKeys.clearFilters.tr().toText(
|
||||||
|
fontSize: 14,
|
||||||
|
isBold: true,
|
||||||
|
color: MyColors.darkPrimaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: ListView.separated(
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return RequestItem(request: requestsVM.providersAcceptedRequestsList[index], appType: AppState().currentAppType, requestIndex: index);
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return 16.height;
|
||||||
|
},
|
||||||
|
itemCount: requestsVM.providersAcceptedRequestsList.length,
|
||||||
|
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8),
|
||||||
|
),
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue