Skip to content

Commit

Permalink
⭐️ Impl: wasBlurCancelled + wasFocusCancelled
Browse files Browse the repository at this point in the history
Summary: Impl. `RNIModalFocusState.wasBlurCancelled`, and `wasBlurCancelled.wasFocusCancelled`.
  • Loading branch information
dominicstop committed Apr 13, 2023
1 parent 3e6286d commit 589f18d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ios/src_library/React Native/RNIModal/RNIModalFocusState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public struct RNIModalFocusStateMachine {
private(set) public var state: RNIModalFocusState = .INITIAL;
private(set) public var statePrev: RNIModalFocusState = .INITIAL;

public var wasBlurCancelled: Bool = false;
public var wasFocusCancelled: Bool = false;

// MARK: - Functions
// ------------------

Expand Down Expand Up @@ -89,5 +92,34 @@ public struct RNIModalFocusStateMachine {
self.state = nextState;
self.statePrev = prevState;
};

if prevState.isBlurring && nextState.isFocusing {
self.wasBlurCancelled = true;

} else if prevState.isFocusing && nextState.isBlurring {
self.wasFocusCancelled = true;
};

#if DEBUG
print(
"Log - RNIModalFocusState.set"
+ " - prevState: \(prevState)"
+ " - nextState: \(nextState)"
+ " - self.wasBlurCancelled: \(self.wasBlurCancelled)"
+ " - self.wasFocusCancelled: \(self.wasFocusCancelled)"
);
#endif

self.resetIfNeeded();
};

mutating func resetIfNeeded(){
if self.state.isBlurred {
self.wasBlurCancelled = false;
};

if self.state.isFocused {
self.wasFocusCancelled = false;
};
};
};

0 comments on commit 589f18d

Please sign in to comment.