Skip to content

Commit

Permalink
Fix #97 (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocoford authored Jun 26, 2023
1 parent 8a378a8 commit 3f1d7f2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Sources/BottomSheet/BottomSheetView/BottomSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ internal struct BottomSheetView<HContent: View, MContent: View>: View {
// Make the GeometryReader ignore specific safe area (for transition to work)
// On iPhone and iPad not floating ignore bottom safe area, because the BottomSheet moves to the bottom edge
// On iPad floating and Mac ignore top safe area, because the BottomSheet moves to the top edge
.edgesIgnoringSafeArea(
self.isIPadFloatingOrMac ? .top : .bottom
)
.ignoresSafeAreaCompatible(.container, edges: self.isIPadFloatingOrMac ? .top : .bottom)
}
}
38 changes: 38 additions & 0 deletions Sources/BottomSheet/Helper/Extensions/ViewExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// ViewExtension.swift
//
//
// Created by Chocoford on 2023/6/16.
//

import SwiftUI

enum SafeAreaRegionsCompatible {
case all
case container
case keyboard

@available(iOS 14.0, macOS 11.0, macCatalyst 14.0, *)
var safeAreaRegions: SafeAreaRegions {
switch self {
case .all:
return .all
case .container:
return .container
case .keyboard:
return .keyboard
}
}
}

internal extension View {
@ViewBuilder
func ignoresSafeAreaCompatible(_ regions: SafeAreaRegionsCompatible = .all,
edges: Edge.Set = .all) -> some View {
if #available(iOS 14.0, macOS 11.0, *) {
ignoresSafeArea(regions.safeAreaRegions, edges: edges)
} else {
edgesIgnoringSafeArea(edges)
}
}
}

0 comments on commit 3f1d7f2

Please sign in to comment.