Skip to content

Commit

Permalink
Update SOCModifier.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
joogps committed Mar 29, 2024
1 parent 6d7872d commit e38be07
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions Sources/SlideOverCard/SOCModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,7 @@ internal struct SOCModifier<ViewContent: View, Style: ShapeStyle>: ViewModifier
content: content)
}

@ViewBuilder
func body(content: Content) -> some View {
if #available(iOS 15.0, *) {
reactiveContent(content: content)
.overlay {
WindowAccessor(callback: { window in
manager.set(window: window)
})
.allowsHitTesting(false)
}
} else {
ZStack {
reactiveContent(content: content)

WindowAccessor { window in
manager.set(window: window)
}
.allowsHitTesting(false)
}
}
}

func reactiveContent(content: Content) -> some View {
content
.onReceive(Just(colorScheme)) { value in
manager.set(colorScheme: value)
Expand All @@ -70,5 +48,13 @@ internal struct SOCModifier<ViewContent: View, Style: ShapeStyle>: ViewModifier
manager.dismiss()
}
}
.background(windowAccessor)
}

var windowAccessor: some View {
WindowAccessor { window in
manager.set(window: window)
}
.allowsHitTesting(false)
}
}

0 comments on commit e38be07

Please sign in to comment.