From 1a158f49bb7de67116f40b932619c35a5576b9d2 Mon Sep 17 00:00:00 2001 From: Zohaib Iqbal Kambrani <> Date: Wed, 9 Jun 2021 16:23:18 +0300 Subject: [PATCH] no message --- ios/Runner/Base.lproj/Main.storyboard | 21 ++++++--- ios/Runner/MainAppViewController.swift | 11 +++-- ios/Runner/VCEmbeder.swift | 30 +++++++----- ios/Runner/VideoCallViewController.swift | 58 ++++++++++-------------- 4 files changed, 64 insertions(+), 56 deletions(-) diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard index 17833007..9f1b5e1a 100755 --- a/ios/Runner/Base.lproj/Main.storyboard +++ b/ios/Runner/Base.lproj/Main.storyboard @@ -39,6 +39,7 @@ + @@ -50,7 +51,7 @@ - + @@ -78,6 +79,11 @@ + + + + + @@ -134,6 +140,7 @@ + @@ -150,6 +157,7 @@ + @@ -160,20 +168,19 @@ + - - + + - - + + - - diff --git a/ios/Runner/MainAppViewController.swift b/ios/Runner/MainAppViewController.swift index c6466343..9a59b862 100644 --- a/ios/Runner/MainAppViewController.swift +++ b/ios/Runner/MainAppViewController.swift @@ -47,8 +47,10 @@ extension MainAppViewController : ICallProtocol{ func prepareVideoCallView(){ videoCallContainer = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)) - videoCallContainer.alpha = 0.0 videoCallContainer.backgroundColor = UIColor.black + videoCallContainer.isHidden = true + videoCallContainer.clipsToBounds = true + view.addSubview(videoCallContainer) setVideoViewConstrints() NSLayoutConstraint.activate(vdoCallViewMaxConstraint) @@ -97,12 +99,13 @@ extension MainAppViewController : ICallProtocol{ } private func showVideoCallView(_ value:Bool){ + videoCallContainer.alpha = value ? 0.0 : 1 + self.videoCallContainer.isHidden = !value + UIView.animate(withDuration: 0.5) { self.videoCallContainer.alpha = value ? 1.0 : 0.0 } completion: { complete in - if(value == false){ - self.videoCallContainer.removeFromSuperview() - } + self.videoCallContainer.isHidden = !value } } diff --git a/ios/Runner/VCEmbeder.swift b/ios/Runner/VCEmbeder.swift index e86dde75..7e2ea0fd 100644 --- a/ios/Runner/VCEmbeder.swift +++ b/ios/Runner/VCEmbeder.swift @@ -9,25 +9,31 @@ import Foundation extension UIView { - func fill(to parent: UIView) { - topAnchor.constraint(equalTo: parent.topAnchor).isActive = true - leadingAnchor.constraint(equalTo: parent.leadingAnchor).isActive = true - bottomAnchor.constraint(equalTo: parent.bottomAnchor).isActive = true - trailingAnchor.constraint(equalTo: parent.trailingAnchor).isActive = true + func fill(to parent: UIView, animateDuration:Double = 0.5) { + self.topAnchor.constraint(equalTo: parent.topAnchor).isActive = true + self.leadingAnchor.constraint(equalTo: parent.leadingAnchor).isActive = true + self.bottomAnchor.constraint(equalTo: parent.bottomAnchor).isActive = true + self.trailingAnchor.constraint(equalTo: parent.trailingAnchor).isActive = true + UIView.animate(withDuration: animateDuration) { + parent.layoutIfNeeded() + } } - func fillToParent() { + func fillToParent(animateDuration:Double = 0.5) { if let parent = self.superview{ - topAnchor.constraint(equalTo: parent.topAnchor).isActive = true - leadingAnchor.constraint(equalTo: parent.leadingAnchor).isActive = true - bottomAnchor.constraint(equalTo: parent.bottomAnchor).isActive = true - trailingAnchor.constraint(equalTo: parent.trailingAnchor).isActive = true + self.topAnchor.constraint(equalTo: parent.topAnchor).isActive = true + self.leadingAnchor.constraint(equalTo: parent.leadingAnchor).isActive = true + self.bottomAnchor.constraint(equalTo: parent.bottomAnchor).isActive = true + self.trailingAnchor.constraint(equalTo: parent.trailingAnchor).isActive = true + UIView.animate(withDuration: animateDuration) { + parent.layoutIfNeeded() + } } } - func fillTo(view:UIView) { + func fillInTo(view:UIView) { view.addSubview(self) - fill(to: view) + fillToParent() } } diff --git a/ios/Runner/VideoCallViewController.swift b/ios/Runner/VideoCallViewController.swift index a05957c9..689c9f63 100644 --- a/ios/Runner/VideoCallViewController.swift +++ b/ios/Runner/VideoCallViewController.swift @@ -101,17 +101,19 @@ class VideoCallViewController: UIViewController { sender.isSelected = minimized onMinimize?(minimized) - self.videoMuteBtn.isHidden = minimized - self.micMuteBtn.isHidden = minimized - let min_ = minimized - UIView.animate(withDuration: 1) { + UIView.animate(withDuration: 0.5) { self.actionsHeightConstraint.constant = min_ ? 30 : 60 self.localvideoTopMargin.constant = min_ ? 20 : 40 + self.videoMuteBtn.isHidden = min_ + self.micMuteBtn.isHidden = min_ - let vdoBound = self.localVideo.bounds - self.publisher?.view?.frame = CGRect(x: 0, y: 0, width: vdoBound.size.width, height: vdoBound.size.height) + 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() } } @@ -324,14 +326,8 @@ class VideoCallViewController: UIViewController { extension VideoCallViewController: OTSessionDelegate { func sessionDidConnect(_ session: OTSession) { - print("The client connected to the OpenTok session.") - - - - - timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(VideoCallViewController.updateTimer)), userInfo: nil, repeats: true) - - + print("The client connected to the OpenTok session.") + timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: (#selector(VideoCallViewController.updateTimer)), userInfo: nil, repeats: true) setupPublisher() } @@ -373,27 +369,23 @@ extension VideoCallViewController: OTSessionDelegate { func session(_ session: OTSession, streamCreated stream: OTStream) { - subscriber = OTSubscriber(stream: stream, delegate: self) - guard let subscriber = subscriber else { - return - } + subscriber = OTSubscriber(stream: stream, delegate: self) + guard let subscriber = subscriber else { + return + } - var error: OTError? - session.subscribe(subscriber, error: &error) - guard error == nil else { - print(error!) - return - } + var error: OTError? + session.subscribe(subscriber, error: &error) + guard error == nil else { + print(error!) + return + } - guard let subscriberView = subscriber.view else { - return - } - subscriberView.frame = UIScreen.main.bounds - view.insertSubview(subscriberView, at: 0) - -// if nil == subscriber { -// setupSubscribe(stream) -// } + 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) } func setupSubscribe(_ stream: OTStream?) {