From e235b6059fed69f72864135ca2c4dd90c6c7c46b Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Thu, 21 Mar 2024 13:58:56 +1100 Subject: [PATCH] fix an issue where the keyboard can be covering voice call buttons --- Session/Calls/Call Management/SessionCallManager.swift | 6 +++++- Session/Calls/Views & Modals/IncomingCallBanner.swift | 2 +- Session/Meta/AppDelegate.swift | 5 ++++- SessionUIKit/Components/TopBannerController.swift | 6 ++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index c5dfd5c4a..1133c443d 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -3,6 +3,7 @@ import UIKit import CallKit import GRDB +import SessionUIKit import SessionMessagingKit import SignalCoreKit import SignalUtilitiesKit @@ -219,7 +220,10 @@ public final class SessionCallManager: NSObject, CallManagerProtocol { preconditionFailure() // FIXME: Handle more gracefully } - if let conversationVC: ConversationVC = presentingVC as? ConversationVC, conversationVC.viewModel.threadData.threadId == call.sessionId { + if + let conversationVC: ConversationVC = (presentingVC as? TopBannerController)?.wrappedViewController() as? ConversationVC, + conversationVC.viewModel.threadData.threadId == call.sessionId + { let callVC = CallVC(for: call) callVC.conversationVC = conversationVC conversationVC.inputAccessoryView?.isHidden = true diff --git a/Session/Calls/Views & Modals/IncomingCallBanner.swift b/Session/Calls/Views & Modals/IncomingCallBanner.swift index 0a5ca1330..c420b5626 100644 --- a/Session/Calls/Views & Modals/IncomingCallBanner.swift +++ b/Session/Calls/Views & Modals/IncomingCallBanner.swift @@ -202,7 +202,7 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate { else { preconditionFailure() } // FIXME: Handle more gracefully let callVC = CallVC(for: self.call) - if let conversationVC = presentingVC as? ConversationVC { + if let conversationVC = (presentingVC as? TopBannerController)?.wrappedViewController() as? ConversationVC { callVC.conversationVC = conversationVC conversationVC.inputAccessoryView?.isHidden = true conversationVC.inputAccessoryView?.alpha = 0 diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 29e4bde0b..05aa1286f 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -834,7 +834,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD let callVC: CallVC = CallVC(for: call) - if let conversationVC: ConversationVC = presentingVC as? ConversationVC, conversationVC.viewModel.threadData.threadId == call.sessionId { + if + let conversationVC: ConversationVC = (presentingVC as? TopBannerController)?.wrappedViewController() as? ConversationVC, + conversationVC.viewModel.threadData.threadId == call.sessionId + { callVC.conversationVC = conversationVC conversationVC.inputAccessoryView?.isHidden = true conversationVC.inputAccessoryView?.alpha = 0 diff --git a/SessionUIKit/Components/TopBannerController.swift b/SessionUIKit/Components/TopBannerController.swift index a9cc5108e..545171759 100644 --- a/SessionUIKit/Components/TopBannerController.swift +++ b/SessionUIKit/Components/TopBannerController.swift @@ -150,6 +150,12 @@ public class TopBannerController: UIViewController { } // MARK: - Functions + public func wrappedViewController() -> UIViewController? { + if let navVC = child as? UINavigationController { + return navVC.topViewController + } + return child + } public func attachChild() { child.willMove(toParent: self)