diff --git a/ios/RNIModalView/RNIModalView.swift b/ios/RNIModalView/RNIModalView.swift new file mode 100644 index 00000000..f74df6ef --- /dev/null +++ b/ios/RNIModalView/RNIModalView.swift @@ -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); + }; +}; diff --git a/ios/RNIModalView/RNIModalViewModule.swift b/ios/RNIModalView/RNIModalViewModule.swift new file mode 100644 index 00000000..a63ccbc5 --- /dev/null +++ b/ios/RNIModalView/RNIModalViewModule.swift @@ -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) { + }; + }; +}; diff --git a/src/RNIModalView/RNIModalView.ts b/src/RNIModalView/RNIModalView.ts new file mode 100644 index 00000000..7418c2d6 --- /dev/null +++ b/src/RNIModalView/RNIModalView.ts @@ -0,0 +1,5 @@ +import { requireNativeViewManager } from 'expo-modules-core'; +import type { RNIModalViewProps } from './RNIModalViewTypes'; + +export const RNIModalView: React.ComponentType = + requireNativeViewManager('RNIModalView'); \ No newline at end of file diff --git a/src/RNIModalView/RNIModalViewEvents.ts b/src/RNIModalView/RNIModalViewEvents.ts new file mode 100644 index 00000000..767d73c6 --- /dev/null +++ b/src/RNIModalView/RNIModalViewEvents.ts @@ -0,0 +1,7 @@ +export type OnModalViewReactTagDidSetEventPayload = { + reactTag?: number; +}; + +export type OnModalViewReactTagDidSetEvent = (event: { + nativeEvent: OnModalViewReactTagDidSetEventPayload +}) => void; \ No newline at end of file diff --git a/src/RNIModalView/RNIModalViewModule.ts b/src/RNIModalView/RNIModalViewModule.ts new file mode 100644 index 00000000..75249cf0 --- /dev/null +++ b/src/RNIModalView/RNIModalViewModule.ts @@ -0,0 +1,11 @@ +import { requireNativeModule } from 'expo-modules-core'; + +interface RNIModalViewModule { + notifyComponentWillUnmount( + reactTag: number, + isManuallyTriggered: boolean + ): void; +}; + +export const RNIModalViewModule: RNIModalViewModule = + requireNativeModule('RNIModalView'); \ No newline at end of file diff --git a/src/RNIModalView/RNIModalViewTypes.ts b/src/RNIModalView/RNIModalViewTypes.ts new file mode 100644 index 00000000..c45d16a3 --- /dev/null +++ b/src/RNIModalView/RNIModalViewTypes.ts @@ -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; \ No newline at end of file diff --git a/src/RNIModalView/index.ts b/src/RNIModalView/index.ts new file mode 100644 index 00000000..bd48932b --- /dev/null +++ b/src/RNIModalView/index.ts @@ -0,0 +1,4 @@ + +export * from './RNIModalView'; +export * from './RNIModalViewTypes'; +export * from './RNIModalViewEvents'; \ No newline at end of file