Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Commit 688aa65

Browse files
authored
Merge pull request #4 from 29CM-Developers/nuil/modal-dismiss-callback
바텀시트 dismiss 콜백 함수에 Dim 영역, 스크롤을 통해 바텀시트를 닫았는지 여부를 반환합니다.
2 parents 03385fb + 7174dff commit 688aa65

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

PanModal/Controller/PanModalPresentationController.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ open class PanModalPresentationController: UIPresentationController {
9999
return presentedViewController as? PanModalPresentable
100100
}
101101

102+
/**
103+
A Flag is Tap the dimmed background to return whether it is off or on
104+
*/
105+
private var isDismissedForCancel: Bool = false
106+
102107
// MARK: - Views
103108

104109
/**
@@ -113,6 +118,7 @@ open class PanModalPresentationController: UIPresentationController {
113118
}
114119
view.didTap = { [weak self] _ in
115120
if self?.presentable?.allowsTapToDismiss == true {
121+
self?.isDismissedForCancel = true
116122
self?.presentedViewController.dismiss(animated: true)
117123
}
118124
}
@@ -203,7 +209,7 @@ open class PanModalPresentationController: UIPresentationController {
203209
}
204210

205211
override public func dismissalTransitionWillBegin() {
206-
presentable?.panModalWillDismiss()
212+
presentable?.panModalWillDismiss(isDismissedForCancel: self.isDismissedForCancel)
207213

208214
guard let coordinator = presentedViewController.transitionCoordinator else {
209215
backgroundView.dimState = .off
@@ -223,8 +229,7 @@ open class PanModalPresentationController: UIPresentationController {
223229

224230
override public func dismissalTransitionDidEnd(_ completed: Bool) {
225231
if !completed { return }
226-
227-
presentable?.panModalDidDismiss()
232+
presentable?.panModalDidDismiss(isDismissedForCancel: self.isDismissedForCancel)
228233
}
229234

230235
/**
@@ -527,6 +532,7 @@ private extension PanModalPresentationController {
527532
transition(to: .shortForm)
528533

529534
} else {
535+
self.isDismissedForCancel = true
530536
presentedViewController.dismiss(animated: true)
531537
}
532538

@@ -545,6 +551,7 @@ private extension PanModalPresentationController {
545551
transition(to: .shortForm)
546552

547553
} else {
554+
self.isDismissedForCancel = true
548555
presentedViewController.dismiss(animated: true)
549556
}
550557
}

PanModal/Presentable/PanModalPresentable+Defaults.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ public extension PanModalPresentable where Self: UIViewController {
117117

118118
}
119119

120-
func panModalWillDismiss() {
120+
func panModalWillDismiss(isDismissedForCancel: Bool) {
121121

122122
}
123123

124-
func panModalDidDismiss() {
124+
func panModalDidDismiss(isDismissedForCancel: Bool) {
125125

126126
}
127127
}

PanModal/Presentable/PanModalPresentable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ public protocol PanModalPresentable: AnyObject {
225225

226226
Default value is an empty implementation.
227227
*/
228-
func panModalWillDismiss()
228+
func panModalWillDismiss(isDismissedForCancel: Bool)
229229

230230
/**
231231
Notifies the delegate after the pan modal is dismissed.
232232

233233
Default value is an empty implementation.
234234
*/
235-
func panModalDidDismiss()
235+
func panModalDidDismiss(isDismissedForCancel: Bool)
236236
}
237237
#endif

0 commit comments

Comments
 (0)