Skip to content

Commit

Permalink
💄 Gloss: Re-Organize/Regroup Props
Browse files Browse the repository at this point in the history
Related:
* `TODO:2023-04-21-23-27-27` - Gloss: Re-Organize/Re-group props based on their relationship, not their type.
  • Loading branch information
dominicstop committed Apr 21, 2023
1 parent 5b0f8af commit b22656c
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 71 deletions.
42 changes: 25 additions & 17 deletions ios/src_library/React Native/RNIModalView/RNIModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,15 @@ public class RNIModalView:
@objc var onPresentationControllerWillDismiss: RCTBubblingEventBlock?;
@objc var onPresentationControllerDidDismiss: RCTBubblingEventBlock?;
@objc var onPresentationControllerDidAttemptToDismiss: RCTBubblingEventBlock?;

// MARK: - Properties: React Props - Value
// ---------------------------------------

// MARK: - Properties: React Props - General
// -----------------------------------------

/// user-provided identifier for this modal
@objc var modalID: NSString? = nil;

// MARK: - Properties: React Props - BG-Related
// --------------------------------------------

@objc var isModalBGBlurred: Bool = true {
didSet {
Expand All @@ -114,23 +120,13 @@ public class RNIModalView:
}
};

// MARK: - Properties: React Props - Presentation/Transition
// ---------------------------------------------------------

@objc var modalPresentationStyle: NSString = "";

@objc var modalTransitionStyle: NSString = "";

/// user-provided identifier for this modal
@objc var modalID: NSString? = nil;

/// disable swipe gesture recognizer for this modal
@objc var enableSwipeGesture: Bool = true {
didSet {
let newValue = self.enableSwipeGesture;
guard newValue != oldValue else { return };

self.enableSwipeGesture(newValue);
}
};

@objc var hideNonVisibleModals: Bool = false;

/// control modal present/dismiss by mounting/un-mounting the react subview
Expand All @@ -142,6 +138,16 @@ public class RNIModalView:
///
@objc var presentViaMount: Bool = false;

/// disable swipe gesture recognizer for this modal
@objc var enableSwipeGesture: Bool = true {
didSet {
let newValue = self.enableSwipeGesture;
guard newValue != oldValue else { return };

self.enableSwipeGesture(newValue);
}
};

/// allow modal to be programmatically closed even when not current focused
/// * `true`: the modal can be dismissed even when it's not the topmost
/// presented modal.
Expand All @@ -160,7 +166,9 @@ public class RNIModalView:
vc.isModalInPresentation = newValue
}
};


// MARK: - Properties: React Props - Sheet-Related
// -----------------------------------------------

@objc var modalSheetDetents: NSArray?;

