|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:mc_common_app/config/routes.dart';
|
|
|
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/utils.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/requests_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/info_bottom_sheet.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/txt_field.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
|
|
|
|
|
Future buildSendOfferBottomSheet(BuildContext context, RequestDetailPageArguments requestDetailPageArguments) {
|
|
|
|
|
final requestDetail = requestDetailPageArguments.requestModel;
|
|
|
|
|
return showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
enableDrag: true,
|
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return Consumer(builder: (BuildContext context, RequestsVM requestsVM, Widget? child) {
|
|
|
|
|
return InfoBottomSheet(
|
|
|
|
|
title: LocaleKeys.makeAnOffer.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,
|
|
|
|
|
TxtField(
|
|
|
|
|
value: requestsVM.offerPrice,
|
|
|
|
|
errorValue: requestsVM.offerPriceError,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
hint: LocaleKeys.enterAmount.tr(),
|
|
|
|
|
numbersOnly: true,
|
|
|
|
|
onChanged: (v) => requestsVM.updateOfferPrice(v),
|
|
|
|
|
),
|
|
|
|
|
if (requestDetail.requestType == RequestsTypeEnum.serviceRequest.getIdFromRequestTypeStatusEnum()) ...[
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
value: requestsVM.serviceItem,
|
|
|
|
|
errorValue: requestsVM.offerPriceError,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
hint: "Service Item",
|
|
|
|
|
onChanged: (v) => requestsVM.updateServiceItem(v),
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
value: requestsVM.itemManufacturer,
|
|
|
|
|
errorValue: requestsVM.offerPriceError,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
hint: "Manufacturer",
|
|
|
|
|
onChanged: (v) => requestsVM.updateItemManufacturer(v),
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
errorValue: "",
|
|
|
|
|
hint: "Manufactured On",
|
|
|
|
|
value: requestsVM.serviceItemCreatedOn,
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
postfixData: Icons.calendar_month_rounded,
|
|
|
|
|
postFixDataColor: MyColors.darkTextColor,
|
|
|
|
|
onTap: () async {
|
|
|
|
|
final formattedDate = await Utils.pickDateFromDatePicker(context, firstDate: DateTime(2020), lastDate: DateTime.now());
|
|
|
|
|
requestsVM.updateServiceItemCreatedOn(formattedDate);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
maxLines: 5,
|
|
|
|
|
value: requestsVM.offerDescription,
|
|
|
|
|
errorValue: requestsVM.offerDescriptionError,
|
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
|
hint: LocaleKeys.description.tr(),
|
|
|
|
|
onChanged: (v) => requestsVM.updateOfferDescription(v),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
25.height,
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: LocaleKeys.submit.tr(),
|
|
|
|
|
maxHeight: 55,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
requestsVM.onSendOfferPressed(
|
|
|
|
|
context: context,
|
|
|
|
|
receiverId: requestDetail.customerID,
|
|
|
|
|
message: requestsVM.offerDescription,
|
|
|
|
|
requestId: requestDetail.id,
|
|
|
|
|
offerPrice: requestsVM.offerPrice,
|
|
|
|
|
requestModel: requestDetail,
|
|
|
|
|
requestIndex: requestDetailPageArguments.requestIndex,
|
|
|
|
|
isFromChatScreen: false,
|
|
|
|
|
manufacturedById: 1,
|
|
|
|
|
// Todo: It should be the ID of the manufacturer
|
|
|
|
|
manufacturedOn: requestsVM.serviceItemCreatedOn,
|
|
|
|
|
serviceItemName: requestsVM.serviceItem);
|
|
|
|
|
},
|
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
|
),
|
|
|
|
|
19.height,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|