models refinement
parent
08fd442a36
commit
76fd46c654
@ -1,44 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final account = accountFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:mc_common_app/models/parent_list.dart';
|
||||
|
||||
|
||||
|
||||
|
||||
Account accountFromJson(String str) => Account.fromJson(json.decode(str));
|
||||
|
||||
String accountToJson(Account data) => json.encode(data.toJson());
|
||||
|
||||
class Account {
|
||||
Account({
|
||||
required this.parentList,
|
||||
required this.selectedItem,
|
||||
});
|
||||
|
||||
List<ParentList>? parentList;
|
||||
int selectedItem;
|
||||
|
||||
factory Account.fromJson(Map<String, dynamic> json) => Account(
|
||||
parentList: json["parentList"] == null
|
||||
? null
|
||||
: List<ParentList>.from(
|
||||
json["parentList"].map((x) => ParentList.fromJson(x))),
|
||||
selectedItem:
|
||||
json["selectedItem"] == null ? null : json["selectedItem"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"parentList": parentList == null
|
||||
? null
|
||||
: List<dynamic>.from(parentList!.map((x) => x.toJson())),
|
||||
"selectedItem": selectedItem == null ? null : selectedItem,
|
||||
};
|
||||
|
||||
Map<String, dynamic> toJsonData() => {
|
||||
"selectedItem": selectedItem == null ? null : selectedItem,
|
||||
};
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||
import 'package:mc_common_app/models/services/service_model.dart';
|
||||
import 'package:mc_common_app/models/widgets_models.dart';
|
||||
import 'package:mc_common_app/models/general/widgets_models.dart';
|
||||
|
||||
class CustomTimeDateSlotModel {
|
||||
TimeSlotModel? date;
|
||||
@ -0,0 +1,49 @@
|
||||
class ChatMessageModel {
|
||||
String? senderUserID;
|
||||
String? senderName;
|
||||
int? messageType;
|
||||
String? message;
|
||||
RequestOffer? requestOffer;
|
||||
int? requestID;
|
||||
int? requestOfferID;
|
||||
|
||||
ChatMessageModel({this.senderUserID, this.senderName, this.messageType, this.message, this.requestOffer, this.requestID, this.requestOfferID});
|
||||
|
||||
ChatMessageModel.fromJson(Map<String, dynamic> json) {
|
||||
senderUserID = json['senderUserID'];
|
||||
senderName = json['senderName'];
|
||||
messageType = json['messageType'];
|
||||
message = json['message'];
|
||||
if (json['requestOffer'] != null) {
|
||||
requestOffer = RequestOffer.fromJson(json['requestOffer']);
|
||||
} else {
|
||||
requestOffer = null;
|
||||
}
|
||||
requestID = json['requestID'];
|
||||
requestOfferID = json['requestOfferID'];
|
||||
}
|
||||
}
|
||||
|
||||
class RequestOffer {
|
||||
int? id;
|
||||
int? requestID;
|
||||
int? serviceProviderID;
|
||||
int? offerStatus;
|
||||
String? comment;
|
||||
int? price;
|
||||
String? offeredItemCreatedBy;
|
||||
String? offeredItemCreatedOn;
|
||||
|
||||
RequestOffer({this.id, this.requestID, this.serviceProviderID, this.offerStatus, this.comment, this.price, this.offeredItemCreatedBy, this.offeredItemCreatedOn});
|
||||
|
||||
RequestOffer.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
requestID = json['requestID'];
|
||||
serviceProviderID = json['serviceProviderID'];
|
||||
offerStatus = json['offerStatus'];
|
||||
comment = json['comment'];
|
||||
price = json['price'];
|
||||
offeredItemCreatedBy = json['offeredItemCreatedBy'];
|
||||
offeredItemCreatedOn = json['offeredItemCreatedOn'];
|
||||
}
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
class ConfigModel {
|
||||
ConfigModel(this.endpoint, this.organizationName);
|
||||
|
||||
String endpoint;
|
||||
|
||||
String organizationName;
|
||||
|
||||
factory ConfigModel.fromJson(Map<String, dynamic> json) =>
|
||||
ConfigModel("", "");
|
||||
|
||||
// Map<String, dynamic> toJson() => _$ConfigModelToJson(this);
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
class ContentInfoModel {
|
||||
int? totalItemsCount;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<ContentInfoDataModel>? data;
|
||||
|
||||
ContentInfoModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
ContentInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(new ContentInfoDataModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ContentInfoDataModel {
|
||||
int? contentInfoId;
|
||||
int? contentTypeId;
|
||||
String? content;
|
||||
String? contentTypeNameEn;
|
||||
String? contentTypeNameAr;
|
||||
String? fileName;
|
||||
String? exposeFilePath;
|
||||
|
||||
ContentInfoDataModel({this.contentInfoId, this.contentTypeId, this.content, this.contentTypeNameEn, this.contentTypeNameAr, this.fileName, this.exposeFilePath});
|
||||
|
||||
ContentInfoDataModel.fromJson(Map<String, dynamic> json) {
|
||||
contentInfoId = json['contentInfoId'];
|
||||
contentTypeId = json['contentTypeId'];
|
||||
content = json['content'];
|
||||
contentTypeNameEn = json['contentTypeNameEn'];
|
||||
contentTypeNameAr = json['contentTypeNameAr'];
|
||||
fileName = json['fileName'];
|
||||
exposeFilePath = json['exposeFilePath'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['contentInfoId'] = this.contentInfoId;
|
||||
data['contentTypeId'] = this.contentTypeId;
|
||||
data['content'] = this.content;
|
||||
data['contentTypeNameEn'] = this.contentTypeNameEn;
|
||||
data['contentTypeNameAr'] = this.contentTypeNameAr;
|
||||
data['fileName'] = this.fileName;
|
||||
data['exposeFilePath'] = this.exposeFilePath;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
class MemberModel {
|
||||
int? totalItemsCount;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<MemberDataModel>? data;
|
||||
|
||||
MemberModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
MemberModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(new MemberDataModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class MemberDataModel {
|
||||
int? committeeId;
|
||||
String? firstName;
|
||||
String? lastName;
|
||||
String? description;
|
||||
String? picture;
|
||||
int? orderNo;
|
||||
|
||||
MemberDataModel({this.committeeId, this.firstName, this.lastName, this.description, this.picture, this.orderNo});
|
||||
|
||||
MemberDataModel.fromJson(Map<String, dynamic> json) {
|
||||
committeeId = json['committeeId'];
|
||||
firstName = json['firstName'];
|
||||
lastName = json['lastName'];
|
||||
description = json['description'];
|
||||
picture = json['picture'];
|
||||
orderNo = json['orderNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['committeeId'] = this.committeeId;
|
||||
data['firstName'] = this.firstName;
|
||||
data['lastName'] = this.lastName;
|
||||
data['description'] = this.description;
|
||||
data['picture'] = this.picture;
|
||||
data['orderNo'] = this.orderNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
class ParentList {
|
||||
ParentList({
|
||||
required this.dbId,
|
||||
required this.text,
|
||||
required this.path,
|
||||
required this.isSelected,
|
||||
});
|
||||
|
||||
int dbId;
|
||||
String text;
|
||||
String path;
|
||||
bool isSelected;
|
||||
|
||||
factory ParentList.fromJson(Map<String, dynamic> json) => ParentList(
|
||||
dbId: json["dbId"] == null ? null : json["dbId"],
|
||||
text: json["text"] == null ? null : json["text"],
|
||||
path: json["path"] == null ? null : json["path"],
|
||||
isSelected: false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"dbId": dbId == null ? null : dbId,
|
||||
"text": text == null ? null : text,
|
||||
"path": path == null ? null : path,
|
||||
};
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
///
|
||||
/// This example was taken from
|
||||
/// https://flutter.dev/docs/development/data-and-backend/json
|
||||
///
|
||||
|
||||
/// This allows the `User` class to access private members in
|
||||
/// the generated file. The value for this is *.g.dart, where
|
||||
/// the star denotes the source file name.
|
||||
|
||||
/// An annotation for the code generator to know that this class needs the
|
||||
/// JSON serialization logic to be generated.
|
||||
|
||||
class BackendResponse {
|
||||
BackendResponse({required this.id, required this.isOk, required this.result});
|
||||
|
||||
int id;
|
||||
bool isOk;
|
||||
dynamic result;
|
||||
|
||||
/// A necessary factory constructor for creating a new User instance
|
||||
/// from a map. Pass the map to the generated `_$UserFromJson()` constructor.
|
||||
/// The constructor is named after the source class, in this case, User.
|
||||
factory BackendResponse.fromJson(Map<String, dynamic> json) =>
|
||||
BackendResponse(
|
||||
id: 1,
|
||||
isOk: false,
|
||||
result: null,
|
||||
);
|
||||
//
|
||||
// /// `toJson` is the convention for a class to declare support for serialization
|
||||
// /// to JSON. The implementation simply calls the private, generated
|
||||
// /// helper method `_$UserToJson`.
|
||||
// Map<String, dynamic> toJson() => _$BackendResponseToJson(this);
|
||||
}
|
||||
@ -1,125 +0,0 @@
|
||||
// To parse this JSON data, do
|
||||
//
|
||||
// final subscription = subscriptionFromJson(jsonString);
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
Subscription subscriptionFromJson(String str) => Subscription.fromJson(json.decode(str));
|
||||
|
||||
String subscriptionToJson(Subscription data) => json.encode(data.toJson());
|
||||
|
||||
class SubscriptionModel {
|
||||
SubscriptionModel({
|
||||
this.messageStatus,
|
||||
this.totalItemsCount,
|
||||
this.data,
|
||||
this.message,
|
||||
});
|
||||
|
||||
int? messageStatus;
|
||||
int? totalItemsCount;
|
||||
List<Subscription>? data;
|
||||
String? message;
|
||||
|
||||
factory SubscriptionModel.fromJson(Map<String, dynamic> json) => SubscriptionModel(
|
||||
messageStatus: json["messageStatus"],
|
||||
totalItemsCount: json["totalItemsCount"],
|
||||
data: json["data"] == null ? [] : List<Subscription>.from(json["data"]!.map((x) => Subscription.fromJson(x))),
|
||||
message: json["message"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"messageStatus": messageStatus,
|
||||
"totalItemsCount": totalItemsCount,
|
||||
"data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
"message": message,
|
||||
};
|
||||
}
|
||||
|
||||
class Subscription {
|
||||
Subscription({
|
||||
this.id,
|
||||
this.name,
|
||||
this.description,
|
||||
this.durationName,
|
||||
this.durationDays,
|
||||
this.price,
|
||||
this.currency,
|
||||
this.numberOfBranches,
|
||||
this.numberOfSubUsers,
|
||||
this.numberOfAds,
|
||||
this.countryId,
|
||||
this.countryName,
|
||||
this.isSubscribed,
|
||||
this.subscriptionAppliedId,
|
||||
this.serviceProviderId,
|
||||
this.dateStart,
|
||||
this.dateEnd,
|
||||
this.isExpired,
|
||||
this.isActive,
|
||||
});
|
||||
|
||||
int? id;
|
||||
String? name;
|
||||
String? description;
|
||||
String? durationName;
|
||||
int? durationDays;
|
||||
double? price;
|
||||
String? currency;
|
||||
int? numberOfBranches;
|
||||
int? numberOfSubUsers;
|
||||
int? numberOfAds;
|
||||
int? countryId;
|
||||
String? countryName;
|
||||
bool? isSubscribed;
|
||||
int? subscriptionAppliedId;
|
||||
int? serviceProviderId;
|
||||
DateTime? dateStart;
|
||||
DateTime? dateEnd;
|
||||
bool? isExpired;
|
||||
bool? isActive;
|
||||
|
||||
factory Subscription.fromJson(Map<String, dynamic> json) => Subscription(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
description: json["description"],
|
||||
durationName: json["durationName"],
|
||||
durationDays: json["durationDays"],
|
||||
price: json["price"]?.toDouble(),
|
||||
currency: json["currency"],
|
||||
numberOfBranches: json["numberOfBranches"],
|
||||
numberOfSubUsers: json["numberOfSubUsers"],
|
||||
numberOfAds: json["numberOfAds"],
|
||||
countryId: json["countryID"],
|
||||
countryName: json["countryName"]!,
|
||||
isSubscribed: json["isSubscribed"],
|
||||
subscriptionAppliedId: json["subscriptionAppliedID"],
|
||||
serviceProviderId: json["serviceProviderID"],
|
||||
dateStart: json["dateStart"] == null ? null : DateTime.parse(json["dateStart"]),
|
||||
dateEnd: json["dateEnd"] == null ? null : DateTime.parse(json["dateEnd"]),
|
||||
isExpired: json["isExpired"],
|
||||
isActive: json["isActive"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"description": description,
|
||||
"durationName": durationName,
|
||||
"durationDays": durationDays,
|
||||
"price": price,
|
||||
"currency": currency,
|
||||
"numberOfBranches": numberOfBranches,
|
||||
"numberOfSubUsers": numberOfSubUsers,
|
||||
"numberOfAds": numberOfAds,
|
||||
"countryID": countryId,
|
||||
"countryName": countryName,
|
||||
"isSubscribed": isSubscribed,
|
||||
"subscriptionAppliedID": subscriptionAppliedId,
|
||||
"serviceProviderID": serviceProviderId,
|
||||
"dateStart": dateStart?.toIso8601String(),
|
||||
"dateEnd": dateEnd?.toIso8601String(),
|
||||
"isExpired": isExpired,
|
||||
"isActive": isActive,
|
||||
};
|
||||
}
|
||||
@ -1,74 +0,0 @@
|
||||
class SurahModel {
|
||||
int? totalItemsCount;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<SurahModelData>? data;
|
||||
|
||||
SurahModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
SurahModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = [];
|
||||
json['data'].forEach((v) {
|
||||
data?.add(SurahModelData.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = totalItemsCount;
|
||||
data['statusCode'] = statusCode;
|
||||
data['message'] = message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class SurahModelData {
|
||||
int? id;
|
||||
int? surahID;
|
||||
String? nameAR;
|
||||
String? nameEN;
|
||||
int? numberOfAyahs;
|
||||
String? englishNameTranslation;
|
||||
int? revelationID;
|
||||
String? revelationType;
|
||||
int? startPageNo;
|
||||
int? endPageNo;
|
||||
|
||||
SurahModelData({this.id, this.surahID, this.nameAR, this.nameEN, this.numberOfAyahs, this.englishNameTranslation, this.revelationID, this.revelationType, this.startPageNo, this.endPageNo});
|
||||
|
||||
SurahModelData.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
surahID = json['surahID'];
|
||||
nameAR = json['nameAR'];
|
||||
nameEN = json['nameEN'];
|
||||
numberOfAyahs = json['numberOfAyahs'];
|
||||
englishNameTranslation = json['englishNameTranslation'];
|
||||
revelationID = json['revelation_ID'];
|
||||
revelationType = json['revelationType'];
|
||||
startPageNo = json['startPageNo'];
|
||||
endPageNo = json['endPageNo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['surahID'] = this.surahID;
|
||||
data['nameAR'] = this.nameAR;
|
||||
data['nameEN'] = this.nameEN;
|
||||
data['numberOfAyahs'] = this.numberOfAyahs;
|
||||
data['englishNameTranslation'] = this.englishNameTranslation;
|
||||
data['revelation_ID'] = this.revelationID;
|
||||
data['revelationType'] = this.revelationType;
|
||||
data['startPageNo'] = this.startPageNo;
|
||||
data['endPageNo'] = this.endPageNo;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
// // To parse this JSON data, do
|
||||
// //
|
||||
// // final account = accountFromJson(jsonString);
|
||||
//
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// import 'package:mc_common_app/models/parent_list.dart';
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// Account accountFromJson(String str) => Account.fromJson(json.decode(str));
|
||||
//
|
||||
// String accountToJson(Account data) => json.encode(data.toJson());
|
||||
//
|
||||
// class Account {
|
||||
// Account({
|
||||
// required this.parentList,
|
||||
// required this.selectedItem,
|
||||
// });
|
||||
//
|
||||
// List<ParentList>? parentList;
|
||||
// int selectedItem;
|
||||
//
|
||||
// factory Account.fromJson(Map<String, dynamic> json) => Account(
|
||||
// parentList: json["parentList"] == null
|
||||
// ? null
|
||||
// : List<ParentList>.from(
|
||||
// json["parentList"].map((x) => ParentList.fromJson(x))),
|
||||
// selectedItem:
|
||||
// json["selectedItem"] == null ? null : json["selectedItem"],
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() => {
|
||||
// "parentList": parentList == null
|
||||
// ? null
|
||||
// : List<dynamic>.from(parentList!.map((x) => x.toJson())),
|
||||
// "selectedItem": selectedItem == null ? null : selectedItem,
|
||||
// };
|
||||
//
|
||||
// Map<String, dynamic> toJsonData() => {
|
||||
// "selectedItem": selectedItem == null ? null : selectedItem,
|
||||
// };
|
||||
// }
|
||||
@ -0,0 +1,12 @@
|
||||
// class ConfigModel {
|
||||
// ConfigModel(this.endpoint, this.organizationName);
|
||||
//
|
||||
// String endpoint;
|
||||
//
|
||||
// String organizationName;
|
||||
//
|
||||
// factory ConfigModel.fromJson(Map<String, dynamic> json) =>
|
||||
// ConfigModel("", "");
|
||||
//
|
||||
// // Map<String, dynamic> toJson() => _$ConfigModelToJson(this);
|
||||
// }
|
||||
@ -0,0 +1,65 @@
|
||||
// class ContentInfoModel {
|
||||
// int? totalItemsCount;
|
||||
// int? statusCode;
|
||||
// String? message;
|
||||
// List<ContentInfoDataModel>? data;
|
||||
//
|
||||
// ContentInfoModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
//
|
||||
// ContentInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
// totalItemsCount = json['totalItemsCount'];
|
||||
// statusCode = json['statusCode'];
|
||||
// message = json['message'];
|
||||
// if (json['data'] != null) {
|
||||
// data = [];
|
||||
// json['data'].forEach((v) {
|
||||
// data?.add(new ContentInfoDataModel.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['totalItemsCount'] = this.totalItemsCount;
|
||||
// data['statusCode'] = this.statusCode;
|
||||
// data['message'] = this.message;
|
||||
// if (this.data != null) {
|
||||
// data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class ContentInfoDataModel {
|
||||
// int? contentInfoId;
|
||||
// int? contentTypeId;
|
||||
// String? content;
|
||||
// String? contentTypeNameEn;
|
||||
// String? contentTypeNameAr;
|
||||
// String? fileName;
|
||||
// String? exposeFilePath;
|
||||
//
|
||||
// ContentInfoDataModel({this.contentInfoId, this.contentTypeId, this.content, this.contentTypeNameEn, this.contentTypeNameAr, this.fileName, this.exposeFilePath});
|
||||
//
|
||||
// ContentInfoDataModel.fromJson(Map<String, dynamic> json) {
|
||||
// contentInfoId = json['contentInfoId'];
|
||||
// contentTypeId = json['contentTypeId'];
|
||||
// content = json['content'];
|
||||
// contentTypeNameEn = json['contentTypeNameEn'];
|
||||
// contentTypeNameAr = json['contentTypeNameAr'];
|
||||
// fileName = json['fileName'];
|
||||
// exposeFilePath = json['exposeFilePath'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['contentInfoId'] = this.contentInfoId;
|
||||
// data['contentTypeId'] = this.contentTypeId;
|
||||
// data['content'] = this.content;
|
||||
// data['contentTypeNameEn'] = this.contentTypeNameEn;
|
||||
// data['contentTypeNameAr'] = this.contentTypeNameAr;
|
||||
// data['fileName'] = this.fileName;
|
||||
// data['exposeFilePath'] = this.exposeFilePath;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
@ -0,0 +1,62 @@
|
||||
// class MemberModel {
|
||||
// int? totalItemsCount;
|
||||
// int? statusCode;
|
||||
// String? message;
|
||||
// List<MemberDataModel>? data;
|
||||
//
|
||||
// MemberModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
//
|
||||
// MemberModel.fromJson(Map<String, dynamic> json) {
|
||||
// totalItemsCount = json['totalItemsCount'];
|
||||
// statusCode = json['statusCode'];
|
||||
// message = json['message'];
|
||||
// if (json['data'] != null) {
|
||||
// data = [];
|
||||
// json['data'].forEach((v) {
|
||||
// data?.add(new MemberDataModel.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['totalItemsCount'] = this.totalItemsCount;
|
||||
// data['statusCode'] = this.statusCode;
|
||||
// data['message'] = this.message;
|
||||
// if (this.data != null) {
|
||||
// data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class MemberDataModel {
|
||||
// int? committeeId;
|
||||
// String? firstName;
|
||||
// String? lastName;
|
||||
// String? description;
|
||||
// String? picture;
|
||||
// int? orderNo;
|
||||
//
|
||||
// MemberDataModel({this.committeeId, this.firstName, this.lastName, this.description, this.picture, this.orderNo});
|
||||
//
|
||||
// MemberDataModel.fromJson(Map<String, dynamic> json) {
|
||||
// committeeId = json['committeeId'];
|
||||
// firstName = json['firstName'];
|
||||
// lastName = json['lastName'];
|
||||
// description = json['description'];
|
||||
// picture = json['picture'];
|
||||
// orderNo = json['orderNo'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['committeeId'] = this.committeeId;
|
||||
// data['firstName'] = this.firstName;
|
||||
// data['lastName'] = this.lastName;
|
||||
// data['description'] = this.description;
|
||||
// data['picture'] = this.picture;
|
||||
// data['orderNo'] = this.orderNo;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
@ -0,0 +1,26 @@
|
||||
// class ParentList {
|
||||
// ParentList({
|
||||
// required this.dbId,
|
||||
// required this.text,
|
||||
// required this.path,
|
||||
// required this.isSelected,
|
||||
// });
|
||||
//
|
||||
// int dbId;
|
||||
// String text;
|
||||
// String path;
|
||||
// bool isSelected;
|
||||
//
|
||||
// factory ParentList.fromJson(Map<String, dynamic> json) => ParentList(
|
||||
// dbId: json["dbId"] == null ? null : json["dbId"],
|
||||
// text: json["text"] == null ? null : json["text"],
|
||||
// path: json["path"] == null ? null : json["path"],
|
||||
// isSelected: false,
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() => {
|
||||
// "dbId": dbId == null ? null : dbId,
|
||||
// "text": text == null ? null : text,
|
||||
// "path": path == null ? null : path,
|
||||
// };
|
||||
// }
|
||||
@ -0,0 +1,34 @@
|
||||
// ///
|
||||
// /// This example was taken from
|
||||
// /// https://flutter.dev/docs/development/data-and-backend/json
|
||||
// ///
|
||||
//
|
||||
// /// This allows the `User` class to access private members in
|
||||
// /// the generated file. The value for this is *.g.dart, where
|
||||
// /// the star denotes the source file name.
|
||||
//
|
||||
// /// An annotation for the code generator to know that this class needs the
|
||||
// /// JSON serialization logic to be generated.
|
||||
//
|
||||
// class BackendResponse {
|
||||
// BackendResponse({required this.id, required this.isOk, required this.result});
|
||||
//
|
||||
// int id;
|
||||
// bool isOk;
|
||||
// dynamic result;
|
||||
//
|
||||
// /// A necessary factory constructor for creating a new User instance
|
||||
// /// from a map. Pass the map to the generated `_$UserFromJson()` constructor.
|
||||
// /// The constructor is named after the source class, in this case, User.
|
||||
// factory BackendResponse.fromJson(Map<String, dynamic> json) =>
|
||||
// BackendResponse(
|
||||
// id: 1,
|
||||
// isOk: false,
|
||||
// result: null,
|
||||
// );
|
||||
// //
|
||||
// // /// `toJson` is the convention for a class to declare support for serialization
|
||||
// // /// to JSON. The implementation simply calls the private, generated
|
||||
// // /// helper method `_$UserToJson`.
|
||||
// // Map<String, dynamic> toJson() => _$BackendResponseToJson(this);
|
||||
// }
|
||||
@ -0,0 +1,125 @@
|
||||
// // To parse this JSON data, do
|
||||
// //
|
||||
// // final subscription = subscriptionFromJson(jsonString);
|
||||
//
|
||||
// import 'dart:convert';
|
||||
//
|
||||
// Subscription subscriptionFromJson(String str) => Subscription.fromJson(json.decode(str));
|
||||
//
|
||||
// String subscriptionToJson(Subscription data) => json.encode(data.toJson());
|
||||
//
|
||||
// class SubscriptionModel {
|
||||
// SubscriptionModel({
|
||||
// this.messageStatus,
|
||||
// this.totalItemsCount,
|
||||
// this.data,
|
||||
// this.message,
|
||||
// });
|
||||
//
|
||||
// int? messageStatus;
|
||||
// int? totalItemsCount;
|
||||
// List<Subscription>? data;
|
||||
// String? message;
|
||||
//
|
||||
// factory SubscriptionModel.fromJson(Map<String, dynamic> json) => SubscriptionModel(
|
||||
// messageStatus: json["messageStatus"],
|
||||
// totalItemsCount: json["totalItemsCount"],
|
||||
// data: json["data"] == null ? [] : List<Subscription>.from(json["data"]!.map((x) => Subscription.fromJson(x))),
|
||||
// message: json["message"],
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() => {
|
||||
// "messageStatus": messageStatus,
|
||||
// "totalItemsCount": totalItemsCount,
|
||||
// "data": data == null ? [] : List<dynamic>.from(data!.map((x) => x.toJson())),
|
||||
// "message": message,
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// class Subscription {
|
||||
// Subscription({
|
||||
// this.id,
|
||||
// this.name,
|
||||
// this.description,
|
||||
// this.durationName,
|
||||
// this.durationDays,
|
||||
// this.price,
|
||||
// this.currency,
|
||||
// this.numberOfBranches,
|
||||
// this.numberOfSubUsers,
|
||||
// this.numberOfAds,
|
||||
// this.countryId,
|
||||
// this.countryName,
|
||||
// this.isSubscribed,
|
||||
// this.subscriptionAppliedId,
|
||||
// this.serviceProviderId,
|
||||
// this.dateStart,
|
||||
// this.dateEnd,
|
||||
// this.isExpired,
|
||||
// this.isActive,
|
||||
// });
|
||||
//
|
||||
// int? id;
|
||||
// String? name;
|
||||
// String? description;
|
||||
// String? durationName;
|
||||
// int? durationDays;
|
||||
// double? price;
|
||||
// String? currency;
|
||||
// int? numberOfBranches;
|
||||
// int? numberOfSubUsers;
|
||||
// int? numberOfAds;
|
||||
// int? countryId;
|
||||
// String? countryName;
|
||||
// bool? isSubscribed;
|
||||
// int? subscriptionAppliedId;
|
||||
// int? serviceProviderId;
|
||||
// DateTime? dateStart;
|
||||
// DateTime? dateEnd;
|
||||
// bool? isExpired;
|
||||
// bool? isActive;
|
||||
//
|
||||
// factory Subscription.fromJson(Map<String, dynamic> json) => Subscription(
|
||||
// id: json["id"],
|
||||
// name: json["name"],
|
||||
// description: json["description"],
|
||||
// durationName: json["durationName"],
|
||||
// durationDays: json["durationDays"],
|
||||
// price: json["price"]?.toDouble(),
|
||||
// currency: json["currency"],
|
||||
// numberOfBranches: json["numberOfBranches"],
|
||||
// numberOfSubUsers: json["numberOfSubUsers"],
|
||||
// numberOfAds: json["numberOfAds"],
|
||||
// countryId: json["countryID"],
|
||||
// countryName: json["countryName"]!,
|
||||
// isSubscribed: json["isSubscribed"],
|
||||
// subscriptionAppliedId: json["subscriptionAppliedID"],
|
||||
// serviceProviderId: json["serviceProviderID"],
|
||||
// dateStart: json["dateStart"] == null ? null : DateTime.parse(json["dateStart"]),
|
||||
// dateEnd: json["dateEnd"] == null ? null : DateTime.parse(json["dateEnd"]),
|
||||
// isExpired: json["isExpired"],
|
||||
// isActive: json["isActive"],
|
||||
// );
|
||||
//
|
||||
// Map<String, dynamic> toJson() => {
|
||||
// "id": id,
|
||||
// "name": name,
|
||||
// "description": description,
|
||||
// "durationName": durationName,
|
||||
// "durationDays": durationDays,
|
||||
// "price": price,
|
||||
// "currency": currency,
|
||||
// "numberOfBranches": numberOfBranches,
|
||||
// "numberOfSubUsers": numberOfSubUsers,
|
||||
// "numberOfAds": numberOfAds,
|
||||
// "countryID": countryId,
|
||||
// "countryName": countryName,
|
||||
// "isSubscribed": isSubscribed,
|
||||
// "subscriptionAppliedID": subscriptionAppliedId,
|
||||
// "serviceProviderID": serviceProviderId,
|
||||
// "dateStart": dateStart?.toIso8601String(),
|
||||
// "dateEnd": dateEnd?.toIso8601String(),
|
||||
// "isExpired": isExpired,
|
||||
// "isActive": isActive,
|
||||
// };
|
||||
// }
|
||||
@ -0,0 +1,74 @@
|
||||
// class SurahModel {
|
||||
// int? totalItemsCount;
|
||||
// int? statusCode;
|
||||
// String? message;
|
||||
// List<SurahModelData>? data;
|
||||
//
|
||||
// SurahModel({this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
//
|
||||
// SurahModel.fromJson(Map<String, dynamic> json) {
|
||||
// totalItemsCount = json['totalItemsCount'];
|
||||
// statusCode = json['statusCode'];
|
||||
// message = json['message'];
|
||||
// if (json['data'] != null) {
|
||||
// data = [];
|
||||
// json['data'].forEach((v) {
|
||||
// data?.add(SurahModelData.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['totalItemsCount'] = totalItemsCount;
|
||||
// data['statusCode'] = statusCode;
|
||||
// data['message'] = message;
|
||||
// if (this.data != null) {
|
||||
// data['data'] = this.data?.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class SurahModelData {
|
||||
// int? id;
|
||||
// int? surahID;
|
||||
// String? nameAR;
|
||||
// String? nameEN;
|
||||
// int? numberOfAyahs;
|
||||
// String? englishNameTranslation;
|
||||
// int? revelationID;
|
||||
// String? revelationType;
|
||||
// int? startPageNo;
|
||||
// int? endPageNo;
|
||||
//
|
||||
// SurahModelData({this.id, this.surahID, this.nameAR, this.nameEN, this.numberOfAyahs, this.englishNameTranslation, this.revelationID, this.revelationType, this.startPageNo, this.endPageNo});
|
||||
//
|
||||
// SurahModelData.fromJson(Map<String, dynamic> json) {
|
||||
// id = json['id'];
|
||||
// surahID = json['surahID'];
|
||||
// nameAR = json['nameAR'];
|
||||
// nameEN = json['nameEN'];
|
||||
// numberOfAyahs = json['numberOfAyahs'];
|
||||
// englishNameTranslation = json['englishNameTranslation'];
|
||||
// revelationID = json['revelation_ID'];
|
||||
// revelationType = json['revelationType'];
|
||||
// startPageNo = json['startPageNo'];
|
||||
// endPageNo = json['endPageNo'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
// data['id'] = this.id;
|
||||
// data['surahID'] = this.surahID;
|
||||
// data['nameAR'] = this.nameAR;
|
||||
// data['nameEN'] = this.nameEN;
|
||||
// data['numberOfAyahs'] = this.numberOfAyahs;
|
||||
// data['englishNameTranslation'] = this.englishNameTranslation;
|
||||
// data['revelation_ID'] = this.revelationID;
|
||||
// data['revelationType'] = this.revelationType;
|
||||
// data['startPageNo'] = this.startPageNo;
|
||||
// data['endPageNo'] = this.endPageNo;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
@ -1,60 +1,32 @@
|
||||
import 'dart:io';
|
||||
import 'package:http/io_client.dart';
|
||||
import 'package:mc_common_app/classes/app_state.dart';
|
||||
import 'package:mc_common_app/classes/consts.dart';
|
||||
import 'package:mc_common_app/main.dart';
|
||||
import 'package:mc_common_app/utils/utils.dart';
|
||||
import 'package:signalr_netcore/http_connection_options.dart';
|
||||
import 'package:signalr_netcore/hub_connection.dart';
|
||||
import 'package:signalr_netcore/hub_connection_builder.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:signalr_core/signalr_core.dart';
|
||||
|
||||
abstract class ChatRepo {
|
||||
Future<HubConnection?> buildChatHubConnection();
|
||||
Future<HubConnection> getHubConnection();
|
||||
}
|
||||
|
||||
class ChatRepoImp implements ChatRepo {
|
||||
@override
|
||||
Future<HubConnection?> buildChatHubConnection() async {
|
||||
Future<HubConnection> getHubConnection() async {
|
||||
final userId = AppState().getUser.data!.userInfo!.userId ?? "";
|
||||
HttpConnectionOptions httpOptions = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
|
||||
HubConnection hubConnection = HubConnectionBuilder()
|
||||
final hubUrl = "https://ms.hmg.com/McHub?userID=$userId";
|
||||
logger.i("Connecting with Hub ($hubUrl)");
|
||||
|
||||
HubConnection hub;
|
||||
hub = HubConnectionBuilder()
|
||||
.withUrl(
|
||||
"${ApiConsts.chatHubUrl}?userID=$userId",
|
||||
options: httpOptions,
|
||||
)
|
||||
.withAutomaticReconnect(
|
||||
retryDelays: <int>[2000, 5000, 10000, 20000],
|
||||
)
|
||||
.configureLogging(
|
||||
Logger("configureLogging"),
|
||||
)
|
||||
hubUrl,
|
||||
HttpConnectionOptions(
|
||||
client: IOClient(HttpClient()
|
||||
..badCertificateCallback = (x, y, z) => true),
|
||||
logging: (level, message) {
|
||||
print(message);
|
||||
},
|
||||
))
|
||||
.build();
|
||||
hubConnection.onclose(
|
||||
({Exception? error}) {
|
||||
logger.i("onClose");
|
||||
},
|
||||
);
|
||||
hubConnection.onreconnecting(
|
||||
({Exception? error}) {
|
||||
logger.i("onReconnecting");
|
||||
},
|
||||
);
|
||||
hubConnection.onreconnected(
|
||||
({String? connectionId}) {
|
||||
logger.i("onReconnected");
|
||||
},
|
||||
);
|
||||
if (hubConnection.state != HubConnectionState.Connected) {
|
||||
await hubConnection.start();
|
||||
logger.i("Started HubConnection");
|
||||
|
||||
try {
|
||||
hubConnection.on("ReceiveMessageRequestOffer", (List<Object?>? arguments) {
|
||||
Utils.showToast("I received ping : ${arguments.toString()}");
|
||||
});
|
||||
} catch (e) {
|
||||
logger.i("Error in OnSendQuestionToParticipant");
|
||||
}
|
||||
}
|
||||
return hubConnection;
|
||||
return hub;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,39 +1,68 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:mc_common_app/classes/app_state.dart';
|
||||
import 'package:mc_common_app/extensions/string_extensions.dart';
|
||||
import 'package:mc_common_app/main.dart';
|
||||
import 'package:mc_common_app/repositories/chat_repo.dart';
|
||||
import 'package:mc_common_app/utils/enums.dart';
|
||||
import 'package:mc_common_app/utils/utils.dart';
|
||||
import 'package:signalr_netcore/hub_connection.dart';
|
||||
import 'package:signalr_core/signalr_core.dart';
|
||||
|
||||
class ChatVM extends ChangeNotifier {
|
||||
class ChatVM extends ChangeNotifier {
|
||||
final ChatRepo chatRepo;
|
||||
|
||||
ChatVM({required this.chatRepo});
|
||||
|
||||
HubConnection? hubConnection;
|
||||
late HubConnection hubConnection;
|
||||
|
||||
Future<void> buildHubConnection() async {
|
||||
hubConnection = await chatRepo.buildChatHubConnection();
|
||||
// if (hubConnection.state != HubConnectionState.Connected) {
|
||||
try {
|
||||
hubConnection = await chatRepo.getHubConnection();
|
||||
await hubConnection.start();
|
||||
hubConnection.on("ReceiveMessageRequestOffer", (List<Object?>? arguments) {
|
||||
print("this is the offer: ${arguments.toString()}");
|
||||
Utils.showToast("I received ping : ${arguments.toString()}");
|
||||
});
|
||||
} catch (e) {
|
||||
logger.i("Error: ${e.toString()}");
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> onSendMessageForRequestOffer() async {
|
||||
if (hubConnection == null || hubConnection!.state != HubConnectionState.Connected) {
|
||||
Future<bool> onSendMessageForRequestOffer(
|
||||
{required String receiverId, required ChatMessageTypeEnum chatMessageType, required String message, required int requestId, required String offerPrice}) async {
|
||||
if (hubConnection.state != HubConnectionState.connected) {
|
||||
await buildHubConnection();
|
||||
}
|
||||
if (hubConnection != null) {
|
||||
hubConnection!.invoke(
|
||||
if (hubConnection.state == HubConnectionState.connected) {
|
||||
final providerId = AppState().getUser.data!.userInfo!.providerId;
|
||||
print("providerId: $providerId");
|
||||
hubConnection.invoke(
|
||||
"SendMessageRequestOffer",
|
||||
args: <Object>[
|
||||
// <String, dynamic>{
|
||||
// "employeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER ?? "",
|
||||
// "employeeName": AppState().memberInformationList!.eMPLOYEENAME ?? "",
|
||||
// "marathonId": AppState().getMarathonProjectId,
|
||||
// "prizeId": "8577B2E8-5DD7-43F0-10DD-08DACB0AC064",
|
||||
// }
|
||||
<String, dynamic>{
|
||||
"ReceiverUserID": receiverId,
|
||||
"MessageType": chatMessageType.getIdFromChatMessageTypeEnum(),
|
||||
"Message": message,
|
||||
"RequestID": requestId,
|
||||
"RequestOfferID": 0,
|
||||
"RequestOffer": <String, dynamic>{
|
||||
"RequestID": requestId,
|
||||
"Price": double.parse(offerPrice),
|
||||
"ServiceProviderID": providerId,
|
||||
"OfferStatus": RequestOfferStatusEnum.offer.getIdFromRequestOfferStatusEnum(),
|
||||
"Comment": message,
|
||||
},
|
||||
}
|
||||
],
|
||||
).catchError((e) {
|
||||
logger.i("error in invoking SendMessageRequestOffer: ${e.toString()}");
|
||||
Utils.showToast(e.toString());
|
||||
return null;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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: const 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: const 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 }
|
||||
Loading…
Reference in New Issue