-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add Reanimated native view #7366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5952bc4
Create iOS view
piaskowyk 6eaaa8f
Create Android view
piaskowyk 20179f2
Rename
piaskowyk ec89ec9
Remove unused import
piaskowyk f45eab2
Remove unused import
piaskowyk f0ab05e
Fix compatibility with next.js
piaskowyk 7f311b2
Run formatter
piaskowyk 2d7a076
Update header
piaskowyk d8be69f
Update formatter again
piaskowyk 1018056
Add use strict
piaskowyk 911bf80
Fix jest
piaskowyk 4bb9da4
Probably fix CI?
piaskowyk 36118f6
Probably fix CI again?
piaskowyk efc07e4
I hope that Jest will work
piaskowyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...native-reanimated/android/src/main/java/com/swmansion/reanimated/view/ReanimatedView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) {} | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
...reanimated/android/src/main/java/com/swmansion/reanimated/view/ReanimatedViewManager.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
packages/react-native-reanimated/apple/reanimated/apple/view/ReanimatedView.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
25 changes: 25 additions & 0 deletions
25
packages/react-native-reanimated/apple/reanimated/apple/view/ReanimatedView.mm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/react-native-reanimated/src/specs/ReanimatedNativeComponent.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
piaskowyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| export default codegenNativeComponent<NativeProps>('ReanimatedView'); | ||
16 changes: 16 additions & 0 deletions
16
packages/react-native-reanimated/src/specs/ReanimatedViewProvider.native.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>; | ||
piaskowyk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| ReanimatedNativeView = require('./ReanimatedNativeComponent').default; | ||
| } | ||
|
|
||
| // ts-prune-ignore-next-line | ||
| export default ReanimatedNativeView; | ||
5 changes: 5 additions & 0 deletions
5
packages/react-native-reanimated/src/specs/ReanimatedViewProvider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>; | ||
piaskowyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.