diff --git a/android/app/agconnect-services.json b/android/app/agconnect-services.json
new file mode 100644
index 0000000..20a7546
--- /dev/null
+++ b/android/app/agconnect-services.json
@@ -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"
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 198bc87..5590740 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -31,6 +31,7 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
+apply plugin: 'com.huawei.agconnect'
android {
compileSdkVersion 33
@@ -51,13 +52,19 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "hmg.cloudSolutions.mohem"
- minSdkVersion 21
+ minSdkVersion 28
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
+ debug {
+ keyAlias keystoreProperties['keyAlias']
+ keyPassword keystoreProperties['keyPassword']
+ storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
+ storePassword keystoreProperties['storePassword']
+ }
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
@@ -68,6 +75,9 @@ android {
buildTypes {
release {
signingConfig signingConfigs.release
+ minifyEnabled true
+ shrinkResources true
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index f187ebd..3f5e424 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -7,12 +7,21 @@
-
+
+
+
+
+
+
+
+
+
+ NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+ NSAllowsArbitraryLoadsForMedia
+
+ NSAllowsArbitraryLoadsInWebContent
+
+
CADisableMinimumFrameDurationOnPhone
CFBundleDevelopmentRegion
@@ -33,7 +42,7 @@
NFCReaderUsageDescription
This App requires access to NFC to mark your attendance.
NSCameraUsageDescription
- This app requires camera access to capture & upload pictures.
+ This app requires camera access to capture & upload picture as profile image.
NSFaceIDUsageDescription
This app requires Face ID to allow biometric authentication for app login.
NSLocationAlwaysAndWhenInUseUsageDescription
@@ -46,15 +55,13 @@
This app requires photo library access to select image as document & upload it.
NSMicrophoneUsageDescription
This app requires microphone access to for call.
- NSPhotoLibraryUsageDescription
- This app requires photo library access to select image as document & upload it.
UIBackgroundModes
- fetch
+ fetch
remote-notification
FirebaseAppDelegateProxyEnabled
-
+
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
@@ -80,14 +87,9 @@
ITSAppUsesNonExemptEncryption
-
com.apple.developer.nfc.readersession.formats
TAG
- com.apple.developer.nfc.readersession.felica.systemcodes
-
- 0000
-
diff --git a/lib/api/chat/chat_api_client.dart b/lib/api/chat/chat_api_client.dart
index b4c0a2c..f727c7d 100644
--- a/lib/api/chat/chat_api_client.dart
+++ b/lib/api/chat/chat_api_client.dart
@@ -31,7 +31,8 @@ class ChatApiClient {
"employeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(),
"password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG",
"isMobile": true,
- "deviceToken": AppState().getDeviceToken,
+ "deviceToken":AppState().getIsHuawei ? AppState().getHuaweiPushToken : AppState().getDeviceToken,
+ "isHuaweiDevice": AppState().getIsHuawei,
},
);
diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart
index 95631a9..76b10ce 100644
--- a/lib/api/dashboard_api_client.dart
+++ b/lib/api/dashboard_api_client.dart
@@ -111,6 +111,7 @@ class DashboardApiClient {
// Generate a v4 (random) id
Map postParams = {
+ // "UID": await PlatformDeviceId.getDeviceId, //uuid.v4(), //Mobile Id
"UID": uuid.v4(), //Mobile Id
"Latitude": lat,
"Longitude": long,
@@ -199,17 +200,18 @@ class DashboardApiClient {
}, url, postParams);
}
-// Future setAdvertisementViewed(String masterID, int advertisementId) async {
-// String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed";
-//
-// Map postParams = {
-// "ItgNotificationMasterId": masterID,
-// "ItgAdvertisement": {"advertisementId": advertisementId, "acknowledgment": true} //Mobile Id
-// };
-// postParams.addAll(AppState().postParamsJson);
-// return await ApiClient().postJsonForObject((json) {
-// // ItgMainRes responseData = ItgMainRes.fromJson(json);
-// return json;
-// }, url, postParams);
-// }
+ Future setAdvertisementViewed(String masterID, int advertisementId) async {
+ String url = "${ApiConsts.cocRest}Mohemm_ITG_UpdateAdvertisementAsViewed";
+
+ Map postParams = {
+ "ItgNotificationMasterId": masterID,
+ "EmployeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(),
+ "ItgAdvertisement": {"advertisementId": advertisementId, "acknowledgment": true} //Mobile Id
+ };
+ postParams.addAll(AppState().postParamsJson);
+ return await ApiClient().postJsonForObject((json) {
+ // ItgMainRes responseData = ItgMainRes.fromJson(json);
+ return json;
+ }, url, postParams);
+ }
}
diff --git a/lib/api/marathon/marathon_api_client.dart b/lib/api/marathon/marathon_api_client.dart
index ee3810f..9497b48 100644
--- a/lib/api/marathon/marathon_api_client.dart
+++ b/lib/api/marathon/marathon_api_client.dart
@@ -34,6 +34,20 @@ class MarathonApiClient {
);
}
+ Future getMarathonersCount({required String marathonId}) async {
+ Response response = await ApiClient().getJsonForResponse(
+ ApiConsts.marathonGetMarathonersCount + '?marathonId=$marathonId',
+ token: AppState().getMarathonToken == null || AppState().getMarathonToken == "" ? await getMarathonToken() : AppState().getMarathonToken,
+ );
+
+ var json = jsonDecode(response.body);
+ logger.i("json in getMarathonersCount: $json");
+
+ MarathonGenericModel marathonGenericModel = MarathonGenericModel.fromJson(json);
+
+ return marathonGenericModel.data as int;
+ }
+
Future getProjectId() async {
return await ApiClient().postJsonForObject(
(json) {
@@ -89,6 +103,7 @@ class MarathonApiClient {
);
}
+
Future getNextQuestion({required String? questionId, required String marathonId}) async {
Map jsonObject = {
"previousQuestionId": questionId,
diff --git a/lib/api/worklist/worklist_api_client.dart b/lib/api/worklist/worklist_api_client.dart
index 82b865c..d55dc8d 100644
--- a/lib/api/worklist/worklist_api_client.dart
+++ b/lib/api/worklist/worklist_api_client.dart
@@ -14,6 +14,7 @@ import 'package:mohem_flutter_app/models/get_mo_notification_body_list_model.dar
import 'package:mohem_flutter_app/models/get_notification_buttons_list_model.dart';
import 'package:mohem_flutter_app/models/get_po_Item_history_list_model.dart';
import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart';
+import 'package:mohem_flutter_app/models/get_pr_information_list.dart';
import 'package:mohem_flutter_app/models/get_pr_notification_body_list_model.dart';
import 'package:mohem_flutter_app/models/get_quotation_analysis_list_model.dart';
import 'package:mohem_flutter_app/models/get_stamp_ms_notification_body_list_model.dart';
@@ -626,4 +627,19 @@ class WorkListApiClient {
return responseData.updateUserItemTypesList;
}, url, postParams);
}
+
+ Future getPRDetailsForPO(String poLineID) async {
+ String url = "${ApiConsts.erpRest}GET_PR_INFORMATION";
+ Map postParams = {
+ "P_PO_LINE_ID": poLineID,
+ "P_PAGE_LIMIT": 100,
+ "P_PAGE_NUM": 1,
+ };
+ postParams.addAll(AppState().postParamsJson);
+ return await ApiClient().postJsonForObject((json) {
+ GenericResponseModel responseData = GenericResponseModel.fromJson(json);
+ return responseData.getPRInformationList;
+ }, url, postParams);
+ }
+
}
diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart
index cf7b96c..23be328 100644
--- a/lib/app_state/app_state.dart
+++ b/lib/app_state/app_state.dart
@@ -1,7 +1,6 @@
import 'dart:io';
import 'package:easy_localization/easy_localization.dart';
-import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:mohem_flutter_app/models/chat/get_user_login_token_model.dart';
import 'package:mohem_flutter_app/models/itg_forms_models/request_detail_model.dart';
import 'package:mohem_flutter_app/models/member_information_list_model.dart';
@@ -79,7 +78,19 @@ class AppState {
bool get getIsDemoMarathon => _isDemoMarathon;
- final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 4.0, mobileType: Platform.isAndroid ? "android" : "ios");
+ bool _isHuawei = false;
+
+ set setIsHuawei(bool value) => _isHuawei = value;
+
+ bool get getIsHuawei => _isHuawei;
+
+ String _huaweiPushToken = "";
+
+ set setHuaweiPushToken(String value) => _huaweiPushToken = value;
+
+ String get getHuaweiPushToken => _huaweiPushToken;
+
+ final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 4.4, mobileType: Platform.isAndroid ? "android" : "ios");
void setPostParamsInitConfig() {
isAuthenticated = false;
diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart
index 96fd4b0..688fd70 100644
--- a/lib/classes/consts.dart
+++ b/lib/classes/consts.dart
@@ -37,6 +37,7 @@ class ApiConsts {
static String marathonSubmitAnswerUrl = marathonBaseUrl + "question/submit";
static String marathonQualifiersUrl = marathonBaseUrl + "winner/getWinner/";
static String marathonSelectedWinner = marathonBaseUrl + "winner/getSelectedWinner/";
+ static String marathonGetMarathonersCount = marathonBaseUrl + "Participant/GetRemainingParticipants";
//DummyCards for the UI
static CardContent dummyQuestion = const CardContent();
diff --git a/lib/classes/date_uitl.dart b/lib/classes/date_uitl.dart
index 3cae1cd..89e237d 100644
--- a/lib/classes/date_uitl.dart
+++ b/lib/classes/date_uitl.dart
@@ -60,13 +60,13 @@ class DateUtil {
}
}
date = date + " $hours:$mins:$secs";
- DateTime returnDate = DateFormat("MM/dd/yyyy HH:mm:ss").parse(date);
+ DateTime returnDate = DateFormat("MM/dd/yyyy HH:mm:ss", "en_US").parse(date);
return returnDate;
}
static DateTime convertSimpleStringDateToDateddMMyyyy(String date) {
- return DateFormat("MM/dd/yyyy hh:mm:ss").parse(date);
+ return DateFormat("MM/dd/yyyy hh:mm:ss", "en_US").parse(date);
}
static DateTime convertStringToDateNoTimeZone(String date) {
@@ -123,7 +123,7 @@ class DateUtil {
}
static String formatDateToTime(DateTime date) {
- return DateFormat('hh:mm a').format(date);
+ return DateFormat('hh:mm a', "en_US").format(date);
}
static String yearMonthDay(DateTime dateTime) {
@@ -419,7 +419,7 @@ class DateUtil {
/// [dateTime] convert DateTime to data formatted
static String getDayMonthDateFormatted(DateTime dateTime) {
if (dateTime != null)
- return DateFormat('dd/MM').format(dateTime);
+ return DateFormat('dd/MM', "en_US").format(dateTime);
else
return "";
}
@@ -466,7 +466,7 @@ class DateUtil {
/// [dateTime] convert DateTime to data formatted
static String getDayMonthYearHourMinuteDateFormatted(DateTime dateTime) {
if (dateTime != null)
- return dateTime.day.toString() + "/" + dateTime.month.toString() + "/" + dateTime.year.toString() + " " + DateFormat('HH:mm').format(dateTime);
+ return dateTime.day.toString() + "/" + dateTime.month.toString() + "/" + dateTime.year.toString() + " " + DateFormat('HH:mm', "en_US").format(dateTime);
else
return "";
}
@@ -491,11 +491,11 @@ class DateUtil {
}
static String getFormattedDate(DateTime dateTime, String formattedString) {
- return DateFormat(formattedString).format(dateTime);
+ return DateFormat(formattedString, "en_US").format(dateTime);
}
static String convertISODateToJsonDate(String isoDate) {
- return "/Date(" + DateFormat('mm-dd-yyy').parse(isoDate).millisecondsSinceEpoch.toString() + ")/";
+ return "/Date(" + DateFormat('mm-dd-yyy', "en_US").parse(isoDate).millisecondsSinceEpoch.toString() + ")/";
}
// static String getDay(DayOfWeek dayOfWeek) {
diff --git a/lib/classes/lottie_consts.dart b/lib/classes/lottie_consts.dart
index bcc7149..e112243 100644
--- a/lib/classes/lottie_consts.dart
+++ b/lib/classes/lottie_consts.dart
@@ -9,4 +9,5 @@ class MyLottieConsts {
static const String congratsGif = "assets/images/congrats.gif";
static const String loadingLottie = "assets/lottie/loading_lottie.json";
static const String noWinnerLottie = "assets/lottie/no_winner.json";
+ static const String audioPlaybackLottie = "assets/lottie/audio_playback.json";
}
diff --git a/lib/classes/my_custom_stream.dart b/lib/classes/my_custom_stream.dart
new file mode 100644
index 0000000..2a0927f
--- /dev/null
+++ b/lib/classes/my_custom_stream.dart
@@ -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 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',
+ );
+ }
+}
\ No newline at end of file
diff --git a/lib/classes/notifications.dart b/lib/classes/notifications.dart
index cebf76d..e3d7997 100644
--- a/lib/classes/notifications.dart
+++ b/lib/classes/notifications.dart
@@ -1,13 +1,14 @@
-import 'dart:convert';
import 'dart:io';
+
+import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
+// import 'package:huawei_hmsavailability/huawei_hmsavailability.dart';
+import 'package:huawei_push/huawei_push.dart' as huawei_push;
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/utils.dart';
-import 'package:mohem_flutter_app/main.dart';
import 'package:permission_handler/permission_handler.dart';
-import 'package:firebase_core/firebase_core.dart';
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
@@ -18,6 +19,10 @@ class AppNotifications {
factory AppNotifications() => _instance;
+ // late HmsApiAvailability hmsApiAvailability;
+
+ String _huaweiToken = '';
+
Future requestPermissions() async {
if (Platform.isIOS) {
await flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation()?.requestPermissions(alert: true, badge: true, sound: true);
@@ -35,6 +40,10 @@ class AppNotifications {
}
void init(String? firebaseToken) async {
+ // if (Platform.isAndroid) {
+ // hmsApiAvailability = HmsApiAvailability();
+ // }
+
await requestPermissions();
AppState().setDeviceToken = firebaseToken;
await Permission.notification.isDenied.then((bool value) {
@@ -57,10 +66,53 @@ class AppNotifications {
FirebaseMessaging.instance.onTokenRefresh.listen((String token) {
AppState().setDeviceToken = token;
});
+
+ if (Platform.isAndroid) {
+ // await hmsApiAvailability.isHMSAvailable().then((value) async {
+ if (!(await Utils.isGoogleServicesAvailable())) {
+
+ huawei_push.Push.enableLogger();
+ var result = await huawei_push.Push.setAutoInitEnabled(true);
+
+ huawei_push.Push.onNotificationOpenedApp.listen((message) {
+ // newMessage(toFirebaseRemoteMessage(message));
+ }, onError: (e) => print(e.toString()));
+
+ huawei_push.Push.onMessageReceivedStream.listen((message) {
+ // newMessage(toFirebaseRemoteMessage(message));
+ }, onError: (e) => print(e.toString()));
+ }
+ // }).catchError((err) {
+ // print(err);
+ // });
+ }
+ }
+
+ void initHuaweiPush(Function loginCallback) {
+ AppState().setIsHuawei = true;
+ initTokenStream(loginCallback);
+ huawei_push.Push.getToken("");
+ }
+
+ // HUAWEI PUSH TOKEN IMPLEMENTATION
+ void _onTokenEvent(String event) {
+ _huaweiToken = event;
+ AppState().setHuaweiPushToken = _huaweiToken;
+ debugPrint("HUAWEI PUSH TOKEN: $_huaweiToken");
+ }
+
+ void _onTokenError(Object error) {}
+
+ Future initTokenStream(Function loginCallback) async {
+ huawei_push.Push.getTokenStream.listen(_onTokenEvent, onError: _onTokenError).onData((data) {
+ AppState().setHuaweiPushToken = data;
+ debugPrint("HUAWEI PUSH TOKEN: $data");
+ loginCallback();
+ });
}
void _handleMessage(RemoteMessage message) {
- Utils.saveStringFromPrefs("isAppOpendByChat", "true");
+ Utils.saveStringFromPrefs("isAppOpendByChat", "false");
}
void _handleOpenApp(RemoteMessage message) {
@@ -77,7 +129,6 @@ AndroidNotificationChannel channel = const AndroidNotificationChannel(
Future backgroundMessageHandler(RemoteMessage message) async {
await Firebase.initializeApp();
- Utils.saveStringFromPrefs("isAppOpendByChat", "true");
- logger.w(message.data["user_chat_history_response"]);
+ Utils.saveStringFromPrefs("isAppOpendByChat", "false");
Utils.saveStringFromPrefs("notificationData", message.data["user_chat_history_response"].toString());
}
diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart
index 5990edf..34831c2 100644
--- a/lib/classes/utils.dart
+++ b/lib/classes/utils.dart
@@ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluttertoast/fluttertoast.dart';
+import 'package:google_api_availability/google_api_availability.dart';
import 'package:mohem_flutter_app/app_state/app_state.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/config/routes.dart';
@@ -115,12 +116,14 @@ class Utils {
} else {
if (!AppState().isAuthenticated) {
showDialog(
+ barrierDismissible: false,
context: cxt,
builder: (cxt) => ConfirmDialog(
message: errorMessage,
onTap: () {
Navigator.pushNamedAndRemoveUntil(cxt, AppRoutes.login, (Route route) => false);
},
+ onCloseTap: () {},
),
);
} else {
@@ -264,7 +267,7 @@ class Utils {
static String getMonthNamedFormat(DateTime date) {
/// it will return like "29-Sep-2022"
- return DateFormat('dd-MMM-yyyy').format(date);
+ return DateFormat('dd-MMM-yyyy', "en_US").format(date);
}
static String reverseFormatDate(String date) {
@@ -334,9 +337,9 @@ class Utils {
return date;
} else {
if (date.toLowerCase().split("-")[1].length == 3) {
- return DateFormat('dd-MM-yyyy').format(DateFormat('dd-MMM-yyyy').parseLoose(date));
+ return DateFormat('dd-MM-yyyy', "en_US").format(DateFormat('dd-MMM-yyyy', "en_US").parseLoose(date));
} else {
- return DateFormat('dd-MM-yyyy').format(DateFormat('yyyy-MM-dd').parseLoose(date));
+ return DateFormat('dd-MM-yyyy', "en_US").format(DateFormat('yyyy-MM-dd', "en_US").parseLoose(date));
}
// return DateFormat('yyyy-MM-dd').format(DateFormat('dd-MM-yyyy').parseLoose(date));
}
@@ -388,4 +391,14 @@ class Utils {
print(err);
});
}
+
+ //HUAWEI DECISION MAKING
+ static Future isGoogleServicesAvailable() async {
+ GooglePlayServicesAvailability availability = await GoogleApiAvailability.instance.checkGooglePlayServicesAvailability();
+ String status = availability.toString().split('.').last;
+ if (status == "success") {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/lib/dialogs/otp_dialog.dart b/lib/dialogs/otp_dialog.dart
index 9158b94..9f7c82e 100644
--- a/lib/dialogs/otp_dialog.dart
+++ b/lib/dialogs/otp_dialog.dart
@@ -9,7 +9,6 @@ import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/otp_widget.dart';
-import 'package:sizer/sizer.dart';
final ValueNotifier otpFieldClear = ValueNotifier("");
diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart
index b916f23..45cfc05 100644
--- a/lib/extensions/string_extensions.dart
+++ b/lib/extensions/string_extensions.dart
@@ -22,6 +22,17 @@ extension TrimString on String {
}
}
+String displayLocalizedContent({required bool isPhoneLangArabic, required int selectedLanguage, required String englishContent, required String arabicContent}) {
+ if (selectedLanguage == 1) {
+ return englishContent;
+ } else if (selectedLanguage == 2) {
+ return arabicContent;
+ } else if (selectedLanguage == 3) {
+ return isPhoneLangArabic ? arabicContent : englishContent;
+ }
+ return englishContent;
+}
+
extension EmailValidator on String {
Widget get toWidget => Text(this);
@@ -111,9 +122,10 @@ extension EmailValidator on String {
decoration: isUnderLine ? TextDecoration.underline : null),
);
- Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines, double? height}) => Text(
+ Widget toText16({Color? color, bool isUnderLine = false, bool isBold = false, int? maxlines, double? height, bool isCentered = false}) => Text(
this,
maxLines: maxlines,
+ textAlign: isCentered ? TextAlign.center : null,
style: TextStyle(
color: color ?? MyColors.darkTextColor,
fontSize: 16,
@@ -158,13 +170,15 @@ extension EmailValidator on String {
style: TextStyle(height: 1, color: color ?? MyColors.darkTextColor, fontSize: 22, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
);
- Widget toText24({Color? color, bool isBold = false}) => Text(
+ Widget toText24({Color? color, bool isBold = false, bool isCentered = false}) => Text(
this,
+ textAlign: isCentered ? TextAlign.center : null,
style: TextStyle(height: 23 / 24, color: color ?? MyColors.darkTextColor, fontSize: 24, letterSpacing: -1.44, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
);
- Widget toText30({Color? color, bool isBold = false}) => Text(
+ Widget toText30({Color? color, bool isBold = false, bool isCentered = false}) => Text(
this,
+ textAlign: isCentered ? TextAlign.center : null,
style: TextStyle(height: 20 / 32, color: color ?? MyColors.darkTextColor, fontSize: 32, letterSpacing: -1.2, fontWeight: isBold ? FontWeight.bold : FontWeight.w600),
);
@@ -219,7 +233,7 @@ extension EmailValidator on String {
String date = this.split("T")[0];
String time = this.split("T")[1];
var dates = date.split("-");
- return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a').format(DateFormat('hh:mm:ss').parse(time))}";
+ return "${dates[2]} ${getMonth(int.parse(dates[1]))} ${dates[0]} ${DateFormat('hh:mm a', "en_US").format(DateFormat('hh:mm:ss', "en_US").parse(time))}";
}
String getMonth(int month) {
diff --git a/lib/main.dart b/lib/main.dart
index ae2d367..07590f3 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -9,10 +9,10 @@ import 'package:mohem_flutter_app/classes/consts.dart';
import 'package:mohem_flutter_app/config/routes.dart';
import 'package:mohem_flutter_app/generated/codegen_loader.g.dart';
import 'package:mohem_flutter_app/models/post_params_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/provider/dashboard_provider_model.dart';
import 'package:mohem_flutter_app/provider/eit_provider_model.dart';
-import 'package:mohem_flutter_app/provider/hmg_connection_provider.dart';
import 'package:mohem_flutter_app/theme/app_theme.dart';
import 'package:mohem_flutter_app/ui/marathon/marathon_provider.dart';
import 'package:month_year_picker/month_year_picker.dart';
@@ -28,7 +28,6 @@ Logger logger = Logger(
// output: null, // U
);
-
class MyHttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
@@ -71,9 +70,9 @@ Future main() async {
ChangeNotifierProvider(
create: (_) => MarathonProvider(),
),
- ChangeNotifierProvider(
- create: (_) => HmgConnectionProvider(),
- )
+ // ChangeNotifierProvider(
+ // create: (_) => ChatCallProvider(),
+ // ),
],
child: const MyApp(),
),
@@ -265,4 +264,3 @@ class MyApp extends StatelessWidget {
// });
// }
// }
-
diff --git a/lib/models/chat/call.dart b/lib/models/chat/call.dart
index 7f8f6eb..ce58ae3 100644
--- a/lib/models/chat/call.dart
+++ b/lib/models/chat/call.dart
@@ -7,127 +7,191 @@ import 'dart:convert';
class CallDataModel {
CallDataModel({
this.callerId,
- this.callReceiverID,
- this.notificationForeground,
- this.message,
+ this.callerDetails,
+ this.receiverId,
+ this.receiverDetails,
this.title,
- this.type,
- this.identity,
- this.name,
- this.isCall,
- this.isWebrtc,
- this.contant,
- this.contantNo,
- this.chatEventId,
- this.fileTypeId,
- this.currentUserId,
- this.chatSource,
- this.userChatHistoryLineRequestList,
- this.server,
+ this.calltype,
});
String? callerId;
- String? callReceiverID;
- String? notificationForeground;
- String? message;
- String? title;
- String? type;
- String? identity;
- String? name;
- String? isCall;
- String? isWebrtc;
- String? contant;
- String? contantNo;
- String? chatEventId;
- dynamic? fileTypeId;
- String? currentUserId;
- String? chatSource;
- List? userChatHistoryLineRequestList;
- String? server;
+ CallerDetails? callerDetails;
+ String? receiverId;
+ ReceiverDetails? receiverDetails;
+ dynamic title;
+ String? calltype;
factory CallDataModel.fromRawJson(String str) => CallDataModel.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory CallDataModel.fromJson(Map json) => CallDataModel(
- callerId: json["callerID"] == null ? null : json["callerID"],
- callReceiverID: json["callReceiverID"] == null ? null : json["callReceiverID"],
- notificationForeground: json["notification_foreground"] == null ? null : json["notification_foreground"],
- message: json["message"] == null ? null : json["message"],
- title: json["title"] == null ? null : json["title"],
- type: json["type"] == null ? null : json["type"],
- identity: json["identity"] == null ? null : json["identity"],
- name: json["name"] == null ? null : json["name"],
- isCall: json["is_call"] == null ? null : json["is_call"],
- isWebrtc: json["is_webrtc"] == null ? null : json["is_webrtc"],
- contant: json["contant"] == null ? null : json["contant"],
- contantNo: json["contantNo"] == null ? null : json["contantNo"],
- chatEventId: json["chatEventId"] == null ? null : json["chatEventId"],
- fileTypeId: json["fileTypeId"],
- currentUserId: json["currentUserId"] == null ? null : json["currentUserId"],
- chatSource: json["chatSource"] == null ? null : json["chatSource"],
- userChatHistoryLineRequestList: json["userChatHistoryLineRequestList"] == null
- ? null
- : List.from(
- json["userChatHistoryLineRequestList"].map(
- (x) => UserChatHistoryLineRequestList.fromJson(x),
- ),
- ),
- server: json["server"] == null ? null : json["server"],
- );
+ callerId: json["callerID"],
+ callerDetails: json["callerDetails"] == null ? null : CallerDetails.fromJson(json["callerDetails"]),
+ receiverId: json["receiverID"],
+ receiverDetails: json["receiverDetails"] == null ? null : ReceiverDetails.fromJson(json["receiverDetails"]),
+ title: json["title"],
+ calltype: json["calltype"],
+ );
+
+ Map toJson() => {
+ "callerID": callerId,
+ "callerDetails": callerDetails?.toJson(),
+ "receiverID": receiverId,
+ "receiverDetails": receiverDetails?.toJson(),
+ "title": title,
+ "calltype": calltype,
+ };
+}
+
+class CallerDetails {
+ CallerDetails({
+ this.response,
+ this.errorResponses,
+ });
+
+ Response? response;
+ dynamic errorResponses;
+
+ factory CallerDetails.fromRawJson(String str) => CallerDetails.fromJson(json.decode(str));
+
+ String toRawJson() => json.encode(toJson());
+
+ factory CallerDetails.fromJson(Map json) => CallerDetails(
+ response: json["response"] == null ? null : Response.fromJson(json["response"]),
+ errorResponses: json["errorResponses"],
+ );
Map toJson() => {
- "callerID": callerId == null ? null : callerId,
- "callReceiverID": callReceiverID == null ? null : callReceiverID,
- "notification_foreground": notificationForeground == null ? null : notificationForeground,
- "message": message == null ? null : message,
- "title": title == null ? null : title,
- "type": type == null ? null : type,
- "identity": identity == null ? null : identity,
- "name": name == null ? null : name,
- "is_call": isCall == null ? null : isCall,
- "is_webrtc": isWebrtc == null ? null : isWebrtc,
- "contant": contant == null ? null : contant,
- "contantNo": contantNo == null ? null : contantNo,
- "chatEventId": chatEventId == null ? null : chatEventId,
- "fileTypeId": fileTypeId,
- "currentUserId": currentUserId == null ? null : currentUserId,
- "chatSource": chatSource == null ? null : chatSource,
- "userChatHistoryLineRequestList": userChatHistoryLineRequestList == null
- ? null
- : List.from(
- userChatHistoryLineRequestList!.map(
- (x) => x.toJson(),
- ),
- ),
- "server": server == null ? null : server,
- };
+ "response": response?.toJson(),
+ "errorResponses": errorResponses,
+ };
}
-class UserChatHistoryLineRequestList {
- UserChatHistoryLineRequestList({
- this.isSeen,
- this.isDelivered,
- this.targetUserId,
- this.targetUserStatus,
+class Response {
+ Response({
+ this.id,
+ this.userName,
+ this.email,
+ this.phone,
+ this.title,
+ this.token,
+ this.isDomainUser,
+ this.isActiveCode,
+ this.encryptedUserId,
+ this.encryptedUserName,
});
- bool? isSeen;
- bool? isDelivered;
- int? targetUserId;
- int? targetUserStatus;
+ int? id;
+ String? userName;
+ String? email;
+ dynamic phone;
+ String? title;
+ String? token;
+ bool? isDomainUser;
+ bool? isActiveCode;
+ String? encryptedUserId;
+ String? encryptedUserName;
+
+ factory Response.fromRawJson(String str) => Response.fromJson(json.decode(str));
+
+ String toRawJson() => json.encode(toJson());
+
+ factory Response.fromJson(Map json) => Response(
+ id: json["id"],
+ userName: json["userName"],
+ email: json["email"],
+ phone: json["phone"],
+ title: json["title"],
+ token: json["token"],
+ isDomainUser: json["isDomainUser"],
+ isActiveCode: json["isActiveCode"],
+ encryptedUserId: json["encryptedUserId"],
+ encryptedUserName: json["encryptedUserName"],
+ );
+
+ Map toJson() => {
+ "id": id,
+ "userName": userName,
+ "email": email,
+ "phone": phone,
+ "title": title,
+ "token": token,
+ "isDomainUser": isDomainUser,
+ "isActiveCode": isActiveCode,
+ "encryptedUserId": encryptedUserId,
+ "encryptedUserName": encryptedUserName,
+ };
+}
+
+class ReceiverDetails {
+ ReceiverDetails({
+ 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,
+ });
+
+ int? id;
+ String? userName;
+ String? email;
+ dynamic phone;
+ dynamic title;
+ int? userStatus;
+ String? image;
+ int? unreadMessageCount;
+ dynamic userAction;
+ bool? isPin;
+ bool? isFav;
+ bool? isAdmin;
+ String? rKey;
+ int? totalCount;
+
+ factory ReceiverDetails.fromRawJson(String str) => ReceiverDetails.fromJson(json.decode(str));
+
+ String toRawJson() => json.encode(toJson());
- factory UserChatHistoryLineRequestList.fromJson(Map json) => UserChatHistoryLineRequestList(
- isSeen: json["isSeen"] == null ? null : json["isSeen"],
- isDelivered: json["isDelivered"] == null ? null : json["isDelivered"],
- targetUserId: json["targetUserId"] == null ? null : json["targetUserId"],
- targetUserStatus: json["targetUserStatus"] == null ? null : json["targetUserStatus"],
- );
+ factory ReceiverDetails.fromJson(Map json) => ReceiverDetails(
+ 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"],
+ );
Map toJson() => {
- "isSeen": isSeen == null ? null : isSeen,
- "isDelivered": isDelivered == null ? null : isDelivered,
- "targetUserId": targetUserId == null ? null : targetUserId,
- "targetUserStatus": targetUserStatus == null ? null : targetUserStatus,
- };
+ "id": id,
+ "userName": userName,
+ "email": email,
+ "phone": phone,
+ "title": title,
+ "userStatus": userStatus,
+ "image": image,
+ "unreadMessageCount": unreadMessageCount,
+ "userAction": userAction,
+ "isPin": isPin,
+ "isFav": isFav,
+ "isAdmin": isAdmin,
+ "rKey": rKey,
+ "totalCount": totalCount,
+ };
}
diff --git a/lib/models/generic_response_model.dart b/lib/models/generic_response_model.dart
index ed00de4..a5677af 100644
--- a/lib/models/generic_response_model.dart
+++ b/lib/models/generic_response_model.dart
@@ -28,6 +28,7 @@ import 'package:mohem_flutter_app/models/get_mobile_login_info_list_model.dart';
import 'package:mohem_flutter_app/models/get_notification_buttons_list_model.dart';
import 'package:mohem_flutter_app/models/get_po_Item_history_list_model.dart';
import 'package:mohem_flutter_app/models/get_po_notification_body_list_model.dart';
+import 'package:mohem_flutter_app/models/get_pr_information_list.dart';
import 'package:mohem_flutter_app/models/get_pr_notification_body_list_model.dart';
import 'package:mohem_flutter_app/models/get_quotation_analysis_list_model.dart';
import 'package:mohem_flutter_app/models/get_schedule_shifts_details_list_model.dart';
@@ -226,6 +227,7 @@ class GenericResponseModel {
List? getPoItemHistoryList;
GetPoNotificationBodyList? getPoNotificationBodyList;
GetPrNotificationBodyList? getPrNotificationBodyList;
+ GetPRInformationList? getPRInformationList;
List? getQuotationAnalysisList;
List? getRFCEmployeeListList;
List? getRespondAttributeValueList;
@@ -490,6 +492,7 @@ class GenericResponseModel {
this.getPoItemHistoryList,
this.getPoNotificationBodyList,
this.getPrNotificationBodyList,
+ this.getPRInformationList,
this.getQuotationAnalysisList,
this.getRFCEmployeeListList,
this.getRespondAttributeValueList,
@@ -979,6 +982,7 @@ class GenericResponseModel {
}
getPoNotificationBodyList = json['GetPoNotificationBodyList'] != null ? GetPoNotificationBodyList.fromJson(json['GetPoNotificationBodyList']) : null;
getPrNotificationBodyList = json['GetPrNotificationBodyList'] != null ? GetPrNotificationBodyList.fromJson(json['GetPrNotificationBodyList']) : null;
+ getPRInformationList = json['PR_Information_List'] != null ? GetPRInformationList.fromJson(json['PR_Information_List']) : null;
if (json['GetQuotationAnalysisList'] != null) {
getQuotationAnalysisList = [];
json['GetQuotationAnalysisList'].forEach((v) {
@@ -1602,6 +1606,10 @@ class GenericResponseModel {
data['GetPrNotificationBodyList'] = this.getPrNotificationBodyList!.toJson();
}
+ if (this.getPRInformationList != null) {
+ data['PR_Information_List'] = this.getPRInformationList!.toJson();
+ }
+
if (this.getQuotationAnalysisList != null) {
data['GetQuotationAnalysisList'] = this.getQuotationAnalysisList!.map((v) => v.toJson()).toList();
}
diff --git a/lib/models/get_po_notification_body_list_model.dart b/lib/models/get_po_notification_body_list_model.dart
index d0473dc..a1a56e6 100644
--- a/lib/models/get_po_notification_body_list_model.dart
+++ b/lib/models/get_po_notification_body_list_model.dart
@@ -158,6 +158,7 @@ class POLines {
String? nEEDBYDATE;
int? nOOFROWS;
int? pOHEADERID;
+ int? pOLINEID;
String? pROMISEDDATE;
String? pRNUM;
num? qUANTITY;
@@ -181,6 +182,7 @@ class POLines {
this.nEEDBYDATE,
this.nOOFROWS,
this.pOHEADERID,
+ this.pOLINEID,
this.pROMISEDDATE,
this.pRNUM,
this.qUANTITY,
@@ -204,6 +206,7 @@ class POLines {
nEEDBYDATE = json['NEED_BY_DATE'];
nOOFROWS = json['NO_OF_ROWS'];
pOHEADERID = json['PO_HEADER_ID'];
+ pOLINEID = json['PO_LINE_ID'];
pROMISEDDATE = json['PROMISED_DATE'];
pRNUM = json['PR_NUM'];
qUANTITY = json['QUANTITY'];
@@ -229,6 +232,7 @@ class POLines {
data['NEED_BY_DATE'] = this.nEEDBYDATE;
data['NO_OF_ROWS'] = this.nOOFROWS;
data['PO_HEADER_ID'] = this.pOHEADERID;
+ data['PO_LINE_ID'] = this.pOLINEID;
data['PROMISED_DATE'] = this.pROMISEDDATE;
data['PR_NUM'] = this.pRNUM;
data['QUANTITY'] = this.qUANTITY;
diff --git a/lib/models/get_pr_information_list.dart b/lib/models/get_pr_information_list.dart
new file mode 100644
index 0000000..33ede12
--- /dev/null
+++ b/lib/models/get_pr_information_list.dart
@@ -0,0 +1,125 @@
+class GetPRInformationList {
+ List? pRHeader;
+ List? pRLines;
+ String? pCURRENCYCODE;
+
+ GetPRInformationList({this.pRHeader, this.pRLines, this.pCURRENCYCODE});
+
+ GetPRInformationList.fromJson(Map json) {
+ if (json['PRHeader'] != null) {
+ pRHeader = [];
+ json['PRHeader'].forEach((v) {
+ pRHeader!.add(new PRHeader.fromJson(v));
+ });
+ }
+ if (json['PRLines'] != null) {
+ pRLines = [];
+ json['PRLines'].forEach((v) {
+ pRLines!.add(new PRLines.fromJson(v));
+ });
+ }
+ pCURRENCYCODE = json['P_CURRENCY_CODE'];
+ }
+
+ Map toJson() {
+ Map data = new Map();
+ 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 json) {
+ dESCRIPTION = json['DESCRIPTION'];
+ pRNUMBER = json['PR_NUMBER'];
+ rEQUISITIONTOTAL = json['REQUISITION_TOTAL'];
+ tAXTOTAL = json['TAX_TOTAL'];
+ }
+
+ Map toJson() {
+ Map data = new Map();
+ 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 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 toJson() {
+ Map data = new Map();
+ 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;
+ }
+}
diff --git a/lib/provider/chat_call_provider.dart b/lib/provider/chat_call_provider.dart
new file mode 100644
index 0000000..45205df
--- /dev/null
+++ b/lib/provider/chat_call_provider.dart
@@ -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 _createPeerConnection() async {
+ // {"url": "stun:stun.l.google.com:19302"},
+ Map configuration = {
+ "iceServers": [
+ {"urls": 'stun:15.185.116.59:3478'},
+ {"urls": "turn:15.185.116.59:3479", "username": "admin", "credential": "admin"}
+ ]
+ };
+
+ Map 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 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