chat finalized.

design_3.0_cx_module
Sikander Saleem 2 weeks ago
parent c31771aaa7
commit 1f074b33e5

@ -88,36 +88,37 @@ class _ServiceRequestDetailMainState extends State<ServiceRequestDetailMain> {
Navigator.pop(context); Navigator.pop(context);
}, },
actions: [ actions: [
Selector<ServiceRequestDetailProvider, bool>( if (context.userProvider.isEngineer || context.userProvider.isNurse)
selector: (_, myModel) => myModel.isLoading, // Selects only the userName Selector<ServiceRequestDetailProvider, bool>(
builder: (_, isLoading, __) { selector: (_, myModel) => myModel.isLoading, // Selects only the userName
if (isLoading) { builder: (_, isLoading, __) {
return const SizedBox(); if (isLoading) {
} else { return const SizedBox();
ServiceRequestDetailProvider provider = Provider.of<ServiceRequestDetailProvider>(context, listen: false); } else {
int? statusValue = provider.currentWorkOrder?.data?.status?.value; ServiceRequestDetailProvider provider = Provider.of<ServiceRequestDetailProvider>(context, listen: false);
if (statusValue == 2 || statusValue == 3 || statusValue == 5 || statusValue == 6) { int? statusValue = provider.currentWorkOrder?.data?.status?.value;
getChatToken(moduleId, provider.currentWorkOrder?.data?.workOrderNo ?? ""); if (statusValue == 2 || statusValue == 3 || statusValue == 5 || statusValue == 6) {
return Consumer<ChatProvider>(builder: (pContext, requestProvider, _) { getChatToken(moduleId, provider.currentWorkOrder?.data?.workOrderNo ?? "");
return IconButton( return Consumer<ChatProvider>(builder: (pContext, requestProvider, _) {
icon: const Icon(Icons.chat_bubble), return IconButton(
onPressed: () { icon: const Icon(Icons.chat_bubble),
Navigator.push( onPressed: () {
context, Navigator.push(
CupertinoPageRoute( context,
builder: (context) => ChatPage( CupertinoPageRoute(
moduleId: 3, builder: (context) => ChatPage(
requestId: widget.requestId, moduleId: moduleId,
title: _requestProvider.currentWorkOrder?.data?.workOrderNo ?? "", requestId: widget.requestId,
readOnly: _requestProvider.isReadOnlyRequest, title: _requestProvider.currentWorkOrder?.data?.workOrderNo ?? "",
))); readOnly: _requestProvider.isReadOnlyRequest,
}, )));
).toShimmer(context: context, isShow: requestProvider.chatLoginTokenLoading, radius: 30, height: 30, width: 30); },
}); ).toShimmer(context: context, isShow: requestProvider.chatLoginTokenLoading, radius: 30, height: 30, width: 30);
});
}
return const SizedBox();
} }
return const SizedBox(); }),
}
}),
isNurse isNurse
? IconButton( ? IconButton(
icon: 'qr'.toSvgAsset( icon: 'qr'.toSvgAsset(

@ -43,15 +43,16 @@ class ChatApiClient {
ChatLoginResponse? chatLoginResponse; ChatLoginResponse? chatLoginResponse;
Future<ChatLoginResponse?> getChatLoginToken(int moduleId, int requestId, String title, String employeeNumber) async { Future<ChatLoginResponse?> getChatLoginToken(int moduleId, int requestId, String title, String employeeNumber, String assigneeEmployeeNumber) async {
Response response = await ApiClient().postJsonForResponse(URLs.chatSdkToken, { Response response = await ApiClient().postJsonForResponse(URLs.chatSdkToken, {
"apiKey": URLs.chatApiKey, "apiKey": URLs.chatApiKey,
"employeeNumber": employeeNumber, "employeeNumber": employeeNumber,
"assigneeEmployeeNumber": assigneeEmployeeNumber,
"userDetails": {"userName": ApiManager.instance.user?.username, "email": ApiManager.instance.user?.email}, "userDetails": {"userName": ApiManager.instance.user?.username, "email": ApiManager.instance.user?.email},
"contextEnabled": true, "contextEnabled": true,
"moduleCode": moduleId.toString(), "moduleCode": moduleId.toString(),
"referenceId": requestId.toString(), "referenceId": requestId.toString(),
"referenceType": "ticket", // "referenceType": "ticket",
"title": title "title": title
}); });
@ -65,7 +66,7 @@ class ChatApiClient {
} }
Future<ChatParticipantModel?> loadParticipants(int moduleId, int referenceId, String? assigneeEmployeeNumber) async { Future<ChatParticipantModel?> loadParticipants(int moduleId, int referenceId, String? assigneeEmployeeNumber) async {
Response response = await ApiClient().getJsonForResponse("${URLs.chatHubUrlApi}/chat/context/$moduleId/$referenceId", token: chatLoginResponse!.token); Response response = await ApiClient().getJsonForResponse("${URLs.chatHubUrlApi}/chat/context/$moduleId/$referenceId?assigneeEmployeeNumber=$assigneeEmployeeNumber", token: chatLoginResponse!.token);
if (!kReleaseMode) { if (!kReleaseMode) {
// logger.i("login-res: " + response.body); // logger.i("login-res: " + response.body);

@ -57,56 +57,6 @@ import 'model/user_chat_history_model.dart';
late HubConnection chatHubConnection; late HubConnection chatHubConnection;
class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin { class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin {
// ScrollController scrollController = ScrollController();
//
// TextEditingController message = TextEditingController();
// TextEditingController search = TextEditingController();
// TextEditingController searchGroup = TextEditingController();
//
// List<ChatUser>? pChatHistory, searchedChats;
// String chatCID = '';
// bool isLoading = true;
// bool isChatScreenActive = false;
// int receiverID = 0;
// late File selectedFile;
// String sFileType = "";
//
// List<ChatUser> favUsersList = [];
// int paginationVal = 0;
// int? cTypingUserId = 0;
// bool isTextMsg = false, isReplyMsg = false, isAttachmentMsg = false, isVoiceMsg = false;
//
// // Audio Recoding Work
// Timer? _timer;
// int _recodeDuration = 0;
// bool isRecoding = false;
// bool isPause = false;
// bool isPlaying = false;
// String? path;
// String? musicFile;
// late Directory appDirectory;
// late RecorderController recorderController;
// late PlayerController playerController;
//
// // List<GetEmployeeSubordinatesList> getEmployeeSubordinatesList = [];
// List<ChatUser> teamMembersList = [];
//
// // groups.GetUserGroups userGroups = groups.GetUserGroups();
// Material.TextDirection textDirection = Material.TextDirection.ltr;
// bool isRTL = false;
// String msgText = "";
//
// //Chat Home Page Counter
// int chatUConvCounter = 0;
//
// // late List<groupchathistory.GetGroupChatHistoryAsync> groupChatHistory, groupChatReplyData;
//
// /// Search Provider
// List<ChatUser>? chatUsersList = [];
// int pageNo = 1;
//
// bool disbaleChatForThisUser = false;
bool isTyping = false; bool isTyping = false;
bool chatLoginTokenLoading = false; bool chatLoginTokenLoading = false;
@ -164,11 +114,13 @@ class ChatProvider with ChangeNotifier, DiagnosticableTreeMixin {
chatLoginTokenLoading = true; chatLoginTokenLoading = true;
notifyListeners(); notifyListeners();
try { try {
chatLoginResponse = await ChatApiClient().getChatLoginToken(moduleId, requestId, title, myId); chatLoginResponse = await ChatApiClient().getChatLoginToken(moduleId, requestId, title, myId, assigneeEmployeeNumber);
chatParticipantModel = await ChatApiClient().loadParticipants(moduleId, requestId, assigneeEmployeeNumber); chatParticipantModel = await ChatApiClient().loadParticipants(moduleId, requestId, assigneeEmployeeNumber);
sender = chatParticipantModel?.participants?.singleWhere((participant) => participant.employeeNumber == myId); sender = chatParticipantModel?.participants?.firstWhere((participant) => participant.employeeNumber == myId);
recipient = chatParticipantModel?.participants?.singleWhere((participant) => participant.employeeNumber == assigneeEmployeeNumber); recipient = chatParticipantModel?.participants?.firstWhere((participant) => participant.employeeNumber == assigneeEmployeeNumber);
} catch (ex) {} } catch (ex) {
print(ex);
}
chatLoginTokenLoading = false; chatLoginTokenLoading = false;
notifyListeners(); notifyListeners();
} }

@ -71,7 +71,7 @@ class ChatFilePicker extends StatelessWidget {
fromFilePicker(BuildContext context) async { fromFilePicker(BuildContext context) async {
FilePickerResult? result = await FilePicker.platform.pickFiles( FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom, type: FileType.custom,
allowedExtensions: ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xlsx', 'pptx'], allowedExtensions: ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xlsx', 'pptx', 'txt'],
); );
if ((result?.paths ?? []).isNotEmpty) { if ((result?.paths ?? []).isNotEmpty) {
Navigator.pop(context, File(result!.paths.first!)); Navigator.pop(context, File(result!.paths.first!));

@ -4,9 +4,15 @@ class ChatLoginResponse {
String? userName; String? userName;
int? applicationId; int? applicationId;
int? expiresIn; int? expiresIn;
String? context; Context? context;
ChatLoginResponse({this.token, this.userId, this.userName, this.applicationId, this.expiresIn, this.context}); ChatLoginResponse(
{this.token,
this.userId,
this.userName,
this.applicationId,
this.expiresIn,
this.context});
ChatLoginResponse.fromJson(Map<String, dynamic> json) { ChatLoginResponse.fromJson(Map<String, dynamic> json) {
token = json['token']; token = json['token'];
@ -14,7 +20,8 @@ class ChatLoginResponse {
userName = json['userName']; userName = json['userName'];
applicationId = json['applicationId']; applicationId = json['applicationId'];
expiresIn = json['expiresIn']; expiresIn = json['expiresIn'];
context = json['context']; context =
json['context'] != null ? new Context.fromJson(json['context']) : null;
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
@ -24,7 +31,71 @@ class ChatLoginResponse {
data['userName'] = this.userName; data['userName'] = this.userName;
data['applicationId'] = this.applicationId; data['applicationId'] = this.applicationId;
data['expiresIn'] = this.expiresIn; data['expiresIn'] = this.expiresIn;
data['context'] = this.context; if (this.context != null) {
data['context'] = this.context!.toJson();
}
return data;
}
}
class Context {
String? conversationId;
String? moduleCode;
String? referenceId;
String? title;
List<DeepLinks>? deepLinks;
Context(
{this.conversationId,
this.moduleCode,
this.referenceId,
this.title,
this.deepLinks});
Context.fromJson(Map<String, dynamic> json) {
conversationId = json['conversationId'];
moduleCode = json['moduleCode'];
referenceId = json['referenceId'];
title = json['title'];
if (json['deepLinks'] != null) {
deepLinks = <DeepLinks>[];
json['deepLinks'].forEach((v) {
deepLinks!.add(new DeepLinks.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['conversationId'] = this.conversationId;
data['moduleCode'] = this.moduleCode;
data['referenceId'] = this.referenceId;
data['title'] = this.title;
if (this.deepLinks != null) {
data['deepLinks'] = this.deepLinks!.map((v) => v.toJson()).toList();
}
return data;
}
}
class DeepLinks {
String? employeeNumber;
int? userId;
String? userName;
DeepLinks({this.employeeNumber, this.userId, this.userName});
DeepLinks.fromJson(Map<String, dynamic> json) {
employeeNumber = json['employeeNumber'];
userId = json['userId'];
userName = json['userName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['employeeNumber'] = this.employeeNumber;
data['userId'] = this.userId;
data['userName'] = this.userName;
return data; return data;
} }
} }

Loading…
Cancel
Save