@@ -389,10 +389,19 @@ class UiUtils {
389389 public static func showToast( message: String , duration: TimeInterval = 3.0 , level: ToastLevel = . error) {
390390 // Grab the last window (instead the key window) so we can show
391391 // the toast over they keyboard when it's presented.
392- guard let parent = UIApplication . shared. windows. last else {
392+ guard let topWindow = UIApplication . shared. windows. last else {
393393 Cache . log. error ( " UiUtils.showToast - parent window not set " )
394394 return
395395 }
396+ var parent : UIView = topWindow
397+ if #available( iOS 16 , * ) {
398+ // UIRemoteKeyboardWindow is no longer available in iOS 16 so keyboard (if presented) may
399+ // cover the toast.
400+ // Show toast over the input accessory view if visible.
401+ if let inputView = UiUtils . topViewController ( rootViewController: ( UIApplication . shared. delegate as! AppDelegate ) . window? . rootViewController) ? . inputAccessoryView {
402+ parent = inputView
403+ }
404+ }
396405
397406 let iconSize : CGFloat = 32
398407 let spacing : CGFloat = 8
@@ -600,17 +609,17 @@ class UiUtils {
600609 }
601610
602611 public static func topViewController( rootViewController: UIViewController ? ) -> UIViewController ? {
603- guard let rootViewController = rootViewController else { return nil }
604- guard let presented = rootViewController . presentedViewController else {
605- return rootViewController
612+ guard let controller = rootViewController else { return nil }
613+ if let presented = controller . presentedViewController {
614+ return topViewController ( rootViewController: presented )
606615 }
607- switch presented {
616+ switch controller {
608617 case let navigationController as UINavigationController :
609618 return topViewController ( rootViewController: navigationController. viewControllers. last)
610619 case let tabBarController as UITabBarController :
611620 return topViewController ( rootViewController: tabBarController. selectedViewController)
612621 default :
613- return topViewController ( rootViewController : presented )
622+ return controller
614623 }
615624 }
616625
0 commit comments