@pinwheel/react-native-pinwheel 3.5.1 → 3.5.2
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.
|
@@ -89,7 +89,7 @@ class Pinwheel : FrameLayout {
|
|
|
89
89
|
Handler(Looper.getMainLooper()).post {
|
|
90
90
|
if (this.pinwheelFragment == null) {
|
|
91
91
|
this.token?.let {
|
|
92
|
-
val pinwheelFragment = PinwheelFragment.newInstanceWithAdvancedOptions(it, "react native", "3.5.
|
|
92
|
+
val pinwheelFragment = PinwheelFragment.newInstanceWithAdvancedOptions(it, "react native", "3.5.2", getReactNativeVersion(), this.handleInsets, this.useDarkMode)
|
|
93
93
|
pinwheelEventListener?.let { listener ->
|
|
94
94
|
pinwheelFragment.pinwheelEventListener = listener
|
|
95
95
|
}
|
package/ios/RTNPinwheelView.mm
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
#import <react/renderer/components/RTNPinwheelSpec/Props.h>
|
|
8
8
|
#import <react/renderer/components/RTNPinwheelSpec/RCTComponentViewHelpers.h>
|
|
9
9
|
|
|
10
|
-
#import "RTNPinwheelEvents.h"
|
|
11
10
|
#import "RCTFabricComponentsPlugins.h"
|
|
11
|
+
#import "RTNPinwheelEvents.h"
|
|
12
12
|
|
|
13
13
|
using namespace facebook::react;
|
|
14
14
|
|
|
@@ -17,186 +17,306 @@ using namespace facebook::react;
|
|
|
17
17
|
|
|
18
18
|
@implementation RTNPinwheelView
|
|
19
19
|
|
|
20
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
21
|
-
|
|
22
|
-
return concreteComponentDescriptorProvider<RTNPinwheelComponentDescriptor>();
|
|
20
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
21
|
+
return concreteComponentDescriptorProvider<RTNPinwheelComponentDescriptor>();
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if ((self = [super initWithFrame:frame])) {
|
|
26
|
+
[self initPinwheelWrapperVC];
|
|
27
|
+
}
|
|
28
|
+
return self;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
- (instancetype)initWithFrame:(CGRect)frame token:(NSString *)token {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
if ((self = [super initWithFrame:frame])) {
|
|
33
|
+
_token = token;
|
|
34
|
+
}
|
|
35
|
+
return self;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (self.token != nil) {
|
|
46
|
-
self.pinwheelWrapperVC = [[PinwheelWrapperVC alloc] initWithToken:self.token delegate:self sdk:@"react native" version:@"3.5.1" useDarkMode:self.useDarkMode useAppBoundDomains:NO useAppBoundDomainsForNativeLink:NO];
|
|
47
|
-
[self addSubview:self.pinwheelWrapperVC.view];
|
|
38
|
+
// Helper to find parent VC from a UIView
|
|
39
|
+
- (UIViewController *)getParentViewController {
|
|
40
|
+
UIResponder *responder = self.nextResponder;
|
|
41
|
+
while (responder) {
|
|
42
|
+
if ([responder isKindOfClass:[UIViewController class]]) {
|
|
43
|
+
return (UIViewController *)responder;
|
|
48
44
|
}
|
|
45
|
+
responder = responder.nextResponder;
|
|
46
|
+
}
|
|
47
|
+
return nil;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
|
-
- (void)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
- (void)cleanUpPinwheelWrapperVC {
|
|
51
|
+
if (self.pinwheelWrapperVC != nil) {
|
|
52
|
+
[self.pinwheelWrapperVC willMoveToParentViewController:nil];
|
|
53
|
+
[self.pinwheelWrapperVC.view removeFromSuperview];
|
|
54
|
+
[self.pinwheelWrapperVC removeFromParentViewController];
|
|
55
|
+
self.pinwheelWrapperVC = nil;
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
- (void)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
- (void)initPinwheelWrapperVC {
|
|
60
|
+
[self cleanUpPinwheelWrapperVC];
|
|
61
|
+
|
|
62
|
+
if (self.token == nil) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
UIViewController *parentVC = [self getParentViewController];
|
|
67
|
+
if (!parentVC) {
|
|
68
|
+
// Not yet attached to the hierarchy, skip for now and `didMoveToWindow`
|
|
69
|
+
// will retry later.
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
self.pinwheelWrapperVC =
|
|
74
|
+
[[PinwheelWrapperVC alloc] initWithToken:self.token
|
|
75
|
+
delegate:self
|
|
76
|
+
sdk:@"react native"
|
|
77
|
+
version:@"3.5.2"
|
|
78
|
+
useDarkMode:self.useDarkMode
|
|
79
|
+
useAppBoundDomains:NO
|
|
80
|
+
useAppBoundDomainsForNativeLink:NO];
|
|
81
|
+
|
|
82
|
+
// Guard against double-attachment (shouldn’t happen after cleanup, but safe).
|
|
83
|
+
if (self.pinwheelWrapperVC.parentViewController == parentVC) {
|
|
84
|
+
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[parentVC addChildViewController:self.pinwheelWrapperVC];
|
|
89
|
+
[self addSubview:self.pinwheelWrapperVC.view];
|
|
90
|
+
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
91
|
+
[self.pinwheelWrapperVC didMoveToParentViewController:parentVC];
|
|
92
|
+
}
|
|
61
93
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
94
|
+
- (void)didMoveToWindow {
|
|
95
|
+
[super didMoveToWindow];
|
|
96
|
+
if (self.window) {
|
|
97
|
+
if (!self.pinwheelWrapperVC) {
|
|
98
|
+
[self initPinwheelWrapperVC];
|
|
65
99
|
}
|
|
100
|
+
} else {
|
|
101
|
+
[self cleanUpPinwheelWrapperVC];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
66
104
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
105
|
+
- (void)dealloc {
|
|
106
|
+
[self cleanUpPinwheelWrapperVC];
|
|
107
|
+
}
|
|
70
108
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
109
|
+
- (void)setToken:(NSString *)newToken {
|
|
110
|
+
if (![_token isEqualToString:newToken]) {
|
|
111
|
+
_token = newToken;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
75
114
|
|
|
76
|
-
|
|
115
|
+
- (void)updateProps:(Props::Shared const &)props
|
|
116
|
+
oldProps:(Props::Shared const &)oldProps {
|
|
117
|
+
const auto &oldViewProps =
|
|
118
|
+
*std::static_pointer_cast<RTNPinwheelProps const>(_props);
|
|
119
|
+
const auto &newViewProps =
|
|
120
|
+
*std::static_pointer_cast<RTNPinwheelProps const>(props);
|
|
121
|
+
|
|
122
|
+
if (oldViewProps.token != newViewProps.token) {
|
|
123
|
+
NSString *convertedToken =
|
|
124
|
+
[NSString stringWithUTF8String:newViewProps.token.c_str()];
|
|
125
|
+
[self setToken:convertedToken];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (oldViewProps.useDarkMode != newViewProps.useDarkMode) {
|
|
129
|
+
self.useDarkMode = newViewProps.useDarkMode;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Ensures that the view is always re-initialized whenever the props change,
|
|
133
|
+
// or the React Native component is re-mounted. On the new architecture, there
|
|
134
|
+
// are optimizations which causes the view to be re-used in these scenarios,
|
|
135
|
+
// whereas the ideal functionality here is to have the Link modal reset to the
|
|
136
|
+
// starting state.
|
|
137
|
+
[self initPinwheelWrapperVC];
|
|
138
|
+
|
|
139
|
+
[super updateProps:props oldProps:oldProps];
|
|
77
140
|
}
|
|
78
141
|
|
|
79
|
-
- (void)layoutSubviews
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
142
|
+
- (void)layoutSubviews {
|
|
143
|
+
[super layoutSubviews];
|
|
144
|
+
if (self.pinwheelWrapperVC != nil) {
|
|
145
|
+
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
146
|
+
}
|
|
85
147
|
}
|
|
86
148
|
|
|
87
|
-
- (void)onEventWithName:(NSString *)name
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
149
|
+
- (void)onEventWithName:(NSString *)name
|
|
150
|
+
event:(NSDictionary<NSString *, id> *)event {
|
|
151
|
+
NSLog(@"%@", name);
|
|
152
|
+
NSDictionary *dataToSend = @{@"name" : name, @"payload" : event};
|
|
153
|
+
[RTNPinwheelEvents.sharedInstance handlePinwheelEvent:dataToSend];
|
|
91
154
|
}
|
|
92
155
|
|
|
93
156
|
- (void)onExit:(NSDictionary<NSString *, id> *)error {
|
|
94
|
-
|
|
157
|
+
NSLog(@"%@", error);
|
|
95
158
|
}
|
|
96
159
|
|
|
97
160
|
- (void)onSuccess:(NSDictionary<NSString *, id> *)result {
|
|
98
|
-
|
|
161
|
+
NSLog(@"%@", result);
|
|
99
162
|
}
|
|
100
163
|
|
|
101
164
|
- (void)onLogin:(NSDictionary<NSString *, id> *)result {
|
|
102
|
-
|
|
165
|
+
NSLog(@"%@", result);
|
|
103
166
|
}
|
|
104
167
|
|
|
105
168
|
- (void)onLoginAttempt:(NSDictionary<NSString *, id> *)result {
|
|
106
|
-
|
|
169
|
+
NSLog(@"%@", result);
|
|
107
170
|
}
|
|
108
171
|
|
|
109
172
|
- (void)onError:(NSDictionary<NSString *, id> *)error {
|
|
110
|
-
|
|
173
|
+
NSLog(@"%@", error);
|
|
111
174
|
}
|
|
112
175
|
|
|
113
176
|
@end
|
|
114
177
|
|
|
115
|
-
Class<RCTComponentViewProtocol> RTNPinwheelCls(void)
|
|
116
|
-
{
|
|
178
|
+
Class<RCTComponentViewProtocol> RTNPinwheelCls(void) {
|
|
117
179
|
return RTNPinwheelView.class;
|
|
118
180
|
}
|
|
119
181
|
|
|
120
182
|
#else
|
|
121
183
|
|
|
122
|
-
#import "RTNPinwheelView.h"
|
|
123
184
|
#import "RTNPinwheelEvents.h"
|
|
185
|
+
#import "RTNPinwheelView.h"
|
|
124
186
|
|
|
125
187
|
@implementation RTNPinwheelView
|
|
126
188
|
|
|
127
189
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
190
|
+
if ((self = [super initWithFrame:frame])) {
|
|
191
|
+
[self initPinwheelWrapperVC];
|
|
192
|
+
}
|
|
193
|
+
return self;
|
|
132
194
|
}
|
|
133
195
|
|
|
134
196
|
- (instancetype)initWithFrame:(CGRect)frame token:(NSString *)token {
|
|
135
|
-
|
|
136
|
-
|
|
197
|
+
if ((self = [super initWithFrame:frame])) {
|
|
198
|
+
_token = token;
|
|
199
|
+
}
|
|
200
|
+
return self;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Helper to find parent VC from a UIView
|
|
204
|
+
- (UIViewController *)getParentViewController {
|
|
205
|
+
UIResponder *responder = self.nextResponder;
|
|
206
|
+
while (responder) {
|
|
207
|
+
if ([responder isKindOfClass:[UIViewController class]]) {
|
|
208
|
+
return (UIViewController *)responder;
|
|
137
209
|
}
|
|
138
|
-
|
|
210
|
+
responder = responder.nextResponder;
|
|
211
|
+
}
|
|
212
|
+
return nil;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
- (void)cleanUpPinwheelWrapperVC {
|
|
216
|
+
if (self.pinwheelWrapperVC != nil) {
|
|
217
|
+
[self.pinwheelWrapperVC willMoveToParentViewController:nil];
|
|
218
|
+
[self.pinwheelWrapperVC.view removeFromSuperview];
|
|
219
|
+
[self.pinwheelWrapperVC removeFromParentViewController];
|
|
220
|
+
self.pinwheelWrapperVC = nil;
|
|
221
|
+
}
|
|
139
222
|
}
|
|
140
223
|
|
|
141
224
|
- (void)initPinwheelWrapperVC {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
225
|
+
[self cleanUpPinwheelWrapperVC];
|
|
226
|
+
|
|
227
|
+
if (self.token == nil) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
UIViewController *parentVC = [self getParentViewController];
|
|
232
|
+
if (!parentVC) {
|
|
233
|
+
// Not yet attached to the hierarchy, skip for now and `didMoveToWindow`
|
|
234
|
+
// will retry later.
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
self.pinwheelWrapperVC =
|
|
239
|
+
[[PinwheelWrapperVC alloc] initWithToken:self.token
|
|
240
|
+
delegate:self
|
|
241
|
+
sdk:@"react native"
|
|
242
|
+
version:@"3.5.2"
|
|
243
|
+
useDarkMode:self.useDarkMode
|
|
244
|
+
useAppBoundDomains:NO
|
|
245
|
+
useAppBoundDomainsForNativeLink:NO];
|
|
246
|
+
|
|
247
|
+
// Guard against double-attachment (shouldn’t happen after cleanup, but safe).
|
|
248
|
+
if (self.pinwheelWrapperVC.parentViewController == parentVC) {
|
|
249
|
+
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
[parentVC addChildViewController:self.pinwheelWrapperVC];
|
|
254
|
+
[self addSubview:self.pinwheelWrapperVC.view];
|
|
255
|
+
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
256
|
+
[self.pinwheelWrapperVC didMoveToParentViewController:parentVC];
|
|
257
|
+
}
|
|
146
258
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
259
|
+
- (void)didMoveToWindow {
|
|
260
|
+
[super didMoveToWindow];
|
|
261
|
+
if (self.window) {
|
|
262
|
+
if (!self.pinwheelWrapperVC) {
|
|
263
|
+
[self initPinwheelWrapperVC];
|
|
150
264
|
}
|
|
265
|
+
} else {
|
|
266
|
+
[self cleanUpPinwheelWrapperVC];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
- (void)dealloc {
|
|
271
|
+
[self cleanUpPinwheelWrapperVC];
|
|
151
272
|
}
|
|
152
273
|
|
|
153
274
|
- (void)setToken:(NSString *)newToken {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
275
|
+
if (![_token isEqualToString:newToken]) {
|
|
276
|
+
_token = newToken;
|
|
277
|
+
[self initPinwheelWrapperVC];
|
|
278
|
+
}
|
|
158
279
|
}
|
|
159
280
|
|
|
160
281
|
- (void)setUseDarkMode:(BOOL)newUseDarkMode {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
282
|
+
if (_useDarkMode != newUseDarkMode) {
|
|
283
|
+
_useDarkMode = newUseDarkMode;
|
|
284
|
+
[self initPinwheelWrapperVC];
|
|
285
|
+
}
|
|
165
286
|
}
|
|
166
287
|
|
|
167
|
-
- (void)layoutSubviews
|
|
168
|
-
{
|
|
288
|
+
- (void)layoutSubviews {
|
|
169
289
|
[super layoutSubviews];
|
|
170
290
|
self.pinwheelWrapperVC.view.frame = self.bounds;
|
|
171
291
|
}
|
|
172
292
|
|
|
173
|
-
- (void)onEventWithName:(NSString *)name
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
293
|
+
- (void)onEventWithName:(NSString *)name
|
|
294
|
+
event:(NSDictionary<NSString *, id> *)event {
|
|
295
|
+
NSLog(@"%@", name);
|
|
296
|
+
NSDictionary *dataToSend = @{@"name" : name, @"payload" : event};
|
|
297
|
+
[RTNPinwheelEvents.sharedInstance handlePinwheelEvent:dataToSend];
|
|
177
298
|
}
|
|
178
299
|
|
|
179
300
|
- (void)onExit:(NSDictionary<NSString *, id> *)error {
|
|
180
|
-
|
|
301
|
+
NSLog(@"%@", error);
|
|
181
302
|
}
|
|
182
303
|
|
|
183
304
|
- (void)onSuccess:(NSDictionary<NSString *, id> *)result {
|
|
184
|
-
|
|
305
|
+
NSLog(@"%@", result);
|
|
185
306
|
}
|
|
186
307
|
|
|
187
308
|
- (void)onLogin:(NSDictionary<NSString *, id> *)result {
|
|
188
|
-
|
|
309
|
+
NSLog(@"%@", result);
|
|
189
310
|
}
|
|
190
311
|
|
|
191
312
|
- (void)onLoginAttempt:(NSDictionary<NSString *, id> *)result {
|
|
192
|
-
|
|
313
|
+
NSLog(@"%@", result);
|
|
193
314
|
}
|
|
194
315
|
|
|
195
316
|
- (void)onError:(NSDictionary<NSString *, id> *)error {
|
|
196
|
-
|
|
317
|
+
NSLog(@"%@", error);
|
|
197
318
|
}
|
|
198
319
|
|
|
199
320
|
@end
|
|
200
321
|
|
|
201
|
-
|
|
202
322
|
#endif
|