-
-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate Atmosphere to new arch (#3091)
* feat: migrate Atmosphere to new arch * feat: align with new impl and prepare for reusage
- Loading branch information
Showing
12 changed files
with
186 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
32 changes: 32 additions & 0 deletions
32
...oid/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXAtmosphereManagerDelegate.java
This file contains 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,32 @@ | ||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Do not edit this file as changes may cause incorrect behavior and will be lost | ||
* once the code is regenerated. | ||
* | ||
* @generated by codegen project: GeneratePropsJavaDelegate.js | ||
*/ | ||
|
||
package com.facebook.react.viewmanagers; | ||
|
||
import android.view.View; | ||
import androidx.annotation.Nullable; | ||
import com.facebook.react.bridge.DynamicFromObject; | ||
import com.facebook.react.uimanager.BaseViewManagerDelegate; | ||
import com.facebook.react.uimanager.BaseViewManagerInterface; | ||
|
||
public class RNMBXAtmosphereManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXAtmosphereManagerInterface<T>> extends BaseViewManagerDelegate<T, U> { | ||
public RNMBXAtmosphereManagerDelegate(U viewManager) { | ||
super(viewManager); | ||
} | ||
@Override | ||
public void setProperty(T view, String propName, @Nullable Object value) { | ||
switch (propName) { | ||
case "reactStyle": | ||
mViewManager.setReactStyle(view, new DynamicFromObject(value)); | ||
break; | ||
default: | ||
super.setProperty(view, propName, value); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...id/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXAtmosphereManagerInterface.java
This file contains 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,17 @@ | ||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Do not edit this file as changes may cause incorrect behavior and will be lost | ||
* once the code is regenerated. | ||
* | ||
* @generated by codegen project: GeneratePropsJavaInterface.js | ||
*/ | ||
|
||
package com.facebook.react.viewmanagers; | ||
|
||
import android.view.View; | ||
import com.facebook.react.bridge.Dynamic; | ||
|
||
public interface RNMBXAtmosphereManagerInterface<T extends View> { | ||
void setReactStyle(T view, Dynamic value); | ||
} |
This file contains 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 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 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,15 @@ | ||
#ifdef RCT_NEW_ARCH_ENABLED | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import <React/RCTUIManager.h> | ||
#import <React/RCTViewComponentView.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RNMBXAtmosphereComponentView : RCTViewComponentView | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif // RCT_NEW_ARCH_ENABLED |
This file contains 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,82 @@ | ||
#ifdef RCT_NEW_ARCH_ENABLED | ||
|
||
#import "RNMBXAtmosphereComponentView.h" | ||
#import "RNMBXFabricHelpers.h" | ||
|
||
#import <React/RCTConversions.h> | ||
#import <React/RCTFabricComponentsPlugins.h> | ||
|
||
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h> | ||
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h> | ||
#import <react/renderer/components/rnmapbox_maps_specs/Props.h> | ||
#import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h> | ||
// needed for compilation for some reason | ||
#import <CoreFoundation/CoreFoundation.h> | ||
#import <CoreLocation/CoreLocation.h> | ||
|
||
@interface MapView : UIView | ||
@end | ||
|
||
#import <rnmapbox_maps-Swift.h> | ||
|
||
using namespace facebook::react; | ||
|
||
@interface RNMBXAtmosphereComponentView () <RCTRNMBXAtmosphereViewProtocol> | ||
@end | ||
|
||
@implementation RNMBXAtmosphereComponentView { | ||
RNMBXAtmosphere *_view; | ||
} | ||
|
||
- (instancetype)initWithFrame:(CGRect)frame | ||
{ | ||
if (self = [super initWithFrame:frame]) { | ||
static const auto defaultProps = std::make_shared<const RNMBXAtmosphereProps>(); | ||
_props = defaultProps; | ||
[self prepareView]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)prepareView | ||
{ | ||
_view = [[RNMBXAtmosphere alloc] init]; | ||
|
||
self.contentView = _view; | ||
} | ||
|
||
#pragma mark - RCTComponentViewProtocol | ||
|
||
+ (ComponentDescriptorProvider)componentDescriptorProvider | ||
{ | ||
return concreteComponentDescriptorProvider<RNMBXAtmosphereComponentDescriptor>(); | ||
} | ||
|
||
|
||
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps | ||
{ | ||
const auto &newProps = *std::static_pointer_cast<const RNMBXAtmosphereProps>(props); | ||
id reactStyle = RNMBXConvertFollyDynamicToId(newProps.reactStyle); | ||
if (reactStyle != nil) { | ||
_view.reactStyle = reactStyle; | ||
} | ||
|
||
[super updateProps:props oldProps:oldProps]; | ||
} | ||
|
||
- (void)prepareForRecycle | ||
{ | ||
[super prepareForRecycle]; | ||
[self prepareView]; | ||
} | ||
|
||
|
||
@end | ||
|
||
Class<RCTComponentViewProtocol> RNMBXAtmosphereCls(void) | ||
{ | ||
return RNMBXAtmosphereComponentView.class; | ||
} | ||
|
||
#endif // RCT_NEW_ARCH_ENABLED |
2 changes: 1 addition & 1 deletion
2
ios/RNMBX/RNMBXAtmosphereManager.m → ios/RNMBX/RNMBXAtmosphereViewManager.m
This file contains 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
4 changes: 2 additions & 2 deletions
4
ios/RNMBX/RNMBXAtmosphereManager.swift → ios/RNMBX/RNMBXAtmosphereViewManager.swift
This file contains 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 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 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 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,12 @@ | ||
import type { HostComponent, ViewProps } from 'react-native'; | ||
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; | ||
|
||
import type { UnsafeMixed } from './codegenUtils'; | ||
|
||
export interface NativeProps extends ViewProps { | ||
reactStyle: UnsafeMixed<any>; | ||
} | ||
|
||
export default codegenNativeComponent<NativeProps>( | ||
'RNMBXAtmosphere', | ||
) as HostComponent<NativeProps>; |