Merge branch 'master' of https://gitlab.com/Cloud_Solution/mohemm-flutter-app into sultan-dev
# Conflicts: # assets/langs/ar-SA.json # assets/langs/en-US.json # lib/app_state/app_state.dart # lib/generated/locale_keys.g.dartmohemm_HMG_flutter_upgrade
commit
fd6058e87d
@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"agcgw_all":{
|
||||||
|
"CN":"connect-drcn.dbankcloud.cn",
|
||||||
|
"CN_back":"connect-drcn.hispace.hicloud.com",
|
||||||
|
"DE":"connect-dre.dbankcloud.cn",
|
||||||
|
"DE_back":"connect-dre.hispace.hicloud.com",
|
||||||
|
"RU":"connect-drru.hispace.dbankcloud.ru",
|
||||||
|
"RU_back":"connect-drru.hispace.dbankcloud.cn",
|
||||||
|
"SG":"connect-dra.dbankcloud.cn",
|
||||||
|
"SG_back":"connect-dra.hispace.hicloud.com"
|
||||||
|
},
|
||||||
|
"websocketgw_all":{
|
||||||
|
"CN":"connect-ws-drcn.hispace.dbankcloud.cn",
|
||||||
|
"CN_back":"connect-ws-drcn.hispace.dbankcloud.com",
|
||||||
|
"DE":"connect-ws-dre.hispace.dbankcloud.cn",
|
||||||
|
"DE_back":"connect-ws-dre.hispace.dbankcloud.com",
|
||||||
|
"RU":"connect-ws-drru.hispace.dbankcloud.ru",
|
||||||
|
"RU_back":"connect-ws-drru.hispace.dbankcloud.cn",
|
||||||
|
"SG":"connect-ws-dra.hispace.dbankcloud.cn",
|
||||||
|
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
|
||||||
|
},
|
||||||
|
"client":{
|
||||||
|
"cp_id":"2640966000002322881",
|
||||||
|
"product_id":"737518067793559971",
|
||||||
|
"client_id":"715996003571874624",
|
||||||
|
"client_secret":"B5B89A56A53847C6BB9D216A8747E75952760DF9A8232239D8744CD847A8FFDA",
|
||||||
|
"project_id":"737518067793559971",
|
||||||
|
"app_id":"104737117",
|
||||||
|
"api_key":"DAEDACKDrYgyco9mjPV9ZUjCSh1kCr/GBV0nseHH0z2mnxlZ41RksOKmyTi+PUTwmGEPK+VxCup4F9oUf4VbDnCsjB7aNBShYcjR+g==",
|
||||||
|
"package_name":"hmg.cloudSolutions.mohem"
|
||||||
|
},
|
||||||
|
"oauth_client":{
|
||||||
|
"client_id":"104737117",
|
||||||
|
"client_type":1
|
||||||
|
},
|
||||||
|
"app_info":{
|
||||||
|
"app_id":"104737117",
|
||||||
|
"package_name":"hmg.cloudSolutions.mohem"
|
||||||
|
},
|
||||||
|
"configuration_version":"3.0",
|
||||||
|
"appInfos":[
|
||||||
|
{
|
||||||
|
"package_name":"hmg.cloudSolutions.mohem",
|
||||||
|
"client":{
|
||||||
|
"app_id":"104737117"
|
||||||
|
},
|
||||||
|
"app_info":{
|
||||||
|
"package_name":"hmg.cloudSolutions.mohem",
|
||||||
|
"app_id":"104737117"
|
||||||
|
},
|
||||||
|
"oauth_client":{
|
||||||
|
"client_type":1,
|
||||||
|
"client_id":"104737117"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||||
|
<path id="delete_1_" data-name="delete (1)" d="M13.657,2.343A8,8,0,0,0,2.343,13.657,8,8,0,0,0,13.657,2.343Zm-2.2,8.012a.781.781,0,1,1-1.1,1.1L8,9.1,5.645,11.46a.781.781,0,0,1-1.1-1.1L6.9,8,4.54,5.645a.781.781,0,0,1,1.1-1.1L8,6.9,10.355,4.54a.781.781,0,0,1,1.1,1.1L9.1,8Zm0,0" fill="#ca3332"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 386 B |
File diff suppressed because one or more lines are too long
@ -0,0 +1,21 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:just_audio/just_audio.dart';
|
||||||
|
|
||||||
|
class MyCustomStream extends StreamAudioSource {
|
||||||
|
final Uint8List bytes;
|
||||||
|
|
||||||
|
MyCustomStream(this.bytes);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<StreamAudioResponse> request([int? start, int? end]) async {
|
||||||
|
start ??= 0;
|
||||||
|
end ??= bytes.length;
|
||||||
|
return StreamAudioResponse(
|
||||||
|
sourceLength: bytes.length,
|
||||||
|
contentLength: end - start,
|
||||||
|
offset: start,
|
||||||
|
stream: Stream.value(bytes.sublist(start, end)),
|
||||||
|
contentType: 'audio/aac',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,159 @@
|
|||||||
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
||||||
|
|
||||||
|
class CreateGroupRequest {
|
||||||
|
String? groupName;
|
||||||
|
int? adminUserId;
|
||||||
|
List<ChatUser>? groupUserList;
|
||||||
|
bool? canAttach;
|
||||||
|
bool? canAudioC;
|
||||||
|
bool? canShareS;
|
||||||
|
bool? canVideoC;
|
||||||
|
bool? isMeeting;
|
||||||
|
bool? canArchive;
|
||||||
|
int? groupId;
|
||||||
|
CreateGroupRequest(
|
||||||
|
{this.groupName,
|
||||||
|
this.adminUserId,
|
||||||
|
this.groupUserList,
|
||||||
|
this.canAttach,
|
||||||
|
this.canAudioC,
|
||||||
|
this.canShareS,
|
||||||
|
this.canVideoC,
|
||||||
|
this.isMeeting,
|
||||||
|
this.canArchive,
|
||||||
|
this.groupId
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateGroupRequest.fromJson(Map<String, dynamic> json) {
|
||||||
|
groupName = json['groupName'];
|
||||||
|
adminUserId = json['adminUserId'];
|
||||||
|
if (json['groupUserList'] != null) {
|
||||||
|
groupUserList = <ChatUser>[];
|
||||||
|
json['groupUserList'].forEach((v) {
|
||||||
|
groupUserList!.add(new ChatUser.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
canAttach = json['canAttach'];
|
||||||
|
canAudioC = json['canAudioC'];
|
||||||
|
canShareS = json['canShareS'];
|
||||||
|
canVideoC = json['canVideoC'];
|
||||||
|
isMeeting = json['isMeeting'];
|
||||||
|
canArchive = json['canArchive'];
|
||||||
|
groupId = json['groupId'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['groupName'] = this.groupName;
|
||||||
|
data['adminUserId'] = this.adminUserId;
|
||||||
|
if (this.groupUserList != null) {
|
||||||
|
data['groupUserList'] =
|
||||||
|
this.groupUserList!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
data['canAttach'] = this.canAttach;
|
||||||
|
data['canAudioC'] = this.canAudioC;
|
||||||
|
data['canShareS'] = this.canShareS;
|
||||||
|
data['canVideoC'] = this.canVideoC;
|
||||||
|
data['isMeeting'] = this.isMeeting;
|
||||||
|
data['canArchive'] = this.canArchive;
|
||||||
|
data['groupId'] = this.groupId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupUserList {
|
||||||
|
int? id;
|
||||||
|
String? userName;
|
||||||
|
String? email;
|
||||||
|
dynamic? phone;
|
||||||
|
String? title;
|
||||||
|
int? userStatus;
|
||||||
|
String? image;
|
||||||
|
int? unreadMessageCount;
|
||||||
|
int? userAction;
|
||||||
|
bool? isPin;
|
||||||
|
bool? isFav;
|
||||||
|
bool? isAdmin;
|
||||||
|
Null? rKey;
|
||||||
|
int? totalCount;
|
||||||
|
bool? isHuaweiDevice;
|
||||||
|
Null? deviceToken;
|
||||||
|
String? token;
|
||||||
|
bool? isDomainUser;
|
||||||
|
bool? isActiveCode;
|
||||||
|
String? encryptedUserId;
|
||||||
|
String? encryptedUserName;
|
||||||
|
|
||||||
|
GroupUserList(
|
||||||
|
{this.id,
|
||||||
|
this.userName,
|
||||||
|
this.email,
|
||||||
|
this.phone,
|
||||||
|
this.title,
|
||||||
|
this.userStatus,
|
||||||
|
this.image,
|
||||||
|
this.unreadMessageCount,
|
||||||
|
this.userAction,
|
||||||
|
this.isPin,
|
||||||
|
this.isFav,
|
||||||
|
this.isAdmin,
|
||||||
|
this.rKey,
|
||||||
|
this.totalCount,
|
||||||
|
this.isHuaweiDevice,
|
||||||
|
this.deviceToken,
|
||||||
|
this.token,
|
||||||
|
this.isDomainUser,
|
||||||
|
this.isActiveCode,
|
||||||
|
this.encryptedUserId,
|
||||||
|
this.encryptedUserName});
|
||||||
|
|
||||||
|
GroupUserList.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
userName = json['userName'];
|
||||||
|
email = json['email'];
|
||||||
|
phone = json['phone'];
|
||||||
|
title = json['title'];
|
||||||
|
userStatus = json['userStatus'];
|
||||||
|
image = json['image'];
|
||||||
|
unreadMessageCount = json['unreadMessageCount'];
|
||||||
|
userAction = json['userAction'];
|
||||||
|
isPin = json['isPin'];
|
||||||
|
isFav = json['isFav'];
|
||||||
|
isAdmin = json['isAdmin'];
|
||||||
|
rKey = json['rKey'];
|
||||||
|
totalCount = json['totalCount'];
|
||||||
|
isHuaweiDevice = json['isHuaweiDevice'];
|
||||||
|
deviceToken = json['deviceToken'];
|
||||||
|
token = json['token'];
|
||||||
|
isDomainUser = json['isDomainUser'];
|
||||||
|
isActiveCode = json['isActiveCode'];
|
||||||
|
encryptedUserId = json['encryptedUserId'];
|
||||||
|
encryptedUserName = json['encryptedUserName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['userName'] = this.userName;
|
||||||
|
data['email'] = this.email;
|
||||||
|
data['phone'] = this.phone;
|
||||||
|
data['title'] = this.title;
|
||||||
|
data['userStatus'] = this.userStatus;
|
||||||
|
data['image'] = this.image;
|
||||||
|
data['unreadMessageCount'] = this.unreadMessageCount;
|
||||||
|
data['userAction'] = this.userAction;
|
||||||
|
data['isPin'] = this.isPin;
|
||||||
|
data['isFav'] = this.isFav;
|
||||||
|
data['isAdmin'] = this.isAdmin;
|
||||||
|
data['rKey'] = this.rKey;
|
||||||
|
data['totalCount'] = this.totalCount;
|
||||||
|
data['isHuaweiDevice'] = this.isHuaweiDevice;
|
||||||
|
data['deviceToken'] = this.deviceToken;
|
||||||
|
data['token'] = this.token;
|
||||||
|
data['isDomainUser'] = this.isDomainUser;
|
||||||
|
data['isActiveCode'] = this.isActiveCode;
|
||||||
|
data['encryptedUserId'] = this.encryptedUserId;
|
||||||
|
data['encryptedUserName'] = this.encryptedUserName;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,264 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:just_audio/just_audio.dart';
|
||||||
|
|
||||||
|
class GetGroupChatHistoryAsync {
|
||||||
|
int? groupChatHistoryId;
|
||||||
|
String? contant;
|
||||||
|
String? contantNo;
|
||||||
|
int? chatEventId;
|
||||||
|
dynamic? fileTypeId;
|
||||||
|
bool? isSeen;
|
||||||
|
bool? isDelivered;
|
||||||
|
String? createdDate;
|
||||||
|
int? chatSource;
|
||||||
|
int? currentUserId;
|
||||||
|
String? currentUserName;
|
||||||
|
int? groupId;
|
||||||
|
String? groupName;
|
||||||
|
dynamic? encryptedGroupId;
|
||||||
|
dynamic? encryptedGroupName;
|
||||||
|
dynamic? callStatus;
|
||||||
|
String? conversationId;
|
||||||
|
List<GroupChatHistoryTargetUserList>? groupChatHistoryTargetUserList;
|
||||||
|
FileTypeResponse? fileTypeResponse;
|
||||||
|
GroupChatReplyResponse? groupChatReplyResponse;
|
||||||
|
bool? isReplied;
|
||||||
|
bool? isImageLoaded;
|
||||||
|
Uint8List? image;
|
||||||
|
File? voice;
|
||||||
|
AudioPlayer? voiceController;
|
||||||
|
GetGroupChatHistoryAsync(
|
||||||
|
{this.groupChatHistoryId,
|
||||||
|
this.contant,
|
||||||
|
this.contantNo,
|
||||||
|
this.chatEventId,
|
||||||
|
this.fileTypeId,
|
||||||
|
this.isSeen,
|
||||||
|
this.isDelivered,
|
||||||
|
this.createdDate,
|
||||||
|
this.chatSource,
|
||||||
|
this.currentUserId,
|
||||||
|
this.currentUserName,
|
||||||
|
this.groupId,
|
||||||
|
this.groupName,
|
||||||
|
this.encryptedGroupId,
|
||||||
|
this.encryptedGroupName,
|
||||||
|
this.callStatus,
|
||||||
|
this.conversationId,
|
||||||
|
this.groupChatHistoryTargetUserList,
|
||||||
|
this.fileTypeResponse,
|
||||||
|
this.groupChatReplyResponse,
|
||||||
|
this.image,
|
||||||
|
this.isImageLoaded,
|
||||||
|
this.isReplied,
|
||||||
|
this.voice,
|
||||||
|
this.voiceController
|
||||||
|
});
|
||||||
|
|
||||||
|
GetGroupChatHistoryAsync.fromJson(Map<String, dynamic> json) {
|
||||||
|
groupChatHistoryId = json['groupChatHistoryId'];
|
||||||
|
contant = json['contant'];
|
||||||
|
contantNo = json['contantNo'];
|
||||||
|
chatEventId = json['chatEventId'];
|
||||||
|
fileTypeId = json['fileTypeId'];
|
||||||
|
isSeen = json['isSeen'];
|
||||||
|
isDelivered = json['isDelivered'];
|
||||||
|
createdDate = json['createdDate'];
|
||||||
|
chatSource = json['chatSource'];
|
||||||
|
currentUserId = json['currentUserId'];
|
||||||
|
currentUserName = json['currentUserName'];
|
||||||
|
groupId = json['groupId'];
|
||||||
|
groupName = json['groupName'];
|
||||||
|
encryptedGroupId = json['encryptedGroupId'];
|
||||||
|
encryptedGroupName = json['encryptedGroupName'];
|
||||||
|
callStatus = json['callStatus'];
|
||||||
|
conversationId = json['conversationId'];
|
||||||
|
if (json['groupChatHistoryTargetUserList'] != null) {
|
||||||
|
groupChatHistoryTargetUserList = <GroupChatHistoryTargetUserList>[];
|
||||||
|
json['groupChatHistoryTargetUserList'].forEach((v) {
|
||||||
|
groupChatHistoryTargetUserList!
|
||||||
|
.add(new GroupChatHistoryTargetUserList.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
fileTypeResponse = json['fileTypeResponse'] != null
|
||||||
|
? new FileTypeResponse.fromJson(json['fileTypeResponse'])
|
||||||
|
: null;
|
||||||
|
groupChatReplyResponse = json["userChatReplyResponse"] == null ? null : GroupChatReplyResponse.fromJson(json["userChatReplyResponse"]);
|
||||||
|
|
||||||
|
isReplied= json['isReplied'];
|
||||||
|
isImageLoaded= json['isImageLoaded'];
|
||||||
|
image= json['image'];
|
||||||
|
voice= json['voice'];
|
||||||
|
voiceController = json["fileTypeId"] == 13 ? AudioPlayer() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['groupChatHistoryId'] = this.groupChatHistoryId;
|
||||||
|
data['contant'] = this.contant;
|
||||||
|
data['contantNo'] = this.contantNo;
|
||||||
|
data['chatEventId'] = this.chatEventId;
|
||||||
|
data['fileTypeId'] = this.fileTypeId;
|
||||||
|
data['isSeen'] = this.isSeen;
|
||||||
|
data['isDelivered'] = this.isDelivered;
|
||||||
|
data['createdDate'] = this.createdDate;
|
||||||
|
data['chatSource'] = this.chatSource;
|
||||||
|
data['currentUserId'] = this.currentUserId;
|
||||||
|
data['currentUserName'] = this.currentUserName;
|
||||||
|
data['groupId'] = this.groupId;
|
||||||
|
data['groupName'] = this.groupName;
|
||||||
|
data['encryptedGroupId'] = this.encryptedGroupId;
|
||||||
|
data['encryptedGroupName'] = this.encryptedGroupName;
|
||||||
|
data['callStatus'] = this.callStatus;
|
||||||
|
data['conversationId'] = this.conversationId;
|
||||||
|
if (this.groupChatHistoryTargetUserList != null) {
|
||||||
|
data['groupChatHistoryTargetUserList'] =
|
||||||
|
this.groupChatHistoryTargetUserList!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.fileTypeResponse != null) {
|
||||||
|
data['fileTypeResponse'] = this.fileTypeResponse!.toJson();
|
||||||
|
}
|
||||||
|
if(this.groupChatReplyResponse !=null) {
|
||||||
|
data['groupChatReplyResponse'] = this.groupChatReplyResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
data['isReplied'] =isReplied;
|
||||||
|
data['isImageLoaded'] = isImageLoaded;
|
||||||
|
data['image'] = image;
|
||||||
|
data['voice'] = voice;
|
||||||
|
data["fileTypeId"] == 13 ? AudioPlayer() : null;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupChatHistoryTargetUserList {
|
||||||
|
int? groupChatHistoryLineId;
|
||||||
|
bool? isSeen;
|
||||||
|
bool? isDelivered;
|
||||||
|
int? targetUserId;
|
||||||
|
String? targetUserName;
|
||||||
|
Null? userAction;
|
||||||
|
|
||||||
|
GroupChatHistoryTargetUserList(
|
||||||
|
{this.groupChatHistoryLineId,
|
||||||
|
this.isSeen,
|
||||||
|
this.isDelivered,
|
||||||
|
this.targetUserId,
|
||||||
|
this.targetUserName,
|
||||||
|
this.userAction});
|
||||||
|
|
||||||
|
GroupChatHistoryTargetUserList.fromJson(Map<String, dynamic> json) {
|
||||||
|
groupChatHistoryLineId = json['groupChatHistoryLineId'];
|
||||||
|
isSeen = json['isSeen'];
|
||||||
|
isDelivered = json['isDelivered'];
|
||||||
|
targetUserId = json['targetUserId'];
|
||||||
|
targetUserName = json['targetUserName'];
|
||||||
|
userAction = json['userAction'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['groupChatHistoryLineId'] = this.groupChatHistoryLineId;
|
||||||
|
data['isSeen'] = this.isSeen;
|
||||||
|
data['isDelivered'] = this.isDelivered;
|
||||||
|
data['targetUserId'] = this.targetUserId;
|
||||||
|
data['targetUserName'] = this.targetUserName;
|
||||||
|
data['userAction'] = this.userAction;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FileTypeResponse {
|
||||||
|
int? fileTypeId;
|
||||||
|
dynamic? fileTypeName;
|
||||||
|
dynamic? fileTypeDescription;
|
||||||
|
dynamic? fileKind;
|
||||||
|
dynamic? fileName;
|
||||||
|
|
||||||
|
FileTypeResponse(
|
||||||
|
{this.fileTypeId,
|
||||||
|
this.fileTypeName,
|
||||||
|
this.fileTypeDescription,
|
||||||
|
this.fileKind,
|
||||||
|
this.fileName});
|
||||||
|
|
||||||
|
FileTypeResponse.fromJson(Map<String, dynamic> json) {
|
||||||
|
fileTypeId = json['fileTypeId'];
|
||||||
|
fileTypeName = json['fileTypeName'];
|
||||||
|
fileTypeDescription = json['fileTypeDescription'];
|
||||||
|
fileKind = json['fileKind'];
|
||||||
|
fileName = json['fileName'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['fileTypeId'] = this.fileTypeId;
|
||||||
|
data['fileTypeName'] = this.fileTypeName;
|
||||||
|
data['fileTypeDescription'] = this.fileTypeDescription;
|
||||||
|
data['fileKind'] = this.fileKind;
|
||||||
|
data['fileName'] = this.fileName;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class GroupChatReplyResponse {
|
||||||
|
GroupChatReplyResponse(
|
||||||
|
{this.userChatHistoryId,
|
||||||
|
this.chatEventId,
|
||||||
|
this.contant,
|
||||||
|
this.contantNo,
|
||||||
|
this.fileTypeId,
|
||||||
|
this.createdDate,
|
||||||
|
this.targetUserId,
|
||||||
|
this.targetUserName,
|
||||||
|
this.fileTypeResponse,
|
||||||
|
this.isImageLoaded,
|
||||||
|
this.image,
|
||||||
|
this.voice});
|
||||||
|
|
||||||
|
int? userChatHistoryId;
|
||||||
|
int? chatEventId;
|
||||||
|
String? contant;
|
||||||
|
String? contantNo;
|
||||||
|
dynamic? fileTypeId;
|
||||||
|
DateTime? createdDate;
|
||||||
|
int? targetUserId;
|
||||||
|
String? targetUserName;
|
||||||
|
FileTypeResponse? fileTypeResponse;
|
||||||
|
bool? isImageLoaded;
|
||||||
|
Uint8List? image;
|
||||||
|
Uint8List? voice;
|
||||||
|
|
||||||
|
factory GroupChatReplyResponse.fromJson(Map<String, dynamic> json) => GroupChatReplyResponse(
|
||||||
|
userChatHistoryId: json["userChatHistoryId"] == null ? null : json["userChatHistoryId"],
|
||||||
|
chatEventId: json["chatEventId"] == null ? null : json["chatEventId"],
|
||||||
|
contant: json["contant"] == null ? null : json["contant"],
|
||||||
|
contantNo: json["contantNo"] == null ? null : json["contantNo"],
|
||||||
|
fileTypeId: json["fileTypeId"],
|
||||||
|
createdDate: json["createdDate"] == null ? null : DateTime.parse(json["createdDate"]),
|
||||||
|
targetUserId: json["targetUserId"] == null ? null : json["targetUserId"],
|
||||||
|
targetUserName: json["targetUserName"] == null ? null : json["targetUserName"],
|
||||||
|
fileTypeResponse: json["fileTypeResponse"] == null ? null : FileTypeResponse.fromJson(json["fileTypeResponse"]),
|
||||||
|
isImageLoaded: false,
|
||||||
|
image: null,
|
||||||
|
voice: null,
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"userChatHistoryId": userChatHistoryId == null ? null : userChatHistoryId,
|
||||||
|
"chatEventId": chatEventId == null ? null : chatEventId,
|
||||||
|
"contant": contant == null ? null : contant,
|
||||||
|
"contantNo": contantNo == null ? null : contantNo,
|
||||||
|
"fileTypeId": fileTypeId,
|
||||||
|
"createdDate": createdDate == null ? null : createdDate!.toIso8601String(),
|
||||||
|
"targetUserId": targetUserId == null ? null : targetUserId,
|
||||||
|
"targetUserName": targetUserName == null ? null : targetUserName,
|
||||||
|
"fileTypeResponse": fileTypeResponse == null ? null : fileTypeResponse!.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
class GetPRInformationList {
|
||||||
|
List<PRHeader>? pRHeader;
|
||||||
|
List<PRLines>? pRLines;
|
||||||
|
String? pCURRENCYCODE;
|
||||||
|
|
||||||
|
GetPRInformationList({this.pRHeader, this.pRLines, this.pCURRENCYCODE});
|
||||||
|
|
||||||
|
GetPRInformationList.fromJson(Map<String, dynamic> json) {
|
||||||
|
if (json['PRHeader'] != null) {
|
||||||
|
pRHeader = <PRHeader>[];
|
||||||
|
json['PRHeader'].forEach((v) {
|
||||||
|
pRHeader!.add(new PRHeader.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (json['PRLines'] != null) {
|
||||||
|
pRLines = <PRLines>[];
|
||||||
|
json['PRLines'].forEach((v) {
|
||||||
|
pRLines!.add(new PRLines.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pCURRENCYCODE = json['P_CURRENCY_CODE'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
if (this.pRHeader != null) {
|
||||||
|
data['PRHeader'] = this.pRHeader!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
if (this.pRLines != null) {
|
||||||
|
data['PRLines'] = this.pRLines!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
data['P_CURRENCY_CODE'] = this.pCURRENCYCODE;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PRHeader {
|
||||||
|
String? dESCRIPTION;
|
||||||
|
String? pRNUMBER;
|
||||||
|
String? rEQUISITIONTOTAL;
|
||||||
|
String? tAXTOTAL;
|
||||||
|
|
||||||
|
PRHeader({this.dESCRIPTION, this.pRNUMBER, this.rEQUISITIONTOTAL, this.tAXTOTAL});
|
||||||
|
|
||||||
|
PRHeader.fromJson(Map<String, dynamic> json) {
|
||||||
|
dESCRIPTION = json['DESCRIPTION'];
|
||||||
|
pRNUMBER = json['PR_NUMBER'];
|
||||||
|
rEQUISITIONTOTAL = json['REQUISITION_TOTAL'];
|
||||||
|
tAXTOTAL = json['TAX_TOTAL'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['DESCRIPTION'] = this.dESCRIPTION;
|
||||||
|
data['PR_NUMBER'] = this.pRNUMBER;
|
||||||
|
data['REQUISITION_TOTAL'] = this.rEQUISITIONTOTAL;
|
||||||
|
data['TAX_TOTAL'] = this.tAXTOTAL;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PRLines {
|
||||||
|
String? cOSTCENTER;
|
||||||
|
String? dESCRIPTION;
|
||||||
|
int? fROMROWNUM;
|
||||||
|
int? iTEMAMU;
|
||||||
|
String? iTEMCODE;
|
||||||
|
int? lINEAMOUNT;
|
||||||
|
int? lINENUM;
|
||||||
|
int? nOOFROWS;
|
||||||
|
int? qUANTITY;
|
||||||
|
int? rOWNUM;
|
||||||
|
int? tOROWNUM;
|
||||||
|
int? uNITPRICE;
|
||||||
|
String? uOM;
|
||||||
|
|
||||||
|
PRLines(
|
||||||
|
{this.cOSTCENTER,
|
||||||
|
this.dESCRIPTION,
|
||||||
|
this.fROMROWNUM,
|
||||||
|
this.iTEMAMU,
|
||||||
|
this.iTEMCODE,
|
||||||
|
this.lINEAMOUNT,
|
||||||
|
this.lINENUM,
|
||||||
|
this.nOOFROWS,
|
||||||
|
this.qUANTITY,
|
||||||
|
this.rOWNUM,
|
||||||
|
this.tOROWNUM,
|
||||||
|
this.uNITPRICE,
|
||||||
|
this.uOM});
|
||||||
|
|
||||||
|
PRLines.fromJson(Map<String, dynamic> json) {
|
||||||
|
cOSTCENTER = json['COST_CENTER'];
|
||||||
|
dESCRIPTION = json['DESCRIPTION'];
|
||||||
|
fROMROWNUM = json['FROM_ROW_NUM'];
|
||||||
|
iTEMAMU = json['ITEM_AMU'];
|
||||||
|
iTEMCODE = json['ITEM_CODE'];
|
||||||
|
lINEAMOUNT = json['LINE_AMOUNT'];
|
||||||
|
lINENUM = json['LINE_NUM'];
|
||||||
|
nOOFROWS = json['NO_OF_ROWS'];
|
||||||
|
qUANTITY = json['QUANTITY'];
|
||||||
|
rOWNUM = json['ROW_NUM'];
|
||||||
|
tOROWNUM = json['TO_ROW_NUM'];
|
||||||
|
uNITPRICE = json['UNIT_PRICE'];
|
||||||
|
uOM = json['UOM'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['COST_CENTER'] = this.cOSTCENTER;
|
||||||
|
data['DESCRIPTION'] = this.dESCRIPTION;
|
||||||
|
data['FROM_ROW_NUM'] = this.fROMROWNUM;
|
||||||
|
data['ITEM_AMU'] = this.iTEMAMU;
|
||||||
|
data['ITEM_CODE'] = this.iTEMCODE;
|
||||||
|
data['LINE_AMOUNT'] = this.lINEAMOUNT;
|
||||||
|
data['LINE_NUM'] = this.lINENUM;
|
||||||
|
data['NO_OF_ROWS'] = this.nOOFROWS;
|
||||||
|
data['QUANTITY'] = this.qUANTITY;
|
||||||
|
data['ROW_NUM'] = this.rOWNUM;
|
||||||
|
data['TO_ROW_NUM'] = this.tOROWNUM;
|
||||||
|
data['UNIT_PRICE'] = this.uNITPRICE;
|
||||||
|
data['UOM'] = this.uOM;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,187 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter_webrtc/flutter_webrtc.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart';
|
||||||
|
|
||||||
|
class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin {
|
||||||
|
///////////////////// Web RTC Video Calling //////////////////////
|
||||||
|
// Video Call
|
||||||
|
late RTCPeerConnection _peerConnection;
|
||||||
|
RTCVideoRenderer _localVideoRenderer = RTCVideoRenderer();
|
||||||
|
final RTCVideoRenderer _remoteRenderer = RTCVideoRenderer();
|
||||||
|
|
||||||
|
MediaStream? _localStream;
|
||||||
|
MediaStream? _remoteStream;
|
||||||
|
|
||||||
|
void initCallListeners() {
|
||||||
|
chatHubConnection.on("OnCallAcceptedAsync", onCallAcceptedAsync);
|
||||||
|
chatHubConnection.on("OnIceCandidateAsync", onIceCandidateAsync);
|
||||||
|
chatHubConnection.on("OnOfferAsync", onOfferAsync);
|
||||||
|
chatHubConnection.on("OnAnswerOffer", onAnswerOffer);
|
||||||
|
chatHubConnection.on("OnHangUpAsync", onHangUpAsync);
|
||||||
|
chatHubConnection.on("OnCallDeclinedAsync", onCallDeclinedAsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Video Constraints
|
||||||
|
var videoConstraints = {
|
||||||
|
"video": {
|
||||||
|
"mandatory": {
|
||||||
|
"width": {"min": 320},
|
||||||
|
"height": {"min": 180}
|
||||||
|
},
|
||||||
|
"optional": [
|
||||||
|
{
|
||||||
|
"width": {"max": 1280}
|
||||||
|
},
|
||||||
|
{"frameRate": 25},
|
||||||
|
{"facingMode": "user"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"frameRate": 25,
|
||||||
|
"width": 420, //420,//640,//1280,
|
||||||
|
"height": 240 //240//480//720
|
||||||
|
};
|
||||||
|
|
||||||
|
// Audio Constraints
|
||||||
|
var audioConstraints = {
|
||||||
|
"sampleRate": 8000,
|
||||||
|
"sampleSize": 16,
|
||||||
|
"channelCount": 2,
|
||||||
|
"echoCancellation": true,
|
||||||
|
"audio": true,
|
||||||
|
};
|
||||||
|
|
||||||
|
Future<RTCPeerConnection> _createPeerConnection() async {
|
||||||
|
// {"url": "stun:stun.l.google.com:19302"},
|
||||||
|
Map<String, dynamic> configuration = {
|
||||||
|
"iceServers": [
|
||||||
|
{"urls": 'stun:15.185.116.59:3478'},
|
||||||
|
{"urls": "turn:15.185.116.59:3479", "username": "admin", "credential": "admin"}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
Map<String, dynamic> offerSdpConstraints = {
|
||||||
|
"mandatory": {
|
||||||
|
"OfferToReceiveAudio": true,
|
||||||
|
"OfferToReceiveVideo": true,
|
||||||
|
},
|
||||||
|
"optional": [],
|
||||||
|
};
|
||||||
|
|
||||||
|
RTCPeerConnection pc = await createPeerConnection(configuration, offerSdpConstraints);
|
||||||
|
// if (pc != null) print(pc);
|
||||||
|
//pc.addStream(widget.localStream);
|
||||||
|
|
||||||
|
pc.onIceCandidate = (e) {
|
||||||
|
if (e.candidate != null) {
|
||||||
|
print(json.encode({
|
||||||
|
'candidate': e.candidate.toString(),
|
||||||
|
'sdpMid': e.sdpMid.toString(),
|
||||||
|
'sdpMlineIndex': e.sdpMLineIndex,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
pc.onIceConnectionState = (e) {
|
||||||
|
print(e);
|
||||||
|
};
|
||||||
|
pc.onAddStream = (stream) {
|
||||||
|
print('addStream: ' + stream.id);
|
||||||
|
_remoteRenderer.srcObject = stream;
|
||||||
|
};
|
||||||
|
return pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
initRenderers();
|
||||||
|
_createPeerConnection().then((pc) {
|
||||||
|
_peerConnection = pc;
|
||||||
|
// _setRemoteDescription(widget.info);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void initRenderers() {
|
||||||
|
_localVideoRenderer.initialize();
|
||||||
|
_remoteRenderer.initialize();
|
||||||
|
initLocalCamera();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initLocalCamera() async {
|
||||||
|
_localStream = await navigator.mediaDevices.getUserMedia({'video': true, 'audio': true});
|
||||||
|
_localVideoRenderer.srcObject = _localStream;
|
||||||
|
// _localVideoRenderer.srcObject = await navigator.mediaDevices
|
||||||
|
// .getUserMedia({'video': true, 'audio': true});
|
||||||
|
print('this source Object');
|
||||||
|
print('this suarce ${_localVideoRenderer.srcObject != null}');
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void startCall({required String callType}) {}
|
||||||
|
|
||||||
|
void endCall() {}
|
||||||
|
|
||||||
|
void checkCall(Map<String, dynamic> message) {
|
||||||
|
switch (message["callStatus"]) {
|
||||||
|
case 'connected':
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
case 'offer':
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
case 'accept':
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
case 'candidate':
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
case 'bye':
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
case 'leave':
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// Listeners Methods ////
|
||||||
|
|
||||||
|
void onCallAcceptedAsync(List<Object?>? params) {}
|
||||||
|
|
||||||
|
void onIceCandidateAsync(List<Object?>? params) {}
|
||||||
|
|
||||||
|
void onOfferAsync(List<Object?>? params) {}
|
||||||
|
|
||||||
|
void onAnswerOffer(List<Object?>? params) {}
|
||||||
|
|
||||||
|
void onHangUpAsync(List<Object?>? params) {}
|
||||||
|
|
||||||
|
void onCallDeclinedAsync(List<Object?>? params) {}
|
||||||
|
|
||||||
|
//// Invoke Methods
|
||||||
|
|
||||||
|
Future<void> invoke({required String invokeMethod, required String currentUserID, required String targetUserID, bool isVideoCall = false, var data}) async {
|
||||||
|
List<Object> args = [];
|
||||||
|
if (invokeMethod == "answerCallAsync") {
|
||||||
|
args = [currentUserID, targetUserID];
|
||||||
|
} else if (invokeMethod == "CallUserAsync") {
|
||||||
|
args = [currentUserID, targetUserID, isVideoCall];
|
||||||
|
} else if (invokeMethod == "IceCandidateAsync") {
|
||||||
|
args = [targetUserID, data];
|
||||||
|
} else if (invokeMethod == "OfferAsync") {
|
||||||
|
args = [targetUserID, data];
|
||||||
|
} else if (invokeMethod == "AnswerOfferAsync") {
|
||||||
|
args = [targetUserID, data];
|
||||||
|
//json In Data
|
||||||
|
}
|
||||||
|
await chatHubConnection.invoke(invokeMethod, args: args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopListeners() async {
|
||||||
|
chatHubConnection.off('OnCallDeclinedAsync');
|
||||||
|
chatHubConnection.off('OnCallAcceptedAsync');
|
||||||
|
chatHubConnection.off('OnIceCandidateAsync');
|
||||||
|
chatHubConnection.off('OnAnswerOffer');
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:wifi_iot/wifi_iot.dart';
|
||||||
|
|
||||||
|
class HmgConnectionProvider extends ChangeNotifier {
|
||||||
|
bool isConnectedToHMG = false;
|
||||||
|
|
||||||
|
Future<bool> checkHmgNetworkConnectivity() async {
|
||||||
|
if (await WiFiForIoTPlugin.getSSID() == AppState().getMohemmWifiSSID) {
|
||||||
|
isConnectedToHMG = true;
|
||||||
|
} else {
|
||||||
|
isConnectedToHMG = false;
|
||||||
|
}
|
||||||
|
AppState().isConnectedToHMG = isConnectedToHMG;
|
||||||
|
return isConnectedToHMG;
|
||||||
|
}
|
||||||
|
|
||||||
|
void connectWithHmgNetwork() async {
|
||||||
|
try {
|
||||||
|
bool isConnected = await WiFiForIoTPlugin.connect("MOHEMM-CONNECT", password: "0987654321", joinOnce: Platform.isIOS ? false : true, security: NetworkSecurity.WPA, withInternet: false);
|
||||||
|
|
||||||
|
if (isConnected) {
|
||||||
|
await WiFiForIoTPlugin.forceWifiUsage(true);
|
||||||
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
|
isConnectedToHMG=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
isConnectedToHMG = false;
|
||||||
|
AppState().isConnectedToHMG = isConnectedToHMG;
|
||||||
|
print("----------------o----");
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> closeWifiRequest() async {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
await WiFiForIoTPlugin.forceWifiUsage(false);
|
||||||
|
}
|
||||||
|
isConnectedToHMG = false;
|
||||||
|
AppState().isConnectedToHMG = isConnectedToHMG;
|
||||||
|
return await WiFiForIoTPlugin.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,697 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/rendering.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/config/routes.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/main.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/create_group_request.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_user_groups_by_id.dart'
|
||||||
|
as groups;
|
||||||
|
import 'package:mohem_flutter_app/models/get_action_history_list_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/worklist/get_favorite_replacements_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/worklist/replacement_list_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/dynamic_forms/dynamic_textfield_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class CreateGroupBottomSheet extends StatefulWidget {
|
||||||
|
int? notificationID;
|
||||||
|
String title, apiMode;
|
||||||
|
List<GetActionHistoryList>? actionHistoryList;
|
||||||
|
Function(ReplacementList) onSelectEmployee;
|
||||||
|
bool fromChat;
|
||||||
|
groups.GroupResponse groupDetails;
|
||||||
|
|
||||||
|
CreateGroupBottomSheet({
|
||||||
|
Key? key,
|
||||||
|
required this.title,
|
||||||
|
required this.apiMode,
|
||||||
|
this.notificationID,
|
||||||
|
this.actionHistoryList,
|
||||||
|
required this.onSelectEmployee,
|
||||||
|
required this.fromChat,
|
||||||
|
required this.groupDetails,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<CreateGroupBottomSheet> createState() => _CreateGroupBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CreateGroupBottomSheetState extends State<CreateGroupBottomSheet> {
|
||||||
|
TextEditingController username = TextEditingController();
|
||||||
|
ScrollController sc = ScrollController();
|
||||||
|
bool isAudioCall = true;
|
||||||
|
bool isVideoCall = true;
|
||||||
|
bool isAttachments = true;
|
||||||
|
bool isShareScreen = true;
|
||||||
|
String searchText = "";
|
||||||
|
String groupName = "";
|
||||||
|
List<String>? optionsList = [
|
||||||
|
LocaleKeys.fullName.tr(),
|
||||||
|
LocaleKeys.username.tr(),
|
||||||
|
LocaleKeys.endDate.tr(),
|
||||||
|
];
|
||||||
|
List<GetFavoriteReplacements>? favUsersList;
|
||||||
|
|
||||||
|
List<ReplacementList>? replacementList;
|
||||||
|
List<ReplacementList>? favouriteUserList;
|
||||||
|
List<ReplacementList>? nonFavouriteUserList;
|
||||||
|
|
||||||
|
// Chat Items
|
||||||
|
late ChatProviderModel provider;
|
||||||
|
|
||||||
|
int _selectedSearchIndex = 0;
|
||||||
|
List<ChatUser> selectedUsers = [];
|
||||||
|
|
||||||
|
void fetchUserByInput({bool isNeedLoading = true}) async {
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
replacementList = await WorkListApiClient().searchUserByInput(
|
||||||
|
userName: _selectedSearchIndex == 0 ? searchText : "",
|
||||||
|
userId: _selectedSearchIndex == 1 ? searchText : "",
|
||||||
|
email: _selectedSearchIndex == 2 ? searchText : "",
|
||||||
|
);
|
||||||
|
favouriteUserList = replacementList
|
||||||
|
?.where((ReplacementList element) => element.isFavorite ?? false)
|
||||||
|
.toList();
|
||||||
|
nonFavouriteUserList = replacementList
|
||||||
|
?.where((ReplacementList element) => !(element.isFavorite ?? false))
|
||||||
|
.toList();
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
} catch (e) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(e, context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNeedLoading) Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fetchChatUser({bool isNeedLoading = true}) async {
|
||||||
|
if (provider.pageNo == 1) provider.chatUsersList!.clear();
|
||||||
|
try {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
await ChatApiClient()
|
||||||
|
.getChatMemberFromSearch(searchText,
|
||||||
|
AppState().chatDetails!.response!.id!, provider.pageNo)
|
||||||
|
.then((ChatUserModel value) {
|
||||||
|
if (value.response != null) {
|
||||||
|
if (provider.pageNo == 1) {
|
||||||
|
provider.chatUsersList = value.response;
|
||||||
|
} else {
|
||||||
|
print("--------------------------Added More----------------------");
|
||||||
|
provider.chatUsersList!.addAll(value.response!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
provider.chatUsersList!.removeWhere((ChatUser element) =>
|
||||||
|
element.id == AppState().chatDetails!.response!.id);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
} catch (e) {
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
Utils.handleException(e, context, null);
|
||||||
|
}
|
||||||
|
if (isNeedLoading) Utils.hideLoading(context);
|
||||||
|
setState(() {});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollListener() async {
|
||||||
|
if (sc.position.pixels == sc.position.maxScrollExtent) {
|
||||||
|
provider.pageNo++;
|
||||||
|
logger.w(provider.chatUsersList!.length);
|
||||||
|
logger.w(provider.pageNo);
|
||||||
|
fetchChatUser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
sc.addListener(scrollListener);
|
||||||
|
provider = Provider.of<ChatProviderModel>(context, listen: false);
|
||||||
|
if (widget.groupDetails.groupName !=null) {
|
||||||
|
setState(() {
|
||||||
|
groupName = widget.groupDetails.groupName!;
|
||||||
|
isAudioCall = widget.groupDetails.canAudioC!;
|
||||||
|
isVideoCall = widget.groupDetails.canVideoC!;
|
||||||
|
isAttachments = widget.groupDetails.canAttach!;
|
||||||
|
isShareScreen = widget.groupDetails.canShareS!;
|
||||||
|
for (groups.GroupUserList items in widget.groupDetails.groupUserList!) {
|
||||||
|
{
|
||||||
|
selectedUsers.add(ChatUser.fromJson(items.toJson()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
provider.chatUsersList = [];
|
||||||
|
provider.pageNo = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: MediaQuery.of(context).size.height - 100,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
widget.title.toText24(isBold: true),
|
||||||
|
21.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
DynamicTextFieldWidget(
|
||||||
|
"Group Name",
|
||||||
|
groupName.isEmpty ? "Please enter group name" : groupName,
|
||||||
|
inputAction: TextInputAction.done,
|
||||||
|
onChange: (String text) {
|
||||||
|
groupName = text;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
).expanded,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
//11.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: CheckboxListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: "Audio Call".toText10(),
|
||||||
|
|
||||||
|
checkboxShape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
side: BorderSide(
|
||||||
|
width: 1.5,
|
||||||
|
color: Theme.of(context).unselectedWidgetColor),
|
||||||
|
|
||||||
|
value: isAudioCall,
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
setState(() {
|
||||||
|
isAudioCall = newValue!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
controlAffinity: ListTileControlAffinity
|
||||||
|
.leading, // <-- leading Checkbox
|
||||||
|
)).expanded,
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: CheckboxListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: "Video Call".toText10(),
|
||||||
|
checkboxShape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
value: isVideoCall,
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
setState(() {
|
||||||
|
isVideoCall = newValue!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
controlAffinity: ListTileControlAffinity
|
||||||
|
.leading, // <-- leading Checkbox
|
||||||
|
)).expanded
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: CheckboxListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
title: "Attachments".toText10(),
|
||||||
|
checkboxShape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
value: isAttachments,
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
setState(() {
|
||||||
|
isAttachments = newValue!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
controlAffinity: ListTileControlAffinity
|
||||||
|
.leading, // <-- leading Checkbox
|
||||||
|
)).expanded,
|
||||||
|
SizedBox(
|
||||||
|
height: 35,
|
||||||
|
child: CheckboxListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
checkboxShape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10)),
|
||||||
|
title: "Share Screen".toText10(),
|
||||||
|
value: isShareScreen,
|
||||||
|
onChanged: (bool? newValue) {
|
||||||
|
setState(() {
|
||||||
|
isShareScreen = newValue!;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
controlAffinity: ListTileControlAffinity
|
||||||
|
.leading, // <-- leading Checkbox
|
||||||
|
)).expanded
|
||||||
|
],
|
||||||
|
),
|
||||||
|
11.height,
|
||||||
|
"User Search".toText16(),
|
||||||
|
11.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
radioOption(widget.fromChat ? "UserId" : "Name", 0,
|
||||||
|
_selectedSearchIndex),
|
||||||
|
radioOption("User Name", 1, _selectedSearchIndex),
|
||||||
|
radioOption("Email", 2, _selectedSearchIndex),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
14.height,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
DynamicTextFieldWidget(
|
||||||
|
"Search",
|
||||||
|
"Search By Username",
|
||||||
|
inputAction: TextInputAction.done,
|
||||||
|
suffixIconData: Icons.search,
|
||||||
|
onChange: (String text) {
|
||||||
|
searchText = text;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
).expanded,
|
||||||
|
IconButton(
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
onPressed: () async {
|
||||||
|
await SystemChannels.textInput
|
||||||
|
.invokeMethod('TextInput.hide');
|
||||||
|
widget.fromChat ? fetchChatUser() : fetchUserByInput();
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.search),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (replacementList != null)
|
||||||
|
replacementList!.isEmpty
|
||||||
|
? Utils.getNoDataWidget(context).expanded
|
||||||
|
: ListView(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
padding: EdgeInsets.only(top: 21, bottom: 8),
|
||||||
|
children: [
|
||||||
|
if (favouriteUserList?.isNotEmpty ?? false) ...[
|
||||||
|
"Favorites".toText16(),
|
||||||
|
12.height,
|
||||||
|
ListView.separated(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemBuilder: (BuildContext cxt, int index) =>
|
||||||
|
employeeItemView(favouriteUserList![index]),
|
||||||
|
separatorBuilder:
|
||||||
|
(BuildContext cxt, int index) => Container(
|
||||||
|
height: 1,
|
||||||
|
color: MyColors.borderE3Color,
|
||||||
|
),
|
||||||
|
itemCount: favouriteUserList?.length ?? 0),
|
||||||
|
12.height,
|
||||||
|
],
|
||||||
|
if (nonFavouriteUserList?.isNotEmpty ?? false) ...[
|
||||||
|
"Related".toText16(),
|
||||||
|
12.height,
|
||||||
|
ListView.separated(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
shrinkWrap: true,
|
||||||
|
itemBuilder: (BuildContext cxt, int index) =>
|
||||||
|
employeeItemView(
|
||||||
|
nonFavouriteUserList![index]),
|
||||||
|
separatorBuilder:
|
||||||
|
(BuildContext cxt, int index) => Container(
|
||||||
|
height: 1,
|
||||||
|
color: MyColors.borderE3Color,
|
||||||
|
),
|
||||||
|
itemCount: nonFavouriteUserList?.length ?? 0),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
selectedUsers!.isNotEmpty
|
||||||
|
? SizedBox(
|
||||||
|
height: 95,
|
||||||
|
child: ListView.builder(
|
||||||
|
physics: const ClampingScrollPhysics(),
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: selectedUsers!.length,
|
||||||
|
itemBuilder: (BuildContext context, int index2) {
|
||||||
|
return Stack(children: [
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
12.height,
|
||||||
|
Stack(children: [
|
||||||
|
Container(
|
||||||
|
padding:const EdgeInsets.all(5),
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
"assets/images/user.svg",
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
)),
|
||||||
|
Positioned(
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
child: InkWell(
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
'assets/icons/close.svg',
|
||||||
|
height:15,
|
||||||
|
width:15
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
// provider.chatUsersList![index]
|
||||||
|
// .isChecked = false;
|
||||||
|
|
||||||
|
List<ChatUser> user = provider
|
||||||
|
.chatUsersList!
|
||||||
|
.where((ChatUser value) =>
|
||||||
|
value.userName ==
|
||||||
|
selectedUsers[index2]
|
||||||
|
.userName)
|
||||||
|
.toList();
|
||||||
|
if (user.isNotEmpty) {
|
||||||
|
user.first.isChecked = false;
|
||||||
|
}
|
||||||
|
selectedUsers.remove(
|
||||||
|
selectedUsers[index2]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
))
|
||||||
|
],),
|
||||||
|
(selectedUsers![index2]
|
||||||
|
.userName!
|
||||||
|
.replaceFirst(".", " ")
|
||||||
|
.capitalizeFirstofEach ??
|
||||||
|
"")
|
||||||
|
.toText12(color: MyColors.darkTextColor)
|
||||||
|
.paddingOnly(left: 5, top: 5),
|
||||||
|
selectedUsers![index2].isTyping!
|
||||||
|
? 'Typing...'
|
||||||
|
.toText10(
|
||||||
|
color: MyColors.textMixColor,
|
||||||
|
)
|
||||||
|
.paddingOnly(left: 5.0)
|
||||||
|
: const SizedBox()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// IconButton(onPressed: (){}, icon: const Icon(Icons.close_outlined, color: Colors.red, size: 20)),
|
||||||
|
|
||||||
|
]);
|
||||||
|
}))
|
||||||
|
: 0.height,
|
||||||
|
|
||||||
|
if (widget.fromChat)
|
||||||
|
if (provider.chatUsersList != null && widget.fromChat)
|
||||||
|
provider.chatUsersList!.isEmpty
|
||||||
|
? Column(
|
||||||
|
children: [
|
||||||
|
20.height,
|
||||||
|
Utils.getNoDataWidget(context),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: ListView.separated(
|
||||||
|
itemCount: provider.chatUsersList!.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const ClampingScrollPhysics(),
|
||||||
|
controller: sc,
|
||||||
|
padding: const EdgeInsets.only(bottom: 80.0, top: 20),
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 55,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
SvgPicture.asset(
|
||||||
|
"assets/images/user.svg",
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 5,
|
||||||
|
bottom: 1,
|
||||||
|
child: Container(
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: provider
|
||||||
|
.chatUsersList![index]
|
||||||
|
.userStatus ==
|
||||||
|
1
|
||||||
|
? MyColors.green2DColor
|
||||||
|
: Colors.red,
|
||||||
|
),
|
||||||
|
).circle(10),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
(provider.chatUsersList![index].userName!
|
||||||
|
.replaceFirst(".", " ")
|
||||||
|
.capitalizeFirstofEach ??
|
||||||
|
"")
|
||||||
|
.toText14(
|
||||||
|
color: MyColors.darkTextColor)
|
||||||
|
.paddingOnly(left: 11, top: 13),
|
||||||
|
provider.chatUsersList![index].isTyping!
|
||||||
|
? 'Typing...'
|
||||||
|
.toText10(
|
||||||
|
color: MyColors.textMixColor,
|
||||||
|
)
|
||||||
|
.paddingOnly(left: 11.0)
|
||||||
|
: const SizedBox()
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
SizedBox(
|
||||||
|
width: 60,
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: <Widget>[
|
||||||
|
if (provider.chatUsersList![index]
|
||||||
|
.unreadMessageCount! >
|
||||||
|
0)
|
||||||
|
Container(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: MyColors.redColor,
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: (provider
|
||||||
|
.chatUsersList![index]
|
||||||
|
.unreadMessageCount!
|
||||||
|
.toString())
|
||||||
|
.toText10(
|
||||||
|
color: MyColors.white,
|
||||||
|
)
|
||||||
|
.center,
|
||||||
|
).paddingOnly(right: 10).center,
|
||||||
|
Checkbox(
|
||||||
|
value: provider
|
||||||
|
.chatUsersList![index].isChecked,
|
||||||
|
shape: CircleBorder(),
|
||||||
|
onChanged: (bool? value) {
|
||||||
|
setState(() {
|
||||||
|
provider.chatUsersList![index]
|
||||||
|
.isChecked = value;
|
||||||
|
if (provider.chatUsersList![index]
|
||||||
|
.isChecked ==
|
||||||
|
true) {
|
||||||
|
selectedUsers.add(provider
|
||||||
|
.chatUsersList![index]);
|
||||||
|
} else {
|
||||||
|
selectedUsers.remove(provider
|
||||||
|
.chatUsersList![index]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) =>
|
||||||
|
const Divider(color: MyColors.lightGreyE5Color)
|
||||||
|
.paddingOnly(left: 59),
|
||||||
|
).expanded,
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 21, right: 21, bottom: 0, top: 21).expanded,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
DefaultButton(
|
||||||
|
LocaleKeys.cancel.tr(),
|
||||||
|
() {
|
||||||
|
Navigator.pop(context);
|
||||||
|
provider.chatUsersList = [];
|
||||||
|
provider.pageNo = 1;
|
||||||
|
},
|
||||||
|
textColor: MyColors.grey3AColor,
|
||||||
|
colors: const [
|
||||||
|
Color(0xffE6E6E6),
|
||||||
|
Color(0xffE6E6E6),
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 14, right: 14, bottom: 15, top: 10).expanded,
|
||||||
|
DefaultButton(
|
||||||
|
LocaleKeys.submit.tr(),
|
||||||
|
() {
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// provider.chatUsersList = [];
|
||||||
|
// provider.pageNo = 1;
|
||||||
|
createGroup();
|
||||||
|
},
|
||||||
|
textColor: MyColors.whiteColor,
|
||||||
|
colors: const [
|
||||||
|
Color(0xff32D892),
|
||||||
|
Color(0xff1AB170),
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 15, right: 15, bottom: 15, top: 10).expanded,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget employeeItemView(ReplacementList replacement) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
widget.onSelectEmployee(replacement);
|
||||||
|
},
|
||||||
|
child: SizedBox(
|
||||||
|
height: 50,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
CircularAvatar(
|
||||||
|
url: replacement.employeeImage ?? "",
|
||||||
|
height: 30,
|
||||||
|
width: 30,
|
||||||
|
isImageBase64: true,
|
||||||
|
),
|
||||||
|
16.width,
|
||||||
|
Expanded(
|
||||||
|
child: (replacement.employeeDisplayName ?? "").toText12(),
|
||||||
|
),
|
||||||
|
Icon(Icons.star,
|
||||||
|
size: 16,
|
||||||
|
color: replacement.isFavorite!
|
||||||
|
? MyColors.yellowFavColor
|
||||||
|
: MyColors.borderCEColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget radioOption(String title, int value, int groupValue) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.transparent,
|
||||||
|
border: Border.all(color: MyColors.borderColor, width: 1),
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
Radius.circular(100),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(4),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: value == groupValue
|
||||||
|
? MyColors.grey3AColor
|
||||||
|
: Colors.transparent,
|
||||||
|
borderRadius: const BorderRadius.all(
|
||||||
|
Radius.circular(100),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
9.width,
|
||||||
|
title.toText12(color: MyColors.grey57Color)
|
||||||
|
],
|
||||||
|
).onPress(() {
|
||||||
|
_selectedSearchIndex = value;
|
||||||
|
setState(() {});
|
||||||
|
}).expanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
void createGroup() async {
|
||||||
|
RegExp validCharacters = RegExp(r'^[a-zA-Z0-9_\-=@,\.;]+$');
|
||||||
|
if (!validCharacters.hasMatch(groupName)) {
|
||||||
|
Utils.showToast("Please enter valid group Name");
|
||||||
|
} else if (groupName.length < 10) {
|
||||||
|
Utils.showToast("Group name should be minimum 10 character long");
|
||||||
|
} else {
|
||||||
|
List<ChatUser>? mainUsers = [];
|
||||||
|
ChatUser admin =
|
||||||
|
ChatUser.fromJson(AppState().chatDetails!.response!.toJson());
|
||||||
|
admin.isAdmin = true;
|
||||||
|
admin.userStatus = 2;
|
||||||
|
admin.unreadMessageCount = 0;
|
||||||
|
admin.totalCount = 0;
|
||||||
|
mainUsers.add(admin);
|
||||||
|
CreateGroupRequest request = CreateGroupRequest(
|
||||||
|
groupUserList: [...selectedUsers, ...mainUsers].toList(),
|
||||||
|
canArchive: false,
|
||||||
|
isMeeting: false,
|
||||||
|
canShareS: isShareScreen,
|
||||||
|
canAudioC: isAudioCall,
|
||||||
|
canAttach: isAttachments,
|
||||||
|
canVideoC: isVideoCall,
|
||||||
|
groupName: groupName,
|
||||||
|
adminUserId: AppState().chatDetails!.response!.id);
|
||||||
|
|
||||||
|
if(widget.groupDetails!.groupId !=null){
|
||||||
|
request.groupId =widget.groupDetails!.groupId;
|
||||||
|
await provider.updateGroupAndUsers(request);
|
||||||
|
}else {
|
||||||
|
await provider.addGroupAndUsers(request);
|
||||||
|
}
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:intl/intl.dart' as intl;
|
||||||
|
|
||||||
|
class CustomAutoDirection extends StatefulWidget {
|
||||||
|
final String text;
|
||||||
|
final Widget child;
|
||||||
|
final void Function(bool isRTL)? onDirectionChange;
|
||||||
|
|
||||||
|
const CustomAutoDirection({Key? key, required this.text, required this.child, this.onDirectionChange}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_CustomAutoDirectionState createState() => _CustomAutoDirectionState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CustomAutoDirectionState extends State<CustomAutoDirection> {
|
||||||
|
late String text;
|
||||||
|
late Widget childWidget;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
text = widget.text;
|
||||||
|
childWidget = widget.child;
|
||||||
|
return Directionality(textDirection: isRTL(text) ? TextDirection.rtl : TextDirection.ltr, child: childWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(CustomAutoDirection oldWidget) {
|
||||||
|
if (isRTL(oldWidget.text) != isRTL(widget.text)) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) => widget.onDirectionChange?.call(isRTL(widget.text)));
|
||||||
|
}
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isRTL(String text) {
|
||||||
|
if (text.isEmpty) return Directionality.of(context) == TextDirection.rtl;
|
||||||
|
return intl.Bidi.detectRtlDirectionality(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,643 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'dart:typed_data';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:just_audio/just_audio.dart';
|
||||||
|
import 'package:mohem_flutter_app/api/chat/chat_api_client.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/my_custom_stream.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/main.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_group_chat_history.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/chat_full_image_preview.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/common.dart';
|
||||||
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:rxdart/rxdart.dart';
|
||||||
|
|
||||||
|
class GroupChatBubble extends StatelessWidget {
|
||||||
|
GroupChatBubble({Key? key, required this.dateTime, required this.cItem})
|
||||||
|
: super(key: key);
|
||||||
|
final String dateTime;
|
||||||
|
final GetGroupChatHistoryAsync cItem;
|
||||||
|
|
||||||
|
bool isCurrentUser = false;
|
||||||
|
|
||||||
|
bool isSeen = false;
|
||||||
|
|
||||||
|
bool isReplied = false;
|
||||||
|
|
||||||
|
bool isVoice = false;
|
||||||
|
|
||||||
|
int? fileTypeID;
|
||||||
|
|
||||||
|
String? fileTypeName;
|
||||||
|
|
||||||
|
late ChatProviderModel provider;
|
||||||
|
|
||||||
|
String? fileTypeDescription;
|
||||||
|
|
||||||
|
bool isDelivered = false;
|
||||||
|
|
||||||
|
String userName = '';
|
||||||
|
|
||||||
|
late Offset screenOffset;
|
||||||
|
|
||||||
|
void makeAssign() {
|
||||||
|
isCurrentUser = cItem.currentUserId == AppState().chatDetails!.response!.id
|
||||||
|
? true
|
||||||
|
: false;
|
||||||
|
isSeen = cItem.isSeen == true ? true : false;
|
||||||
|
isReplied = cItem.groupChatReplyResponse != null ? true : false;
|
||||||
|
// isVoice = cItem.fileTypeId == 13 && cItem.voiceController != null ? true : false;
|
||||||
|
fileTypeID = cItem.fileTypeId;
|
||||||
|
fileTypeName = cItem.fileTypeResponse != null
|
||||||
|
? cItem.fileTypeResponse!.fileTypeName
|
||||||
|
: "";
|
||||||
|
fileTypeDescription = cItem.fileTypeResponse != null
|
||||||
|
? cItem.fileTypeResponse!.fileTypeDescription
|
||||||
|
: "";
|
||||||
|
isDelivered = cItem.currentUserId == AppState().chatDetails!.response!.id &&
|
||||||
|
cItem.isDelivered == true
|
||||||
|
? true
|
||||||
|
: false;
|
||||||
|
userName = AppState().chatDetails!.response!.userName ==
|
||||||
|
cItem.currentUserName.toString()
|
||||||
|
? "You"
|
||||||
|
: cItem.currentUserName.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void playVoice(
|
||||||
|
BuildContext context, {
|
||||||
|
required SingleUserChatModel data,
|
||||||
|
}) async {
|
||||||
|
if (data.voice != null && data.voice!.existsSync()) {
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
Duration? duration = await data.voiceController!
|
||||||
|
.setAudioSource(MyCustomStream(data.voice!.readAsBytesSync()));
|
||||||
|
await data.voiceController!.seek(duration);
|
||||||
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
||||||
|
await data.voiceController!.setVolume(1.0);
|
||||||
|
await data.voiceController!.load();
|
||||||
|
data.voiceController!.play();
|
||||||
|
} else {
|
||||||
|
await data.voiceController!.setFilePath(data!.voice!.path);
|
||||||
|
Duration? duration = await data.voiceController!.load();
|
||||||
|
await data.voiceController!.seek(duration);
|
||||||
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
||||||
|
await data.voiceController!.play();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Utils.showLoading(context);
|
||||||
|
Uint8List encodedString = await ChatApiClient().downloadURL(
|
||||||
|
fileName: data.contant!,
|
||||||
|
fileTypeDescription: provider.getFileTypeDescription(
|
||||||
|
data.fileTypeResponse!.fileTypeName ?? ""));
|
||||||
|
// try {
|
||||||
|
File sFile = await provider.downChatVoice(
|
||||||
|
encodedString, data.fileTypeResponse!.fileTypeName ?? "", data);
|
||||||
|
if (sFile.path.isEmpty) {
|
||||||
|
logger.d("Path Is Emptyyyyyyy");
|
||||||
|
} else {
|
||||||
|
logger.d("Path Exsists");
|
||||||
|
}
|
||||||
|
data.voice = sFile;
|
||||||
|
if (Platform.isIOS) {
|
||||||
|
logger.d("isIOS");
|
||||||
|
Duration? duration = await data.voiceController!
|
||||||
|
.setAudioSource(MyCustomStream(data.voice!.readAsBytesSync()));
|
||||||
|
await data.voiceController!.seek(duration);
|
||||||
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
||||||
|
await data.voiceController!.setVolume(1.0);
|
||||||
|
await data.voiceController!.load();
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
data.voiceController!.play();
|
||||||
|
} else {
|
||||||
|
Duration? duration =
|
||||||
|
await data.voiceController!.setFilePath(sFile.path);
|
||||||
|
await data.voiceController!.setLoopMode(LoopMode.off);
|
||||||
|
await data.voiceController!.seek(duration);
|
||||||
|
Utils.hideLoading(context);
|
||||||
|
await data.voiceController!.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pausePlaying(BuildContext context,
|
||||||
|
{required SingleUserChatModel data}) async {
|
||||||
|
await data.voiceController!.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rePlay(BuildContext context, {required SingleUserChatModel data}) async {
|
||||||
|
if (data.voice != null && data.voice!.existsSync()) {
|
||||||
|
await data.voiceController!.seek(Duration.zero);
|
||||||
|
await data.voiceController!.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<PositionData> get _positionDataStream =>
|
||||||
|
Rx.combineLatest3<Duration, Duration, Duration?, PositionData>(
|
||||||
|
cItem.voiceController!.positionStream,
|
||||||
|
cItem.voiceController!.bufferedPositionStream,
|
||||||
|
cItem.voiceController!.durationStream,
|
||||||
|
(Duration position, Duration bufferedPosition, Duration? duration) =>
|
||||||
|
PositionData(
|
||||||
|
position, bufferedPosition, duration ?? Duration.zero));
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size windowSize = MediaQuery.of(context).size;
|
||||||
|
screenOffset = Offset(windowSize.width / 2, windowSize.height / 2);
|
||||||
|
makeAssign();
|
||||||
|
provider = Provider.of<ChatProviderModel>(context, listen: false);
|
||||||
|
return isCurrentUser ? currentUser(context) : receiptUser(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget currentUser(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (isReplied)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 6,
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.gradiantStartColor
|
||||||
|
: MyColors.white),
|
||||||
|
),
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.black.withOpacity(0.10)
|
||||||
|
: MyColors.black.withOpacity(0.30),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
(userName)
|
||||||
|
.toText12(
|
||||||
|
color: MyColors.gradiantStartColor, isBold: false)
|
||||||
|
.paddingOnly(right: 5, top: 5, bottom: 0, left: 5),
|
||||||
|
Directionality(
|
||||||
|
textDirection: provider.getTextDirection(
|
||||||
|
cItem.groupChatReplyResponse != null
|
||||||
|
? cItem.groupChatReplyResponse!.contant
|
||||||
|
.toString()
|
||||||
|
: ""),
|
||||||
|
child: (cItem.groupChatReplyResponse != null
|
||||||
|
? cItem.groupChatReplyResponse!.contant
|
||||||
|
.toString()
|
||||||
|
: "")
|
||||||
|
.toText10(
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.grey71Color
|
||||||
|
: MyColors.white.withOpacity(0.5),
|
||||||
|
isBold: false,
|
||||||
|
maxlines: 4)
|
||||||
|
.paddingOnly(right: 5, top: 5, bottom: 8, left: 5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
if (cItem.groupChatReplyResponse != null)
|
||||||
|
if (cItem.groupChatReplyResponse!.fileTypeId == 12 ||
|
||||||
|
cItem.groupChatReplyResponse!.fileTypeId == 3 ||
|
||||||
|
cItem.groupChatReplyResponse!.fileTypeId == 4)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
child: showImage(
|
||||||
|
isReplyPreview: false,
|
||||||
|
fileName:
|
||||||
|
cItem.groupChatReplyResponse!.contant!,
|
||||||
|
fileTypeDescription: cItem
|
||||||
|
.groupChatReplyResponse!
|
||||||
|
.fileTypeResponse!
|
||||||
|
.fileTypeDescription ??
|
||||||
|
"image/jpg")),
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 16, top: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).paddingOnly(bottom: 7).onPress(() {
|
||||||
|
// provider.scrollToMsg(cItem);
|
||||||
|
}),
|
||||||
|
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 140,
|
||||||
|
width: 227,
|
||||||
|
child: showImage(
|
||||||
|
isReplyPreview: false,
|
||||||
|
fileName: cItem.contant!,
|
||||||
|
fileTypeDescription:
|
||||||
|
cItem.fileTypeResponse!.fileTypeDescription)
|
||||||
|
.onPress(() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
anchorPoint: screenOffset,
|
||||||
|
builder: (BuildContext context) => ChatImagePreviewScreen(
|
||||||
|
imgTitle: cItem.contant!, img: cItem.image!),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).paddingOnly(bottom: 4),
|
||||||
|
if (fileTypeID == 13 && cItem.voiceController != null)
|
||||||
|
currentWaveBubble(context, cItem)
|
||||||
|
else
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
if (fileTypeID == 1 ||
|
||||||
|
fileTypeID == 5 ||
|
||||||
|
fileTypeID == 7 ||
|
||||||
|
fileTypeID == 6 ||
|
||||||
|
fileTypeID == 8
|
||||||
|
// || fileTypeID == 2
|
||||||
|
)
|
||||||
|
SvgPicture.asset(provider.getType(fileTypeName ?? ""),
|
||||||
|
height: 30,
|
||||||
|
width: 22,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
fit: BoxFit.cover)
|
||||||
|
.paddingOnly(left: 0, right: 10),
|
||||||
|
Directionality(
|
||||||
|
textDirection: provider.getTextDirection(cItem.contant ?? ""),
|
||||||
|
child: (cItem.contant ?? "").toText12().expanded),
|
||||||
|
if (fileTypeID == 1 ||
|
||||||
|
fileTypeID == 5 ||
|
||||||
|
fileTypeID == 7 ||
|
||||||
|
fileTypeID == 6 ||
|
||||||
|
fileTypeID == 8
|
||||||
|
//|| fileTypeID == 2
|
||||||
|
)
|
||||||
|
const Icon(Icons.remove_red_eye, size: 16)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
dateTime.toText10(
|
||||||
|
color: MyColors.grey41Color.withOpacity(.5),
|
||||||
|
),
|
||||||
|
7.width,
|
||||||
|
Icon(isDelivered ? Icons.done_all : Icons.done_all,
|
||||||
|
color: isSeen ? MyColors.textMixColor : MyColors.grey9DColor,
|
||||||
|
size: 14),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.paddingOnly(top: 11, left: 13, right: 13, bottom: 5)
|
||||||
|
.objectContainerView(disablePadding: true)
|
||||||
|
.paddingOnly(left: MediaQuery.of(context).size.width * 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget receiptUser(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.only(top: 5, left: 8, right: 13, bottom: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
transform: GradientRotation(.83),
|
||||||
|
begin: Alignment.topRight,
|
||||||
|
end: Alignment.bottomLeft,
|
||||||
|
colors: <Color>[
|
||||||
|
MyColors.gradiantEndColor,
|
||||||
|
MyColors.gradiantStartColor
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
|
if (isReplied)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 6,
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.gradiantStartColor
|
||||||
|
: MyColors.white)),
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.black.withOpacity(0.10)
|
||||||
|
: MyColors.black.withOpacity(0.30),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
(userName)
|
||||||
|
.toText12(
|
||||||
|
color: MyColors.gradiantStartColor,
|
||||||
|
isBold: false)
|
||||||
|
.paddingOnly(right: 5, top: 5, bottom: 0, left: 5),
|
||||||
|
Directionality(
|
||||||
|
textDirection: provider.getTextDirection(
|
||||||
|
cItem.groupChatReplyResponse != null
|
||||||
|
? cItem.groupChatReplyResponse!.contant
|
||||||
|
.toString()
|
||||||
|
: ""),
|
||||||
|
child: (cItem.groupChatReplyResponse != null
|
||||||
|
? cItem.groupChatReplyResponse!.contant
|
||||||
|
.toString()
|
||||||
|
: "")
|
||||||
|
.toText10(
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.grey71Color
|
||||||
|
: MyColors.white.withOpacity(0.5),
|
||||||
|
isBold: false,
|
||||||
|
maxlines: 4)
|
||||||
|
.paddingOnly(
|
||||||
|
right: 5, top: 5, bottom: 8, left: 5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
if (cItem.groupChatReplyResponse != null)
|
||||||
|
if (cItem.groupChatReplyResponse!.fileTypeId == 12 ||
|
||||||
|
cItem.groupChatReplyResponse!.fileTypeId == 3 ||
|
||||||
|
cItem.groupChatReplyResponse!.fileTypeId == 4)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 32,
|
||||||
|
width: 32,
|
||||||
|
child: showImage(
|
||||||
|
isReplyPreview: true,
|
||||||
|
fileName:
|
||||||
|
cItem.groupChatReplyResponse!.contant!,
|
||||||
|
fileTypeDescription: cItem
|
||||||
|
.groupChatReplyResponse!
|
||||||
|
.fileTypeResponse!
|
||||||
|
.fileTypeDescription ??
|
||||||
|
"image/jpg"),
|
||||||
|
),
|
||||||
|
).paddingOnly(left: 10, right: 10, bottom: 16, top: 16)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
).paddingOnly(bottom: 7).onPress(() {
|
||||||
|
// provider.scrollToMsg(cItem);
|
||||||
|
}),
|
||||||
|
if (fileTypeID == 12 || fileTypeID == 4 || fileTypeID == 3)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 140,
|
||||||
|
width: 227,
|
||||||
|
child: showImage(
|
||||||
|
isReplyPreview: false,
|
||||||
|
fileName: cItem.contant ?? "",
|
||||||
|
fileTypeDescription:
|
||||||
|
cItem.fileTypeResponse!.fileTypeDescription ??
|
||||||
|
"image/jpg")
|
||||||
|
.onPress(() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
anchorPoint: screenOffset,
|
||||||
|
builder: (BuildContext context) => ChatImagePreviewScreen(
|
||||||
|
imgTitle: cItem.contant ?? "", img: cItem.image!),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
).paddingOnly(bottom: 4),
|
||||||
|
if (fileTypeID == 13 && cItem.voiceController != null)
|
||||||
|
recipetWaveBubble(context, cItem)
|
||||||
|
else
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
cItem.currentUserName!.toText10(
|
||||||
|
color: Colors.black,
|
||||||
|
).paddingOnly(bottom: 5),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
if (fileTypeID == 1 ||
|
||||||
|
fileTypeID == 5 ||
|
||||||
|
fileTypeID == 7 ||
|
||||||
|
fileTypeID == 6 ||
|
||||||
|
fileTypeID == 8
|
||||||
|
// || fileTypeID == 2
|
||||||
|
)
|
||||||
|
SvgPicture.asset(provider.getType(fileTypeName ?? ""),
|
||||||
|
height: 30,
|
||||||
|
width: 22,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
fit: BoxFit.cover)
|
||||||
|
.paddingOnly(left: 0, right: 10),
|
||||||
|
Directionality(
|
||||||
|
textDirection:
|
||||||
|
provider.getTextDirection(cItem.contant ?? ""),
|
||||||
|
child: (cItem.contant ?? "")
|
||||||
|
.toText12(color: Colors.white)
|
||||||
|
.expanded),
|
||||||
|
if (fileTypeID == 1 ||
|
||||||
|
fileTypeID == 5 ||
|
||||||
|
fileTypeID == 7 ||
|
||||||
|
fileTypeID == 6 ||
|
||||||
|
fileTypeID == 8
|
||||||
|
//|| fileTypeID == 2
|
||||||
|
)
|
||||||
|
const Icon(Icons.remove_red_eye,
|
||||||
|
color: Colors.white, size: 16)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.topRight,
|
||||||
|
child: dateTime.toText10(
|
||||||
|
color: Colors.white.withOpacity(.71),
|
||||||
|
).paddingOnly(top:5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
])).paddingOnly(right: MediaQuery.of(context).size.width * 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget voiceMsg(BuildContext context) {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget showImage(
|
||||||
|
{required bool isReplyPreview,
|
||||||
|
required String fileName,
|
||||||
|
required String fileTypeDescription}) {
|
||||||
|
if (cItem.isImageLoaded! && cItem.image != null) {
|
||||||
|
return Image.memory(
|
||||||
|
cItem.image!,
|
||||||
|
height: isReplyPreview ? 32 : 140,
|
||||||
|
width: isReplyPreview ? 32 : 227,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return FutureBuilder<Uint8List>(
|
||||||
|
future: ChatApiClient().downloadURL(
|
||||||
|
fileName: fileName, fileTypeDescription: fileTypeDescription),
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState != ConnectionState.waiting) {
|
||||||
|
if (snapshot.data == null) {
|
||||||
|
return const SizedBox();
|
||||||
|
} else {
|
||||||
|
cItem.image = snapshot.data;
|
||||||
|
cItem.isImageLoaded = true;
|
||||||
|
return Image.memory(
|
||||||
|
snapshot.data,
|
||||||
|
height: isReplyPreview ? 32 : 140,
|
||||||
|
width: isReplyPreview ? 32 : 227,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return SizedBox(
|
||||||
|
height: isReplyPreview ? 32 : 140,
|
||||||
|
width: isReplyPreview ? 32 : 227,
|
||||||
|
).toShimmer();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget currentWaveBubble(
|
||||||
|
BuildContext context, GetGroupChatHistoryAsync data) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.all(0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 6,
|
||||||
|
color:
|
||||||
|
isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
|
||||||
|
),
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.black.withOpacity(0.10)
|
||||||
|
: MyColors.black.withOpacity(0.30),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
//need to check and verify for group hence for now commented
|
||||||
|
// getPlayer(player: data.voiceController!, modelData: data),
|
||||||
|
StreamBuilder<PositionData>(
|
||||||
|
stream: _positionDataStream,
|
||||||
|
builder:
|
||||||
|
(BuildContext context, AsyncSnapshot<PositionData> snapshot) {
|
||||||
|
PositionData? positionData = snapshot.data;
|
||||||
|
return SeekBar(
|
||||||
|
duration: positionData?.duration ?? Duration.zero,
|
||||||
|
position: positionData?.position ?? Duration.zero,
|
||||||
|
bufferedPosition:
|
||||||
|
positionData?.bufferedPosition ?? Duration.zero,
|
||||||
|
onChangeEnd: data.voiceController!.seek,
|
||||||
|
).expanded;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).circle(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget recipetWaveBubble(
|
||||||
|
BuildContext context, GetGroupChatHistoryAsync data) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.all(0),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border(
|
||||||
|
left: BorderSide(
|
||||||
|
width: 6,
|
||||||
|
color:
|
||||||
|
isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
|
||||||
|
),
|
||||||
|
color: isCurrentUser
|
||||||
|
? MyColors.black.withOpacity(0.10)
|
||||||
|
: MyColors.black.withOpacity(0.30),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
//commented to verify after
|
||||||
|
//getPlayer(player: data.voiceController!, modelData: data),
|
||||||
|
StreamBuilder<PositionData>(
|
||||||
|
stream: _positionDataStream,
|
||||||
|
builder:
|
||||||
|
(BuildContext context, AsyncSnapshot<PositionData> snapshot) {
|
||||||
|
PositionData? positionData = snapshot.data;
|
||||||
|
return SeekBar(
|
||||||
|
duration: positionData?.duration ?? Duration.zero,
|
||||||
|
position: positionData?.position ?? Duration.zero,
|
||||||
|
bufferedPosition:
|
||||||
|
positionData?.bufferedPosition ?? Duration.zero,
|
||||||
|
onChangeEnd: data.voiceController!.seek,
|
||||||
|
).expanded;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).circle(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getPlayer(
|
||||||
|
{required AudioPlayer player, required SingleUserChatModel modelData}) {
|
||||||
|
return StreamBuilder<PlayerState>(
|
||||||
|
stream: player.playerStateStream,
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<PlayerState> snapshot) {
|
||||||
|
PlayerState? playerState = snapshot.data;
|
||||||
|
ProcessingState? processingState = playerState?.processingState;
|
||||||
|
bool? playing = playerState?.playing;
|
||||||
|
if (processingState == ProcessingState.loading ||
|
||||||
|
processingState == ProcessingState.buffering) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.all(8.0),
|
||||||
|
width: 30.0,
|
||||||
|
height: 30.0,
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
} else if (playing != true) {
|
||||||
|
return const Icon(
|
||||||
|
Icons.play_arrow,
|
||||||
|
size: 30,
|
||||||
|
color: MyColors.lightGreenColor,
|
||||||
|
).onPress(() {
|
||||||
|
playVoice(context, data: modelData);
|
||||||
|
});
|
||||||
|
} else if (processingState != ProcessingState.completed) {
|
||||||
|
return const Icon(
|
||||||
|
Icons.pause,
|
||||||
|
size: 30,
|
||||||
|
color: MyColors.lightGreenColor,
|
||||||
|
).onPress(() {
|
||||||
|
pausePlaying(context, data: modelData);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return const Icon(
|
||||||
|
Icons.replay,
|
||||||
|
size: 30,
|
||||||
|
color: MyColors.lightGreenColor,
|
||||||
|
).onPress(() {
|
||||||
|
rePlay(context, data: modelData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,384 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:audio_waveforms/audio_waveforms.dart';
|
||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/main.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/call.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_group_chat_history.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_single_user_chat_list_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_user_groups_by_id.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/chat_call_provider.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/custom_auto_direction.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/call/chat_outgoing_call_screen.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/chat_bubble.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/common.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/group_chat_bubble.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/chat_app_bar_widge.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||||
|
import 'package:signalr_netcore/signalr_client.dart';
|
||||||
|
import 'package:swipe_to/swipe_to.dart';
|
||||||
|
|
||||||
|
class GroupChatDetailedScreenParams {
|
||||||
|
GroupResponse? groupChatDetails;
|
||||||
|
bool? isNewChat;
|
||||||
|
|
||||||
|
GroupChatDetailedScreenParams(this.groupChatDetails, this.isNewChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
class GroupChatDetailScreen extends StatefulWidget {
|
||||||
|
const GroupChatDetailScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<GroupChatDetailScreen> createState() => _GroupChatDetailScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GroupChatDetailScreenState extends State<GroupChatDetailScreen> {
|
||||||
|
final RefreshController _rc = RefreshController(initialRefresh: false);
|
||||||
|
late ChatProviderModel data;
|
||||||
|
late ChatCallProvider callPro;
|
||||||
|
GroupChatDetailedScreenParams? params;
|
||||||
|
|
||||||
|
// var textDirection = TextDirection.RTL;
|
||||||
|
|
||||||
|
void getMoreChat() async {
|
||||||
|
if (params != null) {
|
||||||
|
data.paginationVal = data.paginationVal + 10;
|
||||||
|
if (params != null) {
|
||||||
|
data.getGroupChatHistory(params!.groupChatDetails!
|
||||||
|
// senderUID: AppState().chatDetails!.response!.id!.toInt(),
|
||||||
|
// receiverUID: params!.groupChatDetails!.groupId!,
|
||||||
|
// loadMore: true,
|
||||||
|
// isNewChat: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Future.delayed(
|
||||||
|
const Duration(milliseconds: 1000),
|
||||||
|
);
|
||||||
|
_rc.loadComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
data.disposeAudio();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
params = ModalRoute.of(context)!.settings.arguments as GroupChatDetailedScreenParams;
|
||||||
|
data = Provider.of<ChatProviderModel>(context, listen: false);
|
||||||
|
// callPro = Provider.of<ChatCallProvider>(context, listen: false);
|
||||||
|
if (params != null) {
|
||||||
|
data.getGroupChatHistory(
|
||||||
|
params!.groupChatDetails!
|
||||||
|
// senderUID: AppState().chatDetails!.response!.id!.toInt(),
|
||||||
|
// receiverUID: params!.groupChatHistory!.groupId!,
|
||||||
|
// loadMore: false,
|
||||||
|
// isNewChat: params!.isNewChat!,
|
||||||
|
);
|
||||||
|
data.initAudio(receiverId: params!.groupChatDetails!.groupId!);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: MyColors.backgroundColor,
|
||||||
|
appBar: ChatAppBarWidget(
|
||||||
|
context,
|
||||||
|
title: params!.groupChatDetails!.groupName.toString().replaceAll(".", " ").capitalizeFirstofEach,
|
||||||
|
showHomeButton: false,
|
||||||
|
// showTyping: true,
|
||||||
|
// chatUser: params!.groupChatHistory!.groupChatHistoryTargetUserList as ChatUser,
|
||||||
|
actions: [
|
||||||
|
// SvgPicture.asset("assets/icons/chat/call.svg", width: 21, height: 23).onPress(() {
|
||||||
|
// makeCall(callType: "AUDIO");
|
||||||
|
// }),
|
||||||
|
// 24.width,
|
||||||
|
// SvgPicture.asset("assets/icons/chat/video_call.svg", width: 21, height: 18).onPress(() {
|
||||||
|
// makeCall(callType: "VIDEO");
|
||||||
|
// }),
|
||||||
|
// 21.width,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Consumer<ChatProviderModel>(
|
||||||
|
builder: (BuildContext context, ChatProviderModel m, Widget? child) {
|
||||||
|
return (m.isLoading
|
||||||
|
? ChatHomeShimmer(
|
||||||
|
isDetailedScreen: true,
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SmartRefresher(
|
||||||
|
enablePullDown: false,
|
||||||
|
enablePullUp: true,
|
||||||
|
onLoading: () {
|
||||||
|
getMoreChat();
|
||||||
|
},
|
||||||
|
header: const MaterialClassicHeader(
|
||||||
|
color: MyColors.gradiantEndColor,
|
||||||
|
),
|
||||||
|
controller: _rc,
|
||||||
|
reverse: true,
|
||||||
|
child: ListView.separated(
|
||||||
|
controller: m.scrollController,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
reverse: true,
|
||||||
|
itemCount: m.groupChatHistory.length,
|
||||||
|
padding: const EdgeInsets.all(21),
|
||||||
|
separatorBuilder: (BuildContext cxt, int index) => 8.height,
|
||||||
|
itemBuilder: (BuildContext context, int i) {
|
||||||
|
return SwipeTo(
|
||||||
|
iconColor: MyColors.lightGreenColor,
|
||||||
|
child: GroupChatBubble(
|
||||||
|
dateTime: m.groupChatHistory[i].createdDate!,
|
||||||
|
cItem: m.groupChatHistory[i],
|
||||||
|
),
|
||||||
|
onRightSwipe: () {
|
||||||
|
// m.chatReply(
|
||||||
|
// m.groupChatHistory[i],
|
||||||
|
// );
|
||||||
|
},
|
||||||
|
).onPress(() async {
|
||||||
|
logger.w(m.userChatHistory[i].toJson());
|
||||||
|
if (m.userChatHistory[i].fileTypeResponse != null && m.userChatHistory[i].fileTypeId != null) {
|
||||||
|
if (m.userChatHistory[i].fileTypeId! == 1 ||
|
||||||
|
m.userChatHistory[i].fileTypeId! == 5 ||
|
||||||
|
m.userChatHistory[i].fileTypeId! == 7 ||
|
||||||
|
m.userChatHistory[i].fileTypeId! == 6 ||
|
||||||
|
m.userChatHistory[i].fileTypeId! == 8
|
||||||
|
// || m.userChatHistory[i].fileTypeId! == 2
|
||||||
|
) {
|
||||||
|
m.getChatMedia(context,
|
||||||
|
fileTypeName: m.userChatHistory[i].fileTypeResponse!.fileTypeName ?? "", fileTypeID: m.userChatHistory[i].fileTypeId!, fileName: m.userChatHistory[i].contant!);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
).expanded,
|
||||||
|
if (m.isReplyMsg)
|
||||||
|
SizedBox(
|
||||||
|
height: 82,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(height: 82, color: MyColors.textMixColor, width: 6),
|
||||||
|
Container(
|
||||||
|
color: MyColors.darkTextColor.withOpacity(0.10),
|
||||||
|
padding: const EdgeInsets.only(top: 11, left: 14, bottom: 14, right: 21),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
(AppState().chatDetails!.response!.userName == m.repliedMsg.first.currentUserName.toString()
|
||||||
|
? "You"
|
||||||
|
: m.repliedMsg.first.currentUserName.toString().replaceAll(".", " "))
|
||||||
|
.toText14(color: MyColors.lightGreenColor),
|
||||||
|
(m.repliedMsg.isNotEmpty ? m.repliedMsg.first.contant! : "").toText12(color: MyColors.grey71Color, maxLine: 2)
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
12.width,
|
||||||
|
if (m.isReplyMsg && m.repliedMsg.isNotEmpty) showReplyImage(m.repliedMsg, m),
|
||||||
|
12.width,
|
||||||
|
const Icon(Icons.cancel, size: 23, color: MyColors.grey7BColor).onPress(m.closeMe),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).expanded,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (m.isAttachmentMsg && m.sFileType == ".png" || m.sFileType == ".jpeg" || m.sFileType == ".jpg")
|
||||||
|
SizedBox(height: 200, width: double.infinity, child: Image.file(m.selectedFile, fit: BoxFit.cover)).paddingOnly(left: 21, right: 21, top: 21),
|
||||||
|
const Divider(height: 1, color: MyColors.lightGreyEFColor),
|
||||||
|
if (m.isRecoding)
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(m.buildTimer()).paddingAll(10),
|
||||||
|
if (m.isRecoding && m.isPlaying)
|
||||||
|
WaveBubble(
|
||||||
|
playerController: m.playerController,
|
||||||
|
isPlaying: m.playerController.playerState == PlayerState.playing,
|
||||||
|
onTap: () {},
|
||||||
|
).expanded
|
||||||
|
else
|
||||||
|
AudioWaveforms(
|
||||||
|
waveStyle: const WaveStyle(
|
||||||
|
waveColor: MyColors.lightGreenColor,
|
||||||
|
middleLineColor: Colors.transparent,
|
||||||
|
extendWaveform: true,
|
||||||
|
showBottom: true,
|
||||||
|
showTop: true,
|
||||||
|
waveThickness: 2,
|
||||||
|
showMiddleLine: false,
|
||||||
|
middleLineThickness: 0,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(5),
|
||||||
|
shouldCalculateScrolledPosition: false,
|
||||||
|
margin: EdgeInsets.zero,
|
||||||
|
size: const Size(double.infinity, 30.0),
|
||||||
|
recorderController: m.recorderController,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
).expanded,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.delete_outlined,
|
||||||
|
size: 26,
|
||||||
|
color: MyColors.lightGreenColor,
|
||||||
|
).paddingAll(10).onPress(() {
|
||||||
|
m.deleteRecoding();
|
||||||
|
}),
|
||||||
|
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
|
||||||
|
.onPress(
|
||||||
|
() => m.sendChatMessage(context,
|
||||||
|
targetUserId: params!.groupChatDetails!.groupId!,
|
||||||
|
userStatus: 0,
|
||||||
|
userEmail: "",
|
||||||
|
targetUserName: params!.groupChatDetails!.groupName!),
|
||||||
|
)
|
||||||
|
.paddingOnly(right: 21),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).objectContainerView(disablePadding: true, radius: 0),
|
||||||
|
if (!m.isRecoding)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
CustomAutoDirection(
|
||||||
|
onDirectionChange: (bool isRTL) => m.onDirectionChange(isRTL),
|
||||||
|
text: m.msgText,
|
||||||
|
child: TextField(
|
||||||
|
// textDirection: m.textDirection,
|
||||||
|
controller: m.message,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintTextDirection: m.textDirection,
|
||||||
|
hintText: m.isAttachmentMsg ? m.selectedFile.path.split("/").last : LocaleKeys.typeheretoreply.tr(),
|
||||||
|
hintStyle: TextStyle(color: m.isAttachmentMsg ? MyColors.darkTextColor : MyColors.grey98Color, fontSize: 14),
|
||||||
|
border: InputBorder.none,
|
||||||
|
focusedBorder: InputBorder.none,
|
||||||
|
enabledBorder: InputBorder.none,
|
||||||
|
errorBorder: InputBorder.none,
|
||||||
|
disabledBorder: InputBorder.none,
|
||||||
|
filled: true,
|
||||||
|
fillColor: MyColors.white,
|
||||||
|
contentPadding: const EdgeInsets.only(
|
||||||
|
left: 21,
|
||||||
|
top: 20,
|
||||||
|
bottom: 20,
|
||||||
|
),
|
||||||
|
prefixIconConstraints: const BoxConstraints(),
|
||||||
|
prefixIcon: m.sFileType.isNotEmpty
|
||||||
|
? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 21, right: 15)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
onChanged: (String val) {
|
||||||
|
m.inputBoxDirection(val);
|
||||||
|
m.userTypingInvoke(currentUser: AppState().chatDetails!.response!.id!, reciptUser: params!.groupChatDetails!.groupId!);
|
||||||
|
},
|
||||||
|
).expanded,
|
||||||
|
),
|
||||||
|
if (m.sFileType.isNotEmpty)
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5),
|
||||||
|
("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0),
|
||||||
|
],
|
||||||
|
).onPress(() => m.removeAttachment()).paddingOnly(right: 15),
|
||||||
|
if (m.sFileType.isEmpty)
|
||||||
|
RotationTransition(
|
||||||
|
turns: const AlwaysStoppedAnimation(45 / 360),
|
||||||
|
child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress(
|
||||||
|
() => m.selectImageToUpload(context),
|
||||||
|
),
|
||||||
|
).paddingOnly(right: 15),
|
||||||
|
const Icon(
|
||||||
|
Icons.mic,
|
||||||
|
color: MyColors.lightGreenColor,
|
||||||
|
).paddingOnly(right: 15).onPress(() {
|
||||||
|
m.startRecoding(context);
|
||||||
|
}),
|
||||||
|
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26)
|
||||||
|
.onPress(
|
||||||
|
() =>m.sendGroupChatMessage(context,
|
||||||
|
targetUserId: params!.groupChatDetails!.groupId!,
|
||||||
|
userStatus: 0,
|
||||||
|
userEmail: "",
|
||||||
|
targetUserName: params!.groupChatDetails!.groupName!),
|
||||||
|
)
|
||||||
|
.paddingOnly(right: 21),
|
||||||
|
],
|
||||||
|
).objectContainerView(disablePadding: true, radius: 0),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget showReplyImage(List<SingleUserChatModel> data, ChatProviderModel m) {
|
||||||
|
if (data.first.isImageLoaded! && data.first.image != null) {
|
||||||
|
return Container(
|
||||||
|
width: 43,
|
||||||
|
height: 43,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), image: DecorationImage(image: MemoryImage(data.first.image!), fit: BoxFit.cover)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return data.first.fileTypeResponse != null && data.first.fileTypeResponse!.fileTypeName != null
|
||||||
|
? Container(
|
||||||
|
width: 43,
|
||||||
|
height: 43,
|
||||||
|
constraints: const BoxConstraints(),
|
||||||
|
decoration: BoxDecoration(border: Border.all(color: MyColors.darkGrey3BColor, width: 1), borderRadius: BorderRadius.circular(10.0), color: Colors.white),
|
||||||
|
child: SvgPicture.asset(m.getType(data.first.fileTypeResponse!.fileTypeName ?? ""), alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 5, right: 5, top: 5, bottom: 5))
|
||||||
|
: const SizedBox();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void makeCall({required String callType}) async {
|
||||||
|
callPro.initCallListeners();
|
||||||
|
print("================== Make call Triggered ============================");
|
||||||
|
// Map<String, dynamic> json = {
|
||||||
|
// "callerID": AppState().chatDetails!.response!.id!.toString(),
|
||||||
|
// "callerDetails": AppState().chatDetails!.toJson(),
|
||||||
|
// "receiverID": params!.chatUser!.id.toString(),
|
||||||
|
// "receiverDetails": params!.chatUser!.toJson(),
|
||||||
|
// "title": params!.chatUser!.userName!.replaceAll(".", " "),
|
||||||
|
// "calltype": callType == "VIDEO" ? "Video" : "Audio",
|
||||||
|
// };
|
||||||
|
logger.w(json);
|
||||||
|
// CallDataModel callData = CallDataModel.fromJson(json);
|
||||||
|
// await Navigator.push(
|
||||||
|
// context,
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (BuildContext context) => OutGoingCall(
|
||||||
|
// isVideoCall: callType == "VIDEO" ? true : false,
|
||||||
|
// outGoingCallData: callData,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ).then((value) {
|
||||||
|
// print("then");
|
||||||
|
// callPro.stopListeners();
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:mohem_flutter_app/config/routes.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_user_groups_by_id.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/chat_app_bar_widge.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
class GroupMembersScreen extends StatefulWidget {
|
||||||
|
|
||||||
|
const GroupMembersScreen({Key? key,}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<GroupMembersScreen> createState() => _GroupMembersScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GroupMembersScreenState extends State<GroupMembersScreen> {
|
||||||
|
late ChatProviderModel provider;
|
||||||
|
late List<GroupUserList> groupUserList;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
provider = Provider.of<ChatProviderModel>(context, listen: false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
groupUserList = ModalRoute.of(context)!.settings.arguments as List<GroupUserList>;
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: MyColors.white,
|
||||||
|
appBar: ChatAppBarWidget(
|
||||||
|
context,
|
||||||
|
title: LocaleKeys.groupMembers.tr(),
|
||||||
|
showHomeButton: false,
|
||||||
|
),
|
||||||
|
body:
|
||||||
|
groupUserList!.isNotEmpty ? ListView.separated(
|
||||||
|
itemCount: groupUserList!.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const ClampingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.only(bottom: 5.0),
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
if(groupUserList![index].id != AppState().chatDetails!.response!.id) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 55,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
|
||||||
|
Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
if (groupUserList![index].image == null)
|
||||||
|
SvgPicture.asset(
|
||||||
|
"assets/images/user.svg",
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 5,
|
||||||
|
bottom: 1,
|
||||||
|
child: Container(
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color:groupUserList![index].userStatus == 1
|
||||||
|
? MyColors.green2DColor
|
||||||
|
: Colors.red,
|
||||||
|
),
|
||||||
|
).circle(10),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
(groupUserList![index].userName! ?? "").toText14(
|
||||||
|
color: MyColors.darkTextColor).paddingOnly(
|
||||||
|
left: 11, top: 13),
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
|
||||||
|
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
IconButton(onPressed: (){
|
||||||
|
goToChat(groupUserList![index]);
|
||||||
|
}, icon: Icon(Icons.chat))
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) =>
|
||||||
|
const Divider(color: MyColors.lightGreyE5Color).paddingOnly(
|
||||||
|
left: 70),
|
||||||
|
).paddingAll(10)
|
||||||
|
: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Utils
|
||||||
|
.getNoDataWidget(context)
|
||||||
|
.expanded,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void goToChat(GroupUserList groupUser){
|
||||||
|
|
||||||
|
ChatUser chatUser = ChatUser.fromJson(groupUser.toJson());
|
||||||
|
Navigator.pushNamed(context,
|
||||||
|
AppRoutes.chatDetailed,
|
||||||
|
arguments:
|
||||||
|
ChatDetailedScreenParams(
|
||||||
|
chatUser,
|
||||||
|
false));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,142 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:mohem_flutter_app/app_state/app_state.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/models/chat/get_user_groups_by_id.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/utils.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/widgets/chat_app_bar_widge.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class ManageGroupScreen extends StatefulWidget {
|
||||||
|
const ManageGroupScreen({
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ManageGroupScreen> createState() => _ManageGroupScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ManageGroupScreenState extends State<ManageGroupScreen> {
|
||||||
|
late ChatProviderModel provider;
|
||||||
|
GroupResponse? groupDetails;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
provider = Provider.of<ChatProviderModel>(context, listen: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
groupDetails = ModalRoute.of(context)!.settings.arguments as GroupResponse;
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: MyColors.white,
|
||||||
|
appBar: ChatAppBarWidget(
|
||||||
|
context,
|
||||||
|
title: LocaleKeys.manageGroup.tr(),
|
||||||
|
showHomeButton: false,
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
LocaleKeys.admin
|
||||||
|
.tr()
|
||||||
|
.toText14(color: MyColors.darkTextColor)
|
||||||
|
.paddingOnly(right: 25)!,
|
||||||
|
groupDetails!.groupUserList!.isNotEmpty
|
||||||
|
? ListView.separated(
|
||||||
|
itemCount: groupDetails!.groupUserList!.length,
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const ClampingScrollPhysics(),
|
||||||
|
padding: const EdgeInsets.only(bottom: 5.0),
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 55,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
if (groupDetails!.groupUserList![index].image ==
|
||||||
|
null)
|
||||||
|
SvgPicture.asset(
|
||||||
|
"assets/images/user.svg",
|
||||||
|
height: 48,
|
||||||
|
width: 48,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 5,
|
||||||
|
bottom: 1,
|
||||||
|
child: Container(
|
||||||
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: groupDetails!.groupUserList![index]
|
||||||
|
.userStatus ==
|
||||||
|
1
|
||||||
|
? MyColors.green2DColor
|
||||||
|
: Colors.red,
|
||||||
|
),
|
||||||
|
).circle(10),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
(groupDetails!
|
||||||
|
.groupUserList![index].userName! ??
|
||||||
|
"")
|
||||||
|
.toText14(color: MyColors.darkTextColor)
|
||||||
|
.paddingOnly(left: 11, top: 13),
|
||||||
|
],
|
||||||
|
).expanded,
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Switch(
|
||||||
|
value: groupDetails!
|
||||||
|
.groupUserList![index].isAdmin!,
|
||||||
|
onChanged: groupDetails!
|
||||||
|
.groupUserList![index].id ==
|
||||||
|
AppState().chatDetails!.response!.id
|
||||||
|
? null
|
||||||
|
: (value) {
|
||||||
|
setState(() {
|
||||||
|
groupDetails!.groupUserList![index]
|
||||||
|
.isAdmin = value;
|
||||||
|
updateGroupAdmin(
|
||||||
|
groupDetails!.groupUserList!,
|
||||||
|
groupDetails!.groupId);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (BuildContext context, int index) =>
|
||||||
|
const Divider(color: MyColors.lightGreyE5Color)
|
||||||
|
.paddingOnly(left: 70),
|
||||||
|
).paddingAll(10)
|
||||||
|
: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Utils.getNoDataWidget(context).expanded,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateGroupAdmin(List<GroupUserList> groupUserList, int? groupId) async {
|
||||||
|
//Group id need to be updated..
|
||||||
|
provider.updateGroupAdmin(groupId, groupUserList);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
||||||
|
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
|
||||||
|
import 'package:mohem_flutter_app/provider/hmg_connection_provider.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class HmgConnectivityButton extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Provider.of<HmgConnectionProvider>(context, listen: false).checkHmgNetworkConnectivity();
|
||||||
|
return Consumer<HmgConnectionProvider>(
|
||||||
|
builder: (_, HmgConnectionProvider foo, __) {
|
||||||
|
return Container(
|
||||||
|
height: 45,
|
||||||
|
padding: const EdgeInsets.only(left: 12, right: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(200.0),
|
||||||
|
gradient: const LinearGradient(
|
||||||
|
transform: GradientRotation(.83),
|
||||||
|
begin: Alignment.topRight,
|
||||||
|
end: Alignment.bottomLeft,
|
||||||
|
colors: <Color>[
|
||||||
|
MyColors.gradiantEndColor,
|
||||||
|
MyColors.gradiantStartColor,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: (){
|
||||||
|
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.wifi,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
12.width,
|
||||||
|
LocaleKeys.connectHmgWifi.tr().toText18(color: Colors.white),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue