Skip to content

Commit

Permalink
💫 Update: RNIModalView.set
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Apr 10, 2023
1 parent 58db590 commit dabe4d1
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ public struct RNIModalPresentationStateMachine {
return
};

self.statePrev = prevState;

let isBecomingUnknown = prevState.isNotSpecific && !nextState.isNotSpecific;
let isBecomingUnknown = !prevState.isNotSpecific && nextState.isNotSpecific;
let isSameStep = prevState.step == nextState.step;

/// Do not over-write specific/"known state", with non-specific/"unknown
Expand All @@ -175,16 +173,23 @@ public struct RNIModalPresentationStateMachine {
/// * ✅: `PRESENTING_UNKNOWN` -> `PRESENTING_PROGRAMMATIC`
/// * ❌: `DISMISSING_GESTURE` -> `DISMISSING_UNKNOWN`
///
if isBecomingUnknown && isSameStep {
if isSameStep {
if !isBecomingUnknown {
self.state = nextState;
};

#if DEBUG
print(
"Warning - RNIModalPresentationStateMachine.set"
+ " - arg nextState: \(nextState)"
+ " - prevState: \(prevState)"
+ " - nextState: \(nextState)"
);
#endif
return;
};

self.statePrev = prevState;

if prevState.isDismissingViaGesture && nextState.isPresenting {
self.state = .DISMISS_GESTURE_CANCELLING;
self.onDismissWillCancel?();
Expand All @@ -193,7 +198,7 @@ public struct RNIModalPresentationStateMachine {
self.state = nextState;
self.onDismissDidCancel?();

} else {
} else {
self.state = nextState;
};
};
Expand Down

0 comments on commit dabe4d1

Please sign in to comment.