|
|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart' as lcl;
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/app_state.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
@ -18,6 +17,7 @@ import 'package:mc_common_app/utils/utils.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/ad_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/chat_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/requests_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/views/chat/widgets/chat_bottom_sheets.dart';
|
|
|
|
|
import 'package:mc_common_app/views/requests/request_bottomsheets.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/checkbox_with_title_desc.dart';
|
|
|
|
|
@ -25,7 +25,6 @@ import 'package:mc_common_app/widgets/common_widgets/info_bottom_sheet.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/txt_field.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart' as lcl;
|
|
|
|
|
|
|
|
|
|
class ChatMessageCustomWidget extends StatefulWidget {
|
|
|
|
|
final ChatMessageModel chatMessageModel;
|
|
|
|
|
@ -48,7 +47,7 @@ class ChatMessageCustomWidget extends StatefulWidget {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ChatMessageCustomWidgetState extends State<ChatMessageCustomWidget> {
|
|
|
|
|
Future buildDealBottomSheetForSpecialCar({required ChatMessageModel chatMessageModel, required RequestOfferStatusEnum requestOfferStatusEnum}) {
|
|
|
|
|
Future buildDealNotCompletedBottomSheetOptions({required ChatMessageModel chatMessageModel}) {
|
|
|
|
|
return showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
@ -62,53 +61,57 @@ class _ChatMessageCustomWidgetState extends State<ChatMessageCustomWidget> {
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
12.height,
|
|
|
|
|
ListView(
|
|
|
|
|
children: [
|
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
|
isSelected: chatVM.dealOptionsModelList[0].isSelected!,
|
|
|
|
|
title: '${chatVM.dealOptionsModelList[0].title}',
|
|
|
|
|
description: '',
|
|
|
|
|
onSelection: (bool value) {
|
|
|
|
|
chatVM.updateIsSelectedInDealOptionsModelList(0, value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
|
isSelected: chatVM.dealOptionsModelList[1].isSelected ?? false,
|
|
|
|
|
title: '${chatVM.dealOptionsModelList[1].title}',
|
|
|
|
|
description: '',
|
|
|
|
|
onSelection: (bool value) {
|
|
|
|
|
chatVM.updateIsSelectedInDealOptionsModelList(1, value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (chatVM.dealOptionsModelList[1].isSelected!) ...[
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
value: chatVM.rejectOfferDescription,
|
|
|
|
|
errorValue: chatVM.rejectOfferDescriptionError,
|
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
|
hint: LocaleKeys.description.tr(),
|
|
|
|
|
onChanged: (v) => chatVM.updateRejectOfferDescription(v),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
12.height,
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: chatVM.offerRejectModelList.length,
|
|
|
|
|
separatorBuilder: (BuildContext context, int index) {
|
|
|
|
|
bool indexContains = chatVM.indexesForDealNotCompleted.indexWhere((i) => i == index) != -1;
|
|
|
|
|
if ((!indexContains)) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return const Divider(thickness: 0.5);
|
|
|
|
|
},
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
bool indexContains = chatVM.indexesForDealNotCompleted.indexWhere((i) => i == index) != -1;
|
|
|
|
|
|
|
|
|
|
if (!indexContains) {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OfferRequestCommentModel offerRequestCommentModel = chatVM.offerRejectModelList[index];
|
|
|
|
|
return CircleCheckBoxWithTitle(
|
|
|
|
|
isChecked: offerRequestCommentModel.isSelected ?? false,
|
|
|
|
|
title: '${offerRequestCommentModel.title}',
|
|
|
|
|
onSelected: () {
|
|
|
|
|
chatVM.updateSelectionInOfferRejectModelList(index);
|
|
|
|
|
},
|
|
|
|
|
selectedColor: MyColors.darkPrimaryColor,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (chatVM.offerRejectModelList.last.isSelected ?? false) ...[
|
|
|
|
|
// comparing if the "other" is selected
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
value: chatVM.rejectOfferDescription,
|
|
|
|
|
errorValue: chatVM.rejectOfferDescriptionError,
|
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
|
hint: LocaleKeys.description.tr(),
|
|
|
|
|
onChanged: (v) => chatVM.updateRejectOfferDescription(v),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
25.height,
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: LocaleKeys.submit.tr(),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
String comments = "";
|
|
|
|
|
if (chatVM.selectedOfferRequestCommentModel.index == chatVM.offerRejectModelList.length - 1) //Other
|
|
|
|
|
{
|
|
|
|
|
if (chatVM.offerRejectModelList.last.isSelected ?? false) {
|
|
|
|
|
comments = chatVM.rejectOfferDescription;
|
|
|
|
|
} else {
|
|
|
|
|
comments = chatVM.selectedOfferRequestCommentModel.title ?? "";
|
|
|
|
|
comments = chatVM.offerRejectModelList.firstWhere((element) => element.isSelected!).title ?? "";
|
|
|
|
|
}
|
|
|
|
|
if (!chatVM.isRejectOfferButtonValidated()) {
|
|
|
|
|
return;
|
|
|
|
|
@ -125,13 +128,13 @@ class _ChatMessageCustomWidgetState extends State<ChatMessageCustomWidget> {
|
|
|
|
|
serviceItemName: chatMessageModel.reqOffer!.serviceItemName ?? "",
|
|
|
|
|
manufacturedOn: chatMessageModel.reqOffer!.manufacturedOn ?? "",
|
|
|
|
|
manufacturedById: chatMessageModel.reqOffer!.manufacturedById ?? 0,
|
|
|
|
|
requestOfferStatusEnum: requestOfferStatusEnum,
|
|
|
|
|
requestOfferStatusEnum: RequestOfferStatusEnum.rejected,
|
|
|
|
|
context: context,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
|
final requestVM = context.read<RequestsVM>();
|
|
|
|
|
chatMessageModel.reqOffer!.requestOfferStatusEnum = requestOfferStatusEnum;
|
|
|
|
|
chatMessageModel.reqOffer!.requestOfferStatusEnum = RequestOfferStatusEnum.rejected;
|
|
|
|
|
int index = chatVM.serviceProviderOffersList
|
|
|
|
|
.indexWhere((element) => (element.providerId == requestVM.currentSelectedOffer!.providerId) && (element.requestId == requestVM.currentSelectedOffer!.requestId));
|
|
|
|
|
|
|
|
|
|
@ -139,9 +142,8 @@ class _ChatMessageCustomWidgetState extends State<ChatMessageCustomWidget> {
|
|
|
|
|
chatVM.serviceProviderOffersList[index].requestOfferStatusEnum = chatMessageModel.reqOffer!.requestOfferStatusEnum;
|
|
|
|
|
}
|
|
|
|
|
setState(() {});
|
|
|
|
|
// Navigator.pop(context);
|
|
|
|
|
chatVM.updateRejectOfferDescription('');
|
|
|
|
|
Utils.showToast("Offer ${requestOfferStatusEnum == RequestOfferStatusEnum.rejected ? "Rejected" : "Cancelled"}");
|
|
|
|
|
Utils.showToast(LocaleKeys.offerRejected.tr());
|
|
|
|
|
// navigateReplaceWithName(context, AppRoutes.dashboard);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -156,6 +158,68 @@ class _ChatMessageCustomWidgetState extends State<ChatMessageCustomWidget> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future buildDealBottomSheetOptionsForSpecialCar({required ChatMessageModel chatMessageModel, required RequestOfferStatusEnum requestOfferStatusEnum}) {
|
|
|
|
|
return showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
enableDrag: true,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return Consumer(builder: (BuildContext context, ChatVM chatVM, Widget? child) {
|
|
|
|
|
return InfoBottomSheet(
|
|
|
|
|
title: LocaleKeys.pleaseSpecify.tr().toText(fontSize: 28, isBold: true, letterSpacing: -1.44),
|
|
|
|
|
description: Padding(
|
|
|
|
|
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
12.height,
|
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
|
isSelected: chatVM.dealOptionsModelList[0].isSelected!,
|
|
|
|
|
title: '${chatVM.dealOptionsModelList[0].title}',
|
|
|
|
|
description: '',
|
|
|
|
|
onSelection: (bool value) {
|
|
|
|
|
chatVM.updateIsSelectedInDealOptionsModelList(0, value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
|
isSelected: chatVM.dealOptionsModelList[1].isSelected ?? false,
|
|
|
|
|
title: '${chatVM.dealOptionsModelList[1].title}',
|
|
|
|
|
description: '',
|
|
|
|
|
onSelection: (bool value) {
|
|
|
|
|
chatVM.updateIsSelectedInDealOptionsModelList(1, value);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
25.height,
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: LocaleKeys.continu.tr(),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
if (chatVM.dealOptionsModelList[0].isSelected ?? false) {
|
|
|
|
|
final requestVM = context.read<RequestsVM>();
|
|
|
|
|
return dealCompletedConfirmationBottomSheet(
|
|
|
|
|
mainContext: context,
|
|
|
|
|
requestStatusEnum: RequestStatusEnum.completed,
|
|
|
|
|
requestId: requestVM.currentSelectedRequest!.id,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
buildDealNotCompletedBottomSheetOptions(chatMessageModel: chatMessageModel);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
),
|
|
|
|
|
19.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future buildRejectOrCancelOfferBottomSheet({required ChatMessageModel chatMessageModel, required RequestOfferStatusEnum requestOfferStatusEnum}) {
|
|
|
|
|
return showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
@ -434,7 +498,11 @@ class _ChatMessageCustomWidgetState extends State<ChatMessageCustomWidget> {
|
|
|
|
|
borderColor: MyColors.greenColor,
|
|
|
|
|
isFilled: false,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
offerAcceptConfirmationBottomSheet(chatMessageModel: chatMessageModel);
|
|
|
|
|
if (widget.requestsTypeEnum == RequestsTypeEnum.specialCarRequest) {
|
|
|
|
|
buildDealBottomSheetOptionsForSpecialCar(chatMessageModel: chatMessageModel, requestOfferStatusEnum: requestOfferStatusEnum);
|
|
|
|
|
} else {
|
|
|
|
|
offerAcceptConfirmationBottomSheet(chatMessageModel: chatMessageModel);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: MyColors.white,
|
|
|
|
|
txtColor: MyColors.greenColor,
|
|
|
|
|
|