@pinwheel/react-native-pinwheel 3.2.0-rc.4 → 3.2.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,7 +48,7 @@ class Pinwheel : FrameLayout {
48
48
  private fun createFragment() {
49
49
  Handler(Looper.getMainLooper()).post {
50
50
  this.token?.let {
51
- val pinwheelFragment = PinwheelFragment.newInstance(it, "react native", "3.2.0-rc.4")
51
+ val pinwheelFragment = PinwheelFragment.newInstance(it, "react native", "3.2.0-rc.5")
52
52
  pinwheelEventListener?.let { listener ->
53
53
  pinwheelFragment.pinwheelEventListener = listener
54
54
  }
@@ -1,13 +1,29 @@
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+
1
3
  #import <RTNPinwheelSpec/RTNPinwheelSpec.h>
4
+
5
+ #else
6
+
7
+ #import <React/RCTBridgeModule.h>
8
+
9
+ #endif
10
+
11
+
2
12
  #import <React/RCTEventEmitter.h>
3
13
 
4
14
  NS_ASSUME_NONNULL_BEGIN
5
15
 
6
- @interface RTNPinwheelEvents : RCTEventEmitter <NativePinwheelEventsSpec>
16
+ @interface RTNPinwheelEvents : RCTEventEmitter
17
+
18
+ #ifdef RCT_NEW_ARCH_ENABLED
19
+ <NativePinwheelEventsSpec>
20
+ #else
21
+ <RCTBridgeModule>
22
+ #endif
7
23
 
8
24
  + (instancetype)sharedInstance;
9
25
  - (void)handlePinwheelEvent:(NSDictionary<NSString *, id> *)payload;
10
26
 
11
27
  @end
12
28
 
13
- NS_ASSUME_NONNULL_END
29
+ NS_ASSUME_NONNULL_END
@@ -59,16 +59,20 @@ RCT_EXPORT_MODULE();
59
59
  return @[@"PINWHEEL_EVENT"]; // Add more event names here.
60
60
  }
61
61
 
62
+ #if RCT_NEW_ARCH_ENABLED
62
63
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
63
64
  return std::make_shared<facebook::react::NativePinwheelEventsSpecJSI>(params);
64
65
  }
66
+ #endif
65
67
 
66
- - (void)removeListener {
68
+ RCT_EXPORT_METHOD(removeListener) {
67
69
  [self stopObserving];
68
70
  }
69
71
 
70
- - (void)setListener {
72
+ RCT_EXPORT_METHOD(setListener) {
71
73
  [self startObserving];
72
74
  }
73
75
 
76
+
77
+
74
78
  @end
@@ -8,12 +8,15 @@
8
8
 
9
9
  @implementation RTNPinwheelManager
10
10
 
11
+ #ifdef RCT_NEW_ARCH_ENABLED
11
12
  RCT_EXPORT_MODULE(RTNPinwheelView)
13
+ #else
14
+ RCT_EXPORT_MODULE(RTNPinwheel)
15
+ #endif
12
16
 
13
17
  - (UIView *)view
14
18
  {
15
- RTNPinwheelView *pv = [[RTNPinwheelView alloc] init];
16
- return pv;
19
+ return [[RTNPinwheelView alloc] init];
17
20
  }
18
21
 
19
22
  RCT_EXPORT_VIEW_PROPERTY(token, NSString);
@@ -1,11 +1,24 @@
1
+ #if RCT_NEW_ARCH_ENABLED
2
+
1
3
  #import <React/RCTViewComponentView.h>
2
- #import <UIKit/UIKit.h>
4
+
5
+ # endif
6
+
3
7
  #import <ObjCWrapper/PinwheelVCWrapper.h>
8
+ #import <UIKit/UIKit.h>
4
9
 
5
10
  NS_ASSUME_NONNULL_BEGIN
6
11
 
12
+ #ifdef RCT_NEW_ARCH_ENABLED
13
+
7
14
  @interface RTNPinwheelView : RCTViewComponentView <PinwheelVCWrapperDelegate>
8
15
 
16
+ #else
17
+
18
+ @interface RTNPinwheelView : UIView <PinwheelVCWrapperDelegate>
19
+
20
+ #endif
21
+
9
22
  @property (nonatomic, strong) PinwheelVCWrapper *pinwheelWrapperVC;
10
23
  @property (nonatomic, assign) NSString *token;
11
24
 
@@ -14,4 +27,3 @@ NS_ASSUME_NONNULL_BEGIN
14
27
  @end
15
28
 
16
29
  NS_ASSUME_NONNULL_END
17
-
@@ -1,3 +1,5 @@
1
+ #ifdef RCT_NEW_ARCH_ENABLED
2
+
1
3
  #import "RTNPinwheelView.h"
2
4
 
3
5
  #import <react/renderer/components/RTNPinwheelSpec/ComponentDescriptors.h>
@@ -100,3 +102,74 @@ Class<RCTComponentViewProtocol> RTNPinwheelCls(void)
100
102
  return RTNPinwheelView.class;
101
103
  }
102
104
 
105
+ #else
106
+
107
+ #import "RTNPinwheelView.h"
108
+ #import "RTNPinwheelEvents.h"
109
+
110
+ @implementation RTNPinwheelView
111
+
112
+ - (instancetype)initWithFrame:(CGRect)frame {
113
+ if ((self = [super initWithFrame:frame])) {
114
+ [self initPinwheelWrapperVC];
115
+ }
116
+ return self;
117
+ }
118
+
119
+ - (instancetype)initWithFrame:(CGRect)frame token:(NSString *)token {
120
+ if ((self = [super initWithFrame:frame])) {
121
+ _token = token;
122
+ }
123
+ return self;
124
+ }
125
+
126
+ - (void)initPinwheelWrapperVC {
127
+ if (self.token != nil && self.pinwheelWrapperVC == nil) {
128
+ self.pinwheelWrapperVC = [[PinwheelVCWrapper alloc] initWithToken:self.token delegate:self sdk:@"react native" version: @"3.2.0"];
129
+ [self addSubview:self.pinwheelWrapperVC.view];
130
+ }
131
+ }
132
+
133
+ - (void)setToken:(NSString *)newToken {
134
+ if (![_token isEqualToString:newToken]) {
135
+ _token = newToken;
136
+ [self initPinwheelWrapperVC];
137
+ }
138
+ }
139
+
140
+ - (void)layoutSubviews
141
+ {
142
+ [super layoutSubviews];
143
+ self.pinwheelWrapperVC.view.frame = self.bounds;
144
+ }
145
+
146
+ - (void)onEventWithName:(NSString *)name event:(NSDictionary<NSString *, id> *)event {
147
+ NSLog(@"%@", name);
148
+ NSDictionary *dataToSend = @{@"name": name, @"payload": event};
149
+ [RTNPinwheelEvents.sharedInstance handlePinwheelEvent:dataToSend];
150
+ }
151
+
152
+ - (void)onExit:(NSDictionary<NSString *, id> *)error {
153
+ NSLog(@"%@", error);
154
+ }
155
+
156
+ - (void)onSuccess:(NSDictionary<NSString *, id> *)result {
157
+ NSLog(@"%@", result);
158
+ }
159
+
160
+ - (void)onLogin:(NSDictionary<NSString *, id> *)result {
161
+ NSLog(@"%@", result);
162
+ }
163
+
164
+ - (void)onLoginAttempt:(NSDictionary<NSString *, id> *)result {
165
+ NSLog(@"%@", result);
166
+ }
167
+
168
+ - (void)onError:(NSDictionary<NSString *, id> *)error {
169
+ NSLog(@"%@", error);
170
+ }
171
+
172
+ @end
173
+
174
+
175
+ #endif
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinwheel/react-native-pinwheel",
3
- "version": "3.2.0-rc.4",
3
+ "version": "3.2.0-rc.5",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/Pinwheel.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useCallback } from 'react';
2
2
  import { SafeAreaView } from 'react-native';
3
- import RTNPinwheel from './RTNPinwheelNativeComponent';
3
+ const RTNPinwheel = require('./RTNPinwheelNativeComponent').default;
4
4
  import { PinwheelEvents } from './PinwheelEvents';
5
5
  import { LinkOptions } from './client-events/client';
6
6