Skip to content
Merged
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 @@ -60,7 +60,7 @@ final class RootViewController: UIViewController {
true
},
dismissCompletion: {
// handle dismiss completion if user closed bottom sheet by a gesture
// handle bottom sheet dismissal completion
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ presentBottomSheet(
true
},
dismissCompletion: {
// handle dismiss completion if user closed bottom sheet by a gesture
// handle bottom sheet dismissal completion
}
)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public final class DefaultBottomSheetModalDismissalHandler: BottomSheetModalDism
private let _canBeDismissed: () -> Bool
private let dismissCompletion: (() -> Void)?

private var didInvokeDismissal = false

// MARK: - Init

init(
Expand All @@ -75,6 +77,14 @@ public final class DefaultBottomSheetModalDismissalHandler: BottomSheetModalDism
// User dismissed view controller by swipe-gesture, dismiss handler wasn't invoked
dismissCompletion?()
}

didInvokeDismissal = true
}

public func didEndDismissal() {
guard !didInvokeDismissal else { return }

dismissCompletion?()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public protocol BottomSheetModalDismissalHandler {
var canBeDismissed: Bool { get }

func performDismissal(animated: Bool)

func didEndDismissal()
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public final class BottomSheetPresentationController: UIPresentationController {
removeScrollTrackingIfNeeded()

state = .dismissed
dismissalHandler.didEndDismissal()
} else {
state = .presented
}
Expand Down