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 @@ -9,6 +9,8 @@
import SwiftUI

struct ViewModifierExample: View {
@EnvironmentObject var partialSheetManager: PartialSheetManager

@State var isSheetShown = false
@State var viewContent = "Initial content"
var body: some View {
Expand All @@ -28,6 +30,12 @@ struct ViewModifierExample: View {
ViewModifierView(content: self.$viewContent)
.padding(.vertical, 50)
}
.onAppear {
partialSheetManager.isDraggable = false
}
.onDisappear {
partialSheetManager.isDraggable = true
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/PartialSheet/PartialSheetManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class PartialSheetManager: ObservableObject {
}
}
}
/// Published var to activate or not drag gesture on the partial sheet
@Published var isDraggable: Bool = true
/// The content of the sheet
@Published private(set) var content: AnyView
/// the onDismiss code runned when the partial sheet is closed
Expand Down
4 changes: 3 additions & 1 deletion Sources/PartialSheet/PartialSheetViewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ extension PartialSheet {
.cornerRadius(style.cornerRadius)
.shadow(color: Color(.sRGBLinear, white: 0, opacity: 0.13), radius: 10.0)
.offset(y: self.sheetPosition)
.gesture(drag)
.ifIs(manager.isDraggable, transform: { view in
view.gesture(drag)
})
}
}
}
Expand Down