diff --git a/.gitignore b/.gitignore
index 034a5be..4a374d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,7 +34,6 @@ pubspec.lock
/build/
# Web related
-lib/generated_plugin_registrant.dart
# Symbolication related
app.*.symbols
@@ -46,3 +45,4 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release
+/ios/
diff --git a/assets/icons/chat/call.svg b/assets/icons/chat/call.svg
new file mode 100644
index 0000000..843daf4
--- /dev/null
+++ b/assets/icons/chat/call.svg
@@ -0,0 +1,3 @@
+
diff --git a/assets/icons/chat/video_call.svg b/assets/icons/chat/video_call.svg
new file mode 100644
index 0000000..2fceee6
--- /dev/null
+++ b/assets/icons/chat/video_call.svg
@@ -0,0 +1,6 @@
+
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 2ac7a44..2797543 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -44,6 +44,8 @@
This App requires access to your location to mark your attendance.
NSPhotoLibraryUsageDescription
This app requires photo library access to select image as document & upload it.
+ NSMicrophoneUsageDescription
+ This app requires microphone access to for call.
UIBackgroundModes
remote-notification
diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart
index ead29d7..7439b98 100644
--- a/lib/api/chat/chat_provider_model.dart
+++ b/lib/api/chat/chat_provider_model.dart
@@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart';
import 'package:logger/logger.dart' as L;
+import 'package:logging/logging.dart';
import 'package:mohem_flutter_app/api/api_client.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/consts.dart';
@@ -27,6 +28,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
List? pChatHistory, searchedChats;
late HubConnection hubConnection;
L.Logger logger = L.Logger();
+ bool hubConInitialized = false;
bool isLoading = true;
bool isChatScreenActive = false;
@@ -43,13 +45,27 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
bool _shouldAutoscroll = false;
Future getUserAutoLoginToken() async {
- String userName = AppState().memberInformationList!.eMPLOYEEEMAILADDRESS!.split("@").first.toString();
- //userName
- Response response =
- await ApiClient().postJsonForResponse("${ApiConsts.chatServerBaseApiUrl}user/desktopuserlogin", {"userName": userName, "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG", "loginType": 2});
- login.UserAutoLoginModel userLoginResponse = login.userAutoLoginModelFromJson(response.body);
- AppState().setchatUserDetails = userLoginResponse;
- await buildHubConnection();
+ Response response = await ApiClient().postJsonForResponse(
+ "${ApiConsts.chatServerBaseApiUrl}user/externaluserlogin",
+ {
+ "employeeNumber": int.parse(
+ AppState().memberInformationList!.eMPLOYEENUMBER.toString(),
+ ),
+ "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG"
+ },
+ );
+ login.UserAutoLoginModel userLoginResponse = login.userAutoLoginModelFromJson(
+ response.body,
+ );
+
+ if (userLoginResponse.response != null) {
+ hubConInitialized = true;
+ AppState().setchatUserDetails = userLoginResponse;
+ await buildHubConnection();
+ } else {
+ Utils.showToast(userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr");
+ return;
+ }
}
Future?> getChatMemberFromSearch(String sName, int cUserId) async {
@@ -93,8 +109,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
notifyListeners();
}
- void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore, bool isNewChat = false}) async {
+ Future GetUserChatHistoryNotDeliveredAsync(int userId) async {
+ await hubConnection.invoke("GetUserChatHistoryNotDeliveredAsync", args: [userId]);
+ return "";
+ }
+
+ void getSingleUserChatHistory({required int senderUID, required int receiverUID, required bool loadMore, bool isNewChat = false}) async {
isLoading = true;
+ if (isNewChat) userChatHistory = [];
if (!loadMore) paginationVal = 0;
isChatScreenActive = true;
Response response = await ApiClient().getJsonForResponse(
@@ -117,9 +139,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
}
isLoading = false;
+ await GetUserChatHistoryNotDeliveredAsync(senderUID);
notifyListeners();
}
+ void updateUserChatHistoryStatusAsync(List data) {
+ hubConnection.invoke("UpdateUserChatHistoryStatusAsync", args: [data]);
+ }
+
List getSingleUserChatModel(String str) => List.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x)));
ChatUserModel userToList(String str) => ChatUserModel.fromJson(json.decode(str));
@@ -151,8 +178,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
hubConnection = HubConnectionBuilder()
.withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp)
.withAutomaticReconnect(
- retryDelays: [2000, 5000, 10000, 20000],
- ).build();
+ retryDelays: [2000, 5000, 10000, 20000],
+ )
+ .configureLogging(
+ Logger("Loggin"),
+ )
+ .build();
hubConnection.onclose(
({Exception? error}) {},
);
@@ -169,7 +200,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
// hubConnection.on("OnSeenChatUserAsync", onChatSeen);
//hubConnection.on("OnUserTypingAsync", onUserTyping);
- // hubConnection.on("OnUserCountAsync", userCountAsync);
+ hubConnection.on("OnUserCountAsync", userCountAsync);
hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
hubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus);
@@ -203,6 +234,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void userCountAsync(List