|  |  |  | @ -18,7 +18,6 @@ import 'package:mohem_flutter_app/api/chat/chat_api_client.dart'; | 
		
	
		
			
				|  |  |  |  | // import 'package:huawei_hmsavailability/huawei_hmsavailability.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/api/login_api_client.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/app_state/app_state.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/classes/chat_call_kit.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/classes/colors.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/classes/consts.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/classes/notifications.dart'; | 
		
	
	
		
			
				
					|  |  |  | @ -38,6 +37,7 @@ import 'package:mohem_flutter_app/models/privilege_list_model.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/ui/chat/call/chat_incoming_call_screen.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/widgets/button/default_button.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/widgets/input_widget.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:signalr_netcore/hub_connection.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:wifi_iot/wifi_iot.dart'; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | class LoginScreen extends StatefulWidget { | 
		
	
	
		
			
				
					|  |  |  | @ -111,10 +111,8 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver { | 
		
	
		
			
				|  |  |  |  |     voIPKit.onDidReceiveIncomingPush = ( | 
		
	
		
			
				|  |  |  |  |       Map<String, dynamic> payload, | 
		
	
		
			
				|  |  |  |  |     ) async { | 
		
	
		
			
				|  |  |  |  |       print("🎈 Call Payload Incoming Push:"); | 
		
	
		
			
				|  |  |  |  |       print(payload); | 
		
	
		
			
				|  |  |  |  |       _iosCallPayload = IosCallPayload.fromJson(payload); | 
		
	
		
			
				|  |  |  |  |       _timeOut(); | 
		
	
		
			
				|  |  |  |  |       _timeOut(callDetails: _iosCallPayload!.incomingCallerId!); | 
		
	
		
			
				|  |  |  |  |     }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     voIPKit.onDidRejectIncomingCall = ( | 
		
	
	
		
			
				
					|  |  |  | @ -122,7 +120,10 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver { | 
		
	
		
			
				|  |  |  |  |       String callerId, | 
		
	
		
			
				|  |  |  |  |     ) async { | 
		
	
		
			
				|  |  |  |  |       timeOutTimer.cancel(); | 
		
	
		
			
				|  |  |  |  |       await ChatVoipCall().voipDeclineCall(_iosCallPayload); | 
		
	
		
			
				|  |  |  |  |       declineCall( | 
		
	
		
			
				|  |  |  |  |         cuserid: int.parse(callerId.split("-")[1]), | 
		
	
		
			
				|  |  |  |  |         ruserid: int.parse(callerId.split("-")[0]), | 
		
	
		
			
				|  |  |  |  |       ); | 
		
	
		
			
				|  |  |  |  |       await voIPKit.endCall(); | 
		
	
		
			
				|  |  |  |  |     }; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -133,19 +134,18 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver { | 
		
	
		
			
				|  |  |  |  |       await connectCall(uuid: uuid, callDetails: callerId); | 
		
	
		
			
				|  |  |  |  |       voIPKit.acceptIncomingCall(callerState: CallStateType.calling); | 
		
	
		
			
				|  |  |  |  |       voIPKit.callConnected().then((value) => timeOutTimer.cancel()); | 
		
	
		
			
				|  |  |  |  |       // Utils.showToast("Timer Cancel", longDuration: true); | 
		
	
		
			
				|  |  |  |  |     }; | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void _timeOut() async { | 
		
	
		
			
				|  |  |  |  |     timeOutTimer = Timer(const Duration(seconds: 20), () async { | 
		
	
		
			
				|  |  |  |  |   void _timeOut({required String callDetails}) async { | 
		
	
		
			
				|  |  |  |  |     timeOutTimer = Timer(const Duration(seconds: 25), () async { | 
		
	
		
			
				|  |  |  |  |       String? incomingCallerName = await voIPKit.getIncomingCallerName(); | 
		
	
		
			
				|  |  |  |  |       voIPKit.unansweredIncomingCall( | 
		
	
		
			
				|  |  |  |  |         skipLocalNotification: false, | 
		
	
		
			
				|  |  |  |  |         skipLocalNotification: true, | 
		
	
		
			
				|  |  |  |  |         missedCallTitle: '📞 Missed call', | 
		
	
		
			
				|  |  |  |  |         missedCallBody: 'There was a call from $incomingCallerName', | 
		
	
		
			
				|  |  |  |  |       ); | 
		
	
		
			
				|  |  |  |  |       await ChatVoipCall().voipDeclineCall(_iosCallPayload); | 
		
	
		
			
				|  |  |  |  |       declineCall(cuserid: int.parse(callDetails.split("-")[1]), ruserid: int.parse(callDetails.split("-")[0])); | 
		
	
		
			
				|  |  |  |  |       await voIPKit.endCall(); | 
		
	
		
			
				|  |  |  |  |     }); | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
	
		
			
				
					|  |  |  | @ -163,39 +163,36 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver { | 
		
	
		
			
				|  |  |  |  |       _iosCallPayload = IosCallPayload( | 
		
	
		
			
				|  |  |  |  |           uuid: uuid, incomingCallerId: callDetails.split("-")[0], incomingCallReciverId: callDetails.split("-")[1], incomingCallerName: null, incomingCallType: callDetails.split("-").last); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     // _iosCallPayload = IosCallPayload(uuid: "3423434-423423-43-53-5", incomingCallerId: "266642", incomingCallReciverId: "341682", incomingCallerName: null, incomingCallType: "video"); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     print("🎈 Call Payload callDetails:" + callDetails); | 
		
	
		
			
				|  |  |  |  |     print("🎈 Call Payload Before:" + _iosCallPayload!.toRawJson()); | 
		
	
		
			
				|  |  |  |  |     if (_iosCallPayload!.incomingCallerName == null) { | 
		
	
		
			
				|  |  |  |  |       if (Platform.isIOS) { | 
		
	
		
			
				|  |  |  |  |         Utils.hideLoading(context); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |       // await Utils.saveStringFromPrefs("iosCallPayload", jsonEncode(_iosCallPayload)); | 
		
	
		
			
				|  |  |  |  |       // Utils.showToast("Name Null", longDuration: true); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |       if (Platform.isIOS) { | 
		
	
		
			
				|  |  |  |  |         Future.delayed(Duration(seconds: 3), () async { | 
		
	
		
			
				|  |  |  |  |           MaterialPageRoute pageRoute = await MaterialPageRoute( | 
		
	
		
			
				|  |  |  |  |               builder: (BuildContext context) => StartCallPage( | 
		
	
		
			
				|  |  |  |  |                     payload: _iosCallPayload, | 
		
	
		
			
				|  |  |  |  |                   )); | 
		
	
		
			
				|  |  |  |  |             builder: (BuildContext context) => StartCallPage( | 
		
	
		
			
				|  |  |  |  |               payload: _iosCallPayload, | 
		
	
		
			
				|  |  |  |  |             ), | 
		
	
		
			
				|  |  |  |  |           ); | 
		
	
		
			
				|  |  |  |  |           Navigator.push(context, pageRoute); | 
		
	
		
			
				|  |  |  |  |         }); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |     } else if (AppState().getisUserOnline) { | 
		
	
		
			
				|  |  |  |  |       // await Utils.saveStringFromPrefs("iosCallPayload", jsonEncode(_iosCallPayload)); | 
		
	
		
			
				|  |  |  |  |       BuildContext context = AppRoutes.navigatorKey.currentContext!; | 
		
	
		
			
				|  |  |  |  |       if (Platform.isIOS) { | 
		
	
		
			
				|  |  |  |  |         Future.delayed(Duration(seconds: 3), () async { | 
		
	
		
			
				|  |  |  |  |           MaterialPageRoute pageRoute = await MaterialPageRoute( | 
		
	
		
			
				|  |  |  |  |               builder: (BuildContext context) => StartCallPage( | 
		
	
		
			
				|  |  |  |  |                     payload: _iosCallPayload, | 
		
	
		
			
				|  |  |  |  |                   )); | 
		
	
		
			
				|  |  |  |  |             builder: (BuildContext context) => StartCallPage( | 
		
	
		
			
				|  |  |  |  |               payload: _iosCallPayload, | 
		
	
		
			
				|  |  |  |  |             ), | 
		
	
		
			
				|  |  |  |  |           ); | 
		
	
		
			
				|  |  |  |  |           Navigator.push(context, pageRoute); | 
		
	
		
			
				|  |  |  |  |         }); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       FlutterCallkitIncoming.endAllCalls(); | 
		
	
		
			
				|  |  |  |  |       if (Platform.isAndroid) FlutterCallkitIncoming.endAllCalls(); | 
		
	
		
			
				|  |  |  |  |       if (Platform.isIOS) await voIPKit.endCall(); | 
		
	
		
			
				|  |  |  |  |       Utils.showToast("Something wen't wrong"); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
	
		
			
				
					|  |  |  | @ -233,6 +230,7 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver { | 
		
	
		
			
				|  |  |  |  |           case Event.actionCallDecline: | 
		
	
		
			
				|  |  |  |  |             Utils.saveStringFromPrefs("isIncomingCall", "false"); | 
		
	
		
			
				|  |  |  |  |             Utils.saveStringFromPrefs("inComingCallData", "null"); | 
		
	
		
			
				|  |  |  |  |             declineCall(cuserid: event.body["extra"]["callerDetails"]["currentUserId"], ruserid: event.body["extra"]["callerDetails"]["targetUserId"]); | 
		
	
		
			
				|  |  |  |  |             FlutterCallkitIncoming.endAllCalls(); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             break; | 
		
	
	
		
			
				
					|  |  |  | @ -247,13 +245,25 @@ class _LoginScreenState extends State<LoginScreen> with WidgetsBindingObserver { | 
		
	
		
			
				|  |  |  |  |             FlutterCallkitIncoming.endAllCalls(); | 
		
	
		
			
				|  |  |  |  |             break; | 
		
	
		
			
				|  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |         print('${event.toString()}\n'); | 
		
	
		
			
				|  |  |  |  |         print('${event.body}\n'); | 
		
	
		
			
				|  |  |  |  |       }); | 
		
	
		
			
				|  |  |  |  |     } on Exception { | 
		
	
		
			
				|  |  |  |  |       logger.log(Level.info, "EXCEPTION-ON-EVENTS"); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void declineCall({required int cuserid, required int ruserid}) async { | 
		
	
		
			
				|  |  |  |  |     logger.i("-----------------------Call Decline Hit---------------------------"); | 
		
	
		
			
				|  |  |  |  |     if (chatHubConnection!.state == HubConnectionState.Connected) { | 
		
	
		
			
				|  |  |  |  |       try { | 
		
	
		
			
				|  |  |  |  |         await chatHubConnection!.invoke("CallDeclinedAsync", args: <Object>[cuserid, ruserid]); | 
		
	
		
			
				|  |  |  |  |         await chatHubConnection!.invoke("UpdateUserStatusAsync", args: <Object>[cuserid, 1]); | 
		
	
		
			
				|  |  |  |  |       } catch (e) { | 
		
	
		
			
				|  |  |  |  |         logger.w(e); | 
		
	
		
			
				|  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> moveToCallScreen() async { | 
		
	
		
			
				|  |  |  |  |     dynamic calls = await FlutterCallkitIncoming.activeCalls(); | 
		
	
		
			
				|  |  |  |  |     if (calls is List) { | 
		
	
	
		
			
				
					|  |  |  | 
 |