Request and Chat WIP
parent
a47cae92f2
commit
711be7f5da
@ -0,0 +1,195 @@
|
||||
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/theme/colors.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/extensions/extensions_widget.dart';
|
||||
import 'package:mc_common_app/widgets/txt_field.dart';
|
||||
|
||||
class ChatView extends StatelessWidget {
|
||||
const ChatView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(title: "Chat"),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
itemCount: 15,
|
||||
separatorBuilder: (BuildContext context, int index) => 20.height,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return ChatMessageCustomWidget(
|
||||
isSent: index.isOdd,
|
||||
profileUrl: MyAssets.bnCar,
|
||||
messageText: "Hi, How Are you? I can help you out with the desired request.",
|
||||
messageTypeEnum: index == 10
|
||||
? (MessageTypeEnum.newOfferRequired)
|
||||
: index == 12
|
||||
? (MessageTypeEnum.offerProvided)
|
||||
: (MessageTypeEnum.text),
|
||||
senderName: "Al Abdullah Cars",
|
||||
);
|
||||
}).horPaddingMain(),
|
||||
),
|
||||
10.width,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 7,
|
||||
child: TxtField(
|
||||
// value: adVM.vehicleDemandAmount,
|
||||
// errorValue: adVM.demandAmountError,
|
||||
hint: "Type your message here..",
|
||||
keyboardType: TextInputType.text,
|
||||
isNeedBorder: false,
|
||||
onChanged: (v) => null,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Icon(
|
||||
Icons.send_rounded,
|
||||
color: MyColors.darkPrimaryColor,
|
||||
size: 30,
|
||||
).onPress(() {}))
|
||||
],
|
||||
).toContainer(isShadowEnabled: true),
|
||||
],
|
||||
),
|
||||
// body:
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChatMessageCustomWidget extends StatelessWidget {
|
||||
final String profileUrl;
|
||||
final String senderName;
|
||||
final String messageText;
|
||||
final MessageTypeEnum messageTypeEnum;
|
||||
final bool isSent;
|
||||
|
||||
const ChatMessageCustomWidget({
|
||||
super.key,
|
||||
required this.profileUrl,
|
||||
required this.senderName,
|
||||
required this.messageText,
|
||||
required this.messageTypeEnum,
|
||||
required this.isSent,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Directionality(
|
||||
textDirection: isSent ? TextDirection.rtl : TextDirection.ltr,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Image.asset(
|
||||
profileUrl,
|
||||
width: 34,
|
||||
height: 34,
|
||||
fit: BoxFit.fill,
|
||||
).toCircle(borderRadius: 100),
|
||||
),
|
||||
10.width,
|
||||
Expanded(
|
||||
flex: 10,
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"${isSent ? "You" : senderName}".toText(fontSize: 16, isBold: true),
|
||||
],
|
||||
),
|
||||
5.height,
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: "${messageText}".toText(
|
||||
color: isSent ? MyColors.white : MyColors.lightTextColor,
|
||||
fontSize: 12,
|
||||
// isBold: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (messageTypeEnum == MessageTypeEnum.offerProvided || messageTypeEnum == MessageTypeEnum.newOfferRequired) ...[
|
||||
5.height,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
"40000".toText(fontSize: 19, isBold: true),
|
||||
2.width,
|
||||
"SAR".toText(color: MyColors.lightTextColor, height: 2.2, fontSize: 10, isBold: true),
|
||||
],
|
||||
),
|
||||
10.height,
|
||||
if (messageTypeEnum == MessageTypeEnum.newOfferRequired) ...[
|
||||
Center(
|
||||
child: "You asked for the new offer.".toText(
|
||||
color: MyColors.adPendingStatusColor,
|
||||
fontSize: 12,
|
||||
isItalic: true,
|
||||
),
|
||||
).toContainer(borderRadius: 40, width: double.infinity, backgroundColor: MyColors.adPendingStatusColor.withOpacity(0.16)),
|
||||
] else ...[
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ShowFillButton(
|
||||
maxHeight: 27,
|
||||
title: "Accept",
|
||||
fontSize: 9,
|
||||
borderColor: MyColors.greenColor,
|
||||
isFilled: false,
|
||||
onPressed: () {},
|
||||
backgroundColor: MyColors.white,
|
||||
txtColor: MyColors.greenColor,
|
||||
),
|
||||
),
|
||||
20.width,
|
||||
Expanded(
|
||||
child: ShowFillButton(
|
||||
maxHeight: 27,
|
||||
title: "Reject",
|
||||
borderColor: MyColors.redColor,
|
||||
isFilled: false,
|
||||
onPressed: () {},
|
||||
backgroundColor: MyColors.white,
|
||||
txtColor: MyColors.redColor,
|
||||
fontSize: 9,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
).toContainer(
|
||||
isShadowEnabled: !isSent,
|
||||
backgroundColor: isSent ? MyColors.darkIconColor : MyColors.white,
|
||||
borderRadius: 0,
|
||||
margin: EdgeInsets.fromLTRB(isSent ? 25 : 0, 0, !isSent ? 25 : 0, 0),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum MessageTypeEnum { text, picture, offerProvided, recording, video, newOfferRequired }
|
||||
@ -1,138 +0,0 @@
|
||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||
import 'package:mc_common_app/utils/enums.dart';
|
||||
|
||||
class Request {
|
||||
int requestType;
|
||||
String requestTypeName;
|
||||
String requestStatusName;
|
||||
RequestStatus requestStatus;
|
||||
String cityName;
|
||||
String vehicleTypeName;
|
||||
String countryName;
|
||||
String customerName;
|
||||
dynamic serviceProviders;
|
||||
int offerCount;
|
||||
int id;
|
||||
int customerId;
|
||||
dynamic customer;
|
||||
String brand;
|
||||
String model;
|
||||
int year;
|
||||
bool isNew;
|
||||
String description;
|
||||
List<dynamic> requestImages;
|
||||
int cityId;
|
||||
dynamic city;
|
||||
double price;
|
||||
int paymentStatus;
|
||||
int vehicleTypeId;
|
||||
int countryId;
|
||||
List<dynamic> requestProviderItem;
|
||||
bool isActive;
|
||||
int createdBy;
|
||||
DateTime createdOn;
|
||||
dynamic modifiedBy;
|
||||
dynamic modifiedOn;
|
||||
|
||||
Request({
|
||||
required this.requestType,
|
||||
required this.requestTypeName,
|
||||
required this.requestStatusName,
|
||||
required this.requestStatus,
|
||||
required this.cityName,
|
||||
required this.vehicleTypeName,
|
||||
required this.countryName,
|
||||
required this.customerName,
|
||||
required this.serviceProviders,
|
||||
required this.offerCount,
|
||||
required this.id,
|
||||
required this.customerId,
|
||||
required this.customer,
|
||||
required this.brand,
|
||||
required this.model,
|
||||
required this.year,
|
||||
required this.isNew,
|
||||
required this.description,
|
||||
required this.requestImages,
|
||||
required this.cityId,
|
||||
required this.city,
|
||||
required this.price,
|
||||
required this.paymentStatus,
|
||||
required this.vehicleTypeId,
|
||||
required this.countryId,
|
||||
required this.requestProviderItem,
|
||||
required this.isActive,
|
||||
required this.createdBy,
|
||||
required this.createdOn,
|
||||
required this.modifiedBy,
|
||||
required this.modifiedOn,
|
||||
});
|
||||
|
||||
factory Request.fromJson(Map<String, dynamic> json) => Request(
|
||||
requestType: json["requestType"],
|
||||
requestTypeName: json["requestTypeName"],
|
||||
requestStatusName: json["requestStatusName"],
|
||||
requestStatus: (json['requestStatus'] as int).toRequestStatusEnum(),
|
||||
cityName: json["cityName"],
|
||||
vehicleTypeName: json["vehicleTypeName"],
|
||||
countryName: json["countryName"],
|
||||
customerName: json["customerName"],
|
||||
serviceProviders: json["serviceProviders"],
|
||||
offerCount: json["offerCount"],
|
||||
id: json["id"],
|
||||
customerId: json["customerID"],
|
||||
customer: json["customer"],
|
||||
brand: json["brand"],
|
||||
model: json["model"],
|
||||
year: json["year"],
|
||||
isNew: json["isNew"],
|
||||
description: json["description"],
|
||||
requestImages: List<dynamic>.from(json["requestImages"].map((x) => x)),
|
||||
cityId: json["cityID"],
|
||||
city: json["city"],
|
||||
price: json["price"],
|
||||
paymentStatus: json["paymentStatus"],
|
||||
vehicleTypeId: json["vehicleTypeID"],
|
||||
countryId: json["countryID"],
|
||||
requestProviderItem: List<dynamic>.from(json["requestProviderItem"].map((x) => x)),
|
||||
isActive: json["isActive"],
|
||||
createdBy: json["createdBy"],
|
||||
createdOn: DateTime.parse(json["createdOn"]),
|
||||
modifiedBy: json["modifiedBy"],
|
||||
modifiedOn: json["modifiedOn"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"requestType": requestType,
|
||||
"requestTypeName": requestTypeName,
|
||||
"requestStatusName": requestStatusName,
|
||||
"requestStatus": requestStatus,
|
||||
"cityName": cityName,
|
||||
"vehicleTypeName": vehicleTypeName,
|
||||
"countryName": countryName,
|
||||
"customerName": customerName,
|
||||
"serviceProviders": serviceProviders,
|
||||
"offerCount": offerCount,
|
||||
"id": id,
|
||||
"customerID": customerId,
|
||||
"customer": customer,
|
||||
"brand": brand,
|
||||
"model": model,
|
||||
"year": year,
|
||||
"isNew": isNew,
|
||||
"description": description,
|
||||
"requestImages": List<dynamic>.from(requestImages.map((x) => x)),
|
||||
"cityID": cityId,
|
||||
"city": city,
|
||||
"price": price,
|
||||
"paymentStatus": paymentStatus,
|
||||
"vehicleTypeID": vehicleTypeId,
|
||||
"countryID": countryId,
|
||||
"requestProviderItem": List<dynamic>.from(requestProviderItem.map((x) => x)),
|
||||
"isActive": isActive,
|
||||
"createdBy": createdBy,
|
||||
"createdOn": createdOn.toIso8601String(),
|
||||
"modifiedBy": modifiedBy,
|
||||
"modifiedOn": modifiedOn,
|
||||
};
|
||||
}
|
||||
@ -1,63 +1,69 @@
|
||||
import 'package:car_customer_app/view_models/requests_view_model.dart';
|
||||
import 'package:car_customer_app/views/requests/widget/request_item.dart';
|
||||
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/theme/colors.dart';
|
||||
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
|
||||
import 'package:mc_common_app/utils/enums.dart';
|
||||
import 'package:mc_common_app/utils/navigator.dart';
|
||||
import 'package:mc_common_app/widgets/common_widgets/categories_list.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../requests/widget/request_item.dart';
|
||||
|
||||
class RequestsFragment extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: MyColors.backgroundColor,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Consumer(builder: (BuildContext context, RequestsVM requestsVM, Widget? child) {
|
||||
return Column(
|
||||
children: [
|
||||
ShowFillButton(
|
||||
title: "title",
|
||||
onPressed: () {
|
||||
context.read<RequestsVM>().getRequests();
|
||||
}),
|
||||
16.height,
|
||||
FiltersList(
|
||||
filterList: requestsVM.requestsFilterOptions,
|
||||
onFilterTapped: (index, selectedFilterId) => requestsVM.applyFilterOnRequestsVM(index: index),
|
||||
),
|
||||
8.height,
|
||||
Expanded(
|
||||
child: requestsVM.isRequestLoading
|
||||
? Center(child: CircularProgressIndicator())
|
||||
: requestsVM.requests.length == 0
|
||||
? Center(
|
||||
child: "No Request Available".toText(
|
||||
isBold: true,
|
||||
),
|
||||
)
|
||||
: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return RequestItem(requestsVM.requests[index]);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return 16.height;
|
||||
},
|
||||
itemCount: requestsVM.requests.length,
|
||||
padding: EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
top: 8,
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
color: MyColors.backgroundColor,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
child: Consumer(builder: (BuildContext context, RequestsVM requestsVM, Widget? child) {
|
||||
return Column(
|
||||
children: [
|
||||
16.height,
|
||||
FiltersList(
|
||||
filterList: requestsVM.requestsTypeFilterOptions,
|
||||
onFilterTapped: (index, selectedFilterId) {
|
||||
requestsVM.applyFilterOnRequestsVM(requestsTypeEnum: selectedFilterId.toRequestTypeStatusEnum());
|
||||
},
|
||||
),
|
||||
8.height,
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async => await requestsVM.getMyRequests(isNeedToRebuild: true),
|
||||
child: requestsVM.state == ViewState.busy
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: requestsVM.myFilteredRequests.isEmpty
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
"No Requests to show.".toText(fontSize: 16, color: MyColors.lightTextColor),
|
||||
],
|
||||
)
|
||||
: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return RequestItem(request: requestsVM.myRequests[index]);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return 16.height;
|
||||
},
|
||||
itemCount: requestsVM.myRequests.length,
|
||||
padding: EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
))
|
||||
],
|
||||
);
|
||||
}),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => navigateWithName(context, AppRoutes.createRequestPage),
|
||||
backgroundColor: MyColors.darkPrimaryColor,
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MyColors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,84 +1,87 @@
|
||||
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/models/requests/offers_model.dart';
|
||||
import 'package:mc_common_app/theme/colors.dart';
|
||||
import 'package:mc_common_app/utils/navigator.dart';
|
||||
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
||||
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||
|
||||
class OfferListPage extends StatelessWidget {
|
||||
final List<OffersModel> offersList;
|
||||
|
||||
OfferListPage({required this.offersList});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: CustomAppBar(
|
||||
title: "Offers",
|
||||
),
|
||||
body: ListView.separated(
|
||||
itemBuilder: (context, index) {
|
||||
return showOfferItem();
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return 16.height;
|
||||
},
|
||||
itemCount: 2,
|
||||
padding: EdgeInsets.all(16),
|
||||
),
|
||||
);
|
||||
}
|
||||
appBar: CustomAppBar(title: "Offers"),
|
||||
body: offersList.isEmpty
|
||||
? Center(child: "No Requests to show.".toText(fontSize: 16, color: MyColors.lightTextColor))
|
||||
: ListView.separated(
|
||||
itemCount: offersList.length,
|
||||
padding: EdgeInsets.all(16),
|
||||
itemBuilder: (context, index) {
|
||||
OffersModel offersModel = offersList[index];
|
||||
return Stack(
|
||||
alignment: Alignment.bottomRight,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"${offersModel.serviceProvider!.companyName ?? ""}".toText(fontSize: 16, isBold: true),
|
||||
|
||||
Widget showOfferItem() {
|
||||
return Stack(
|
||||
alignment: Alignment.bottomRight,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"Toyota Corolla".toText(fontSize: 16, isBold: true),
|
||||
Center(
|
||||
child: "2".toText(
|
||||
color: Colors.white,
|
||||
isBold: true,
|
||||
fontSize: 10,
|
||||
),
|
||||
).toContainer(
|
||||
backgroundColor: MyColors.redColor,
|
||||
borderRadius: 100,
|
||||
paddingAll: 1,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child:
|
||||
"Dear, how you doing. I have great offer for You for this car. Dear, how you doing. I have great offer for You for this car. Dear, how you doing. I have great offer for You for this car. Dear, how you doing. I have great offer for You for this car. Dear, how you doing. I have great offer for You for this car."
|
||||
.toText(
|
||||
color: MyColors.lightTextColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
12.width,
|
||||
"9 Hours Ago".toText(
|
||||
color: MyColors.lightTextColor,
|
||||
)
|
||||
],
|
||||
//Un read offers count
|
||||
|
||||
// Center(
|
||||
// child: "2".toText(
|
||||
// color: Colors.white,
|
||||
// isBold: true,
|
||||
// fontSize: 10,
|
||||
// ),
|
||||
// ).toContainer(
|
||||
// backgroundColor: MyColors.redColor,
|
||||
// borderRadius: 100,
|
||||
// paddingAll: 1,
|
||||
// width: 20,
|
||||
// height: 20,
|
||||
// ),
|
||||
],
|
||||
),
|
||||
8.height,
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: "${offersModel.comment} and This is dummy text edition.".toText(
|
||||
color: MyColors.lightTextColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
12.width,
|
||||
"9 Hours Ago".toText(
|
||||
color: MyColors.lightTextColor,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_forward,
|
||||
color: MyColors.darkIconColor,
|
||||
size: 18,
|
||||
),
|
||||
],
|
||||
).onPress(() {
|
||||
navigateWithName(context, AppRoutes.chatView);
|
||||
}).toContainer(isShadowEnabled: true);
|
||||
},
|
||||
separatorBuilder: (context, index) => 16.height,
|
||||
),
|
||||
],
|
||||
),
|
||||
Icon(
|
||||
Icons.arrow_forward,
|
||||
color: MyColors.darkIconColor,
|
||||
size: 18,
|
||||
),
|
||||
],
|
||||
).toContainer(
|
||||
isShadowEnabled: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue