forked from lucaszischka/BottomSheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix "Ignored keyboard safe area on iPhone." lucaszischka#97
- Loading branch information
Chocoford
committed
Jun 16, 2023
1 parent
37f4d16
commit cebd220
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, *) | ||
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) | ||
} | ||
} | ||
} |