From 18453405822470fa42a061f0da7a8211ce43f62c Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Mon, 13 Feb 2023 14:22:54 +1100 Subject: [PATCH 1/6] WIP: refactor on the call UI to add switching function of caller and callee's video views --- .../Calls/Call Management/SessionCall.swift | 4 + Session/Calls/CallVC.swift | 88 +++++++++++++++++-- .../Calls/Views & Modals/CallVideoView.swift | 5 +- .../Calls/WebRTCSession+UI.swift | 4 + 4 files changed, 90 insertions(+), 11 deletions(-) diff --git a/Session/Calls/Call Management/SessionCall.swift b/Session/Calls/Call Management/SessionCall.swift index 4c3250429..de3f64f48 100644 --- a/Session/Calls/Call Management/SessionCall.swift +++ b/Session/Calls/Call Management/SessionCall.swift @@ -356,6 +356,10 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { webRTCSession.attachLocalRenderer(renderer) } + func removeLocalVideoRenderer(_ renderer: RTCVideoRenderer) { + webRTCSession.removeLocalRenderer(renderer) + } + // MARK: - Delegate public func webRTCIsConnected() { diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 49152e981..cc6609c5e 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -8,6 +8,9 @@ import SessionMessagingKit import SessionUtilitiesKit final class CallVC: UIViewController, VideoPreviewDelegate { + static let floatingVideoViewWidth: CGFloat = UIDevice.current.isIPad ? 160 : 80 + static let floatingVideoViewHeight: CGFloat = UIDevice.current.isIPad ? 346: 173 + let call: SessionCall var latestKnownAudioOutputDeviceName: String? var durationTimer: Timer? @@ -23,25 +26,92 @@ final class CallVC: UIViewController, VideoPreviewDelegate { // MARK: - UI Components - private lazy var localVideoView: LocalVideoView = { + private lazy var floatingLocalVideoView: LocalVideoView = { let result = LocalVideoView() result.clipsToBounds = true result.themeBackgroundColor = .backgroundSecondary result.isHidden = !call.isVideoEnabled result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 result.layer.masksToBounds = true - result.set(.width, to: LocalVideoView.width) - result.set(.height, to: LocalVideoView.height) - result.makeViewDraggable() + result.set(.width, to: Self.floatingVideoViewWidth) + result.set(.height, to: Self.floatingVideoViewHeight) + + return result + }() + + private lazy var floatingRemoteVideoView: RemoteVideoView = { + let result = RemoteVideoView() + result.clipsToBounds = true + result.themeBackgroundColor = .backgroundSecondary + result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 + result.layer.masksToBounds = true + result.set(.width, to: Self.floatingVideoViewWidth) + result.set(.height, to: Self.floatingVideoViewHeight) return result }() - private lazy var remoteVideoView: RemoteVideoView = { + private lazy var fullScreenLocalVideoView: LocalVideoView = { + let result = LocalVideoView() + result.alpha = 0 + result.themeBackgroundColor = .backgroundPrimary + result.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleFullScreenVideoViewTapped))) + + return result + }() + + private lazy var fullScreenRemoteVideoView: RemoteVideoView = { let result = RemoteVideoView() result.alpha = 0 result.themeBackgroundColor = .backgroundPrimary - result.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleRemoteVieioViewTapped))) + result.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleFullScreenVideoViewTapped))) + + return result + }() + + private lazy var switchVideoButton: UIButton = { + let result = UIButton(type: .custom) + result.setImage( + UIImage(named: "ic_switch_camera")? + .withRenderingMode(.alwaysTemplate), + for: .normal + ) + result.themeTintColor = .textPrimary + result.addTarget(self, action: #selector(switchVideo), for: UIControl.Event.touchUpInside) + result.set(.width, to: 20) + result.set(.height, to: 20) + + return result + }() + + private lazy var switchVideoButtonContainer: UIView = { + let result = UIView() + result.themeBackgroundColor = .backgroundPrimary + result.layer.cornerRadius = UIDevice.current.isIPad ? 12 : 6 + result.layer.masksToBounds = true + result.addSubview(switchVideoButton) + switchVideoButton.pin(.leading, to: .leading, of: result, withInset: Values.smallSpacing) + switchVideoButton.pin(.trailing, to: .trailing, of: result, withInset: Values.smallSpacing) + switchVideoButton.pin(.bottom, to: .bottom, of: result, withInset: Values.smallSpacing) + switchVideoButton.pin(.top, to: .top, of: result, withInset: Values.largeSpacing) + + return result + }() + + private lazy var floatingViewContainer: UIView = { + let result = UIView() + result.makeViewDraggable() + result.addSubview(switchVideoButtonContainer) + switchVideoButtonContainer.pin(.trailing, to: .trailing, of: result) + switchVideoButtonContainer.pin(.bottom, to: .bottom, of: result) + + result.addSubview(floatingLocalVideoView) + floatingLocalVideoView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top], to: result) + floatingLocalVideoView.pin(.bottom, to: .bottom, of: result, withInset: 36) + + result.addSubview(floatingRemoteVideoView) + floatingRemoteVideoView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top], to: result) + floatingRemoteVideoView.pin(.bottom, to: .bottom, of: result, withInset: 36) return result }() @@ -584,6 +654,10 @@ final class CallVC: UIViewController, VideoPreviewDelegate { call.isVideoEnabled = true } + @objc private func switchVideo() { + + } + @objc private func switchCamera() { cameraManager.switchCamera() } @@ -645,7 +719,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { } } - @objc private func handleRemoteVieioViewTapped(gesture: UITapGestureRecognizer) { + @objc private func handleFullScreenVideoViewTapped(gesture: UITapGestureRecognizer) { let isHidden = callDurationLabel.alpha < 0.5 UIView.animate(withDuration: 0.5) { diff --git a/Session/Calls/Views & Modals/CallVideoView.swift b/Session/Calls/Views & Modals/CallVideoView.swift index 899732f66..d2e8894c0 100644 --- a/Session/Calls/Views & Modals/CallVideoView.swift +++ b/Session/Calls/Views & Modals/CallVideoView.swift @@ -87,10 +87,7 @@ class RemoteVideoView: TargetView { // MARK: LocalVideoView class LocalVideoView: TargetView { - - static let width: CGFloat = UIDevice.current.isIPad ? 160 : 80 - static let height: CGFloat = UIDevice.current.isIPad ? 346: 173 - + override func renderFrame(_ frame: RTCVideoFrame?) { super.renderFrame(frame) DispatchMainThreadSafe { diff --git a/SessionMessagingKit/Calls/WebRTCSession+UI.swift b/SessionMessagingKit/Calls/WebRTCSession+UI.swift index 305d1bfb7..2594d8a15 100644 --- a/SessionMessagingKit/Calls/WebRTCSession+UI.swift +++ b/SessionMessagingKit/Calls/WebRTCSession+UI.swift @@ -6,6 +6,10 @@ extension WebRTCSession { localVideoTrack.add(renderer) } + public func removeLocalRenderer(_ renderer: RTCVideoRenderer) { + localVideoTrack.remove(renderer) + } + public func attachRemoteRenderer(_ renderer: RTCVideoRenderer) { remoteVideoTrack?.add(renderer) } From 0ccfdcd24d1f3b2d50f2d025ff130676b94aaab0 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 14 Feb 2023 16:34:27 +1100 Subject: [PATCH 2/6] WIP: switch video view --- Session/Calls/CallVC.swift | 79 ++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index cc6609c5e..707b72ebc 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -24,6 +24,13 @@ final class CallVC: UIViewController, VideoPreviewDelegate { return result }() + enum FloatingViewVideoSource { + case local + case remote + } + + var floatingViewVideoSource: FloatingViewVideoSource = .local + // MARK: - UI Components private lazy var floatingLocalVideoView: LocalVideoView = { @@ -41,6 +48,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var floatingRemoteVideoView: RemoteVideoView = { let result = RemoteVideoView() + result.alpha = 0 result.clipsToBounds = true result.themeBackgroundColor = .backgroundSecondary result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 @@ -91,8 +99,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { result.layer.masksToBounds = true result.addSubview(switchVideoButton) switchVideoButton.pin(.leading, to: .leading, of: result, withInset: Values.smallSpacing) - switchVideoButton.pin(.trailing, to: .trailing, of: result, withInset: Values.smallSpacing) - switchVideoButton.pin(.bottom, to: .bottom, of: result, withInset: Values.smallSpacing) + switchVideoButton.pin(.trailing, to: .trailing, of: result, withInset: -Values.smallSpacing) + switchVideoButton.pin(.bottom, to: .bottom, of: result, withInset: -Values.smallSpacing) switchVideoButton.pin(.top, to: .top, of: result, withInset: Values.largeSpacing) return result @@ -100,6 +108,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var floatingViewContainer: UIView = { let result = UIView() + result.isHidden = true result.makeViewDraggable() result.addSubview(switchVideoButtonContainer) switchVideoButtonContainer.pin(.trailing, to: .trailing, of: result) @@ -107,11 +116,11 @@ final class CallVC: UIViewController, VideoPreviewDelegate { result.addSubview(floatingLocalVideoView) floatingLocalVideoView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top], to: result) - floatingLocalVideoView.pin(.bottom, to: .bottom, of: result, withInset: 36) + floatingLocalVideoView.pin(.bottom, to: .bottom, of: result, withInset: -36) result.addSubview(floatingRemoteVideoView) floatingRemoteVideoView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top], to: result) - floatingRemoteVideoView.pin(.bottom, to: .bottom, of: result, withInset: 36) + floatingRemoteVideoView.pin(.bottom, to: .bottom, of: result, withInset: -36) return result }() @@ -335,7 +344,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { self.call.remoteVideoStateDidChange = { isEnabled in DispatchQueue.main.async { UIView.animate(withDuration: 0.25) { - self.remoteVideoView.alpha = isEnabled ? 1 : 0 + let remoteVideoView: RemoteVideoView = self.floatingViewVideoSource == .remote ? self.floatingRemoteVideoView : self.fullScreenRemoteVideoView + remoteVideoView.alpha = isEnabled ? 1 : 0 } if self.callInfoLabel.alpha < 0.5 { @@ -445,13 +455,16 @@ final class CallVC: UIViewController, VideoPreviewDelegate { view.addSubview(profilePictureContainer) // Remote video view - call.attachRemoteVideoRenderer(remoteVideoView) - view.addSubview(remoteVideoView) - remoteVideoView.translatesAutoresizingMaskIntoConstraints = false - remoteVideoView.pin(to: view) + call.attachRemoteVideoRenderer(fullScreenRemoteVideoView) + view.addSubview(fullScreenRemoteVideoView) + fullScreenRemoteVideoView.translatesAutoresizingMaskIntoConstraints = false + fullScreenRemoteVideoView.pin(to: view) // Local video view - call.attachLocalVideoRenderer(localVideoView) + call.attachLocalVideoRenderer(floatingLocalVideoView) + view.addSubview(fullScreenLocalVideoView) + fullScreenLocalVideoView.translatesAutoresizingMaskIntoConstraints = false + fullScreenLocalVideoView.pin(to: view) // Fade view view.addSubview(fadeView) @@ -501,12 +514,12 @@ final class CallVC: UIViewController, VideoPreviewDelegate { callDurationLabel.center(in: callInfoLabelContainer) } - private func addLocalVideoView() { + private func addFloatingVideoView() { let safeAreaInsets = UIApplication.shared.keyWindow?.safeAreaInsets - CurrentAppContext().mainWindow?.addSubview(localVideoView) - localVideoView.autoPinEdge(toSuperviewEdge: .right, withInset: Values.smallSpacing) + CurrentAppContext().mainWindow?.addSubview(floatingViewContainer) + floatingViewContainer.autoPinEdge(toSuperviewEdge: .right, withInset: Values.smallSpacing) let topMargin = (safeAreaInsets?.top ?? 0) + Values.veryLargeSpacing - localVideoView.autoPinEdge(toSuperviewEdge: .top, withInset: topMargin) + floatingViewContainer.autoPinEdge(toSuperviewEdge: .top, withInset: topMargin) } override func viewDidAppear(_ animated: Bool) { @@ -515,7 +528,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { if (call.isVideoEnabled && shouldRestartCamera) { cameraManager.start() } shouldRestartCamera = true - addLocalVideoView() + addFloatingVideoView() + let remoteVideoView: RemoteVideoView = self.floatingViewVideoSource == .remote ? self.floatingRemoteVideoView : self.fullScreenRemoteVideoView remoteVideoView.alpha = (call.isRemoteVideoEnabled ? 1 : 0) } @@ -524,7 +538,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { if (call.isVideoEnabled && shouldRestartCamera) { cameraManager.stop() } - localVideoView.removeFromSuperview() + floatingViewContainer.removeFromSuperview() } // MARK: - Orientation @@ -571,7 +585,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { self.callInfoLabel.text = "Call Ended" UIView.animate(withDuration: 0.25) { - self.remoteVideoView.alpha = 0 + let remoteVideoView: RemoteVideoView = self.floatingViewVideoSource == .remote ? self.floatingRemoteVideoView : self.fullScreenRemoteVideoView + remoteVideoView.alpha = 0 self.operationPanel.alpha = 1 self.responsePanel.alpha = 1 self.callInfoLabel.alpha = 1 @@ -629,7 +644,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { @objc private func operateCamera() { if (call.isVideoEnabled) { - localVideoView.isHidden = true + floatingViewContainer.isHidden = true cameraManager.stop() videoButton.themeTintColor = .textPrimary videoButton.themeBackgroundColor = .backgroundSecondary @@ -645,7 +660,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { } func cameraDidConfirmTurningOn() { - localVideoView.isHidden = false + floatingViewContainer.isHidden = false cameraManager.prepare() cameraManager.start() videoButton.themeTintColor = .backgroundSecondary @@ -655,7 +670,31 @@ final class CallVC: UIViewController, VideoPreviewDelegate { } @objc private func switchVideo() { - + if self.floatingViewVideoSource == .remote { + call.removeRemoteVideoRenderer(self.floatingRemoteVideoView) + call.removeLocalVideoRenderer(self.fullScreenLocalVideoView) + + self.floatingRemoteVideoView.alpha = 0 + self.floatingLocalVideoView.alpha = 1 + self.fullScreenRemoteVideoView.alpha = 1 + self.fullScreenLocalVideoView.alpha = 0 + + self.floatingViewVideoSource = .local + call.attachRemoteVideoRenderer(self.fullScreenRemoteVideoView) + call.attachLocalVideoRenderer(self.floatingLocalVideoView) + } else { + call.removeRemoteVideoRenderer(self.fullScreenRemoteVideoView) + call.removeLocalVideoRenderer(self.floatingLocalVideoView) + + self.floatingRemoteVideoView.alpha = 1 + self.floatingLocalVideoView.alpha = 0 + self.fullScreenRemoteVideoView.alpha = 0 + self.fullScreenLocalVideoView.alpha = 1 + + self.floatingViewVideoSource = .remote + call.attachRemoteVideoRenderer(self.floatingRemoteVideoView) + call.attachLocalVideoRenderer(self.fullScreenLocalVideoView) + } } @objc private func switchCamera() { From 1b35085015449d29864dbb3224759c39490a1a66 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 15 Feb 2023 15:32:40 +1100 Subject: [PATCH 3/6] fix local video view --- Session/Calls/CallVC.swift | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 707b72ebc..b829ea3ce 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -35,9 +35,9 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var floatingLocalVideoView: LocalVideoView = { let result = LocalVideoView() + result.alpha = 0 result.clipsToBounds = true result.themeBackgroundColor = .backgroundSecondary - result.isHidden = !call.isVideoEnabled result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 result.layer.masksToBounds = true result.set(.width, to: Self.floatingVideoViewWidth) @@ -86,22 +86,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { ) result.themeTintColor = .textPrimary result.addTarget(self, action: #selector(switchVideo), for: UIControl.Event.touchUpInside) - result.set(.width, to: 20) - result.set(.height, to: 20) - - return result - }() - - private lazy var switchVideoButtonContainer: UIView = { - let result = UIView() - result.themeBackgroundColor = .backgroundPrimary - result.layer.cornerRadius = UIDevice.current.isIPad ? 12 : 6 - result.layer.masksToBounds = true - result.addSubview(switchVideoButton) - switchVideoButton.pin(.leading, to: .leading, of: result, withInset: Values.smallSpacing) - switchVideoButton.pin(.trailing, to: .trailing, of: result, withInset: -Values.smallSpacing) - switchVideoButton.pin(.bottom, to: .bottom, of: result, withInset: -Values.smallSpacing) - switchVideoButton.pin(.top, to: .top, of: result, withInset: Values.largeSpacing) + result.set(.width, to: 60) + result.set(.height, to: 60) return result }() @@ -110,17 +96,12 @@ final class CallVC: UIViewController, VideoPreviewDelegate { let result = UIView() result.isHidden = true result.makeViewDraggable() - result.addSubview(switchVideoButtonContainer) - switchVideoButtonContainer.pin(.trailing, to: .trailing, of: result) - switchVideoButtonContainer.pin(.bottom, to: .bottom, of: result) result.addSubview(floatingLocalVideoView) - floatingLocalVideoView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top], to: result) - floatingLocalVideoView.pin(.bottom, to: .bottom, of: result, withInset: -36) + floatingLocalVideoView.pin(to: result) result.addSubview(floatingRemoteVideoView) - floatingRemoteVideoView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top], to: result) - floatingRemoteVideoView.pin(.bottom, to: .bottom, of: result, withInset: -36) + floatingRemoteVideoView.pin(to: result) return result }() @@ -477,6 +458,12 @@ final class CallVC: UIViewController, VideoPreviewDelegate { minimizeButton.pin(.left, to: .left, of: view) minimizeButton.pin(.top, to: .top, of: view, withInset: 32) + // Swap button + view.addSubview(switchVideoButton) + switchVideoButton.translatesAutoresizingMaskIntoConstraints = false + switchVideoButton.pin(.right, to: .right, of: view) + switchVideoButton.pin(.top, to: .top, of: view, withInset: 32) + // Title label view.addSubview(titleLabel) titleLabel.translatesAutoresizingMaskIntoConstraints = false @@ -661,6 +648,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { func cameraDidConfirmTurningOn() { floatingViewContainer.isHidden = false + let localVideoView: LocalVideoView = self.floatingViewVideoSource == .local ? self.floatingLocalVideoView : self.fullScreenLocalVideoView + localVideoView.alpha = 1 cameraManager.prepare() cameraManager.start() videoButton.themeTintColor = .backgroundSecondary From 335bfb687466e459e2afddb9e306b091e94189ec Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 15 Feb 2023 16:31:06 +1100 Subject: [PATCH 4/6] hiding video view if needed --- Session/Calls/CallVC.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index b829ea3ce..2b5db2e01 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -664,8 +664,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { call.removeLocalVideoRenderer(self.fullScreenLocalVideoView) self.floatingRemoteVideoView.alpha = 0 - self.floatingLocalVideoView.alpha = 1 - self.fullScreenRemoteVideoView.alpha = 1 + self.floatingLocalVideoView.alpha = call.isVideoEnabled ? 1 : 0 + self.fullScreenRemoteVideoView.alpha = call.isRemoteVideoEnabled ? 1 : 0 self.fullScreenLocalVideoView.alpha = 0 self.floatingViewVideoSource = .local @@ -675,10 +675,10 @@ final class CallVC: UIViewController, VideoPreviewDelegate { call.removeRemoteVideoRenderer(self.fullScreenRemoteVideoView) call.removeLocalVideoRenderer(self.floatingLocalVideoView) - self.floatingRemoteVideoView.alpha = 1 + self.floatingRemoteVideoView.alpha = call.isRemoteVideoEnabled ? 1 : 0 self.floatingLocalVideoView.alpha = 0 self.fullScreenRemoteVideoView.alpha = 0 - self.fullScreenLocalVideoView.alpha = 1 + self.fullScreenLocalVideoView.alpha = call.isVideoEnabled ? 1 : 0 self.floatingViewVideoSource = .remote call.attachRemoteVideoRenderer(self.floatingRemoteVideoView) From 5a35907cd3398b96bca6075c1eff472db5c75405 Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 16 Feb 2023 10:34:03 +1100 Subject: [PATCH 5/6] implement new UI/UX design --- Session/Calls/CallVC.swift | 45 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 2b5db2e01..8e385ff12 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -77,32 +77,41 @@ final class CallVC: UIViewController, VideoPreviewDelegate { return result }() - private lazy var switchVideoButton: UIButton = { - let result = UIButton(type: .custom) - result.setImage( - UIImage(named: "ic_switch_camera")? - .withRenderingMode(.alwaysTemplate), - for: .normal - ) - result.themeTintColor = .textPrimary - result.addTarget(self, action: #selector(switchVideo), for: UIControl.Event.touchUpInside) - result.set(.width, to: 60) - result.set(.height, to: 60) - - return result - }() - private lazy var floatingViewContainer: UIView = { let result = UIView() result.isHidden = true + result.themeBackgroundColor = .backgroundSecondary result.makeViewDraggable() + let noVideoIcon: UIImageView = UIImageView( + image: UIImage(systemName: "video.slash")? + .withRenderingMode(.alwaysTemplate) + ) + noVideoIcon.themeTintColor = .textPrimary + noVideoIcon.set(.width, to: 30) + noVideoIcon.set(.height, to: 20) + result.addSubview(noVideoIcon) + noVideoIcon.center(in: result) + result.addSubview(floatingLocalVideoView) floatingLocalVideoView.pin(to: result) result.addSubview(floatingRemoteVideoView) floatingRemoteVideoView.pin(to: result) + let swappingVideoIcon: UIImageView = UIImageView( + image: UIImage(systemName: "arrow.2.squarepath")? + .withRenderingMode(.alwaysTemplate) + ) + swappingVideoIcon.themeTintColor = .textPrimary + swappingVideoIcon.set(.height, to: 20) + swappingVideoIcon.set(.width, to: 20) + result.addSubview(swappingVideoIcon) + swappingVideoIcon.pin(.top, to: .top, of: result, withInset: Values.mediumSpacing) + swappingVideoIcon.pin(.trailing, to: .trailing, of: result, withInset: -Values.mediumSpacing) + + result.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(switchVideo))) + return result }() @@ -458,12 +467,6 @@ final class CallVC: UIViewController, VideoPreviewDelegate { minimizeButton.pin(.left, to: .left, of: view) minimizeButton.pin(.top, to: .top, of: view, withInset: 32) - // Swap button - view.addSubview(switchVideoButton) - switchVideoButton.translatesAutoresizingMaskIntoConstraints = false - switchVideoButton.pin(.right, to: .right, of: view) - switchVideoButton.pin(.top, to: .top, of: view, withInset: 32) - // Title label view.addSubview(titleLabel) titleLabel.translatesAutoresizingMaskIntoConstraints = false From acd494c29d90fe49b4f7dee33f7d833e4ad028fb Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Thu, 16 Feb 2023 11:38:55 +1100 Subject: [PATCH 6/6] minor adjustment for UI/UX --- Session/Calls/CallVC.swift | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Session/Calls/CallVC.swift b/Session/Calls/CallVC.swift index 8e385ff12..f98901d45 100644 --- a/Session/Calls/CallVC.swift +++ b/Session/Calls/CallVC.swift @@ -36,10 +36,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var floatingLocalVideoView: LocalVideoView = { let result = LocalVideoView() result.alpha = 0 - result.clipsToBounds = true result.themeBackgroundColor = .backgroundSecondary - result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 - result.layer.masksToBounds = true result.set(.width, to: Self.floatingVideoViewWidth) result.set(.height, to: Self.floatingVideoViewHeight) @@ -49,10 +46,7 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var floatingRemoteVideoView: RemoteVideoView = { let result = RemoteVideoView() result.alpha = 0 - result.clipsToBounds = true result.themeBackgroundColor = .backgroundSecondary - result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 - result.layer.masksToBounds = true result.set(.width, to: Self.floatingVideoViewWidth) result.set(.height, to: Self.floatingVideoViewHeight) @@ -80,6 +74,9 @@ final class CallVC: UIViewController, VideoPreviewDelegate { private lazy var floatingViewContainer: UIView = { let result = UIView() result.isHidden = true + result.clipsToBounds = true + result.layer.cornerRadius = UIDevice.current.isIPad ? 20 : 10 + result.layer.masksToBounds = true result.themeBackgroundColor = .backgroundSecondary result.makeViewDraggable() @@ -88,8 +85,8 @@ final class CallVC: UIViewController, VideoPreviewDelegate { .withRenderingMode(.alwaysTemplate) ) noVideoIcon.themeTintColor = .textPrimary - noVideoIcon.set(.width, to: 30) - noVideoIcon.set(.height, to: 20) + noVideoIcon.set(.width, to: 34) + noVideoIcon.set(.height, to: 28) result.addSubview(noVideoIcon) noVideoIcon.center(in: result) @@ -104,11 +101,11 @@ final class CallVC: UIViewController, VideoPreviewDelegate { .withRenderingMode(.alwaysTemplate) ) swappingVideoIcon.themeTintColor = .textPrimary - swappingVideoIcon.set(.height, to: 20) - swappingVideoIcon.set(.width, to: 20) + swappingVideoIcon.set(.width, to: 16) + swappingVideoIcon.set(.height, to: 12) result.addSubview(swappingVideoIcon) - swappingVideoIcon.pin(.top, to: .top, of: result, withInset: Values.mediumSpacing) - swappingVideoIcon.pin(.trailing, to: .trailing, of: result, withInset: -Values.mediumSpacing) + swappingVideoIcon.pin(.top, to: .top, of: result, withInset: Values.smallSpacing) + swappingVideoIcon.pin(.trailing, to: .trailing, of: result, withInset: -Values.smallSpacing) result.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(switchVideo)))