diff --git a/Core/Core/Extensions/UIApplicationExtension.swift b/Core/Core/Extensions/UIApplicationExtension.swift index fe149414f..f95bff70b 100644 --- a/Core/Core/Extensions/UIApplicationExtension.swift +++ b/Core/Core/Extensions/UIApplicationExtension.swift @@ -8,17 +8,17 @@ import UIKit import Theme -extension UIApplication { +public extension UIApplication { - public var keyWindow: UIWindow? { + var keyWindow: UIWindow? { UIApplication.shared.windows.first { $0.isKeyWindow } } - public func endEditing(force: Bool = true) { + func endEditing(force: Bool = true) { windows.forEach { $0.endEditing(force) } } - public class func topViewController( + class func topViewController( controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController ) -> UIViewController? { if let navigationController = controller as? UINavigationController { @@ -34,6 +34,15 @@ extension UIApplication { } return controller } + + var windowInsets: UIEdgeInsets { + guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, + let window = windowScene.windows.first else { + return .zero + } + + return window.safeAreaInsets + } } extension UINavigationController { diff --git a/Core/Core/View/Base/DynamicOffsetView.swift b/Core/Core/View/Base/DynamicOffsetView.swift index 59bedd83d..2c4d47fe1 100644 --- a/Core/Core/View/Base/DynamicOffsetView.swift +++ b/Core/Core/View/Base/DynamicOffsetView.swift @@ -12,7 +12,13 @@ public struct DynamicOffsetView: View { private let padHeight: CGFloat = 290 private let collapsedHorizontalHeight: CGFloat = 120 private let collapsedVerticalHeight: CGFloat = 100 - private let expandedHeight: CGFloat = 240 + private var expandedHeight: CGFloat { + let topInset = UIApplication.shared.windowInsets.top + guard topInset > 0 else { + return 240 + } + return 300 - topInset + } private let coordinateBoundaryLower: CGFloat = -115 private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } diff --git a/Course/Course/Presentation/Container/CourseContainerView.swift b/Course/Course/Presentation/Container/CourseContainerView.swift index bc70c08f3..18964fae5 100644 --- a/Course/Course/Presentation/Container/CourseContainerView.swift +++ b/Course/Course/Presentation/Container/CourseContainerView.swift @@ -29,7 +29,15 @@ public struct CourseContainerView: View { private var idiom: UIUserInterfaceIdiom { UIDevice.current.userInterfaceIdiom } private let coordinateBoundaryLower: CGFloat = -115 - private let coordinateBoundaryHigher: CGFloat = 40 + + private var coordinateBoundaryHigher: CGFloat { + let topInset = UIApplication.shared.windowInsets.top + guard topInset > 0 else { + return 40 + } + + return topInset + } private struct GeometryName { static let backButton = "backButton"