Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.uimanager.ViewManager;
import com.swmansion.reanimated.view.ReanimatedViewManager;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

Expand All @@ -29,6 +32,11 @@ public NativeModule getModule(
};
}

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return List.of(new ReanimatedViewManager());
}

@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
Class<? extends NativeModule>[] moduleList =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.swmansion.reanimated.view;

import android.content.Context;
import android.view.ViewGroup;

public class ReanimatedView extends ViewGroup {
public ReanimatedView(Context context) {
super(context);
}

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.swmansion.reanimated.view;

import androidx.annotation.NonNull;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;

public class ReanimatedViewManager extends ViewGroupManager<ReanimatedView> {
@NonNull
@Override
public String getName() {
return "ReanimatedView";
}

@NonNull
@Override
protected ReanimatedView createViewInstance(@NonNull ThemedReactContext themedReactContext) {
return new ReanimatedView(themedReactContext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#import <React/RCTViewComponentView.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface ReanimatedView : RCTViewComponentView
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#import <reanimated/apple/view/ReanimatedView.h>

#import <react/renderer/components/rnreanimated/ComponentDescriptors.h>
#import <react/renderer/components/rnreanimated/EventEmitters.h>
#import <react/renderer/components/rnreanimated/Props.h>
#import <react/renderer/components/rnreanimated/RCTComponentViewHelpers.h>

using namespace facebook::react;

@implementation ReanimatedView

+ (ComponentDescriptorProvider)componentDescriptorProvider
{
return concreteComponentDescriptorProvider<ReanimatedViewComponentDescriptor>();
}

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
{
// const auto &oldViewProps = *std::static_pointer_cast<ReanimatedViewProps const>(_props);
// const auto &newViewProps = *std::static_pointer_cast<ReanimatedViewProps const>(props);

[super updateProps:props oldProps:oldProps];
}

@end
7 changes: 6 additions & 1 deletion packages/react-native-reanimated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,15 @@
},
"codegenConfig": {
"name": "rnreanimated",
"type": "modules",
"type": "all",
"jsSrcsDir": "./src/specs",
"android": {
"javaPackageName": "com.swmansion.reanimated"
},
"ios": {
"componentProvider": {
"ReanimatedView": "ReanimatedView"
}
}
},
"sideEffects": [
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-reanimated/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export {
ScreenTransition,
startScreenTransition,
} from './screenTransition';
export { ReanimatedNativeView } from './specs';
export type { WorkletRuntime } from 'react-native-worklets';
export {
isWorkletFunction,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';
import type { ViewProps } from 'react-native';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';

interface NativeProps extends ViewProps {}

// ts-prune-ignore-next-line
export default codegenNativeComponent<NativeProps>('ReanimatedView');
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

import type { HostComponent } from 'react-native';

import { shouldBeUseWeb } from '../PlatformChecker';

let ReanimatedNativeView: HostComponent<any>;
if (shouldBeUseWeb()) {
// this is a workaround for the jest
ReanimatedNativeView = {} as HostComponent<any>;
} else {
ReanimatedNativeView = require('./ReanimatedNativeComponent').default;
}

// ts-prune-ignore-next-line
export default ReanimatedNativeView;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

import type { HostComponent } from 'react-native';

export default {} as HostComponent<any>;
3 changes: 2 additions & 1 deletion packages/react-native-reanimated/src/specs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

import ReanimatedTurboModule from './NativeReanimatedModule';
import WorkletsTurboModule from './NativeReaWorkletsModule';
import ReanimatedNativeView from './ReanimatedViewProvider';

export { ReanimatedTurboModule, WorkletsTurboModule };
export { ReanimatedNativeView, ReanimatedTurboModule, WorkletsTurboModule };
Loading