Commit 0ccf6e2f authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI: show call options

Keep call options visible unless screen is tapped

Change-Id: Ie5a3dd80e08d656c9315a86c6eb3853a0fe91fcd
parent d7781045
......@@ -35,10 +35,13 @@ class ButtonsContainerView: UIView, NibLoadable {
@IBOutlet weak var dialpadButton: UIButton!
@IBOutlet weak var switchSpeakerButton: UIButton!
@IBOutlet weak var cancelButton: UIButton!
@IBOutlet weak var spaceButton: UIButton!
//@IBOutlet weak var spaceButton: UIButton!
@IBOutlet weak var switchCameraButton: UIButton!
//Constraints
@IBOutlet weak var cancelButtonWidthConstraint: NSLayoutConstraint!
@IBOutlet weak var cancelButtonCenterConstraint: NSLayoutConstraint!
@IBOutlet weak var cancelButtonRightAlligmentConstraint: NSLayoutConstraint!
@IBOutlet weak var cancelButtonBottomConstraint: NSLayoutConstraint!
@IBOutlet weak var cancelButtonHeightConstraint: NSLayoutConstraint!
@IBOutlet weak var stackViewYConstraint: NSLayoutConstraint!
......@@ -83,17 +86,22 @@ class ButtonsContainerView: UIView, NibLoadable {
Bundle.main.loadNibNamed("ButtonsContainerView", owner: self, options: nil)
addSubview(containerView)
containerView.frame = self.bounds
self.container.clipsToBounds = false
}
func withoutOptions() {
self.container.backgroundColor = UIColor.clear
self.backgroundBlurEffect.isHidden = true
switchCameraButton.isHidden = true
muteAudioButton.isHidden = true
muteVideoButton.isHidden = true
pauseCallButton.isHidden = true
dialpadButton.isHidden = true
switchSpeakerButton.isHidden = true
cancelButton.isHidden = false
cancelButtonBottomConstraint.constant = 20
cancelButtonRightAlligmentConstraint.priority = UILayoutPriority(rawValue: 250.0)
cancelButtonCenterConstraint.priority = UILayoutPriority(rawValue: 999.0)
}
func optionsWithSpeaker() {
......@@ -103,12 +111,19 @@ class ButtonsContainerView: UIView, NibLoadable {
muteAudioButton.isHidden = false
if self.viewModel?.isAudioOnly ?? false {
muteVideoButton.isHidden = true
spaceButton.isHidden = true
switchCameraButton.isHidden = true
if self.viewModel?.isSipCall ?? false {
dialpadButton.isHidden = false
}
cancelButtonBottomConstraint.constant = 20
cancelButtonRightAlligmentConstraint.priority = UILayoutPriority(rawValue: 250.0)
cancelButtonCenterConstraint.priority = UILayoutPriority(rawValue: 999.0)
} else {
muteVideoButton.isHidden = false
switchCameraButton.isHidden = false
cancelButtonBottomConstraint.constant = 120
cancelButtonCenterConstraint.priority = UILayoutPriority(rawValue: 250.0)
cancelButtonRightAlligmentConstraint.priority = UILayoutPriority(rawValue: 999.0)
}
pauseCallButton.isHidden = false
switchSpeakerButton.isEnabled = true
......@@ -122,12 +137,19 @@ class ButtonsContainerView: UIView, NibLoadable {
self.isCallStarted = true
if self.viewModel?.isAudioOnly ?? false {
muteVideoButton.isHidden = true
spaceButton.isHidden = true
switchCameraButton.isHidden = true
if self.viewModel?.isSipCall ?? false {
dialpadButton.isHidden = false
}
cancelButtonBottomConstraint.constant = 20
cancelButtonRightAlligmentConstraint.priority = UILayoutPriority(rawValue: 250.0)
cancelButtonCenterConstraint.priority = UILayoutPriority(rawValue: 999.0)
} else {
switchCameraButton.isHidden = false
muteVideoButton.isHidden = false
cancelButtonBottomConstraint.constant = 120
cancelButtonCenterConstraint.priority = UILayoutPriority(rawValue: 250.0)
cancelButtonRightAlligmentConstraint.priority = UILayoutPriority(rawValue: 999.0)
}
switchSpeakerButton.isEnabled = false
self.muteAudioButton.isHidden = false
......
This diff is collapsed.
......@@ -148,36 +148,13 @@
<constraint firstAttribute="height" constant="70" id="iha-aS-TZH"/>
</constraints>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="223-1E-riv">
<rect key="frame" x="162.66666666666666" y="403.66666666666669" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="MN0-Eh-bIu"/>
<constraint firstAttribute="height" constant="50" id="xms-0h-ZuM"/>
</constraints>
<color key="tintColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" image="switch_camera"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="0.0"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
<color key="value" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="roundedCorners" value="NO"/>
</userDefinedRuntimeAttributes>
</button>
</subviews>
<constraints>
<constraint firstItem="gWE-IS-b5p" firstAttribute="centerY" secondItem="rt7-JS-vjg" secondAttribute="centerY" id="1Jq-i7-iGP"/>
<constraint firstItem="CfE-DF-buX" firstAttribute="centerX" secondItem="ZK1-Be-lcD" secondAttribute="centerX" id="51a-aO-iap"/>
<constraint firstItem="223-1E-riv" firstAttribute="centerX" secondItem="ZK1-Be-lcD" secondAttribute="centerX" id="KH5-fw-hla"/>
<constraint firstItem="CfE-DF-buX" firstAttribute="height" secondItem="ZK1-Be-lcD" secondAttribute="height" id="O6Q-I4-gU3"/>
<constraint firstItem="rt7-JS-vjg" firstAttribute="centerX" secondItem="CfE-DF-buX" secondAttribute="centerX" id="QPi-iO-gGH"/>
<constraint firstItem="rt7-JS-vjg" firstAttribute="width" secondItem="CfE-DF-buX" secondAttribute="width" id="VX9-wH-CfO"/>
<constraint firstItem="223-1E-riv" firstAttribute="centerY" secondItem="ZK1-Be-lcD" secondAttribute="centerY" id="cb4-Jh-zso"/>
<constraint firstItem="rt7-JS-vjg" firstAttribute="height" secondItem="CfE-DF-buX" secondAttribute="height" id="glm-Va-dTY"/>
<constraint firstItem="gWE-IS-b5p" firstAttribute="leading" secondItem="rt7-JS-vjg" secondAttribute="leading" constant="-17" id="kOS-1k-vY1"/>
<constraint firstItem="CfE-DF-buX" firstAttribute="centerY" secondItem="ZK1-Be-lcD" secondAttribute="centerY" id="pDf-fu-Le6"/>
......@@ -263,7 +240,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SdV-jx-Mla">
<rect key="frame" x="187.66666666666666" y="658" width="0.0" height="0.0"/>
<rect key="frame" x="187.66666666666666" y="648" width="0.0" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
......@@ -293,10 +270,10 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LK6-u0-eLU" customClass="ButtonsContainerView" customModule="Ring" customModuleProvider="target">
<rect key="frame" x="10" y="658" width="355" height="110"/>
<rect key="frame" x="10" y="568" width="355" height="200"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="110" id="r58-OO-QqE"/>
<constraint firstAttribute="height" constant="200" id="r58-OO-QqE"/>
</constraints>
</view>
</subviews>
......@@ -313,7 +290,7 @@
<constraint firstItem="5E0-lB-SkS" firstAttribute="height" secondItem="QpJ-Sx-9dG" secondAttribute="height" id="KFS-O1-Acs"/>
<constraint firstItem="ZVy-nB-bKJ" firstAttribute="top" secondItem="QpJ-Sx-9dG" secondAttribute="top" id="NrK-DR-BPG"/>
<constraint firstItem="lZI-X0-bkP" firstAttribute="top" secondItem="ZK1-Be-lcD" secondAttribute="top" constant="45" id="Uew-ao-q8k"/>
<constraint firstItem="SdV-jx-Mla" firstAttribute="bottom" secondItem="LK6-u0-eLU" secondAttribute="top" id="YIc-Oj-lc8"/>
<constraint firstItem="SdV-jx-Mla" firstAttribute="bottom" secondItem="LK6-u0-eLU" secondAttribute="top" constant="80" id="YIc-Oj-lc8"/>
<constraint firstItem="ZVy-nB-bKJ" firstAttribute="centerY" secondItem="QpJ-Sx-9dG" secondAttribute="centerY" id="bAN-gX-nPE"/>
<constraint firstItem="lZI-X0-bkP" firstAttribute="trailing" secondItem="LK6-u0-eLU" secondAttribute="trailing" constant="10" id="cl9-Fw-bSb"/>
<constraint firstItem="ZVy-nB-bKJ" firstAttribute="centerX" secondItem="lZI-X0-bkP" secondAttribute="centerX" id="ff0-Nw-f2Y"/>
......@@ -357,7 +334,6 @@
<outlet property="profileImageViewHeightConstraint" destination="V9c-7W-Frv" id="0iC-TD-RuH"/>
<outlet property="profileImageViewWidthConstraint" destination="Miw-Nd-4Fa" id="OSp-7J-TGC"/>
<outlet property="spinner" destination="nwA-ao-thv" id="bJo-Wq-QmV"/>
<outlet property="switchCameraButton" destination="223-1E-riv" id="0Pd-fI-JIR"/>
<outlet property="viewCapturedVideo" destination="ZK1-Be-lcD" id="Go0-ab-yLg"/>
</connections>
</viewController>
......@@ -369,6 +345,5 @@
<resources>
<image name="ic_contact_picture" width="512" height="512"/>
<image name="left_arrow" width="138.24000549316406" height="138.24000549316406"/>
<image name="switch_camera" width="75" height="75"/>
</resources>
</document>
......@@ -38,7 +38,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
@IBOutlet weak var avatarView: UIView!
@IBOutlet weak var avatarViewBlurEffect: UIVisualEffectView!
@IBOutlet private weak var callPulse: UIView!
@IBOutlet weak var switchCameraButton: UIButton!
@IBOutlet private weak var mainView: UIView!
......@@ -80,9 +79,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
fileprivate let disposeBag = DisposeBag()
private let log = SwiftyBeaver.self
private var task: DispatchWorkItem?
private var shouldRotateScreen = false
override var preferredStatusBarStyle: UIStatusBarStyle {
......@@ -124,8 +120,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}
UIDevice.current.isProximityMonitoringEnabled = self.viewModel.isAudioOnly
switchCameraButton.contentVerticalAlignment = .fill
switchCameraButton.contentHorizontalAlignment = .fill
initCallAnimation()
UIApplication.shared.isIdleTimerDisabled = true
......@@ -180,6 +174,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}
func setUpCallButtons() {
self.mainView.bringSubview(toFront: self.buttonsContainer)
self.buttonsContainer.viewModel = self.viewModel.containerViewModel
self.buttonsContainer.cancelButton.rx.tap
.subscribe(onNext: { [weak self] in
......@@ -189,10 +184,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
self.buttonsContainer.dialpadButton.rx.tap
.subscribe(onNext: { [weak self] in
// guard let bag = self?.viewModel.injectionBag else {return}
// let dialpadViewController = DialpadViewController.instantiate(with: bag)
// dialpadViewController.viewModel.inCallDialpad = true
// self?.present(dialpadViewController, animated: true, completion: nil)
self?.viewModel.showDialpad()
}).disposed(by: self.disposeBag)
......@@ -213,7 +204,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
self?.viewModel.togglePauseCall()
}).disposed(by: self.disposeBag)
self.switchCameraButton.rx.tap
self.buttonsContainer.switchCameraButton.rx.tap
.subscribe(onNext: { [weak self] in
self?.viewModel.switchCamera()
}).disposed(by: self.disposeBag)
......@@ -251,9 +242,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
.subscribe(onNext: { [weak self] rotate in
self?.shouldRotateScreen = rotate
}).disposed(by: self.disposeBag)
// disable switch camera button for audio only calls
self.switchCameraButton.isEnabled = !(self.viewModel.isAudioOnly)
}
// swiftlint:disable function_body_length
......@@ -293,7 +281,7 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [weak self] _ in
if self?.durationLabel.text != "" {
if (self?.viewModel.isAudioOnly ?? true) {
if self?.viewModel.isAudioOnly ?? true {
self?.buttonContainerHeightConstraint.constant = 200
self?.buttonsContainer.containerHeightConstraint.constant = 200
self?.buttonsContainer.stackViewYConstraint.constant = 110
......@@ -389,7 +377,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [unowned self] show in
if show {
self.task?.cancel()
self.showCallOptions()
}
}).disposed(by: self.disposeBag)
......@@ -450,7 +437,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
.subscribe(onNext: { [weak self] dontShow in
if dontShow && (!(self?.isCallStarted ?? false)) {
self?.isCallStarted = true
self?.hideCancelButton()
let device = UIDevice.modelName
//Reduce the cancel button for small iPhone
switch device {
......@@ -458,7 +444,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
self?.buttonsContainer.cancelButtonWidthConstraint.constant = 50
self?.buttonsContainer.cancelButtonHeightConstraint.constant = 50
self?.buttonsContainer.cancelButton.cornerRadius = 25
self?.buttonsContainer.cancelButtonBottomConstraint.constant = 30
default : break
}
UIView.animate(withDuration: 0.4, animations: {
......@@ -472,9 +457,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}
func removeFromScreen() {
if !self.infoContainer.isHidden {
task?.cancel()
}
UIDevice.current.isProximityMonitoringEnabled = false
UIApplication.shared.isIdleTimerDisabled = false
self.dismiss(animated: false)
......@@ -587,22 +569,17 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}
func showContactInfo() {
if !self.infoContainer.isHidden {
task?.cancel()
if !self.buttonsContainer.isHidden {
self.hideContactInfo()
return
}
self.isMenuShowed = true
self.buttonsContainer.isHidden = false
if !self.capturedVideo.isHidden {
self.switchCameraButton.isHidden = false
}
self.infoContainer.isHidden = false
self.view.layoutIfNeeded()
UIView.animate(withDuration: 0.2, animations: { [weak self] in
self?.capturedVideoBlurEffect.alpha = 0
self?.resizeCapturedVideo(withInfoContainer: true)
self?.infoContainerTopConstraint.constant = -10
if UIDevice.current.hasNotch && (self?.orientation == .landscapeRight || self?.orientation == .landscapeLeft) {
......@@ -612,18 +589,13 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
} else {
self?.buttonsContainerBottomConstraint.constant = 10
}
self?.capturedVideoBlurEffect.alpha = 0.7
self?.view.layoutIfNeeded()
})
task = DispatchWorkItem {[weak self] in self?.hideContactInfo() }
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 7, execute: task!)
}
func hideContactInfo() {
self.isMenuShowed = false
UIView.animate(withDuration: 0.2, animations: { [unowned self] in
self.capturedVideoBlurEffect.alpha = self.isVideoHidden ? 1 : 0
self.resizeCapturedVideo(withInfoContainer: false)
self.infoContainerTopConstraint.constant = 150
self.buttonsContainerBottomConstraint.constant = -150
......@@ -631,7 +603,6 @@ class CallViewController: UIViewController, StoryboardBased, ViewModelBased {
}, completion: { [weak self] _ in
self?.infoContainer.isHidden = true
self?.buttonsContainer.isHidden = true
self?.switchCameraButton.isHidden = true
})
}
......
......@@ -176,13 +176,7 @@ class CallViewModel: Stateable, ViewModel {
}()
lazy var showCallOptions: Observable<Bool> = { [unowned self] in
return Observable.combineLatest(self.screenTapped.asObservable(),
isActiveVideoCall) { (tapped, shouldRespond) in
if tapped && shouldRespond {
return true
}
return false
}
return self.screenTapped.asObservable()
}()
lazy var showCancelOption: Observable<Bool> = { [unowned self] in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment