Skip to content

Commit

Permalink
💫 Update: RNIModalData
Browse files Browse the repository at this point in the history
Related:
* `TODO:2023-05-01-19-12-26` - Implement: `ModalView` events.
* `TODO:2023-05-01-19-19-20` - Update `RNIModalView` event objects.
  • Loading branch information
dominicstop committed May 5, 2023
1 parent 59bc1da commit 9eaefdf
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 55 deletions.
20 changes: 2 additions & 18 deletions ios/src_library/React Native/RNIModal/RNIModal+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,8 @@ extension RNIModalState where Self: RNIModal {
modalIndexPrev: self.modalIndexPrev,
currentModalIndex: self.currentModalIndex,

modalFocusState: self.modalFocusState.state,
modalFocusStatePref: self.modalFocusState.statePrev,

wasBlurCancelled: self.modalFocusState.wasBlurCancelled,
wasFocusCancelled: self.modalFocusState.wasFocusCancelled,

modalPresentationState: self.modalPresentationState.state,
modalPresentationStatePrev: self.modalPresentationState.statePrev,

isInitialPresent: self.modalPresentationState.isInitialPresent,
wasCancelledPresent: self.modalPresentationState.wasCancelledPresent,
wasCancelledDismiss: self.modalPresentationState.wasCancelledDismiss,

wasCancelledDismissViaGesture:
self.modalPresentationState.wasCancelledDismissViaGesture,

isModalPresented: self.modalPresentationState.isPresented,
isModalInFocus: self.synthesizedIsModalInFocus,
modalFocusState: self.modalFocusState,
modalPresentationState: self.modalPresentationState,

computedIsModalInFocus: self.computedIsModalInFocus,
computedIsModalPresented: self.computedIsModalPresented,
Expand Down
18 changes: 2 additions & 16 deletions ios/src_library/React Native/RNIModal/RNIModalData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@ public struct RNIModalData: RNIDictionarySynthesizable {
public let modalIndexPrev: Int;
public let currentModalIndex: Int;

public let modalFocusState: RNIModalFocusState;
public let modalFocusStatePref: RNIModalFocusState;

public let wasBlurCancelled: Bool;
public let wasFocusCancelled: Bool;

public let modalPresentationState: RNIModalPresentationState;
public let modalPresentationStatePrev: RNIModalPresentationState;

public let isInitialPresent: Bool;
public let wasCancelledPresent: Bool;
public let wasCancelledDismiss: Bool;
public let wasCancelledDismissViaGesture: Bool;

public let isModalPresented: Bool;
public let isModalInFocus: Bool;
public let modalFocusState: RNIModalFocusStateMachine;
public let modalPresentationState: RNIModalPresentationStateMachine;

public let computedIsModalInFocus: Bool;
public let computedIsModalPresented: Bool;
Expand Down
15 changes: 14 additions & 1 deletion ios/src_library/React Native/RNIModal/RNIModalFocusState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public enum RNIModalFocusState: String {
};
};

public struct RNIModalFocusStateMachine {
public struct RNIModalFocusStateMachine: RNIDictionaryRepresentable {

// MARK: - Properties
// ------------------
Expand All @@ -68,6 +68,19 @@ public struct RNIModalFocusStateMachine {
self.statePrev != self.state;
};

// MARK: - RNIDictionaryRepresentable
// ----------------------------------

public var asDictionary: [String : Any] {[
"state": self.state,
"statePrev": self.statePrev,
"isFocused": self.state.isFocused,
"isBlurred": self.state.isBlurred,
"isTransitioning": self.state.isTransitioning,
"wasBlurCancelled": self.wasBlurCancelled,
"wasFocusCancelled": self.wasFocusCancelled,
]};

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public enum RNIModalPresentationState: String, CaseIterable {
};
};

public struct RNIModalPresentationStateMachine {
public struct RNIModalPresentationStateMachine: RNIDictionaryRepresentable {

// MARK: - Properties
// ------------------
Expand Down Expand Up @@ -181,6 +181,20 @@ public struct RNIModalPresentationStateMachine {
self.statePrev != self.state;
};

// MARK: RNIDictionaryRepresentable
// --------------------------------

public var asDictionary: [String : Any] {[
"state": self.state,
"statePrev": self.statePrev,
"isInitialPresent": self.isInitialPresent,
"isPresented": self.isPresented,
"isDismissed": self.state.isDismissed,
"wasCancelledDismiss": self.wasCancelledDismiss,
"wasCancelledPresent": self.wasCancelledPresent,
"wasCancelledDismissViaGesture": self.wasCancelledDismissViaGesture,
]};

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

Expand Down
12 changes: 6 additions & 6 deletions src/components/ModalView/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export class ModalView extends
);

this.setState({
focusState: event.nativeEvent.modalFocusState,
focusState: event.nativeEvent.modalFocusState.state,
});
};

Expand Down Expand Up @@ -528,7 +528,7 @@ export class ModalView extends

this.setState({
isModalInFocus: true,
focusState: event.nativeEvent.modalFocusState,
focusState: event.nativeEvent.modalFocusState.state,
});
};

Expand All @@ -544,7 +544,7 @@ export class ModalView extends
);

