You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
6.8 KiB
Dart
191 lines
6.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
import 'package:mc_common_app/extensions/int_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/theme/colors.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/app_bar.dart';
|
|
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';
|
|
|
|
class RequestDetailPage extends StatelessWidget {
|
|
final RequestModel requestDetail;
|
|
|
|
const RequestDetailPage({Key? key, required this.requestDetail}) : super(key: key);
|
|
|
|
Future buildSendOfferBottomSheet(BuildContext context) {
|
|
return showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
enableDrag: true,
|
|
builder: (BuildContext context) {
|
|
return Consumer(builder: (BuildContext context, RequestsVM requestsVM, Widget? child) {
|
|
return InfoBottomSheet(
|
|
title: "Make an offer".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: "Enter amount",
|
|
onChanged: (v) => requestsVM.updateOfferPrice(v),
|
|
),
|
|
12.height,
|
|
TxtField(
|
|
maxLines: 5,
|
|
value: requestsVM.offerDescription,
|
|
errorValue: requestsVM.offerDescriptionError,
|
|
keyboardType: TextInputType.text,
|
|
hint: "Description",
|
|
onChanged: (v) => requestsVM.updateOfferDescription(v),
|
|
),
|
|
],
|
|
),
|
|
25.height,
|
|
ShowFillButton(
|
|
title: "Submit",
|
|
onPressed: () {
|
|
requestsVM.onSendOfferPressed(
|
|
context: context,
|
|
receiverId: requestDetail.customerID,
|
|
message: requestsVM.offerDescription,
|
|
requestId: requestDetail.id,
|
|
offerPrice: requestsVM.offerPrice,
|
|
);
|
|
},
|
|
maxWidth: double.infinity,
|
|
),
|
|
19.height,
|
|
],
|
|
),
|
|
));
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CustomAppBar(
|
|
title: "Request Detail",
|
|
),
|
|
body: SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Image.asset(MyAssets.bnCar),
|
|
24.height,
|
|
buildRequestContainer(context),
|
|
],
|
|
).toWhiteContainer(
|
|
width: double.infinity,
|
|
allPading: 12,
|
|
margin: const EdgeInsets.only(
|
|
top: 21,
|
|
right: 21,
|
|
left: 21,
|
|
),
|
|
),
|
|
ShowFillButton(
|
|
title: "Send Offer",
|
|
maxWidth: double.infinity,
|
|
margin: const EdgeInsets.all(21),
|
|
onPressed: () {
|
|
buildSendOfferBottomSheet(context);
|
|
// navigateWithName(context, AppRoutes.sendOfferPage);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget buildRequestContainer(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
requestDetail.vehicleTypeName.toText(fontSize: 16, isBold: true),
|
|
showItem("Manufacturer:", requestDetail.brand),
|
|
showItem("Model:", "${requestDetail.year}"),
|
|
],
|
|
),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
"${requestDetail.city ?? ""} ${requestDetail.countryName}".toText(
|
|
color: MyColors.lightTextColor,
|
|
),
|
|
requestDetail.createdOn.getTimeAgo().toText(color: MyColors.lightTextColor),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
showItem("Customer Name", "${requestDetail.customer}"),
|
|
showItem("Description", requestDetail.description),
|
|
showItem("Price Range:", ""),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
"${requestDetail.price.toInt()}".toText(fontSize: 16, isBold: true),
|
|
2.width,
|
|
"SAR:".toText(
|
|
color: MyColors.lightTextColor,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// const Icon(Icons.arrow_forward)
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget showItem(String title, String value) {
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (title.isNotEmpty)
|
|
title.toText(
|
|
color: MyColors.lightTextColor,
|
|
),
|
|
if (title.isNotEmpty) 2.width,
|
|
if (value.isNotEmpty) Expanded(child: value.toText(isBold: true)),
|
|
],
|
|
);
|
|
}
|
|
}
|