minor refactor on the local video view to make it draggable

pull/560/head
Ryan Zhao 3 years ago
parent 2ee4b0119d
commit fb99bc6abd

@ -26,7 +26,7 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
result.contentMode = .scaleAspectFill result.contentMode = .scaleAspectFill
result.set(.width, to: 80) result.set(.width, to: 80)
result.set(.height, to: 173) result.set(.height, to: 173)
// result.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture))) result.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture)))
return result return result
}() }()
@ -263,7 +263,6 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
} }
func setUpViewHierarchy() { func setUpViewHierarchy() {
let safeAreaInsets = UIApplication.shared.keyWindow!.safeAreaInsets
// Profile picture container // Profile picture container
let profilePictureContainer = UIView() let profilePictureContainer = UIView()
view.addSubview(profilePictureContainer) view.addSubview(profilePictureContainer)
@ -274,10 +273,6 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
remoteVideoView.pin(to: view) remoteVideoView.pin(to: view)
// Local video view // Local video view
call.attachLocalVideoRenderer(localVideoView) call.attachLocalVideoRenderer(localVideoView)
view.addSubview(localVideoView)
localVideoView.pin(.right, to: .right, of: view, withInset: -Values.smallSpacing)
let topMargin = safeAreaInsets.top + Values.veryLargeSpacing
localVideoView.pin(.top, to: .top, of: view, withInset: topMargin)
// Fade view // Fade view
view.addSubview(fadeView) view.addSubview(fadeView)
fadeView.translatesAutoresizingMaskIntoConstraints = false fadeView.translatesAutoresizingMaskIntoConstraints = false
@ -317,15 +312,26 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
callInfoLabel.center(in: callInfoLabelContainer) callInfoLabel.center(in: callInfoLabelContainer)
} }
private func addLocalVideoView() {
let safeAreaInsets = UIApplication.shared.keyWindow!.safeAreaInsets
let window = CurrentAppContext().mainWindow!
window.addSubview(localVideoView)
localVideoView.autoPinEdge(toSuperviewEdge: .right, withInset: Values.smallSpacing)
let topMargin = safeAreaInsets.top + Values.veryLargeSpacing
localVideoView.autoPinEdge(toSuperviewEdge: .top, withInset: topMargin)
}
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated) super.viewDidAppear(animated)
if (call.isVideoEnabled && shouldRestartCamera) { cameraManager.start() } if (call.isVideoEnabled && shouldRestartCamera) { cameraManager.start() }
shouldRestartCamera = true shouldRestartCamera = true
addLocalVideoView()
} }
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
if (call.isVideoEnabled && shouldRestartCamera) { cameraManager.stop() } if (call.isVideoEnabled && shouldRestartCamera) { cameraManager.stop() }
localVideoView.removeFromSuperview()
} }
// MARK: Call signalling // MARK: Call signalling

Loading…
Cancel
Save