add background to call vc

This commit is contained in:
ryanzhao 2021-09-22 17:06:14 +10:00
parent 90043702c0
commit 101f7d3d93
1 changed files with 29 additions and 0 deletions

View File

@ -2,6 +2,7 @@ import WebRTC
import SessionUIKit
import SessionMessagingKit
import SessionUtilitiesKit
import UIKit
final class CallVC : UIViewController, WebRTCSessionDelegate {
let sessionID: String
@ -152,6 +153,10 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
}
func setUpViewHierarchy() {
// Background
let background = getBackgroudView()
view.addSubview(background)
background.autoPinEdgesToSuperviewEdges()
// Call info label
view.addSubview(callInfoLabel)
callInfoLabel.translatesAutoresizingMaskIntoConstraints = false
@ -198,6 +203,30 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
switchAudioButton.pin(.left, to: .right, of: hangUpButton, withInset: Values.veryLargeSpacing)
}
private func getBackgroudView() -> UIView {
let background = UIView()
let imageView = UIImageView()
imageView.layer.cornerRadius = 150
imageView.layer.masksToBounds = true
imageView.contentMode = .scaleAspectFill
if let profilePicture = OWSProfileManager.shared().profileAvatar(forRecipientId: sessionID) {
imageView.image = profilePicture
} else {
let displayName = Storage.shared.getContact(with: sessionID)?.name ?? sessionID
imageView.image = Identicon.generatePlaceholderIcon(seed: sessionID, text: displayName, size: 300)
}
background.addSubview(imageView)
imageView.set(.width, to: 300)
imageView.set(.height, to: 300)
imageView.center(in: background)
let blurView = UIView()
blurView.alpha = 0.5
blurView.backgroundColor = .black
background.addSubview(blurView)
blurView.autoPinEdgesToSuperviewEdges()
return background
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
cameraManager.start()