diff --git a/lib/analytics/google-analytics.dart b/lib/analytics/google-analytics.dart index dc4ef2da..e30d9d8f 100644 --- a/lib/analytics/google-analytics.dart +++ b/lib/analytics/google-analytics.dart @@ -13,7 +13,6 @@ import 'package:diplomaticquarterapp/services/permission/permission_service.dart import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; -import 'package:firebase_analytics/observer.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:geocoding/geocoding.dart'; @@ -65,7 +64,7 @@ class GAnalytics { if (await PermissionService.isLocationEnabled()) { final location = await Geolocator.getCurrentPosition(); if (location != null && !location.isMocked) { - final places = await placemarkFromCoordinates(location.latitude, location.longitude, localeIdentifier: 'en_US'); + final places = await placemarkFromCoordinates(location.latitude, location.longitude); final countryCode = places.first.isoCountryCode; _analytics.setUserProperty(name: 'user_country', value: countryCode); } diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart index 49bc7e97..5b6e76ad 100644 --- a/lib/pages/livecare/incoming_call.dart +++ b/lib/pages/livecare/incoming_call.dart @@ -1,26 +1,24 @@ -import 'dart:ui'; - -import 'package:camera/camera.dart'; import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; import 'package:diplomaticquarterapp/pages/conference/widgets/platform_exception_alert_dialog.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; -import 'package:diplomaticquarterapp/pages/videocall-webrtc-rnd/webrtc/start_video_call.dart'; import 'package:diplomaticquarterapp/pages/webRTC/OpenTok/OpenTok.dart'; -import 'package:diplomaticquarterapp/pages/webRTC/signaling.dart'; import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/voipcall/provider/chat_call_provider.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:just_audio/just_audio.dart'; +import 'package:logger/logger.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:provider/provider.dart'; import '../../config/config.dart'; - class IncomingCall extends StatefulWidget { IncomingCallData? incomingCallData; - IncomingCall({ this.incomingCallData}); + IncomingCall({this.incomingCallData}); @override _IncomingCallState createState() => _IncomingCallState(); @@ -29,12 +27,10 @@ class IncomingCall extends StatefulWidget { class _IncomingCallState extends State with SingleTickerProviderStateMixin { late AnimationController _animationController; bool openCallInWeb = true; - final player = AudioPlayer(); - late CameraController _controller; - late Future _initializeControllerFuture; bool isCameraReady = false; - // Signaling signaling = Signaling()..init(); + Logger mylogs = Logger(); + ChatCallProvider? callProv; @override void initState() { @@ -42,6 +38,7 @@ class _IncomingCallState extends State with SingleTickerProviderSt isCameraReady = false; WidgetsBinding.instance.addPostFrameCallback((_) => _runAnimation()); + //mylogs.d(widget.incomingCallData!.toJson()); super.initState(); } @@ -49,149 +46,154 @@ class _IncomingCallState extends State with SingleTickerProviderSt void dispose() { _animationController.dispose(); player.stop(); - // _controller.dispose(); disposeAudioResources(); super.dispose(); } + acceptCall() async { + Future micPer = Permission.microphone.request(); + Future camPer = Permission.camera.request(); + if (await micPer.isGranted && await camPer.isGranted) { + await callProv!.buildHubConnection(); + } else if (await micPer.isDenied) { + micPer = Permission.microphone.request(); + } else if (await camPer.isDenied) { + camPer = Permission.camera.request(); + } + } + @override Widget build(BuildContext context) { + callProv = Provider.of(context); return AppScaffold( isShowAppBar: false, isShowDecPage: false, body: Stack( - alignment: FractionalOffset.center, - children: [ - // new Positioned.fill( - // child: new AspectRatio(aspectRatio: _controller.value.aspectRatio, child: new CameraPreview(_controller)), - // ), - new Positioned.fill( - child: new ClipRect( - // child: new BackdropFilter( - // filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - child: new Container( - decoration: new BoxDecoration(color: Colors.grey[800]!.withOpacity(0.8)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - margin: const EdgeInsets.all(21.0), - child: Row( - children: [ - Image.asset( - "assets/images/new/logo.png", - height: 70, - width: 70, - ), - Container( - margin: const EdgeInsets.only(left: 10.0, right: 10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text( - widget.incomingCallData!.doctorname!, - style: TextStyle(fontSize: 21, fontWeight: FontWeight.bold, color: Colors.white, letterSpacing: -1.26, height: 23 / 12), - ), - Text( - TranslationBase.of(context).videoAppo, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xffC6C6C6), letterSpacing: -0.48, height: 23 / 24), - ), - SizedBox(height: 2), - ], - ), - ), - ], - ), + alignment: FractionalOffset.center, + children: [ + new Positioned.fill( + child: new ClipRect( + child: new Container( + decoration: new BoxDecoration(color: Colors.grey[800]!.withOpacity(0.8)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + margin: const EdgeInsets.all(21.0), + child: Row( + children: [ + Image.asset( + "assets/images/new/logo.png", + height: 70, + width: 70, + ), + Container( + margin: const EdgeInsets.only(left: 10.0, right: 10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Text( + widget.incomingCallData!.doctorname!, + style: TextStyle(fontSize: 21, fontWeight: FontWeight.bold, color: Colors.white, letterSpacing: -1.26, height: 23 / 12), + ), + Text( + TranslationBase.of(context).videoAppo, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xffC6C6C6), letterSpacing: -0.48, height: 23 / 24), + ), + SizedBox(height: 2), + ], ), - Container( - margin: const EdgeInsets.all(21.0), - width: MediaQuery.of(context).size.width, - decoration: cardRadius(15.0, color: Colors.black), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 6.0), - child: Text( - TranslationBase.of(context).appoInfo, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.64, height: 23 / 12), - ), - ), - Container( - padding: const EdgeInsets.only(left: 16.0, right: 16.0), - child: Text( - widget.incomingCallData!.appointmentdate! + ", " + widget.incomingCallData!.appointmenttime!, - style: TextStyle(fontSize: 12.0, letterSpacing: -0.48, color: Color(0xff8E8E8E), fontWeight: FontWeight.w600), - ), - ), - Container( - padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 21.0), - child: Text( - widget.incomingCallData!.clinicname!, - style: TextStyle(fontSize: 12.0, letterSpacing: -0.48, color: Color(0xff8E8E8E), fontWeight: FontWeight.w600), - ), - ), - ], - ), + ), + ], + ), + ), + Container( + margin: const EdgeInsets.all(21.0), + width: MediaQuery.of(context).size.width, + decoration: cardRadius(15.0, color: Colors.black), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 6.0), + child: Text( + TranslationBase.of(context).appoInfo, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Colors.white, letterSpacing: -0.64, height: 23 / 12), ), - Spacer(), - Container( - margin: EdgeInsets.only(bottom: 70.0, left: 49, right: 49), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - RotationTransition( - turns: Tween(begin: 0.0, end: -.1).chain(CurveTween(curve: Curves.elasticIn)).animate(_animationController), - child: Container( - child: RawMaterialButton( - onPressed: () { - _submit(); - }, - elevation: 2.0, - fillColor: Colors.green, - child: Icon( - Icons.call, - color: Colors.white, - size: 35.0, - ), - padding: EdgeInsets.all(15.0), - shape: CircleBorder(), - ), - )), - Container( - child: RawMaterialButton( - onPressed: () { - backToHome(); - }, - elevation: 2.0, - fillColor: Colors.red, - child: Icon( - Icons.call_end, - color: Colors.white, - size: 35.0, - ), - padding: EdgeInsets.all(15.0), - shape: CircleBorder(), - ), + ), + Container( + padding: const EdgeInsets.only(left: 16.0, right: 16.0), + child: Text( + widget.incomingCallData!.appointmentdate! + ", " + widget.incomingCallData!.appointmenttime!, + style: TextStyle(fontSize: 12.0, letterSpacing: -0.48, color: Color(0xff8E8E8E), fontWeight: FontWeight.w600), + ), + ), + Container( + padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 21.0), + child: Text( + widget.incomingCallData!.clinicname!, + style: TextStyle(fontSize: 12.0, letterSpacing: -0.48, color: Color(0xff8E8E8E), fontWeight: FontWeight.w600), + ), + ), + ], + ), + ), + Spacer(), + Container( + margin: EdgeInsets.only(bottom: 70.0, left: 49, right: 49), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + RotationTransition( + turns: Tween(begin: 0.0, end: -.1).chain(CurveTween(curve: Curves.elasticIn)).animate(_animationController), + child: Container( + child: RawMaterialButton( + onPressed: () { + // _submit(); + callProv!.incomingCallData = widget.incomingCallData; + acceptCall(); + }, + elevation: 2.0, + fillColor: Colors.green, + child: Icon( + Icons.call, + color: Colors.white, + size: 35.0, ), - ], + padding: EdgeInsets.all(15.0), + shape: CircleBorder(), + ), + )), + Container( + child: RawMaterialButton( + onPressed: () { + backToHome(); + }, + elevation: 2.0, + fillColor: Colors.red, + child: Icon( + Icons.call_end, + color: Colors.white, + size: 35.0, ), + padding: EdgeInsets.all(15.0), + shape: CircleBorder(), ), - ], - ), + ), + ], ), ), - ), - // ), - ] - // } else { - // return const Center(child: CircularProgressIndicator()); - // } + ], + ), + ), + ), + ), + ], ), ); } @@ -224,17 +226,12 @@ class _IncomingCallState extends State with SingleTickerProviderSt // if(widget.incomingCallData.isWebRTC == "true"){ // return StartVideoCall(caller: caller, receiver: receiver, iAmCaller: false, host: host); // }else{ - return OpenTokConnectCallPage( - apiKey: OPENTOK_API_KEY, - sessionId: widget.incomingCallData!.sessionId!, - token: widget.incomingCallData!.token! - ); + return OpenTokConnectCallPage(apiKey: OPENTOK_API_KEY, sessionId: widget.incomingCallData!.sessionId!, token: widget.incomingCallData!.token!); // } // return VideoCallWebPage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); // Web WebRTC VideoCall // return CallHomePage(receiverId: widget.incomingCallData.receiverID, callerId: widget.incomingCallData.callerID); // App WebRTC VideoCall - }, ), ); @@ -248,8 +245,7 @@ class _IncomingCallState extends State with SingleTickerProviderSt void changeCallStatusAPI(int sessionStatus) { LiveCareService service = new LiveCareService(); - service.endCallAPI(widget.incomingCallData!.sessionId!, sessionStatus, context).then((res) { - }).catchError((err) { + service.endCallAPI(widget.incomingCallData!.sessionId!, sessionStatus, context).then((res) {}).catchError((err) { print(err); }); } @@ -268,7 +264,7 @@ class _IncomingCallState extends State with SingleTickerProviderSt void setAudioFile() async { player.stop(); - await player.setVolume(1.0); // full volume + await player.setVolume(1.0); try { await player.setAsset('assets/sounds/ring_60Sec.mp3').then((value) { player.setLoopMode(LoopMode.one); // loop ring sound diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index e773957a..ee471514 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -8,7 +8,6 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_mod import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/extensions/string_extensions.dart'; import 'package:diplomaticquarterapp/locator.dart'; -import 'package:diplomaticquarterapp/main.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; @@ -33,26 +32,20 @@ import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:intl/intl.dart'; import 'package:local_auth/local_auth.dart'; +import 'package:local_auth_darwin/local_auth_darwin.dart'; import 'package:provider/provider.dart'; -import 'package:local_auth_ios/local_auth_ios.dart'; class ConfirmLogin extends StatefulWidget { final Function? changePageViewIndex; final fromRegistration; final bool isDubai; - const ConfirmLogin( - {Key? key, - this.changePageViewIndex, - this.fromRegistration = false, - this.isDubai = false}) - : super(key: key); + const ConfirmLogin({Key? key, this.changePageViewIndex, this.fromRegistration = false, this.isDubai = false}) : super(key: key); @override _ConfirmLogin createState() => _ConfirmLogin(); @@ -64,8 +57,7 @@ class _ConfirmLogin extends State { var sharedPref = AppSharedPreferences(); bool authenticated = false; final authService = AuthProvider(); - PharmacyModuleViewModel pharmacyModuleViewModel = - locator(); + PharmacyModuleViewModel pharmacyModuleViewModel = locator(); late int mobileNumber; String errorMsg = ''; SelectDeviceIMEIRES? user; @@ -95,10 +87,8 @@ class _ConfirmLogin extends State { int fingrePrintBefore = 0; - AuthenticatedUserObject authenticatedUserObject = - locator(); - AppointmentRateViewModel appointmentRateViewModel = - locator(); + AuthenticatedUserObject authenticatedUserObject = locator(); + AppointmentRateViewModel appointmentRateViewModel = locator(); late ProjectViewModel projectViewModel; late ToDoCountProviderModel toDoProvider; @@ -146,30 +136,16 @@ class _ConfirmLogin extends State { children: [ Text( TranslationBase.of(context).welcomeBack, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64), + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64), ), Text( user!.name!.toLowerCase().capitalizeFirstofEach, - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.w700, - color: Color(0xff2B353E), - height: 1, - letterSpacing: -1.44), + style: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: Color(0xff2B353E), height: 1, letterSpacing: -1.44), ), SizedBox(height: 10), Text( TranslationBase.of(context).accountInfo, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64, - height: 25 / 16), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), ), Container( height: 72, @@ -188,46 +164,28 @@ class _ConfirmLogin extends State { mainAxisSize: MainAxisSize.min, children: [ Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - TranslationBase.of(context) - .lastLoginAt - .toCamelCase, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64), + TranslationBase.of(context).lastLoginAt.toCamelCase, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64), ), Text( // user!.editedOn != null // ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user!.editedOn!)) // : - user!.createdOn != null - ? DateUtil.getDayMonthYearDateFormatted( - DateUtil.convertStringToDate( - user!.createdOn!)) - : '--', - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.48), + user!.createdOn != null ? DateUtil.getDayMonthYearDateFormatted(DateUtil.convertStringToDate(user!.createdOn!)) : '--', + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.48), ), ], ), Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - TranslationBase.of(context) - .lastLoginWith - .toCamelCase, + TranslationBase.of(context).lastLoginWith.toCamelCase, style: TextStyle( fontSize: 10, fontWeight: FontWeight.w600, @@ -250,17 +208,8 @@ class _ConfirmLogin extends State { // user!.editedOn!), // false) // : - user!.createdOn != null - ? DateUtil.formatDateToTimeLang( - DateUtil.convertStringToDate( - user!.createdOn!), - false) - : '--', - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xff575757), - letterSpacing: -0.48), + user!.createdOn != null ? DateUtil.formatDateToTimeLang(DateUtil.convertStringToDate(user!.createdOn!), false) : '--', + style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.48), ), ], ) @@ -269,18 +218,10 @@ class _ConfirmLogin extends State { ), Text( TranslationBase.of(context).pleaseVerify, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2E303A), - letterSpacing: -0.64), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), ), GridView( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 13, - mainAxisSpacing: 9), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), physics: NeverScrollableScrollPhysics(), padding: EdgeInsets.only(top: 9), shrinkWrap: true, @@ -294,62 +235,40 @@ class _ConfirmLogin extends State { ], ) else - Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Image.asset( - 'assets/images/habib-logo.png', - height: 90, - width: 90, - ), - SizedBox(height: 23), - this.onlySMSBox == false - ? Text( - TranslationBase.of(context).verifyLoginWith, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64, - height: 25 / 16), - ) - : Text( - TranslationBase.of(context) - .verifyFingerprint2, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2B353E), - letterSpacing: -0.64, - height: 25 / 16), - ), - SizedBox(height: 23), - Text( - TranslationBase.of(context).pleaseVerify, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: Color(0xff2E303A), - letterSpacing: -0.64), - ), - GridView( - gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 13, - mainAxisSpacing: 9), - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.only(top: 9), - shrinkWrap: true, - children: [ - if (onlySMSBox == false) getButton(3), - if (onlySMSBox == false) getButton(2), - getButton(1), - getButton(4), - ], - ), - ]), + Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + Image.asset( + 'assets/images/habib-logo.png', + height: 90, + width: 90, + ), + SizedBox(height: 23), + this.onlySMSBox == false + ? Text( + TranslationBase.of(context).verifyLoginWith, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), + ) + : Text( + TranslationBase.of(context).verifyFingerprint2, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 25 / 16), + ), + SizedBox(height: 23), + Text( + TranslationBase.of(context).pleaseVerify, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64), + ), + GridView( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 13, mainAxisSpacing: 9), + physics: NeverScrollableScrollPhysics(), + padding: EdgeInsets.only(top: 9), + shrinkWrap: true, + children: [ + if (onlySMSBox == false) getButton(3), + if (onlySMSBox == false) getButton(2), + getButton(1), + getButton(4), + ], + ), + ]), ], ), ), @@ -360,8 +279,7 @@ class _ConfirmLogin extends State { TranslationBase.of(context).useAnotherAccount, () { Navigator.of(context).pushNamed(LOGIN_TYPE); - projectViewModel.analytics.loginRegistration - .login_with_other_account(); + projectViewModel.analytics.loginRegistration.login_with_other_account(); }, ), ], @@ -372,8 +290,7 @@ class _ConfirmLogin extends State { Future _getAvailableBiometrics() async { final bool canAuthenticateWithBiometrics = await auth.canCheckBiometrics; - final bool canAuthenticate = - canAuthenticateWithBiometrics || await auth.isDeviceSupported(); + final bool canAuthenticate = canAuthenticateWithBiometrics || await auth.isDeviceSupported(); var availableBiometrics; try { @@ -402,8 +319,7 @@ class _ConfirmLogin extends State { login_method = type; LoginRegistration.verificationMethod = type; // if(!widget.fromRegistration) - projectViewModel.analytics.loginRegistration - .login_verfication(forRegistration: widget.fromRegistration); + projectViewModel.analytics.loginRegistration.login_verfication(forRegistration: widget.fromRegistration); switch (type) { case 1: @@ -421,8 +337,7 @@ class _ConfirmLogin extends State { default: break; } - sharedPref.setInt(LAST_LOGIN, - this.selectedOption); //this.cs.sharedService.setStorage(this.selectedOption, AuthenticationService.LAST_LOGIN); + sharedPref.setInt(LAST_LOGIN, this.selectedOption); //this.cs.sharedService.setStorage(this.selectedOption, AuthenticationService.LAST_LOGIN); } loginWithSMS(type) { @@ -478,8 +393,7 @@ class _ConfirmLogin extends State { GifLoaderDialogUtils.showMyDialog(context); if (healthId != null || widget.isDubai) { if (!widget.isDubai) { - request.dob = - dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); + request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); } request.healthId = healthId; request.isHijri = isHijri; @@ -535,11 +449,7 @@ class _ConfirmLogin extends State { stickyAuth: true, ), authMessages: [ - IOSAuthMessages( - cancelButton: 'cancel', - goToSettingsButton: 'settings', - goToSettingsDescription: 'Please set up your Touch ID.', - lockOut: 'Please reenable your Touch ID'), + IOSAuthMessages(cancelButton: 'cancel', goToSettingsButton: 'settings', goToSettingsDescription: 'Please set up your Touch ID.', lockOut: 'Please reenable your Touch ID'), ], ); } on PlatformException catch (e) { @@ -595,19 +505,14 @@ class _ConfirmLogin extends State { setDefault() async { showLoader(true); - if (await sharedPref.getObject(IMEI_USER_DATA) != null) - user = SelectDeviceIMEIRES.fromJson( - await sharedPref.getObject(IMEI_USER_DATA)); + if (await sharedPref.getObject(IMEI_USER_DATA) != null) user = SelectDeviceIMEIRES.fromJson(await sharedPref.getObject(IMEI_USER_DATA)); if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { isMoreOption = true; - this.registerd_data = await CheckPatientAuthenticationReq.fromJson( - await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); + this.registerd_data = await CheckPatientAuthenticationReq.fromJson(await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); } - this.mobileNumber = this.registerd_data != null - ? this.registerd_data.patientMobileNumber - : int.parse(this.user!.mobile!); + this.mobileNumber = this.registerd_data != null ? this.registerd_data.patientMobileNumber : int.parse(this.user!.mobile!); this.zipCode = this.registerd_data != null ? this.registerd_data.zipCode : this.user!.outSA == true @@ -626,9 +531,7 @@ class _ConfirmLogin extends State { if (nhic != null) { final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); - dob = nhic['IsHijri'] - ? nhic['DateOfBirth'] - : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); + dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); isHijri = nhic['IsHijri'] ? 1 : 0; healthId = nhic['HealthId']; @@ -651,34 +554,22 @@ class _ConfirmLogin extends State { request.deviceToken = this.deviceToken; request.projectOutSA = this.patientOutSA == true ? true : false; request.loginType = this.selectedOption; - request.oTPSendType = - type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2; + request.oTPSendType = type == 1 ? type : 2; //this.selectedOption == 1 ? 1 : 2; request.zipCode = this.zipCode; request.logInTokenID = this.loginTokenID ?? ""; if (this.registerd_data != null) { - request.searchType = this.registerd_data.searchType != null - ? this.registerd_data.searchType - : 1; - request.patientID = this.registerd_data.patientID != null - ? this.registerd_data.patientID - : 0; - request.patientIdentificationID = request.nationalID = - this.registerd_data.patientIdentificationID != null - ? this.registerd_data.patientIdentificationID - : '0'; + request.searchType = this.registerd_data.searchType != null ? this.registerd_data.searchType : 1; + request.patientID = this.registerd_data.patientID != null ? this.registerd_data.patientID : 0; + request.patientIdentificationID = request.nationalID = this.registerd_data.patientIdentificationID != null ? this.registerd_data.patientIdentificationID : '0'; request.dob = this.registerd_data.dob; request.isRegister = this.registerd_data.isRegister; } else { request.searchType = request.searchType != null ? request.searchType : 2; - request.patientID = - this.user!.patientID != null ? this.user!.patientID : 0; - request.nationalID = - request.nationalID != null ? request.nationalID : '0'; - request.patientIdentificationID = request.patientIdentificationID != null - ? request.patientIdentificationID - : '0'; + request.patientID = this.user!.patientID != null ? this.user!.patientID : 0; + request.nationalID = request.nationalID != null ? request.nationalID : '0'; + request.patientIdentificationID = request.patientIdentificationID != null ? request.patientIdentificationID : '0'; request.isRegister = false; } request.deviceTypeID = request.searchType; @@ -703,19 +594,14 @@ class _ConfirmLogin extends State { res = result, if (result is Map) { - result = CheckActivationCode.fromJson( - result as Map), - if (this.registerd_data != null && - this.registerd_data.isRegister == true) + result = CheckActivationCode.fromJson(result as Map), + if (this.registerd_data != null && this.registerd_data.isRegister == true) { // if(widget.isDubai ==false){ widget.changePageViewIndex!(1), // if(widget.isDubai ==false){ - Navigator.popUntil( - context, - (route) => - Utils.route(route, equalsTo: RegisterNew)), + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), } } else @@ -725,11 +611,8 @@ class _ConfirmLogin extends State { Future.delayed(Duration(seconds: 1), () { AppToast.showErrorToast(message: result); }), - projectViewModel.analytics.loginRegistration - .login_fail(error: result), - projectViewModel.analytics.errorTracking.log( - 'otp_verification_at_confirm_login', - error: result), + projectViewModel.analytics.loginRegistration.login_fail(error: result), + projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result), } }) .catchError((err) { @@ -747,36 +630,27 @@ class _ConfirmLogin extends State { res = result, if (result is Map) { - result = CheckActivationCode.fromJson( - result as Map), - if (this.registerd_data != null && - this.registerd_data.isRegister == true) + result = CheckActivationCode.fromJson(result as Map), + if (this.registerd_data != null && this.registerd_data.isRegister == true) { widget.changePageViewIndex!(1), - Navigator.popUntil( - context, - (route) => - Utils.route(route, equalsTo: RegisterNew)), + Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), } else { sharedPref.remove(FAMILY_FILE), result.list.isFamily = false, userData = result.list, - sharedPref.setString( - BLOOD_TYPE, result.patientBloodType ?? "O+"), + sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? "O+"), //Remove o+ from here Added by Aamir authenticatedUserObject.user = result.list, projectViewModel.setPrivilege(privilegeList: res), sharedPref.setObject(MAIN_USER, result.list), sharedPref.setObject(USER_PROFILE, result.list), loginTokenID = result.logInTokenID, - sharedPref.setObject( - LOGIN_TOKEN_ID, result.logInTokenID), - sharedPref.setString( - TOKEN, result.authenticationTokenID), - projectViewModel.analytics.loginRegistration - .login_successful(), + sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + sharedPref.setString(TOKEN, result.authenticationTokenID), + projectViewModel.analytics.loginRegistration.login_successful(), checkIfUserAgreedBefore(result), } } @@ -789,10 +663,8 @@ class _ConfirmLogin extends State { startSMSService(tempType); }), - projectViewModel.analytics.loginRegistration - .login_fail(error: result), - projectViewModel.analytics.errorTracking - .log('otp_verification_at_confirm_login', error: result) + projectViewModel.analytics.loginRegistration.login_fail(error: result), + projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result) } }) .catchError((err) { @@ -828,25 +700,17 @@ class _ConfirmLogin extends State { print("Has Admission Request: $hasAdmissionRequest"); if (isAdmitted) { if (res['PatientAdmittedInformation'].length != 0) { - getAdmissionInfoResponseModel = - GetAdmissionInfoResponseModel.fromJson( - res['PatientAdmittedInformation'][0]); - projectViewModel.setInPatientProjectID( - res['PatientAdmittedInformation'][0]['ProjectID']); - projectViewModel - .setInPatientAdmissionInfo(getAdmissionInfoResponseModel); + getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); + projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); + projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); projectViewModel.setIsPatientAdmitted(true); } } if (hasAdmissionRequest) { if (res['MedicalInstruction'].length != 0) { - getAdmissionRequestInfoResponseModel = - GetAdmissionRequestInfoResponseModel.fromJson( - res['MedicalInstruction'][0]); - projectViewModel.setInPatientProjectID( - res['MedicalInstruction'][0]['ProjectID']); - projectViewModel.setInPatientAdmissionRequest( - getAdmissionRequestInfoResponseModel); + getAdmissionRequestInfoResponseModel = GetAdmissionRequestInfoResponseModel.fromJson(res['MedicalInstruction'][0]); + projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['ProjectID']); + projectViewModel.setInPatientAdmissionRequest(getAdmissionRequestInfoResponseModel); projectViewModel.setPatientHasAdmissionRequest(true); } } @@ -855,10 +719,7 @@ class _ConfirmLogin extends State { } insertIMEI() { - authService - .insertDeviceImei(selectedOption) - .then((value) => {}) - .catchError((err) { + authService.insertDeviceImei(selectedOption).then((value) => {}).catchError((err) { print(err); }); } @@ -868,8 +729,7 @@ class _ConfirmLogin extends State { ClinicListService service = new ClinicListService(); service.getActiveAppointmentNo(context).then((res) { if (res['MessageStatus'] == 1) { - toDoProvider.setState(res['AppointmentActiveNumber'], - res['AncillaryOrderListCount'], true, "0"); + toDoProvider.setState(res['AppointmentActiveNumber'], res['AncillaryOrderListCount'], true, "0"); // toDoProvider.setState(res['AppointmentActiveNumber'], true, "0"); } else {} }).catchError((err) { @@ -931,14 +791,9 @@ class _ConfirmLogin extends State { }); } - Widget _loginOptionButton( - String _title, String _icon, int _flag, int? _loginIndex) { - bool isDisable = - (_flag == 3 && !checkIfBiometricAvailable(BiometricType.face) || - _flag == 2 && - !checkIfBiometricAvailable(BiometricType.fingerprint) && - _flag == 2 && - !checkIfBiometricAvailable(BiometricType.strong)); + Widget _loginOptionButton(String _title, String _icon, int _flag, int? _loginIndex) { + bool isDisable = (_flag == 3 && !checkIfBiometricAvailable(BiometricType.face) || + _flag == 2 && !checkIfBiometricAvailable(BiometricType.fingerprint) && _flag == 2 && !checkIfBiometricAvailable(BiometricType.strong)); return InkWell( onTap: isDisable ? null @@ -949,8 +804,7 @@ class _ConfirmLogin extends State { }); } else { authenticateUser(_flag, isActive: _loginIndex); - projectViewModel.analytics.loginRegistration.verify_otp_method( - forRegistration: widget.fromRegistration); + projectViewModel.analytics.loginRegistration.verify_otp_method(forRegistration: widget.fromRegistration); } }, child: Container( @@ -975,14 +829,7 @@ class _ConfirmLogin extends State { ), Text( TranslationBase.of(context).verifyThrough + " " + _title, - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.w600, - color: isDisable - ? Color(0xff2B353E).withOpacity(0.7) - : Color(0xff2B353E), - letterSpacing: -0.48, - height: 20 / 16), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: isDisable ? Color(0xff2B353E).withOpacity(0.7) : Color(0xff2B353E), letterSpacing: -0.48, height: 20 / 16), ), ], ), @@ -994,26 +841,16 @@ class _ConfirmLogin extends State { Widget getButton(int flag) { switch (flag) { case 4: - return _loginOptionButton(TranslationBase.of(context).verifyWhatsApp, - 'assets/images/new/verify_whatsapp.svg', flag, null); + return _loginOptionButton(TranslationBase.of(context).verifyWhatsApp, 'assets/images/new/verify_whatsapp.svg', flag, null); break; case 1: - return _loginOptionButton(TranslationBase.of(context).verifySMS, - 'assets/images/new/verify_sms.svg', flag, null); + return _loginOptionButton(TranslationBase.of(context).verifySMS, 'assets/images/new/verify_sms.svg', flag, null); break; case 2: - return _loginOptionButton( - TranslationBase.of(context).verifyFingerprint, - 'assets/images/new/verify_thumb.svg', - flag, - BiometricType.fingerprint.index); + return _loginOptionButton(TranslationBase.of(context).verifyFingerprint, 'assets/images/new/verify_thumb.svg', flag, BiometricType.fingerprint.index); break; case 3: - return _loginOptionButton( - TranslationBase.of(context).verifyFaceID, - 'assets/images/new/verify_face.svg', - flag, - BiometricType.face.index); + return _loginOptionButton(TranslationBase.of(context).verifyFaceID, 'assets/images/new/verify_face.svg', flag, BiometricType.face.index); break; default: @@ -1025,9 +862,7 @@ class _ConfirmLogin extends State { }, child: RoundedContainer( height: 150, - backgroundColor: BiometricType.fingerprint.index == 1 - ? Colors.white - : Colors.white.withOpacity(.7), + backgroundColor: BiometricType.fingerprint.index == 1 ? Colors.white : Colors.white.withOpacity(.7), borderColor: Colors.grey, showBorder: true, child: Padding( @@ -1046,10 +881,7 @@ class _ConfirmLogin extends State { : SizedBox( height: 20, ), - Texts(TranslationBase.of(context).moreVerification, - fontSize: SizeConfig.textMultiplier! * 1.8, - textAlign: TextAlign.center, - color: Colors.black) + Texts(TranslationBase.of(context).moreVerification, fontSize: SizeConfig.textMultiplier! * 1.8, textAlign: TextAlign.center, color: Colors.black) ], ), ), diff --git a/lib/uitl/push-notification-handler.dart b/lib/uitl/push-notification-handler.dart index 10538367..8aeb83f8 100644 --- a/lib/uitl/push-notification-handler.dart +++ b/lib/uitl/push-notification-handler.dart @@ -15,14 +15,10 @@ import 'package:diplomaticquarterapp/uitl/app-permissions.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:firebase_messaging/firebase_messaging.dart' as fir; import 'package:flutter/cupertino.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_ios_voip_kit/call_state_type.dart'; import 'package:flutter_ios_voip_kit/flutter_ios_voip_kit.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; -import 'package:get_it/get_it.dart'; import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; import 'package:huawei_push/huawei_push.dart' as h_push; import 'package:permission_handler/permission_handler.dart'; @@ -34,7 +30,7 @@ import 'navigation_service.dart'; @pragma('vm:entry-point') Future backgroundMessageHandler(dynamic message) async { print("Firebase backgroundMessageHandler!!!"); - fir.RemoteMessage message_; + RemoteMessage message_; if (message is h_push.RemoteMessage) { // if huawei remote message convert it to Firebase Remote Message message_ = toFirebaseRemoteMessage(message); @@ -293,7 +289,6 @@ class PushNotificationHandler { FirebaseMessaging.onBackgroundMessage(backgroundMessageHandler); FirebaseMessaging.instance.getToken(vapidKey: 'BHRJG8sIzcysWxPw3B6xQjz_85nUuCfU6EAmpH18kyUTmB2cj35IdFwCyWSab80SA1v6oBSWVh-p6PcHPw_y00Y').then((String? token) { - print("Push Notification getToken: " + token!); onToken(token!); }); @@ -307,12 +302,10 @@ class PushNotificationHandler { // onToken(token!); // }); FirebaseMessaging.instance.getToken(vapidKey: 'BHRJG8sIzcysWxPw3B6xQjz_85nUuCfU6EAmpH18kyUTmB2cj35IdFwCyWSab80SA1v6oBSWVh-p6PcHPw_y00Y').then((String? token) { - print("Push Notification getToken: " + token!); onToken(token!); }); - - if(Platform.isIOS) { + if (Platform.isIOS) { FirebaseMessaging.instance.getAPNSToken().then((value) { print("Push APNS getToken: " + value!); }); @@ -372,7 +365,6 @@ class PushNotificationHandler { ].request(); print("=-=-=-=-=-=-=-=-=-=-"); print(statuses[Permission.location]); - } } catch (_) { debugPrint(_.toString()); diff --git a/lib/voipcall/call/chat_incoming_call_screen.dart b/lib/voipcall/call/chat_incoming_call_screen.dart index 841eb1bb..b7aa9240 100644 --- a/lib/voipcall/call/chat_incoming_call_screen.dart +++ b/lib/voipcall/call/chat_incoming_call_screen.dart @@ -223,7 +223,7 @@ class _StartCallPageState extends State { height: 10, ), Text( - prov.incomingCallData!.targetUserName ?? "", + prov.incomingCallData!.doctorname ?? "", style: const TextStyle( fontSize: 21, decoration: TextDecoration.none, diff --git a/lib/voipcall/provider/chat_call_provider.dart b/lib/voipcall/provider/chat_call_provider.dart index 6f53e9dd..d82eddac 100644 --- a/lib/voipcall/provider/chat_call_provider.dart +++ b/lib/voipcall/provider/chat_call_provider.dart @@ -3,18 +3,18 @@ import 'dart:convert'; import 'dart:io'; import 'package:diplomaticquarterapp/locator.dart'; -import 'package:diplomaticquarterapp/main.dart'; +import 'package:diplomaticquarterapp/models/LiveCare/IncomingCallData.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/voipcall/call/chat_incoming_call_screen.dart'; import 'package:diplomaticquarterapp/voipcall/model/call.dart'; -import 'package:diplomaticquarterapp/voipcall/model/get_single_user_chat_call.dart'; import 'package:diplomaticquarterapp/voipcall/model/webrtc_payloads.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_webrtc/flutter_webrtc.dart'; import 'package:http/http.dart'; import 'package:just_audio/just_audio.dart'; +import 'package:logger/logger.dart' as log; import 'package:logging/logging.dart'; import 'package:signalr_netcore/signalr_client.dart'; @@ -41,7 +41,8 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { bool isAudioCall = false; bool isCallStarted = false; bool isFrontCamera = true; - SingleUserChatModel? incomingCallData; + + //SingleUserChatModel? incomingCallData; /// WebRTC Connection Variables bool isIncomingCallLoader = true; @@ -50,6 +51,15 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { bool isUserOnline = false; List devices = []; + log.Logger debuglogger = log.Logger(); + + IncomingCallData? _incomingCallData; + + IncomingCallData? get incomingCallData => _incomingCallData; + + set incomingCallData(IncomingCallData? value) { + _incomingCallData = value; + } // // // If you want only to log out the message for the higer level hub protocol: @@ -853,6 +863,10 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { } Future buildHubConnection() async { + doctorID = incomingCallData!.sessionId!.split("**").last; + // doctorID = "6wgFpttYUsdnB-klo-3xeg"; + String path = incomingCallData!.sessionId!.split("**").first; + patientID = incomingCallData!.receiverID; _logger = Logger("ChatPageViewModel"); final logger = _logger; @@ -865,30 +879,35 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { final httpConnectionOptions = new HttpConnectionOptions(httpClient: WebSupportingHttpClient(logger, httpClientCreateCallback: _httpClientCreateCallback), logger: logger, logMessageContent: true); - var urlWithParams = "https://ms.hmg.com/livecare/liveCareHub?UserID=4767770&ProjectId=15&IsAdmin=false&To=$doctorID"; + var urlWithParams = path + "UserID=$patientID&ProjectId=15&IsAdmin=false&To=$doctorID"; + print(urlWithParams); chatHubConnection = await HubConnectionBuilder().withUrl(urlWithParams, options: httpConnectionOptions).withAutomaticReconnect(retryDelays: [2000, 5000, 10000, 20000]).configureLogging(logger).build(); chatHubConnection!.onclose(({error}) { - print("Connection Closed"); + // print("Connection Closed"); Utils.showErrorToast(error.toString()); }); register(); if (chatHubConnection!.state == HubConnectionState.Disconnected) { await chatHubConnection!.start(); print(chatHubConnection!.state); - print("Success Chat Con ID::: " + chatHubConnection!.connectionId.toString()); } if (chatHubConnection!.state == HubConnectionState.Connected) { if (chatHubConnection != null) { - print(chatHubConnection!.connectionId); + patientID = chatHubConnection!.connectionId; + print("DOC: " + doctorID.toString()); + print("PAT " + patientID.toString()); + print("Success Chat Con ID::: " + chatHubConnection!.connectionId.toString()); try { - chatHubConnection!.invoke("Call_Accept", args: [ - {"UserID": 4767770} - ]); - // .onError((error, stackTrace) { - // Utils.showErrorToast(error.toString()); - // }); + chatHubConnection!.invoke("Call_Accepts", args: [ + // jsonEncode({"UserID": int.parse(incomingCallData!.receiverID!)}) + {"UserID": 4767780} + ]).onError( + (error, stackTrace) => print( + error.toString(), + ), + ); } catch (e) { print(e); } @@ -897,13 +916,23 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { } catch (e) { print(e.toString()); Utils.showErrorToast(e.toString()); - await buildHubConnection(); + chatHubConnection!.invoke("Call_Accepts", args: [ + // jsonEncode({"UserID": int.parse(incomingCallData!.receiverID!)}) + {4767780} + ]).onError( + (error, stackTrace) => print( + error.toString(), + ), + ); + // await buildHubConnection(); } } else { Utils.showErrorToast("Doctor ID is not correct"); } } + invoke(String method) async {} + void register() async { chatHubConnection!.on("pre-offer", handlePreOffer); chatHubConnection!.on("OnOffer", handleOnOffer); @@ -912,6 +941,16 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { chatHubConnection!.on("Call_Decline", handleCallDecline); chatHubConnection!.on("Call_NoAnswer", handleNoAnswerCall); chatHubConnection!.on("CallCompleted", handleCallComplete); + chatHubConnection!.on("connected_users", genericCheckEvent); + print("Listners Initiated"); + } + + genericCheckEvent(List? params) async { + print("------------- Generic Event Triggered ---------------"); + print("------------- Generic Event Triggered ---------------"); + print(params); + print("------------- Generic Event Triggered ---------------"); + print("------------- Generic Event Triggered ---------------"); } handlePreOffer(List? params) async { @@ -972,19 +1011,19 @@ class ChatCallProvider with ChangeNotifier, DiagnosticableTreeMixin { handleCallDecline(List? params) { print("----------handle Call Decline Received ----------"); dynamic items = params!.toList(); - logger.d(items); + debuglogger.d(items); } handleNoAnswerCall(List? params) { print("----------handle No Answer Received ----------"); dynamic items = params!.toList(); - logger.d(items); + debuglogger.d(items); } handleCallComplete(List? params) { print("----------handle Call Complete Received ----------"); dynamic items = params!.toList(); - logger.d(items); + debuglogger.d(items); isCallStarted = false; isVideoCall = false; diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 1c6c5a0b..8276eaa0 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -31,7 +31,6 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; -import 'package:diplomaticquarterapp/voipcall/provider/chat_call_provider.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -45,7 +44,6 @@ import 'package:flutter/material.dart'; // import 'package:flutter_amazonpaymentservices/flutter_amazonpaymentservices.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:in_app_review/in_app_review.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -62,7 +60,6 @@ class _AppDrawerState extends State { final InAppReview _inAppReview = InAppReview.instance; ProjectViewModel? projectProvider; - ChatCallProvider? callProv; var sharedPref = new AppSharedPreferences(); var familyFileProvider = FamilyFilesProvider(); PharmacyModuleViewModel pharmacyModuleViewModel = locator(); @@ -88,7 +85,6 @@ class _AppDrawerState extends State { Widget build(BuildContext context) { projectProvider = Provider.of(context); toDoProvider = Provider.of(context); - callProv = Provider.of(context); return Container( width: MediaQuery.of(context).size.width * 0.75, @@ -462,49 +458,6 @@ class _AppDrawerState extends State { }, ), SizedBox(height: 20), - Padding( - padding: const EdgeInsets.all(8.0), - child: TextField( - decoration: InputDecoration( - border: OutlineInputBorder( - borderSide: BorderSide(width: 2, color: Colors.black), - ), - ), - onChanged: (val) { - print(val); - callProv!.doctorID = val; - print(callProv!.doctorID); - }, - ), - ), - SizedBox(height: 20), - Center( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.all(Colors.blue), - ), - onPressed: () async { - Future micPer = Permission.microphone.request(); - Future camPer = Permission.camera.request(); - if (await micPer.isGranted && await camPer.isGranted) { - await callProv!.buildHubConnection(); - } else if (await micPer.isDenied) { - micPer = Permission.microphone.request(); - } else if (await camPer.isDenied) { - camPer = Permission.camera.request(); - } - }, - child: Center( - child: Padding( - padding: const EdgeInsets.all(12.0), - child: Text("Receive Call"), - ), - ), - ), - ), - ) ], )) ],