this.setState({
focusState: event.nativeEvent.modalFocusState,
focusState: event.nativeEvent.modalFocusState.state,
});
};

Expand Down Expand Up @@ -572,7 +572,7 @@ export class ModalView extends

this.setState({
isModalInFocus: false,
focusState: event.nativeEvent.modalFocusState,
focusState: event.nativeEvent.modalFocusState.state,
});
};

Expand Down Expand Up @@ -887,10 +887,10 @@ class ModalViewHelpers {
modalUUID: event.modalNativeID,
modalID: event.modalID,
reactTag: event.reactTag,
isInFocus: event.isModalInFocus,
isInFocus: event.modalFocusState.isFocused,
modalLevel: event.modalIndex,
modalLevelPrev: event.modalIndexPrev,
isPresented: event.isModalPresented,
isPresented: event.modalPresentationState.isPresented,
};
}

Expand Down
44 changes: 31 additions & 13 deletions src/types/RNIModalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,46 @@ export type ModalPresentationState =
| 'DISMISS_GESTURE_CANCELLING'
| 'DISMISSED';


/** Based on `RNIModalFocusStateMachine.asDictionary` */
export type RNIModalFocusStateMachine = {
state: ModalFocusState;
statePrev: ModalFocusState;
isFocused: boolean;
isBlurred: boolean;
isTransitioning: boolean;
wasBlurCancelled: boolean;
wasFocusCancelled: boolean;
};

/** Based on `RNIModalPresentationStateMachine.asDictionary` */
export type RNIModalPresentationStateMachine = {
state: ModalPresentationState;
statePrev: ModalPresentationState;
isInitialPresent: boolean;
isPresented: boolean;
isDismissed: boolean;
wasCancelledDismiss: boolean;
wasCancelledPresent: boolean;
wasCancelledDismissViaGesture: boolean;
};

/** Based on `RNIModalData` */
export type RNIModalData = {
modalNativeID: string;

modalIndex: number;
modalIndexPrev: number;
currentModalIndex: number;
modalFocusState: ModalFocusState;
modalFocusStatePref: ModalFocusState;
wasBlurCancelled: boolean;
wasFocusCancelled: boolean;
modalPresentationState: ModalPresentationState;
modalPresentationStatePrev: ModalPresentationState;
isInitialPresent: boolean;
wasCancelledPresent: boolean;
wasCancelledDismiss: boolean;
wasCancelledDismissViaGesture: boolean;
isModalPresented: boolean;
isModalInFocus: boolean;

modalFocusState: RNIModalFocusStateMachine;
modalPresentationState: RNIModalPresentationStateMachine;

computedIsModalInFocus: boolean;
computedIsModalPresented: boolean;
computedModalIndex: number;
computedViewControllerIndex: number;
computedCurrentModalIndex: number;

synthesizedWindowID?: string;
};
};

0 comments on commit 9eaefdf

Please sign in to comment.