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/doc.svg b/assets/icons/chat/doc.svg
new file mode 100644
index 0000000..1f678df
--- /dev/null
+++ b/assets/icons/chat/doc.svg
@@ -0,0 +1,54 @@
+
+
+
diff --git a/assets/icons/chat/ppt.svg b/assets/icons/chat/ppt.svg
new file mode 100644
index 0000000..5134010
--- /dev/null
+++ b/assets/icons/chat/ppt.svg
@@ -0,0 +1,51 @@
+
+
+
diff --git a/assets/icons/chat/txt.svg b/assets/icons/chat/txt.svg
new file mode 100644
index 0000000..bbaf693
--- /dev/null
+++ b/assets/icons/chat/txt.svg
@@ -0,0 +1,51 @@
+
+
+
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/assets/icons/chat/xls.svg b/assets/icons/chat/xls.svg
new file mode 100644
index 0000000..325f974
--- /dev/null
+++ b/assets/icons/chat/xls.svg
@@ -0,0 +1,53 @@
+
+
+
diff --git a/assets/icons/chat/zip.svg b/assets/icons/chat/zip.svg
new file mode 100644
index 0000000..9aaaf6b
--- /dev/null
+++ b/assets/icons/chat/zip.svg
@@ -0,0 +1,51 @@
+
+
+
diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json
index f72ea36..1c5851a 100644
--- a/assets/langs/ar-SA.json
+++ b/assets/langs/ar-SA.json
@@ -498,5 +498,7 @@
"verification": "تَحَقّق",
"resend": "إعادة إرسال",
"codeExpire": "انتهت صلاحية رمز التحقق",
- "typeheretoreply": "اكتب هنا للرد"
+ "typeheretoreply": "اكتب هنا للرد",
+ "favorite": "مفضلتي",
+ "searchfromchat": "البحث من الدردشة"
}
\ No newline at end of file
diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json
index e0b9019..b4b06f0 100644
--- a/assets/langs/en-US.json
+++ b/assets/langs/en-US.json
@@ -498,5 +498,8 @@
"resend": "Resend",
"codeExpire": "The verification code has been expired",
"allQuestionsCorrect": "You have answered all questions correct",
- "typeheretoreply": "Type here to reply"
+ "typeheretoreply": "Type here to reply",
+ "favorite" : "My Favorites",
+ "searchfromchat": "Search from chat"
+
}
\ No newline at end of file
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 9daee21..43841a1 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -383,7 +383,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
- DEVELOPMENT_TEAM = 3A359E86ZF;
+ DEVELOPMENT_TEAM = 99Z3UD3LJM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Mohemm;
@@ -520,7 +520,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
- DEVELOPMENT_TEAM = 3A359E86ZF;
+ DEVELOPMENT_TEAM = 99Z3UD3LJM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Mohemm;
@@ -549,7 +549,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
- DEVELOPMENT_TEAM = 3A359E86ZF;
+ DEVELOPMENT_TEAM = 99Z3UD3LJM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Mohemm;
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 bcb748c..7439b98 100644
--- a/lib/api/chat/chat_provider_model.dart
+++ b/lib/api/chat/chat_provider_model.dart
@@ -1,37 +1,71 @@
+import 'dart:async';
import 'dart:convert';
+import 'dart:io';
+import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
-import 'package:fluttertoast/fluttertoast.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';
import 'package:mohem_flutter_app/classes/utils.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_single_user_chat_list_model.dart';
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart' as login;
-import 'package:shared_preferences/shared_preferences.dart';
+import 'package:mohem_flutter_app/models/chat/make_user_favotire_unfavorite_chat_model.dart' as fav;
+import 'package:mohem_flutter_app/widgets/image_picker.dart';
import 'package:signalr_netcore/signalr_client.dart';
-import 'package:logger/logger.dart' as L;
+import 'package:uuid/uuid.dart';
class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
+ ScrollController scrollController = ScrollController();
+ TextEditingController message = TextEditingController();
+ TextEditingController search = TextEditingController();
List userChatHistory = [];
List? pChatHistory, searchedChats;
late HubConnection hubConnection;
L.Logger logger = L.Logger();
- TextEditingController message = TextEditingController();
- ScrollController scrollController = ScrollController();
+ bool hubConInitialized = false;
+
bool isLoading = true;
+ bool isChatScreenActive = false;
+ late File selectedFile;
+ bool isFileSelected = false;
+ String sFileType = "";
+ bool isMsgReply = false;
+ List repliedMsg = [];
+ List favUsersList = [];
+ int paginationVal = 0;
+
+ //Scroll
+ bool _firstAutoscrollExecuted = false;
+ bool _shouldAutoscroll = false;
Future getUserAutoLoginToken() async {
- String userName = AppState().memberInformationList!.eMPLOYEEEMAILADDRESS!.split("@").first.toString();
- 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 {
@@ -40,9 +74,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
token: AppState().chatDetails!.response!.token,
);
return searchUserJsonModel(response.body);
- logger.d(response.body);
- isLoading = false;
- notifyListeners();
}
List searchUserJsonModel(String str) => List.from(json.decode(str).map((x) => ChatUser.fromJson(x)));
@@ -53,80 +84,127 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
token: AppState().chatDetails!.response!.token,
);
ChatUserModel recentChat = userToList(response.body);
- pChatHistory = recentChat.response;
+
+ Response favRes = await ApiClient().getJsonForResponse(
+ "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatFavoriteUsers}${AppState().chatDetails!.response!.id}",
+ token: AppState().chatDetails!.response!.token,
+ );
+ ChatUserModel favUList = userToList(favRes.body);
+ if (favUList.response != null) {
+ favUsersList = favUList.response!;
+ favUsersList.sort((ChatUser a, ChatUser b) => a.userName!.toLowerCase().compareTo(b.userName!.toLowerCase()));
+ for (dynamic user in recentChat.response!) {
+ for (dynamic favUser in favUList.response!) {
+ if (user.id == favUser.id) {
+ user.isFav = favUser.isFav;
+ }
+ }
+ }
+ }
+ pChatHistory = recentChat.response == null ? [] : recentChat.response;
+ if (pChatHistory != null) pChatHistory!.sort((ChatUser a, ChatUser b) => a.userName!.toLowerCase().compareTo(b.userName!.toLowerCase()));
+
searchedChats = pChatHistory;
isLoading = false;
notifyListeners();
}
- void getSingleUserChatHistory({required String senderUID, required int receiverUID, required String pagination}) 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(
- "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$pagination",
+ "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal",
token: AppState().chatDetails!.response!.token,
);
- logger.d(response.statusCode);
- print(response.body);
if (response.statusCode == 204) {
- userChatHistory = [];
+ if (isNewChat) {
+ userChatHistory = [];
+ } else if (loadMore) {
+ // userChatHistory = [];
+ Utils.showToast("No More Data To Load");
+ }
} else {
- userChatHistory = getSingleUserChatModel(response.body);
+ if (loadMore) {
+ List temp = getSingleUserChatModel(response.body).reversed.toList();
+ userChatHistory.addAll(temp);
+ } else {
+ userChatHistory = getSingleUserChatModel(response.body).reversed.toList();
+ }
}
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));
+ Future uploadAttachments(String userId, File file) async {
+ dynamic result;
+ dynamic request = MultipartRequest('POST', Uri.parse('${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatMediaImageUploadUrl}'));
+ request.fields.addAll({'userId': userId, 'fileSource': '1'});
+ request.files.add(await MultipartFile.fromPath('files', file.path));
+ request.headers.addAll({'Authorization': 'Bearer ${AppState().chatDetails!.response!.token}'});
+ try {
+ StreamedResponse response = await request.send();
+ if (response.statusCode == 200) {
+ result = jsonDecode(await response.stream.bytesToString());
+ } else {
+ result = [];
+ }
+ } catch (e) {
+ if (kDebugMode) {
+ print(e);
+ }
+ }
+ ;
+ return result;
+ }
+
Future buildHubConnection() async {
HttpConnectionOptions httpOp = HttpConnectionOptions(skipNegotiation: false, logMessageContent: true);
- hubConnection = await HubConnectionBuilder()
+ 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])
+ .withAutomaticReconnect(
+ retryDelays: [2000, 5000, 10000, 20000],
+ )
.configureLogging(
- Logger("Logs Enabled"),
+ Logger("Loggin"),
)
.build();
hubConnection.onclose(
- ({Exception? error}) {
- // logger.d(error);
- },
+ ({Exception? error}) {},
);
hubConnection.onreconnecting(
- ({Exception? error}) {
- // logger.d(error);
- // logger.d("Reconnecting");
- },
+ ({Exception? error}) {},
);
hubConnection.onreconnected(
- ({String? connectionId}) {
- // logger.d("Reconnected");
- },
+ ({String? connectionId}) {},
);
if (hubConnection.state != HubConnectionState.Connected) {
await hubConnection.start();
hubConnection.on("OnUpdateUserStatusAsync", changeStatus);
hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
+ // hubConnection.on("OnSeenChatUserAsync", onChatSeen);
- hubConnection.on("OnUserTypingAsync", onUserTyping);
- // hubConnection.on("OnUserCountAsync", userCountAsync);
- // hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
- // hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
- hubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus);
- } else {
- hubConnection.on("OnUpdateUserStatusAsync", changeStatus);
- hubConnection.on("OnDeliveredChatUserAsync", onMsgReceived);
-
- hubConnection.on("OnUserTypingAsync", onUserTyping);
- // hubConnection.on("OnUserCountAsync", userCountAsync);
- // hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
- // hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
+ //hubConnection.on("OnUserTypingAsync", onUserTyping);
+ hubConnection.on("OnUserCountAsync", userCountAsync);
+ hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow);
+ hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered);
hubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus);
}
- isLoading = false;
- notifyListeners();
}
void updateUserChatStatus(List