From c1de90877749e897f4d456cf2825a96bd02452cf Mon Sep 17 00:00:00 2001 From: Zohaib Iqbal Kambrani <> Date: Wed, 16 Jun 2021 11:16:27 +0300 Subject: [PATCH] no message --- ios/Runner/Base.lproj/Main.storyboard | 161 +++++++++++--------- ios/Runner/Extensions.swift | 13 +- ios/Runner/MainAppViewController.swift | 30 ++-- ios/Runner/VideoCallRequestParameters.swift | 4 +- ios/Runner/VideoCallViewController.swift | 91 ++++++----- 5 files changed, 167 insertions(+), 132 deletions(-) diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard index c1c16274..2bdee5a2 100755 --- a/ios/Runner/Base.lproj/Main.storyboard +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -41,18 +41,94 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -210,76 +286,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -300,23 +309,25 @@ + + + - - + diff --git a/ios/Runner/Extensions.swift b/ios/Runner/Extensions.swift index c73f49e2..b79c8deb 100644 --- a/ios/Runner/Extensions.swift +++ b/ios/Runner/Extensions.swift @@ -9,12 +9,19 @@ import AADraggableView extension AADraggableView{ func enable(_ enable:Bool){ - if enable == false{ + isEnabled = enable + if enable == false{ gestureRecognizers?.forEach({ gest in removeGestureRecognizer(gest) }) - }else{ - isEnabled = true } } } + +extension UIView{ + func hidden(_ hidden:Bool, rootView:UIView){ + UIView.transition(with: rootView, duration: 0.5, options: .transitionCrossDissolve, animations: { + self.isHidden = hidden + }) + } +} diff --git a/ios/Runner/MainAppViewController.swift b/ios/Runner/MainAppViewController.swift index ffca444c..c7b7a18d 100644 --- a/ios/Runner/MainAppViewController.swift +++ b/ios/Runner/MainAppViewController.swift @@ -72,9 +72,7 @@ extension MainAppViewController : ICallProtocol{ } private func showVideo(show:Bool){ - UIView.transition(with: view, duration: 0.5, options: .transitionCrossDissolve, animations: { - self.videoCallContainer.isHidden = !show - }) + self.videoCallContainer.hidden(!show, rootView: view) } private func startVideoCall(result: @escaping FlutterResult, call:FlutterMethodCall) { @@ -83,23 +81,19 @@ extension MainAppViewController : ICallProtocol{ if let arguments = call.arguments as? NSDictionary{ showVideoCallView(true) - videoCallViewController.onRectFloat = { min in - self.rectFloatVideoCallView(min) - if(min){ - self.videoCallContainer.repositionIfNeeded() - } + videoCallViewController.onRectFloat = { isRectFloat in + self.rectFloatVideoCallView(isRectFloat) } - videoCallViewController.onCircleFloat = { min in - self.circleFloatVideoCallView(min) - self.videoCallContainer.reposition = min ? .free : .edgesOnly - self.videoCallContainer.repositionIfNeeded() + videoCallViewController.onCircleFloat = { isCircleFloat in + self.circleFloatVideoCallView(isCircleFloat) } videoCallViewController.onCallConnect = { self.videoCallChannel?.invokeMethod("onCallConnected",arguments: nil) } videoCallViewController.onCallDisconnect = { self.showVideoCallView(false) + self.videoCallViewController.minimizeVideoState(state: false) self.videoCallChannel?.invokeMethod("onCallDisconnected",arguments: nil) } videoCallViewController.callBack = self @@ -130,7 +124,7 @@ extension MainAppViewController : ICallProtocol{ } private func circleFloatVideoCallView(_ value:Bool){ - videoCallContainer.enable(value) + videoCallContainer.reposition = value ? .sticky : .edgesOnly UIView.animate(withDuration: 0.5) { if(value){ @@ -152,9 +146,7 @@ extension MainAppViewController : ICallProtocol{ } private func showVideoCallView(_ value:Bool){ - UIView.animate(withDuration: 0.5) { - self.videoCallContainer.isHidden = !value - } + self.videoCallContainer.hidden(!value, rootView: view) } func sessionDone(res: Any) { @@ -182,14 +174,14 @@ extension MainAppViewController : ICallProtocol{ videoCallContainer.heightAnchor.constraint(equalToConstant: screen.height) ] vdoCallViewFloatRectConstraint = [ - videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor, constant: 20), + videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor, constant: 40), videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20), videoCallContainer.widthAnchor.constraint(equalToConstant: screen.width/3), videoCallContainer.heightAnchor.constraint(equalToConstant: screen.height/3.5) ] vdoCallViewFloatCircleConstraint = [ - videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor), - videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor), + videoCallContainer.topAnchor.constraint(equalTo: view.topAnchor, constant: 40), + videoCallContainer.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20), videoCallContainer.widthAnchor.constraint(equalToConstant: 70), videoCallContainer.heightAnchor.constraint(equalToConstant: 70) ] diff --git a/ios/Runner/VideoCallRequestParameters.swift b/ios/Runner/VideoCallRequestParameters.swift index 2366c562..543d7e8b 100644 --- a/ios/Runner/VideoCallRequestParameters.swift +++ b/ios/Runner/VideoCallRequestParameters.swift @@ -12,7 +12,8 @@ class VideoCallRequestParameters{ var generalId:String? var doctorId:Int? var baseUrl:String? - + var patientName:String? + init(dictionary:NSDictionary){ self.apiKey = dictionary["kApiKey"] as? String self.sessionId = dictionary["kSessionId"] as? String @@ -23,5 +24,6 @@ class VideoCallRequestParameters{ self.generalId = dictionary["generalId"] as? String self.doctorId = dictionary["DoctorId"] as? Int self.baseUrl = dictionary["baseUrl"] as? String + self.patientName = dictionary["patientName"] as? String } } diff --git a/ios/Runner/VideoCallViewController.swift b/ios/Runner/VideoCallViewController.swift index 02a70a0c..83865c6e 100644 --- a/ios/Runner/VideoCallViewController.swift +++ b/ios/Runner/VideoCallViewController.swift @@ -57,14 +57,15 @@ class VideoCallViewController: UIViewController { @IBOutlet weak var remoteVideoMutedIndicator: UIImageView! @IBOutlet weak var localVideoMutedBg: UIView! + @IBOutlet weak var btnScreenTap: UIButton! @IBOutlet weak var localVideoContainer: UIView! @IBOutlet weak var topBar: UIView! @IBOutlet weak var lblCallDuration: UILabel! - @IBOutlet weak var remoteVideo: UIView! - @IBOutlet weak var localVideo: UIView!{ + @IBOutlet weak var fullVideoView: UIView! + @IBOutlet weak var smallVideoView: UIView!{ didSet{ - localVideo.layer.borderColor = UIColor.white.cgColor - localVideoDraggable = localVideo?.superview as? AADraggableView + smallVideoView.layer.borderColor = UIColor.white.cgColor + localVideoDraggable = smallVideoView?.superview as? AADraggableView localVideoDraggable?.reposition = .edgesOnly } } @@ -78,16 +79,28 @@ class VideoCallViewController: UIViewController { gesture.view?.removeFromSuperview() } - @IBAction func onVideoContainerTapped(_ sender: Any) { + @IBAction func btnOnScreenTapped(_ sender: Any) { if(hideVideoBtn.isSelected){ circleFloatBtnTapped(hideVideoBtn) }else if(btnMinimize.isSelected){ btnMinimizeTapped(btnMinimize) - }else if(!btnMinimize.isSelected){ - // Swipe video here } } + + @IBAction func btnSwipeVideoTapped(_ sender: Any) { +// let smallVdoRender = smallVideoView.subviews.first +// let fullVdoRender = fullVideoView.subviews.first +// if let vdo = smallVdoRender{ +// fullVideoView.addSubview(vdo) +// } +// if let vdo = fullVdoRender{ +// smallVideoView.addSubview(vdo) +// } +// +// layoutVideoRenderViews() + } + @IBAction func didClickMuteButton(_ sender: UIButton) { sender.isSelected = !sender.isSelected publisher!.publishAudio = !sender.isSelected @@ -105,7 +118,7 @@ class VideoCallViewController: UIViewController { } else { publisher!.publishVideo = true } - localVideo.isHidden = sender.isSelected + smallVideoView.isHidden = sender.isSelected localVideoMutedBg.isHidden = !sender.isSelected } @@ -130,36 +143,41 @@ class VideoCallViewController: UIViewController { onCircleFloat?(sender.isSelected) topBar.isHidden = sender.isSelected controlButtons.isHidden = sender.isSelected - localVideo.isHidden = sender.isSelected + smallVideoView.isHidden = sender.isSelected self.publisher?.view?.layoutIfNeeded() } - var floated = false @IBAction func btnMinimizeTapped(_ sender: UIButton) { - floated = !floated - onRectFloat?(floated) - sender.isSelected = floated + minimizeVideoState(state: !sender.isSelected) + btnScreenTap.isHidden = !sender.isSelected + } + + func minimizeVideoState(state:Bool){ + btnMinimize.isSelected = state + onRectFloat?(state) - NSLayoutConstraint.activate(floated ? minimizeConstraint : maximisedConstraint) - NSLayoutConstraint.deactivate(floated ? maximisedConstraint : minimizeConstraint) - localVideoDraggable?.enable(!floated) + NSLayoutConstraint.activate(state ? minimizeConstraint : maximisedConstraint) + NSLayoutConstraint.deactivate(state ? maximisedConstraint : minimizeConstraint) + localVideoDraggable?.enable(!state) - lblRemoteUsername.isHidden = floated - hideVideoBtn.isHidden = !floated + lblRemoteUsername.isHidden = state + hideVideoBtn.isHidden = !state lblCallDuration.superview?.isHidden = !hideVideoBtn.isHidden - let min_ = floated UIView.animate(withDuration: 0.5) { - self.videoMuteBtn.isHidden = min_ - self.micMuteBtn.isHidden = min_ - self.camSwitchBtn.isHidden = min_ - - let localVdoSize = self.localVideo.bounds.size - let remoteVdoSize = self.remoteVideo.bounds.size - self.publisher?.view?.frame = CGRect(x: 0, y: 0, width: localVdoSize.width, height: localVdoSize.height) - self.subscriber?.view?.frame = CGRect(x: 0, y: 0, width: remoteVdoSize.width, height: remoteVdoSize.height) - self.publisher?.view?.layoutIfNeeded() - self.subscriber?.view?.layoutIfNeeded() + self.videoMuteBtn.isHidden = state + self.micMuteBtn.isHidden = state + self.camSwitchBtn.isHidden = state + self.layoutVideoRenderViews() + } + } + + func layoutVideoRenderViews(){ + if let publisherVdoSize = publisher?.view?.superview?.bounds.size{ + publisher?.view?.frame = CGRect(x: 0, y: 0, width: publisherVdoSize.width, height: publisherVdoSize.height) + } + if let subscriberVdoSize = subscriber?.view?.superview?.bounds.size{ + subscriber?.view?.frame = CGRect(x: 0, y: 0, width: subscriberVdoSize.width, height: subscriberVdoSize.height) } } @@ -179,6 +197,9 @@ class VideoCallViewController: UIViewController { } func start(params:VideoCallRequestParameters){ + lblRemoteUsername.text = params.patientName ?? "- - -" + btnScreenTap.isHidden = true + hideVideoBtn.isHidden = true self.kApiKey = params.apiKey ?? "" self.kSessionId = params.sessionId ?? "" @@ -193,6 +214,7 @@ class VideoCallViewController: UIViewController { requestCameraPermissionsIfNeeded() hideVideoMuted() setupSession() + } private func changeCallStatus(callStatus:Int){ @@ -397,10 +419,11 @@ extension VideoCallViewController: OTSessionDelegate { showAlert(error?.localizedDescription) } - publisher?.view!.frame = CGRect(x: 0, y: 0, width: localVideo.bounds.size.width, height: localVideo.bounds.size.height) + publisher?.view?.tag = 11 publisher?.view?.layer.cornerRadius = 5 publisher?.view?.clipsToBounds = true - localVideo.addSubview((publisher?.view)!) + smallVideoView.addSubview((publisher?.view)!) + layoutVideoRenderViews() } func sessionDidDisconnect(_ session: OTSession) { @@ -440,9 +463,9 @@ extension VideoCallViewController: OTSessionDelegate { guard let subscriberView = subscriber.view else { return } - - subscriberView.frame = CGRect(x: 0, y: 0, width: remoteVideo.bounds.width, height: remoteVideo.bounds.height) - remoteVideo.addSubview(subscriberView) + subscriberView.tag = 22 + fullVideoView.addSubview(subscriberView) + layoutVideoRenderViews() startUpdateCallDuration() onCallConnect?()