Expand Down
32 changes: 21 additions & 11 deletions ios/src_library/React Native/RNIModalView/RNIModalViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,32 @@ @interface RCT_EXTERN_MODULE(RNIModalViewManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(onPresentationControllerDidDismiss, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPresentationControllerDidAttemptToDismiss, RCTBubblingEventBlock);

// MARK: - Value Props - General
// -----------------------------

// MARK: - Props - RN Component Props
// ----------------------------------
RCT_EXPORT_VIEW_PROPERTY(modalID, NSString);

RCT_EXPORT_VIEW_PROPERTY(presentViaMount , BOOL);
RCT_EXPORT_VIEW_PROPERTY(isModalBGBlurred , BOOL);
RCT_EXPORT_VIEW_PROPERTY(enableSwipeGesture , BOOL);
RCT_EXPORT_VIEW_PROPERTY(hideNonVisibleModals , BOOL);
RCT_EXPORT_VIEW_PROPERTY(isModalBGTransparent , BOOL);
RCT_EXPORT_VIEW_PROPERTY(isModalInPresentation , BOOL);
RCT_EXPORT_VIEW_PROPERTY(allowModalForceDismiss, BOOL);
// MARK: - Value Props - BG-Related
// --------------------------------

RCT_EXPORT_VIEW_PROPERTY(modalID , NSString);
RCT_EXPORT_VIEW_PROPERTY(modalTransitionStyle , NSString);
RCT_EXPORT_VIEW_PROPERTY(isModalBGBlurred, BOOL);
RCT_EXPORT_VIEW_PROPERTY(isModalBGTransparent, BOOL);
RCT_EXPORT_VIEW_PROPERTY(modalBGBlurEffectStyle, NSString);

// MARK: - Value Props - Presentation/Transition
// ---------------------------------------------

RCT_EXPORT_VIEW_PROPERTY(modalPresentationStyle, NSString);
RCT_EXPORT_VIEW_PROPERTY(modalTransitionStyle, NSString);

RCT_EXPORT_VIEW_PROPERTY(hideNonVisibleModals, BOOL);
RCT_EXPORT_VIEW_PROPERTY(presentViaMount, BOOL);
RCT_EXPORT_VIEW_PROPERTY(enableSwipeGesture, BOOL);
RCT_EXPORT_VIEW_PROPERTY(allowModalForceDismiss, BOOL);
RCT_EXPORT_VIEW_PROPERTY(isModalInPresentation, BOOL);

// MARK: - Value Props - Sheet-Related
// -----------------------------------

RCT_EXPORT_VIEW_PROPERTY(modalSheetDetents, NSArray);

Expand Down
30 changes: 16 additions & 14 deletions src/components/ModalView/ModalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,28 @@ export class ModalView extends

private getProps = (propOverride: ModalViewProps | null = null) => {
const {
// native props - flags
presentViaMount,
isModalBGBlurred,
enableSwipeGesture,
hideNonVisibleModals,
isModalBGTransparent,
isModalInPresentation,
allowModalForceDismiss,
// Native Props - General
modalID,
shouldEnableAggressiveCleanup,

// native props - string
modalID,
modalTransitionStyle,
// Native Props - BG-Related
isModalBGBlurred,
isModalBGTransparent,
modalBGBlurEffectStyle,

// Native Props - Presentation/Transition
modalPresentationStyle,
modalTransitionStyle,
hideNonVisibleModals,
presentViaMount,
enableSwipeGesture,
allowModalForceDismiss,
isModalInPresentation,

// native props - objects/arrays
// Native Props - Sheet-Related
modalSheetDetents,

// native props - events
// Native Props - Events
onModalWillPresent,
onModalDidPresent,
onModalWillDismiss,
Expand All @@ -125,7 +127,7 @@ export class ModalView extends
onPresentationControllerDidDismiss,
onPresentationControllerDidAttemptToDismiss,

// component props
// Component Props
autoCloseOnUnmount,
setEnableSwipeGestureFromProps,
setModalInPresentationFromProps,
Expand Down
24 changes: 13 additions & 11 deletions src/components/ModalView/ModalViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,24 @@ import type {
export type ModalViewBaseProps = Partial<
Pick<
RNIModalViewProps,
// props - flags
| 'presentViaMount'
// Props - General
| 'modalID'

// Props - BG-Related
| 'isModalBGBlurred'
| 'enableSwipeGesture'
| 'hideNonVisibleModals'
| 'isModalBGTransparent'
| 'isModalInPresentation'
| 'allowModalForceDismiss'

// props - string
| 'modalID'
| 'modalTransitionStyle'
| 'modalBGBlurEffectStyle'

// Props - Presentation/Transition
| 'modalPresentationStyle'
| 'modalTransitionStyle'
| 'hideNonVisibleModals'
| 'presentViaMount'
| 'enableSwipeGesture'
| 'allowModalForceDismiss'
| 'isModalInPresentation'

// props - object/arrays
// Props - Sheet-Related
| 'modalSheetDetents'

// props - events
Expand Down
36 changes: 18 additions & 18 deletions src/native_components/RNIModalView/RNIModalViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,32 @@ import type {
} from './RNIModalViewEvents';

export type RNIModalViewBaseProps = {
// Props - Flags
// --------------
// Props - General
// ---------------

modalID?: string;

// Props - BG-Related
// ------------------

presentViaMount?: boolean;
isModalBGBlurred?: boolean;
enableSwipeGesture?: boolean;
hideNonVisibleModals?: boolean;
isModalBGTransparent?: boolean;
isModalInPresentation?: boolean;
allowModalForceDismiss?: boolean;
modalBGBlurEffectStyle?: TUIBlurEffectStyles;

// Props - Strings
// --------------
// Props - Presentation/Transition
// -------------------------------

modalID?: string;
modalTransitionStyle?: TUIModalTransitionStyle;
modalBGBlurEffectStyle?: TUIBlurEffectStyles;
modalPresentationStyle?: TUIModalPresentationStyle;

// Props - Objects/Arrays
// ----------------------
hideNonVisibleModals?: boolean;
presentViaMount?: boolean;
enableSwipeGesture?: boolean;
allowModalForceDismiss?: boolean;
isModalInPresentation?: boolean;

// Props - Sheet-Related
// ---------------------

modalSheetDetents?: Array<
TUISheetPresentationControllerDetents | RNIModalCustomSheetDetent
Expand All @@ -58,11 +63,6 @@ export type RNIModalViewBaseProps = {
// Props - Events
// --------------

// TODO: TODO:2023-03-04-13-15-11 - Refactor: Use Will/Did
// Prefix for RNIModalView Events
//
// * Rename - Add `will/did` prefix and deprecate prev. props
//
onModalWillPresent: OnModalWillPresentEvent;
onModalDidPresent: OnModalDidPresentEvent;

Expand Down

0 comments on commit b22656c

Please sign in to comment.