Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import Testing
@Suite(.snapshots(record: .never, diffTool: diffTool))
struct InsetViewModifierUITests {

@Test(
.bug("https://github.com/OpenSwiftUIProject/OpenSwiftUI/issues/511"),
.disabled("Extra spacing value is taken into account. Disable the test case before we fix it.")
)
@Test(.bug("https://github.com/OpenSwiftUIProject/OpenSwiftUI/issues/511"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that SafeAreaPaddingModifier behavior depends on the selected edges, consider adding a snapshot here that exercises a non-.all case (e.g. .safeAreaPadding(.horizontal, 20)) so regressions in edge filtering get caught.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

func safeAreaPaddingWithEdgeInsets() {
struct ContentView: View {
var body: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,20 @@ struct SafeAreaPaddingModifier: ViewModifier {

@usableFromInline
func body(content: SafeAreaPaddingModifier.Content) -> some View {
content.safeAreaInset(edge: .top) {
content.safeAreaInset(edge: .top, spacing: 0) {
insetView(edge: .top)
}.safeAreaInset(edge: .bottom) {
}.safeAreaInset(edge: .bottom, spacing: 0) {
insetView(edge: .bottom)
}.safeAreaInset(edge: .leading) {
}.safeAreaInset(edge: .leading, spacing: 0) {
insetView(edge: .leading)
}.safeAreaInset(edge: .trailing) {
}.safeAreaInset(edge: .trailing, spacing: 0) {
insetView(edge: .trailing)
}
}

private func insetView(edge: Edge) -> some View {
let axis = Axis(edge: edge)
let inset = (insets ?? defaultPadding)[edge]
let inset = edges.contains(edge) ? (insets ?? defaultPadding)[edge] : 0
return axis == .horizontal
? Color.clear.frame(width: inset)
: Color.clear.frame(height: inset)
Expand Down
Loading