mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
WIP: improve call UI
This commit is contained in:
parent
1f65572f30
commit
383f996e82
5 changed files with 40 additions and 5 deletions
|
@ -271,6 +271,19 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
|
|||
if (isVideoEnabled) { cameraManager.stop() }
|
||||
}
|
||||
|
||||
// MARK: Delegate
|
||||
func webRTCDidConnected() {
|
||||
DispatchQueue.main.async {
|
||||
self.callInfoLabel.text = "Connected"
|
||||
UIView.animate(withDuration: 0.5, delay: 1, options: [], animations: {
|
||||
self.callInfoLabel.alpha = 0
|
||||
}, completion: { _ in
|
||||
self.callInfoLabel.isHidden = true
|
||||
self.callInfoLabel.alpha = 1
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Interaction
|
||||
func handleAnswerMessage(_ message: CallMessage) {
|
||||
callInfoLabel.text = "Connecting..."
|
||||
|
@ -278,6 +291,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
|
|||
|
||||
func handleEndCallMessage(_ message: CallMessage) {
|
||||
print("[Calls] Ending call.")
|
||||
callInfoLabel.isHidden = false
|
||||
callInfoLabel.text = "Call Ended"
|
||||
WebRTCSession.current?.dropConnection()
|
||||
WebRTCSession.current = nil
|
||||
|
|
|
@ -37,6 +37,18 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
self.inputAccessoryView?.alpha = 0
|
||||
present(callVC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
internal func showCallVCIfNeeded() {
|
||||
guard hasIncomingCall, let contactSessionID = (thread as? TSContactThread)?.contactSessionID() else { return }
|
||||
hasIncomingCall = false
|
||||
let callVC = CallVC(for: contactSessionID, mode: .offer) // TODO: change to answer
|
||||
callVC.conversationVC = self
|
||||
callVC.modalPresentationStyle = .overFullScreen
|
||||
callVC.modalTransitionStyle = .crossDissolve
|
||||
self.inputAccessoryView?.isHidden = true
|
||||
self.inputAccessoryView?.alpha = 0
|
||||
present(callVC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: Blocking
|
||||
@objc func unblock() {
|
||||
|
|
|
@ -10,6 +10,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
let focusedMessageID: String? // This isn't actually used ATM
|
||||
var unreadViewItems: [ConversationViewItem] = []
|
||||
var scrollButtonConstraint: NSLayoutConstraint?
|
||||
var hasIncomingCall = false
|
||||
// Search
|
||||
var isShowingSearchUI = false
|
||||
var lastSearchedText: String?
|
||||
|
@ -254,6 +255,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
didFinishInitialLayout = true
|
||||
markAllAsRead()
|
||||
self.becomeFirstResponder()
|
||||
showCallVCIfNeeded()
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
|
|
|
@ -10,15 +10,17 @@ extension AppDelegate {
|
|||
DispatchQueue.main.async {
|
||||
let sdp = RTCSessionDescription(type: .offer, sdp: message.sdps![0])
|
||||
guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully
|
||||
let callVC = CallVC(for: message.sender!, mode: .answer(sdp: sdp))
|
||||
callVC.modalPresentationStyle = .overFullScreen
|
||||
callVC.modalTransitionStyle = .crossDissolve
|
||||
if let conversationVC = presentingVC as? ConversationVC {
|
||||
if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == message.sender! {
|
||||
let callVC = CallVC(for: message.sender!, mode: .answer(sdp: sdp))
|
||||
callVC.modalPresentationStyle = .overFullScreen
|
||||
callVC.modalTransitionStyle = .crossDissolve
|
||||
callVC.conversationVC = conversationVC
|
||||
conversationVC.inputAccessoryView?.isHidden = true
|
||||
conversationVC.inputAccessoryView?.alpha = 0
|
||||
presentingVC.present(callVC, animated: true, completion: nil)
|
||||
} else {
|
||||
|
||||
}
|
||||
presentingVC.present(callVC, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
// Answer messages
|
||||
|
|
|
@ -3,6 +3,8 @@ import WebRTC
|
|||
|
||||
public protocol WebRTCSessionDelegate : AnyObject {
|
||||
var videoCapturer: RTCVideoCapturer { get }
|
||||
|
||||
func webRTCDidConnected()
|
||||
}
|
||||
|
||||
/// See https://webrtc.org/getting-started/overview for more information.
|
||||
|
@ -218,6 +220,9 @@ public final class WebRTCSession : NSObject, RTCPeerConnectionDelegate {
|
|||
|
||||
public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCIceConnectionState) {
|
||||
print("[Calls] ICE connection state changed to: \(state).")
|
||||
if state == .connected {
|
||||
delegate?.webRTCDidConnected()
|
||||
}
|
||||
}
|
||||
|
||||
public func peerConnection(_ peerConnection: RTCPeerConnection, didChange state: RTCIceGatheringState) {
|
||||
|
|
Loading…
Reference in a new issue