Skip to content

Commit

Permalink
⭐️ Impl: isInitialPresent
Browse files Browse the repository at this point in the history
Summary: Impl. `RNIModalPresentationStateMachine.isInitialPresent`.
  • Loading branch information
dominicstop committed Apr 13, 2023
1 parent 6d16218 commit c5fe2d8
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,18 @@ public struct RNIModalPresentationStateMachine {
// MARK: - Properties
// ------------------

private var _isInitialPresent: Bool? = nil;

public var wasCancelledDismissViaGesture: Bool = false;


// MARK: - Computed Properties
// ---------------------------

public var isInitialPresent: Bool {
self._isInitialPresent ?? true;
};

public var isPresented: Bool {
self.state.isPresented
};
Expand Down Expand Up @@ -212,22 +219,31 @@ public struct RNIModalPresentationStateMachine {
self.state = nextState;
};

if nextState.isPresenting && self._isInitialPresent == nil {
self._isInitialPresent = true;

} else if nextState.isPresenting && self._isInitialPresent == true {
self._isInitialPresent = false;
};

self.resetIfNeeded();

#if DEBUG
print(
"Log - RNIModalPresentationStateMachine.set"
+ " - statePrev: \(self.statePrev)"
+ " - nextState: \(self.state)"
+ " - wasCancelledDismissViaGesture: \(wasCancelledDismissViaGesture)"
+ " - isInitialPresent: \(self.isInitialPresent)"
);
#endif

self.resetIfNeeded();
};

mutating func resetIfNeeded(){
if self.state == .DISMISSED {
// reset
self.wasCancelledDismissViaGesture = false;
self._isInitialPresent = false;
};
};
};

0 comments on commit c5fe2d8

Please sign in to comment.