Skip to content

Commit

Permalink
fix(native): Update legacy codegen setup (#828)
Browse files Browse the repository at this point in the history
* Update legacy codegen setup

* Change macos version

* Update iOS imports
  • Loading branch information
MrRefactor authored Jun 19, 2024
1 parent f1eb152 commit bccd97d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:

jobs:
android-build:
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include <react/renderer/components/RNCViewPager/EventEmitters.h>
#include <react/renderer/components/RNCViewPager/Props.h>
//These imports come from the common/cpp directory
#include <react/renderer/components/pagerview/EventEmitters.h>
#include <react/renderer/components/pagerview/Props.h>
//This import comes from the codegen directory
#include <react/renderer/components/RNCViewPager/RNCViewPagerState.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/core/LayoutContext.h>
Expand Down
6 changes: 3 additions & 3 deletions ios/Fabric/RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#import <Foundation/Foundation.h>
#import "RNCPagerViewComponentView.h"
#import <RNCViewPager/RNCViewPagerComponentDescriptor.h>
#import <react/renderer/components/RNCViewPager/EventEmitters.h>
#import <react/renderer/components/RNCViewPager/Props.h>
#import <react/renderer/components/RNCViewPager/RCTComponentViewHelpers.h>
#import <react/renderer/components/pagerview/EventEmitters.h>
#import <react/renderer/components/pagerview/Props.h>
#import <react/renderer/components/pagerview/RCTComponentViewHelpers.h>

#import "RCTFabricComponentsPlugins.h"
#import "React/RCTConversions.h"
Expand Down
10 changes: 5 additions & 5 deletions ios/LEGACY/Fabric/LEGACY_RNCPagerViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#import <Foundation/Foundation.h>
#import "LEGACY_RNCPagerViewComponentView.h"
#import <react/renderer/components/LEGACY_RNCViewPager/ComponentDescriptors.h>
#import <react/renderer/components/LEGACY_RNCViewPager/EventEmitters.h>
#import <react/renderer/components/LEGACY_RNCViewPager/Props.h>
#import <react/renderer/components/LEGACY_RNCViewPager/RCTComponentViewHelpers.h>
#import <react/renderer/components/pagerview/ComponentDescriptors.h>
#import <react/renderer/components/pagerview/EventEmitters.h>
#import <react/renderer/components/pagerview/Props.h>
#import <react/renderer/components/pagerview/RCTComponentViewHelpers.h>

#import "RCTFabricComponentsPlugins.h"
#import "React/RCTConversions.h"
Expand Down Expand Up @@ -438,4 +438,4 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecogni
return LEGACY_RNCPagerViewComponentView.class;
}

#endif
#endif
18 changes: 6 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,12 @@
"useTabs": false
},
"codegenConfig": {
"libraries": [
{
"name": "RNCViewPager",
"type": "components",
"jsSrcsDir": "src/PagerViewNativeComponent"
},
{
"name": "LEGACY_RNCViewPager",
"type": "components",
"jsSrcsDir": "src/LEGACY_PagerViewNativeComponent"
}
]
"name": "pagerview",
"type": "all",
"jsSrcsDir": "./src/specs",
"android": {
"javaPackageName": "com.reactnativepagerview"
}
},
"react-native-builder-bob": {
"source": "src",
Expand Down
4 changes: 2 additions & 2 deletions src/PagerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import PagerViewNativeComponent, {
OnPageScrollStateChangedEventData,
OnPageSelectedEventData,
NativeProps,
} from './PagerViewNativeComponent/PagerViewNativeComponent';
} from './specs/PagerViewNativeComponent';

import LEGACY_PagerViewNativeComponent, {
Commands as LEGACY_PagerViewNativeCommands,
} from './LEGACY_PagerViewNativeComponent/LEGACY_PagerViewNativeComponent';
} from './specs/LEGACY_PagerViewNativeComponent';

// The Fabric component for PagerView uses a work around present also in ScrollView:
// https://github.com/callstack/react-native-pager-view/blob/master/ios/Fabric/RNCPagerViewComponentView.mm#L362-L368
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
OnPageSelectedEventData as PagerViewOnPageSelectedEventData,
OnPageScrollStateChangedEventData as PageScrollStateChangedNativeEventData,
NativeProps,
} from './PagerViewNativeComponent/PagerViewNativeComponent';
} from './specs/PagerViewNativeComponent';

export type {
PagerViewOnPageScrollEventData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Note: The types below are duplicated between this file and `src/PagerViewNativeComponent/PagerViewNativeComponent.ts`.
Note: The types below are duplicated between this file and `src/specs/PagerViewNativeComponent.ts`.
This is on purpose. Firstly, we're declaring two native modules with two different iOS implementation flavors, but the same API.
Secondly, as these files serve as a reference point for React Native's new architecture Codegen process (which takes care of the
Expand Down
File renamed without changes.

0 comments on commit bccd97d

Please sign in to comment.