Skip to content

Commit

Permalink
⭐️ Impl: RNIModalView Scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Jun 7, 2024
1 parent 404b930 commit 9e427a1
Show file tree
Hide file tree
Showing 14 changed files with 273 additions and 115 deletions.
17 changes: 0 additions & 17 deletions ios/IosModalView.h

This file was deleted.

71 changes: 0 additions & 71 deletions ios/IosModalView.mm

This file was deleted.

19 changes: 0 additions & 19 deletions ios/IosModalViewManager.mm

This file was deleted.

27 changes: 27 additions & 0 deletions ios/RNIModalView/RNIModalView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// RNIModalView.h
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

#import <react-native-ios-utilities/RNIBaseView.h>

#if RCT_NEW_ARCH_ENABLED
#import <React/RCTViewComponentView.h>
#else
#import <React/RCTView.h>
#endif

@protocol RNIContentViewParentDelegate;
@protocol RNIContentViewDelegate;

@class RCTBridge;

#if RCT_NEW_ARCH_ENABLED
namespace react = facebook::react;
#endif

@interface RNIModalView : RNIBaseView

@end
103 changes: 103 additions & 0 deletions ios/RNIModalView/RNIModalView.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// RNIModalView.mm
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

#import "RNIModalView.h"

#import "react-native-ios-modal/Swift.h"
#import <react-native-ios-utilities/RNIBaseView.h>
#import <react-native-ios-utilities/RNIContentViewParentDelegate.h>

#import <react-native-ios-utilities/UIApplication+RNIHelpers.h>
#import <react-native-ios-utilities/RNIObjcUtils.h>

#if RCT_NEW_ARCH_ENABLED
#include "RNIModalViewComponentDescriptor.h"

#include <react-native-ios-utilities/RNIBaseViewState.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>

#import <React/RCTConversions.h>
#import <React/RCTFabricComponentsPlugins.h>
#import <React/RCTRootComponentView.h>
#import <React/RCTSurfaceTouchHandler.h>

#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/graphics/Float.h>
#include <react/renderer/core/graphicsConversions.h>

#import <react/renderer/components/RNIModalSpec/EventEmitters.h>
#import <react/renderer/components/RNIModalSpec/RCTComponentViewHelpers.h>
#else
#import <React/RCTTouchHandler.h>
#import <React/RCTInvalidating.h>
#endif

#ifdef RCT_NEW_ARCH_ENABLED
using namespace facebook::react;
#endif


@interface RNIModalView () <
RNIContentViewParentDelegate,
#ifdef RCT_NEW_ARCH_ENABLED
RCTRNIModalViewViewProtocol
#else
RCTInvalidating
#endif
> {
// TBA
}
@end

@implementation RNIModalView {
}

// MARK: - Init
// ------------

- (void)initCommon {
[super initCommon];
}

// MARK: - RNIBaseView
// -------------------

+ (Class)viewDelegateClass
{
return nil;
//return [RNIDummyTestViewDelegate class];
}

// MARK: - Fabric
// --------------

#if RCT_NEW_ARCH_ENABLED
+ (ComponentDescriptorProvider)componentDescriptorProvider
{
return concreteComponentDescriptorProvider<RNIModalViewComponentDescriptor>();
}

Class<RCTComponentViewProtocol> RNIModalViewCls(void)
{
return RNIModalView.class;
}
#else

// MARK: - Paper
// -------------

- (void)invalidate
{
// to be impl.
}

#endif
@end



28 changes: 28 additions & 0 deletions ios/RNIModalView/RNIModalViewComponentDescriptor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// RNIModalViewComponentDescriptor.h
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

#if __cplusplus
#pragma once

#include "RNIModalViewShadowNode.h"
#include "RNIBaseViewComponentDescriptor.h"

#include <react-native-ios-utilities/RNIBaseViewState.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>


