import 'dart:developer'; import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/utils/enums.dart'; class ChatMessageModel { int? id; String? senderUserID; String? receiverUserID; String? senderName; int? messageType; ChatMessageTypeEnum? chatMessageTypeEnum; String? chatText; int? requestID; int? reqOfferID; int? serviceProviderID; int? offerStatus; ReqOffer? reqOffer; bool? isRead; String? readOn; bool? isMyMessage; ChatMessageModel({ this.id, this.senderUserID, this.receiverUserID, this.senderName, this.messageType, this.chatMessageTypeEnum, this.chatText, this.requestID, this.reqOfferID, this.serviceProviderID, this.offerStatus, this.reqOffer, this.isRead, this.readOn, this.isMyMessage, }); @override String toString() { return 'ChatMessageModel{id: $id, senderUserID: $senderUserID, senderName: $senderName, messageType: $messageType, chatMessageTypeEnum: $chatMessageTypeEnum, chatText: $chatText, requestID: $requestID, reqOfferID: $reqOfferID, serviceProviderID: $serviceProviderID, offerStatus: $offerStatus, reqOffer: $reqOffer, isRead: $isRead, readOn: $readOn, isMyMessage: $isMyMessage}'; } ChatMessageModel.fromJson(Map json) { final myUserId = AppState().getUser.data!.userInfo!.userId.toString().toUpperCase(); id = json['id']; senderUserID = json['senderUserID']; receiverUserID = json['receiverUserID'] ?? ""; senderName = json['senderName']; messageType = json['messageType']; chatMessageTypeEnum = (json['messageType'] as int).toChatMessageTypeEnum(); chatText = json['chatText']; requestID = json['requestID']; reqOfferID = json['reqOfferID']; serviceProviderID = json['serviceProviderID']; offerStatus = json['offerStatus']; reqOffer = json['reqOffer'] != null ? ReqOffer.fromJson(json['reqOffer']) : null; isRead = json['isRead']; readOn = json['readOn']; isMyMessage = (json['senderUserID']).toString().toUpperCase() == myUserId; } } class ReqOffer { int? id; int? requestID; int? serviceProviderID; int? offerStatus; String? offerStatusText; String? comment; double? price; RequestOfferStatusEnum? requestOfferStatusEnum; ReqOffer({ this.id, this.requestID, this.serviceProviderID, this.offerStatus, this.offerStatusText, this.comment, this.price, this.requestOfferStatusEnum, }); ReqOffer.fromJson(Map json) { id = json['id']; requestID = json['requestID']; serviceProviderID = json['serviceProviderID']; offerStatus = json['offerStatus']; offerStatusText = json['offerStatusText']; comment = json['comment']; price = json['price']; requestOfferStatusEnum = ((json['offerStatus']) as int).toRequestOfferStatusEnum(); } } class OfferRequestCommentModel { int? index; String? title; bool? isSelected; OfferRequestCommentModel({this.index, this.title, this.isSelected}); }