Skip to content

Commit e6465d6

Browse files
authored
feat(ios): add legacy code & change codegen name (#604)
1 parent 5734432 commit e6465d6

18 files changed

+911
-35
lines changed

ios/PagerViewView.mm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#ifdef RCT_NEW_ARCH_ENABLED
22
#import "PagerViewView.h"
33

4-
#import <react/renderer/components/PagerViewView/ComponentDescriptors.h>
5-
#import <react/renderer/components/PagerViewView/EventEmitters.h>
6-
#import <react/renderer/components/PagerViewView/Props.h>
7-
#import <react/renderer/components/PagerViewView/RCTComponentViewHelpers.h>
4+
#import <react/renderer/components/RNCViewPager/ComponentDescriptors.h>
5+
#import <react/renderer/components/RNCViewPager/EventEmitters.h>
6+
#import <react/renderer/components/RNCViewPager/Props.h>
7+
#import <react/renderer/components/RNCViewPager/RCTComponentViewHelpers.h>
88

99
#import "RCTFabricComponentsPlugins.h"
1010

1111
using namespace facebook::react;
1212

13-
@interface PagerViewView () <RCTPagerViewViewViewProtocol>
13+
@interface PagerViewView () <RCTRNCViewPagerViewProtocol>
1414

1515
@end
1616

@@ -20,13 +20,13 @@ @implementation PagerViewView {
2020

2121
+ (ComponentDescriptorProvider)componentDescriptorProvider
2222
{
23-
return concreteComponentDescriptorProvider<PagerViewViewComponentDescriptor>();
23+
return concreteComponentDescriptorProvider<RNCViewPagerComponentDescriptor>();
2424
}
2525

2626
- (instancetype)initWithFrame:(CGRect)frame
2727
{
2828
if (self = [super initWithFrame:frame]) {
29-
static const auto defaultProps = std::make_shared<const PagerViewViewProps>();
29+
static const auto defaultProps = std::make_shared<const RNCViewPagerProps>();
3030
_props = defaultProps;
3131

3232
_view = [[UIView alloc] init];
@@ -39,20 +39,20 @@ - (instancetype)initWithFrame:(CGRect)frame
3939

4040
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
4141
{
42-
const auto &oldViewProps = *std::static_pointer_cast<PagerViewViewProps const>(_props);
43-
const auto &newViewProps = *std::static_pointer_cast<PagerViewViewProps const>(props);
42+
const auto &oldViewProps = *std::static_pointer_cast<RNCViewPagerProps const>(_props);
43+
const auto &newViewProps = *std::static_pointer_cast<RNCViewPagerProps const>(props);
4444

4545
[super updateProps:props oldProps:oldProps];
4646
}
4747

48-
Class<RCTComponentViewProtocol> PagerViewViewCls(void)
48+
Class<RCTComponentViewProtocol> RNCViewPagerCls(void)
4949
{
5050
return PagerViewView.class;
5151
}
5252

5353
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
5454
{
55-
RCTPagerViewViewHandleCommand(self, commandName, args);
55+
RCTRNCViewPagerHandleCommand(self, commandName, args);
5656
}
5757

5858
- (void)setPage:(NSInteger)selectedPage {

ios/PagerViewViewManager.mm

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
#import <React/RCTConvert.h>
3+
#import <UIKit/UIKit.h>
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
@interface RCTConvert (UIPageViewControllerNavigationOrientation)
7+
8+
@end
9+
10+
11+
NS_ASSUME_NONNULL_END
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
#import "RCTConvert+UIPageViewControllerNavigationOrientation.h"
3+
4+
@implementation RCTConvert (UIPageViewControllerNavigationOrientation)
5+
6+
RCT_ENUM_CONVERTER(UIPageViewControllerNavigationOrientation, (@{
7+
@"horizontal": @(UIPageViewControllerNavigationOrientationHorizontal),
8+
@"vertical": @(UIPageViewControllerNavigationOrientationVertical),
9+
}), UIPageViewControllerNavigationOrientationHorizontal, integerValue)
10+
11+
@end

ios/RCTOnPageScrollEvent.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <Foundation/Foundation.h>
2+
#import <React/RCTViewManager.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
@interface RCTOnPageScrollEvent : NSObject <RCTEvent>
7+
8+
- (instancetype) initWithReactTag:(NSNumber *)reactTag
9+
position:(NSNumber *)position
10+
offset:(NSNumber *)offset;
11+
12+
@end
13+
14+
NS_ASSUME_NONNULL_END

ios/RCTOnPageScrollEvent.m

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#import <React/UIView+React.h>
2+
#import "RCTOnPageScrollEvent.h"
3+
4+
@implementation RCTOnPageScrollEvent
5+
{
6+
NSNumber* _position;
7+
NSNumber* _offset;
8+
}
9+
10+
@synthesize viewTag = _viewTag;
11+
12+
- (NSString *)eventName {
13+
return @"onPageScroll";
14+
}
15+
16+
- (instancetype) initWithReactTag:(NSNumber *)reactTag
17+
position:(NSNumber *)position
18+
offset:(NSNumber *)offset;
19+
{
20+
RCTAssertParam(reactTag);
21+
22+
if ((self = [super init])) {
23+
_viewTag = reactTag;
24+
_position = position;
25+
_offset = offset;
26+
}
27+
return self;
28+
}
29+
30+
RCT_NOT_IMPLEMENTED(- (instancetype)init)
31+
- (uint16_t)coalescingKey
32+
{
33+
return 0;
34+
}
35+
36+
37+
- (BOOL)canCoalesce
38+
{
39+
return YES;
40+
}
41+
42+
+ (NSString *)moduleDotMethod
43+
{
44+
return @"RCTEventEmitter.receiveEvent";
45+
}
46+
47+
- (NSArray *)arguments
48+
{
49+
return @[self.viewTag, RCTNormalizeInputEventName(self.eventName), @{
50+
@"position": _position,
51+
@"offset": _offset
52+
}];
53+
}
54+
55+
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent;
56+
{
57+
return newEvent;
58+
}
59+
60+
@end

ios/RCTOnPageScrollStateChanged.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <Foundation/Foundation.h>
2+
#import <React/RCTViewManager.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
@interface RCTOnPageScrollStateChanged : NSObject <RCTEvent>
7+
8+
- (instancetype) initWithReactTag:(NSNumber *)reactTag
9+
state:(NSString *)state
10+
coalescingKey:(uint16_t)coalescingKey;
11+
12+
@end
13+
14+
NS_ASSUME_NONNULL_END

ios/RCTOnPageScrollStateChanged.m

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#import <React/UIView+React.h>
2+
#import "RCTOnPageScrollStateChanged.h"
3+
4+
@implementation RCTOnPageScrollStateChanged
5+
{
6+
NSString* _state;
7+
uint16_t _coalescingKey;
8+
}
9+
10+
@synthesize viewTag = _viewTag;
11+
12+
- (NSString *)eventName {
13+
return @"onPageScrollStateChanged";
14+
}
15+
16+
- (instancetype) initWithReactTag:(NSNumber *)reactTag
17+
state:(NSString *)state
18+
coalescingKey:(uint16_t)coalescingKey;
19+
{
20+
RCTAssertParam(reactTag);
21+
22+
if ((self = [super init])) {
23+
_viewTag = reactTag;
24+
_state = state;
25+
_coalescingKey = coalescingKey;
26+
}
27+
return self;
28+
}
29+
30+
RCT_NOT_IMPLEMENTED(- (instancetype)init)
31+
- (uint16_t)coalescingKey
32+
{
33+
return _coalescingKey;
34+
}
35+
36+
37+
- (BOOL)canCoalesce
38+
{
39+
return NO;
40+
}
41+
42+
+ (NSString *)moduleDotMethod
43+
{
44+
return @"RCTEventEmitter.receiveEvent";
45+
}
46+
47+
- (NSArray *)arguments
48+
{
49+
return @[self.viewTag, RCTNormalizeInputEventName(self.eventName), @{
50+
@"pageScrollState": _state,
51+
}];
52+
}
53+
54+
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent;
55+
{
56+
return newEvent;
57+
}
58+
59+
@end

ios/RCTOnPageSelected.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <Foundation/Foundation.h>
2+
#import <React/RCTViewManager.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
@interface RCTOnPageSelected : NSObject <RCTEvent>
7+
8+
- (instancetype) initWithReactTag:(NSNumber *)reactTag
9+
position:(NSNumber *)position
10+
coalescingKey:(uint16_t)coalescingKey;
11+
12+
@end
13+
14+
NS_ASSUME_NONNULL_END

ios/RCTOnPageSelected.m

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#import <React/UIView+React.h>
2+
#import "RCTOnPageSelected.h"
3+
4+
@implementation RCTOnPageSelected
5+
{
6+
NSNumber* _position;
7+
uint16_t _coalescingKey;
8+
}
9+
10+
@synthesize viewTag = _viewTag;
11+
12+
- (NSString *)eventName {
13+
return @"onPageSelected";
14+
}
15+
16+
- (instancetype) initWithReactTag:(NSNumber *)reactTag
17+
position:(NSNumber *)position
18+
coalescingKey:(uint16_t)coalescingKey;
19+
{
20+
RCTAssertParam(reactTag);
21+
22+
if ((self = [super init])) {
23+
_viewTag = reactTag;
24+
_position = position;
25+
_coalescingKey = coalescingKey;
26+
}
27+
return self;
28+
}
29+
30+
RCT_NOT_IMPLEMENTED(- (instancetype)init)
31+
- (uint16_t)coalescingKey
32+
{
33+
return _coalescingKey;
34+
}
35+
36+
37+
- (BOOL)canCoalesce
38+
{
39+
return NO;
40+
}
41+
42+
+ (NSString *)moduleDotMethod
43+
{
44+
return @"RCTEventEmitter.receiveEvent";
45+
}
46+
47+
- (NSArray *)arguments
48+
{
49+
return @[self.viewTag, RCTNormalizeInputEventName(self.eventName), @{
50+
@"position": _position,
51+
}];
52+
}
53+
54+
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent;
55+
{
56+
return newEvent;
57+
}
58+
59+
@end
60+

0 commit comments

Comments
 (0)