Skip to content

Commit

Permalink
Merge pull request #4 from Kleemann/main
Browse files Browse the repository at this point in the history
Using ZStack to present card via optional binding to object
  • Loading branch information
joogps committed Jan 27, 2021
2 parents f33aced + 78f29a9 commit 1e2ac4f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Sources/SlideOverCard/SlideOverCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,10 @@ extension View {
}

public func slideOverCard<Item:Identifiable, Content:View>(item: Binding<Item?>, onDismiss: (() -> Void)? = nil, dragEnabled: Binding<Bool> = .constant(true), dragToDismiss: Binding<Bool> = .constant(true), displayExitButton: Binding<Bool> = .constant(true), @ViewBuilder content: @escaping (Item) -> Content) -> some View {
Group {
if item.wrappedValue != nil {
let binding = Binding(get: { item.wrappedValue != nil }, set: { if !$0 { item.wrappedValue = nil } })
self.slideOverCard(isPresented: binding, onDismiss: onDismiss, dragEnabled: dragEnabled, dragToDismiss: dragToDismiss, displayExitButton: displayExitButton, content: { content(item.wrappedValue!) } )
} else { self }
let binding = Binding(get: { item.wrappedValue != nil }, set: { if !$0 { item.wrappedValue = nil } })
return ZStack {
self
self.slideOverCard(isPresented: binding, onDismiss: onDismiss, dragEnabled: dragEnabled, dragToDismiss: dragToDismiss, displayExitButton: displayExitButton, content: { content(item.wrappedValue!) } )
}
}

Expand Down

0 comments on commit 1e2ac4f

Please sign in to comment.