Skip to content

Commit

Permalink
🐞 Fix: ModalSheetPresentationStateMachine
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Oct 2, 2024
1 parent c505935 commit 1a91d89
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions ios/Temp/ModalSheetPresentationStateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ extension ModalSheetPresentationStateMachine: ViewControllerLifecycleNotifiable
sender: UIViewController,
isAnimated: Bool
) {
guard !self.isSheetPanGestureActive else {
return;
};

self.setState(nextState: .dismissing);
};

Expand All @@ -266,17 +270,12 @@ extension ModalSheetPresentationStateMachine: ModalSheetViewControllerEventsNoti
self.setState(nextState: .presentingViaGestureCancelled);
};

public func notifyOnSheetDidDismissViaGesture(
sender: UIViewController,
presentationController: UIPresentationController
) {
self.setState(nextState: .dismissedViaGesture);
};

public func notifyOnSheetWillDismissViaGesture(
sender: UIViewController,
presentationController: UIPresentationController
) {
self.isSheetPanGestureActive = true;

guard let transitionCoordinator = sender.transitionCoordinator else {
return;
};
Expand All @@ -295,6 +294,13 @@ extension ModalSheetPresentationStateMachine: ModalSheetViewControllerEventsNoti
};
};

public func notifyOnSheetDidDismissViaGesture(
sender: UIViewController,
presentationController: UIPresentationController
) {
self.setState(nextState: .dismissedViaGesture);
};

public func notifyOnSheetBeingDraggedByPanGesture(
sender: UIViewController,
panGesture: UIPanGestureRecognizer
Expand All @@ -306,14 +312,13 @@ extension ModalSheetPresentationStateMachine: ModalSheetViewControllerEventsNoti
switch panGesture.state {
case .began, .changed:
self.isSheetPanGestureActive = true;
self.setState(nextState: .draggingViaGesture);

case .ended, .cancelled, .failed:
self.isSheetPanGestureActive = false;

default:
break;
};

self.setState(nextState: .draggingViaGesture);
};
};

0 comments on commit 1a91d89

Please sign in to comment.