UI improvements

pull/560/head
Niels Andriesse 4 years ago
parent 34e630b5bf
commit c1a61e897b

@ -18,6 +18,29 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
return RTCCameraVideoCapturer(delegate: webRTCSession.localVideoSource) return RTCCameraVideoCapturer(delegate: webRTCSession.localVideoSource)
}() }()
// MARK: UI Components
private lazy var fadeView: UIView = {
let result = UIView()
let height: CGFloat = 64
var frame = UIScreen.main.bounds
frame.size.height = height
let layer = CAGradientLayer()
layer.frame = frame
layer.colors = [ UIColor(hex: 0x000000).withAlphaComponent(0.4).cgColor, UIColor(hex: 0x000000).withAlphaComponent(0).cgColor ]
result.layer.insertSublayer(layer, at: 0)
result.set(.height, to: height)
return result
}()
private lazy var closeButton: UIButton = {
let result = UIButton(type: .custom)
let image = UIImage(named: "X")!.withTint(.white)
result.setImage(image, for: UIControl.State.normal)
result.set(.width, to: 60)
result.set(.height, to: 60)
return result
}()
// MARK: Mode // MARK: Mode
enum Mode { enum Mode {
case offer case offer
@ -69,6 +92,15 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
localVideoView.pin(.right, to: .right, of: view, withInset: -Values.largeSpacing) localVideoView.pin(.right, to: .right, of: view, withInset: -Values.largeSpacing)
let bottomMargin = UIApplication.shared.keyWindow!.safeAreaInsets.bottom + Values.largeSpacing let bottomMargin = UIApplication.shared.keyWindow!.safeAreaInsets.bottom + Values.largeSpacing
localVideoView.pin(.bottom, to: .bottom, of: view, withInset: -bottomMargin) localVideoView.pin(.bottom, to: .bottom, of: view, withInset: -bottomMargin)
// Fade view
view.addSubview(fadeView)
fadeView.translatesAutoresizingMaskIntoConstraints = false
fadeView.pin([ UIView.HorizontalEdge.left, UIView.VerticalEdge.top, UIView.HorizontalEdge.right ], to: view)
// Close button
view.addSubview(closeButton)
closeButton.translatesAutoresizingMaskIntoConstraints = false
closeButton.pin(.left, to: .left, of: view)
closeButton.pin(.top, to: .top, of: view, withInset: 32)
} }
override func viewDidAppear(_ animated: Bool) { override func viewDidAppear(_ animated: Bool) {
@ -84,4 +116,9 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
deinit { deinit {
WebRTCSession.current = nil WebRTCSession.current = nil
} }
// MARK: Interaction
@objc private func close() {
presentingViewController?.dismiss(animated: true, completion: nil)
}
} }

@ -29,7 +29,9 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
@objc func startCall() { @objc func startCall() {
guard let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return } guard let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return }
let callVC = CallVC(for: contactSessionID, mode: .offer) let callVC = CallVC(for: contactSessionID, mode: .offer)
navigationController!.pushViewController(callVC, animated: true, completion: nil) callVC.modalPresentationStyle = .overFullScreen
callVC.modalTransitionStyle = .crossDissolve
present(callVC, animated: true, completion: nil)
} }
// MARK: Blocking // MARK: Blocking

@ -13,6 +13,8 @@ extension AppDelegate {
alert.addAction(UIAlertAction(title: "Accept", style: .default, handler: { _ in alert.addAction(UIAlertAction(title: "Accept", style: .default, handler: { _ in
let callVC = CallVC(for: message.sender!, mode: .answer(sdp: sdp)) let callVC = CallVC(for: message.sender!, mode: .answer(sdp: sdp))
presentingVC.dismiss(animated: true) { presentingVC.dismiss(animated: true) {
callVC.modalPresentationStyle = .overFullScreen
callVC.modalTransitionStyle = .crossDissolve
presentingVC.present(callVC, animated: true, completion: nil) presentingVC.present(callVC, animated: true, completion: nil)
} }
})) }))
@ -65,17 +67,16 @@ extension AppDelegate {
@objc func getAppModeOrSystemDefault() -> AppMode { @objc func getAppModeOrSystemDefault() -> AppMode {
let userDefaults = UserDefaults.standard let userDefaults = UserDefaults.standard
if userDefaults.dictionaryRepresentation().keys.contains("appMode") {
guard userDefaults.dictionaryRepresentation().keys.contains("appMode") else { let mode = userDefaults.integer(forKey: "appMode")
return AppMode(rawValue: mode) ?? .light
} else {
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
return UITraitCollection.current.userInterfaceStyle == .dark ? .dark : .light return UITraitCollection.current.userInterfaceStyle == .dark ? .dark : .light
} else { } else {
return .light return .light
} }
} }
let mode = userDefaults.integer(forKey: "appMode")
return AppMode(rawValue: mode) ?? .light
} }
} }

Loading…
Cancel
Save