Skip to content

Commit

Permalink
🆕 Add: Init. Impl. for RNIModalView
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Oct 6, 2023
1 parent 8fce587 commit 7eb0a9e
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
46 changes: 46 additions & 0 deletions ios/RNIModalView/RNIModalView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// RNIModalView.swift
// ReactNativeIosModal
//
// Created by Dominic Go on 10/6/23.
//

import ExpoModulesCore

public class RNIModalView: ExpoView {

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

public override var reactTag: NSNumber! {
didSet {
guard let newValue = self.reactTag,
newValue != oldValue
else { return };

self.onReactTagDidSetEvent.callAsFunction([
"reactTag": newValue
]);
}
};

// MARK: Properties - Prop - Events
// --------------------------------

let onReactTagDidSetEvent = EventDispatcher("onReactTagDidSet");

// MARK: Init + Lifecycle
// ----------------------

public required init(appContext: AppContext? = nil) {
super.init(appContext: appContext);
};

public override func layoutSubviews() {
super.layoutSubviews();
};

public override func insertReactSubview(_ subview: UIView!, at atIndex: Int) {
super.insertReactSubview(subview, at: atIndex);
};
};
18 changes: 18 additions & 0 deletions ios/RNIModalView/RNIModalViewModule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// RNIModalViewModule.swift
// ReactNativeIosModal
//
// Created by Dominic Go on 10/6/23.
//

import ExpoModulesCore

public class RNIModalViewModule: Module {

public func definition() -> ModuleDefinition {
Name("RNIModalViewModule");

View(RNIModalView.self) {
};
};
};
5 changes: 5 additions & 0 deletions src/RNIModalView/RNIModalView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { requireNativeViewManager } from 'expo-modules-core';
import type { RNIModalViewProps } from './RNIModalViewTypes';

export const RNIModalView: React.ComponentType<RNIModalViewProps> =
requireNativeViewManager('RNIModalView');
7 changes: 7 additions & 0 deletions src/RNIModalView/RNIModalViewEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type OnModalViewReactTagDidSetEventPayload = {
reactTag?: number;
};

export type OnModalViewReactTagDidSetEvent = (event: {
nativeEvent: OnModalViewReactTagDidSetEventPayload
}) => void;
11 changes: 11 additions & 0 deletions src/RNIModalView/RNIModalViewModule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { requireNativeModule } from 'expo-modules-core';

interface RNIModalViewModule {
notifyComponentWillUnmount(
reactTag: number,
isManuallyTriggered: boolean
): void;
};

export const RNIModalViewModule: RNIModalViewModule =
requireNativeModule('RNIModalView');
10 changes: 10 additions & 0 deletions src/RNIModalView/RNIModalViewTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ViewProps } from 'react-native';
import type { OnModalViewReactTagDidSetEvent } from './RNIModalViewEvents';

export type RNIModalViewBaseProps = {
shouldCleanupOnComponentWillUnmount: boolean;
onReactTagDidSet: OnModalViewReactTagDidSetEvent;
};

export type RNIModalViewProps =
RNIModalViewBaseProps & ViewProps;
4 changes: 4 additions & 0 deletions src/RNIModalView/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export * from './RNIModalView';
export * from './RNIModalViewTypes';
export * from './RNIModalViewEvents';

0 comments on commit 7eb0a9e

Please sign in to comment.