From fbcdd1358c420a11a389d1a0a732b13002835d67 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Fri, 30 Sep 2022 16:44:48 +1000 Subject: [PATCH] WIP: fix video call view --- Session/Calls/CallVC.swift | 15 ++++++++++++++- Session/Calls/Views & Modals/CallVideoView.swift | 10 ++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 704df50d8..8ccef1ea1 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -23,7 +23,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var localVideoView: LocalVideoView = { let result = LocalVideoView() result.isHidden = !call.isVideoEnabled - result.layer.cornerRadius = 10 + result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 result.layer.masksToBounds = true result.set(.width, to: LocalVideoView.width) result.set(.height, to: LocalVideoView.height) @@ -284,6 +284,18 @@ final class CallVC: UIViewController, VideoPreviewDelegate { NotificationCenter.default.addObserver(self, selector: #selector(audioRouteDidChange), name: AVAudioSession.routeChangeNotification, object: nil) } + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { + super.viewWillTransition(to: size, with: coordinator) + let layer = CAGradientLayer() + layer.frame = CGRect(x: 0, y: 0, width: size.width, height: 64) + layer.colors = [ UIColor(hex: 0x000000).withAlphaComponent(0.4).cgColor, UIColor(hex: 0x000000).withAlphaComponent(0).cgColor ] + if let existingSublayer = fadeView.layer.sublayers?[0], existingSublayer is CAGradientLayer { + fadeView.layer.replaceSublayer(existingSublayer, with: layer) + } else { + fadeView.layer.insertSublayer(layer, at: 0) + } + } + deinit { UIDevice.current.endGeneratingDeviceOrientationNotifications() NotificationCenter.default.removeObserver(self) @@ -373,6 +385,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { } @objc func didChangeDeviceOrientation(notification: Notification) { + if UIDevice.current.isIPad { return } func rotateAllButtons(rotationAngle: CGFloat) { let transform = CGAffineTransform(rotationAngle: rotationAngle) diff --git a/Session/Calls/Views & Modals/CallVideoView.swift b/Session/Calls/Views & Modals/CallVideoView.swift index 1f10930f3..899732f66 100644 --- a/Session/Calls/Views & Modals/CallVideoView.swift +++ b/Session/Calls/Views & Modals/CallVideoView.swift @@ -16,6 +16,16 @@ class RemoteVideoView: TargetView { override func renderFrame(_ frame: RTCVideoFrame?) { super.renderFrame(frame) guard let frame = frame else { return } + if UIDevice.current.isIPad { + DispatchMainThreadSafe { +#if targetEnvironment(simulator) + self.contentMode = .scaleAspectFit +#else + self.videoContentMode = .scaleAspectFit +#endif + } + return + } DispatchMainThreadSafe { let frameRatio = Double(frame.height) / Double(frame.width)