namespace facebook::react {

class RNIModalViewComponentDescriptor final
: public RNIBaseViewComponentDescriptor<RNIModalViewShadowNode> {

public:
using RNIBaseViewComponentDescriptor::RNIBaseViewComponentDescriptor;
};

} // namespace facebook::react
#endif
9 changes: 9 additions & 0 deletions ios/RNIModalView/RNIModalViewDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// RNIModalViewDelegate.swift
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

import react_native_ios_utilities

8 changes: 8 additions & 0 deletions ios/RNIModalView/RNIModalViewManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// RNIModalViewManager.m
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

#import <Foundation/Foundation.h>
45 changes: 45 additions & 0 deletions ios/RNIModalView/RNIModalViewShadowNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// RNIModalViewShadowNode.h
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

#if __cplusplus
#pragma once

#include <react-native-ios-utilities/RNIBaseViewShadowNode.h>
#include <react-native-ios-utilities/RNIBaseViewProps.h>
#include <react-native-ios-utilities/RNIBaseViewEventEmitter.h>

#include <react/renderer/components/RNIModalSpec/EventEmitters.h>
#include <react/renderer/components/RNIModalSpec/Props.h>

#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <jsi/jsi.h>


namespace facebook::react {

JSI_EXPORT extern const char RNIModalViewComponentName[] = "RNIModalView";

class JSI_EXPORT RNIModalViewShadowNode final : public RNIBaseViewShadowNode<
RNIModalViewComponentName,
RNIBaseViewProps,
RNIBaseViewEventEmitter
> {

public:
using RNIBaseViewShadowNode::RNIBaseViewShadowNode;

static RNIBaseViewState initialStateData(
const Props::Shared&r , // props
const ShadowNodeFamily::Shared&, // family
const ComponentDescriptor& // componentDescriptor
) {
return {};
}
};

} // facebook::react
#endif
28 changes: 28 additions & 0 deletions ios/Swift.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Swift.h
// react-native-ios-modal
//
// Created by Dominic Go on 6/6/24.
//

// When `use_frameworks!` is used, the generated Swift header is inside
// the module.
// Otherwise, it's available only locally with double-quoted imports.
#if __has_include(<react_native_ios_modal/react_native_ios_modal-Swift.h>)
#import "<react_native_ios_modal/react_native_ios_modal-Swift.h>"
#else
#import "react_native_ios_modal-Swift.h"
#endif


// #import <react-native-ios-utilities/react-native-ios-utilities-Swift.h>
// #import "<react_native_ios_utilities/react_native_ios_utilities-Swift.h>"
// #import <react-native-ios-utilities/react_native_ios_utilities-Swift.h>
// #import <react-native-ios-utilities/react-native-ios-utilities-Swift.h>
// #import <react-native-ios-utilities/react_native_ios_utilities/react_native_ios_utilities-Swift.h>


//#import "react_native_ios_utilities-Swift.h"
// #import "react_native_ios_utilities/react_native_ios_utilities-Swift.h"
//#import <react_native_ios_utilities/react-native-ios-utilities-umbrella.h>
//#import <react_native_ios_utilities-Swift.h>
8 changes: 0 additions & 8 deletions src/IosModalViewNativeComponent.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/native_components/RNIModalView/RNIModalNativeView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { HostComponent, ViewProps } from 'react-native';

import { default as RNIModalViewNativeComponent } from './RNIModalViewNativeComponent';
import type { SharedViewEvents } from 'react-native-ios-utilities';

export interface RNIModalNativeViewBaseProps extends ViewProps {
};

export type RNIModalNativeViewProps =
SharedViewEvents
& RNIModalNativeViewBaseProps;

export const RNIModalNativeView =
RNIModalViewNativeComponent as unknown as HostComponent<RNIModalNativeViewProps>;
10 changes: 10 additions & 0 deletions src/native_components/RNIModalView/RNIModalViewNativeComponent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
import type { HostComponent, ViewProps } from 'react-native';

interface NativeProps extends ViewProps {
}

export default codegenNativeComponent<NativeProps>('RNIModalView', {
excludedPlatforms: ['android'],
interfaceOnly: true,
}) as HostComponent<NativeProps>;
Loading

0 comments on commit 9e427a1

Please sign in to comment.