Skip to content

Commit

Permalink
fix: fixed header for SE device (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
forgotvas authored Jul 9, 2024
1 parent 5f4268c commit 1e5ab71
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
17 changes: 13 additions & 4 deletions Core/Core/Extensions/UIApplicationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion Core/Core/View/Base/DynamicOffsetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
10 changes: 9 additions & 1 deletion Course/Course/Presentation/Container/CourseContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1e5ab71

Please sign in to comment.