react-native-screens 3.22.1 → 3.24.0
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.
- package/android/src/main/java/com/swmansion/rnscreens/SearchBarManager.kt +2 -0
- package/ios/RNSConvert.h +13 -13
- package/ios/RNSConvert.mm +57 -49
- package/ios/RNSEnums.h +6 -0
- package/ios/RNSFullWindowOverlay.h +6 -2
- package/ios/RNSFullWindowOverlay.mm +16 -6
- package/ios/RNSScreen.h +17 -5
- package/ios/RNSScreen.mm +74 -44
- package/ios/RNSScreenContainer.h +2 -2
- package/ios/RNSScreenContainer.mm +11 -8
- package/ios/RNSScreenNavigationContainer.h +1 -1
- package/ios/RNSScreenNavigationContainer.mm +9 -8
- package/ios/RNSScreenStack.h +1 -1
- package/ios/RNSScreenStack.mm +15 -14
- package/ios/RNSScreenStackHeaderConfig.mm +27 -21
- package/ios/RNSScreenStackHeaderSubview.mm +12 -11
- package/ios/RNSScreenWindowTraits.mm +5 -5
- package/ios/RNSSearchBar.h +8 -1
- package/ios/RNSSearchBar.mm +58 -19
- package/ios/UIViewController+RNScreens.mm +7 -7
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -1
- package/lib/commonjs/index.native.js +5 -1
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-stack/types.js.map +1 -1
- package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js +10 -6
- package/lib/commonjs/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +35 -8
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -1
- package/lib/module/index.native.js +5 -1
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-stack/types.js.map +1 -1
- package/lib/module/native-stack/utils/getDefaultHeaderHeight.js +10 -6
- package/lib/module/native-stack/utils/getDefaultHeaderHeight.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +35 -8
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/fabric/ScreenNativeComponent.d.ts +1 -0
- package/lib/typescript/fabric/SearchBarNativeComponent.d.ts +2 -0
- package/lib/typescript/native-stack/types.d.ts +8 -0
- package/lib/typescript/native-stack/utils/getDefaultHeaderHeight.d.ts +1 -1
- package/lib/typescript/types.d.ts +21 -0
- package/native-stack/README.md +12 -1
- package/package.json +1 -1
- package/src/fabric/ScreenNativeComponent.ts +1 -0
- package/src/fabric/SearchBarNativeComponent.ts +3 -0
- package/src/index.native.tsx +7 -0
- package/src/native-stack/types.tsx +6 -0
- package/src/native-stack/utils/getDefaultHeaderHeight.tsx +11 -7
- package/src/native-stack/views/NativeStackView.tsx +36 -6
- package/src/types.tsx +21 -0
package/ios/RNSScreen.mm
CHANGED
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
#import "RNSScreenStack.h"
|
|
25
25
|
#import "RNSScreenStackHeaderConfig.h"
|
|
26
26
|
|
|
27
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
28
|
+
namespace react = facebook::react;
|
|
29
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
30
|
+
|
|
27
31
|
@interface RNSScreenView ()
|
|
28
32
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
29
33
|
<RCTRNSScreenViewProtocol, UIAdaptivePresentationControllerDelegate>
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
__weak RCTBridge *_bridge;
|
|
37
41
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
38
42
|
RCTSurfaceTouchHandler *_touchHandler;
|
|
39
|
-
|
|
43
|
+
react::RNSScreenShadowNode::ConcreteState::Shared _state;
|
|
40
44
|
// on fabric, they are not available by default so we need them exposed here too
|
|
41
45
|
NSMutableArray<UIView *> *_reactSubviews;
|
|
42
46
|
#else
|
|
@@ -49,12 +53,11 @@
|
|
|
49
53
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
50
54
|
{
|
|
51
55
|
if (self = [super initWithFrame:frame]) {
|
|
52
|
-
static const auto defaultProps = std::make_shared<const
|
|
56
|
+
static const auto defaultProps = std::make_shared<const react::RNSScreenProps>();
|
|
53
57
|
_props = defaultProps;
|
|
54
58
|
_reactSubviews = [NSMutableArray new];
|
|
55
59
|
[self initCommonProps];
|
|
56
60
|
}
|
|
57
|
-
|
|
58
61
|
return self;
|
|
59
62
|
}
|
|
60
63
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -103,7 +106,7 @@
|
|
|
103
106
|
{
|
|
104
107
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
105
108
|
if (_state != nullptr) {
|
|
106
|
-
auto newState =
|
|
109
|
+
auto newState = react::RNSScreenState{RCTSizeFromCGSize(self.bounds.size)};
|
|
107
110
|
_state->updateState(std::move(newState));
|
|
108
111
|
UINavigationController *navctr = _controller.navigationController;
|
|
109
112
|
[navctr.view setNeedsLayout];
|
|
@@ -284,8 +287,8 @@
|
|
|
284
287
|
// If screen is already unmounted then there will be no event emitter
|
|
285
288
|
// it will be cleaned in prepareForRecycle
|
|
286
289
|
if (_eventEmitter != nullptr) {
|
|
287
|
-
std::dynamic_pointer_cast<const
|
|
288
|
-
->onDismissed(
|
|
290
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
291
|
+
->onDismissed(react::RNSScreenEventEmitter::OnDismissed{.dismissCount = dismissCount});
|
|
289
292
|
}
|
|
290
293
|
#else
|
|
291
294
|
// TODO: hopefully problems connected to dismissed prop are only the case on paper
|
|
@@ -306,9 +309,9 @@
|
|
|
306
309
|
// If screen is already unmounted then there will be no event emitter
|
|
307
310
|
// it will be cleaned in prepareForRecycle
|
|
308
311
|
if (_eventEmitter != nullptr) {
|
|
309
|
-
std::dynamic_pointer_cast<const
|
|
312
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
310
313
|
->onNativeDismissCancelled(
|
|
311
|
-
|
|
314
|
+
react::RNSScreenEventEmitter::OnNativeDismissCancelled{.dismissCount = dismissCount});
|
|
312
315
|
}
|
|
313
316
|
#else
|
|
314
317
|
if (self.onNativeDismissCancelled) {
|
|
@@ -323,8 +326,8 @@
|
|
|
323
326
|
// If screen is already unmounted then there will be no event emitter
|
|
324
327
|
// it will be cleaned in prepareForRecycle
|
|
325
328
|
if (_eventEmitter != nullptr) {
|
|
326
|
-
std::dynamic_pointer_cast<const
|
|
327
|
-
->onWillAppear(
|
|
329
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
330
|
+
->onWillAppear(react::RNSScreenEventEmitter::OnWillAppear{});
|
|
328
331
|
}
|
|
329
332
|
[self updateLayoutMetrics:_newLayoutMetrics oldLayoutMetrics:_oldLayoutMetrics];
|
|
330
333
|
#else
|
|
@@ -346,8 +349,8 @@
|
|
|
346
349
|
// If screen is already unmounted then there will be no event emitter
|
|
347
350
|
// it will be cleaned in prepareForRecycle
|
|
348
351
|
if (_eventEmitter != nullptr) {
|
|
349
|
-
std::dynamic_pointer_cast<const
|
|
350
|
-
->onWillDisappear(
|
|
352
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
353
|
+
->onWillDisappear(react::RNSScreenEventEmitter::OnWillDisappear{});
|
|
351
354
|
}
|
|
352
355
|
#else
|
|
353
356
|
if (self.onWillDisappear) {
|
|
@@ -362,8 +365,8 @@
|
|
|
362
365
|
// If screen is already unmounted then there will be no event emitter
|
|
363
366
|
// it will be cleaned in prepareForRecycle
|
|
364
367
|
if (_eventEmitter != nullptr) {
|
|
365
|
-
std::dynamic_pointer_cast<const
|
|
366
|
-
->onAppear(
|
|
368
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
369
|
+
->onAppear(react::RNSScreenEventEmitter::OnAppear{});
|
|
367
370
|
}
|
|
368
371
|
#else
|
|
369
372
|
if (self.onAppear) {
|
|
@@ -382,8 +385,8 @@
|
|
|
382
385
|
// If screen is already unmounted then there will be no event emitter
|
|
383
386
|
// it will be cleaned in prepareForRecycle
|
|
384
387
|
if (_eventEmitter != nullptr) {
|
|
385
|
-
std::dynamic_pointer_cast<const
|
|
386
|
-
->onDisappear(
|
|
388
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
389
|
+
->onDisappear(react::RNSScreenEventEmitter::OnDisappear{});
|
|
387
390
|
}
|
|
388
391
|
#else
|
|
389
392
|
if (self.onDisappear) {
|
|
@@ -392,6 +395,20 @@
|
|
|
392
395
|
#endif
|
|
393
396
|
}
|
|
394
397
|
|
|
398
|
+
- (void)notifyGestureCancel
|
|
399
|
+
{
|
|
400
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
401
|
+
if (_eventEmitter != nullptr) {
|
|
402
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
403
|
+
->onGestureCancel(react::RNSScreenEventEmitter::OnGestureCancel{});
|
|
404
|
+
}
|
|
405
|
+
#else
|
|
406
|
+
if (self.onGestureCancel) {
|
|
407
|
+
self.onGestureCancel(nil);
|
|
408
|
+
}
|
|
409
|
+
#endif
|
|
410
|
+
}
|
|
411
|
+
|
|
395
412
|
- (BOOL)isMountedUnderScreenOrReactRoot
|
|
396
413
|
{
|
|
397
414
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -454,8 +471,8 @@
|
|
|
454
471
|
{
|
|
455
472
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
456
473
|
if (_eventEmitter != nullptr) {
|
|
457
|
-
std::dynamic_pointer_cast<const
|
|
458
|
-
->onTransitionProgress(
|
|
474
|
+
std::dynamic_pointer_cast<const react::RNSScreenEventEmitter>(_eventEmitter)
|
|
475
|
+
->onTransitionProgress(react::RNSScreenEventEmitter::OnTransitionProgress{
|
|
459
476
|
.progress = progress, .closing = closing ? 1 : 0, .goingForward = goingForward ? 1 : 0});
|
|
460
477
|
}
|
|
461
478
|
RNSScreenViewEvent *event = [[RNSScreenViewEvent alloc] initWithEventName:@"onTransitionProgress"
|
|
@@ -517,6 +534,16 @@
|
|
|
517
534
|
return self.stackPresentation != RNSScreenStackPresentationPush;
|
|
518
535
|
}
|
|
519
536
|
|
|
537
|
+
- (RNSScreenStackHeaderConfig *_Nullable)findHeaderConfig
|
|
538
|
+
{
|
|
539
|
+
for (UIView *view in self.reactSubviews) {
|
|
540
|
+
if ([view isKindOfClass:RNSScreenStackHeaderConfig.class]) {
|
|
541
|
+
return (RNSScreenStackHeaderConfig *)view;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return nil;
|
|
545
|
+
}
|
|
546
|
+
|
|
520
547
|
#if !TARGET_OS_TV
|
|
521
548
|
/**
|
|
522
549
|
* Updates settings for sheet presentation controller.
|
|
@@ -574,19 +601,24 @@
|
|
|
574
601
|
#pragma mark - Fabric specific
|
|
575
602
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
576
603
|
|
|
577
|
-
|
|
604
|
+
- (BOOL)hasHeaderConfig
|
|
578
605
|
{
|
|
579
|
-
return
|
|
606
|
+
return _config != nil;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
+ (react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
610
|
+
{
|
|
611
|
+
return react::concreteComponentDescriptorProvider<react::RNSScreenComponentDescriptor>();
|
|
580
612
|
}
|
|
581
613
|
|
|
582
614
|
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
583
615
|
{
|
|
584
|
-
[super mountChildComponentView:childComponentView index:index];
|
|
585
616
|
if ([childComponentView isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
|
|
586
|
-
_config = childComponentView;
|
|
587
|
-
|
|
617
|
+
_config = (RNSScreenStackHeaderConfig *)childComponentView;
|
|
618
|
+
_config.screenView = self;
|
|
588
619
|
}
|
|
589
620
|
[_reactSubviews insertObject:childComponentView atIndex:index];
|
|
621
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
590
622
|
}
|
|
591
623
|
|
|
592
624
|
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
@@ -621,11 +653,10 @@
|
|
|
621
653
|
_stackPresentation = RNSScreenStackPresentationPush;
|
|
622
654
|
}
|
|
623
655
|
|
|
624
|
-
- (void)updateProps:(
|
|
625
|
-
oldProps:(facebook::react::Props::Shared const &)oldProps
|
|
656
|
+
- (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps
|
|
626
657
|
{
|
|
627
|
-
const auto &oldScreenProps = *std::static_pointer_cast<const
|
|
628
|
-
const auto &newScreenProps = *std::static_pointer_cast<const
|
|
658
|
+
const auto &oldScreenProps = *std::static_pointer_cast<const react::RNSScreenProps>(_props);
|
|
659
|
+
const auto &newScreenProps = *std::static_pointer_cast<const react::RNSScreenProps>(props);
|
|
629
660
|
|
|
630
661
|
[self setFullScreenSwipeEnabled:newScreenProps.fullScreenSwipeEnabled];
|
|
631
662
|
|
|
@@ -704,22 +735,21 @@
|
|
|
704
735
|
[super updateProps:props oldProps:oldProps];
|
|
705
736
|
}
|
|
706
737
|
|
|
707
|
-
- (void)updateState:(
|
|
708
|
-
oldState:(facebook::react::State::Shared const &)oldState
|
|
738
|
+
- (void)updateState:(react::State::Shared const &)state oldState:(react::State::Shared const &)oldState
|
|
709
739
|
{
|
|
710
|
-
_state = std::static_pointer_cast<const
|
|
740
|
+
_state = std::static_pointer_cast<const react::RNSScreenShadowNode::ConcreteState>(state);
|
|
711
741
|
}
|
|
712
742
|
|
|
713
|
-
- (void)updateLayoutMetrics:(const
|
|
714
|
-
oldLayoutMetrics:(const
|
|
743
|
+
- (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics
|
|
744
|
+
oldLayoutMetrics:(const react::LayoutMetrics &)oldLayoutMetrics
|
|
715
745
|
{
|
|
716
746
|
_newLayoutMetrics = layoutMetrics;
|
|
717
747
|
_oldLayoutMetrics = oldLayoutMetrics;
|
|
718
748
|
UIViewController *parentVC = self.reactViewController.parentViewController;
|
|
719
|
-
if (parentVC != nil && ![parentVC isKindOfClass:[
|
|
749
|
+
if (parentVC != nil && ![parentVC isKindOfClass:[RNSNavigationController class]]) {
|
|
720
750
|
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
721
751
|
}
|
|
722
|
-
// when screen is mounted under
|
|
752
|
+
// when screen is mounted under RNSNavigationController it's size is controller
|
|
723
753
|
// by the navigation controller itself. That is, it is set to fill space of
|
|
724
754
|
// the controller. In that case we ignore react layout system from managing
|
|
725
755
|
// the screen dimensions and we wait for the screen VC to update and then we
|
|
@@ -756,10 +786,10 @@
|
|
|
756
786
|
{
|
|
757
787
|
_reactFrame = frame;
|
|
758
788
|
UIViewController *parentVC = self.reactViewController.parentViewController;
|
|
759
|
-
if (parentVC != nil && ![parentVC isKindOfClass:[
|
|
789
|
+
if (parentVC != nil && ![parentVC isKindOfClass:[RNSNavigationController class]]) {
|
|
760
790
|
[super reactSetFrame:frame];
|
|
761
791
|
}
|
|
762
|
-
// when screen is mounted under
|
|
792
|
+
// when screen is mounted under RNSNavigationController it's size is controller
|
|
763
793
|
// by the navigation controller itself. That is, it is set to fill space of
|
|
764
794
|
// the controller. In that case we ignore react layout system from managing
|
|
765
795
|
// the screen dimensions and we wait for the screen VC to update and then we
|
|
@@ -886,6 +916,8 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
|
|
|
886
916
|
// or successfully swiped back
|
|
887
917
|
[self.screenView notifyAppear];
|
|
888
918
|
[self notifyTransitionProgress:1.0 closing:NO goingForward:_goingForward];
|
|
919
|
+
} else {
|
|
920
|
+
[self.screenView notifyGestureCancel];
|
|
889
921
|
}
|
|
890
922
|
|
|
891
923
|
_isSwiping = NO;
|
|
@@ -928,12 +960,11 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
|
|
|
928
960
|
[super viewDidLayoutSubviews];
|
|
929
961
|
|
|
930
962
|
// The below code makes the screen view adapt dimensions provided by the system. We take these
|
|
931
|
-
// into account only when the view is mounted under
|
|
963
|
+
// into account only when the view is mounted under RNSNavigationController in which case system
|
|
932
964
|
// provides additional padding to account for possible header, and in the case when screen is
|
|
933
965
|
// shown as a native modal, as the final dimensions of the modal on iOS 12+ are shorter than the
|
|
934
966
|
// screen size
|
|
935
|
-
BOOL isDisplayedWithinUINavController =
|
|
936
|
-
[self.parentViewController isKindOfClass:[RNScreensNavigationController class]];
|
|
967
|
+
BOOL isDisplayedWithinUINavController = [self.parentViewController isKindOfClass:[RNSNavigationController class]];
|
|
937
968
|
BOOL isPresentedAsNativeModal = self.parentViewController == nil && self.presentingViewController != nil;
|
|
938
969
|
|
|
939
970
|
if (isDisplayedWithinUINavController || isPresentedAsNativeModal) {
|
|
@@ -1048,7 +1079,7 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
|
|
|
1048
1079
|
if (lastViewController == nil) {
|
|
1049
1080
|
return selfOrNil;
|
|
1050
1081
|
} else {
|
|
1051
|
-
if ([lastViewController conformsToProtocol:@protocol(
|
|
1082
|
+
if ([lastViewController conformsToProtocol:@protocol(RNSViewControllerDelegate)]) {
|
|
1052
1083
|
// If there is a child (should be VC of ScreenContainer or ScreenStack), that has a child that could provide the
|
|
1053
1084
|
// trait, we recursively go into its findChildVCForConfig, and if one of the children has the trait set, we return
|
|
1054
1085
|
// it, otherwise we return self if this VC has config, and nil if it doesn't we use
|
|
@@ -1178,12 +1209,10 @@ Class<RCTComponentViewProtocol> RNSScreenCls(void)
|
|
|
1178
1209
|
|
|
1179
1210
|
// we need to check whether reactSubviews array is empty, because on Fabric child nodes are unmounted first ->
|
|
1180
1211
|
// reactSubviews array may be empty
|
|
1181
|
-
|
|
1182
|
-
|
|
1212
|
+
RNSScreenStackHeaderConfig *config = [self.screenView findHeaderConfig];
|
|
1213
|
+
if (currentIndex > 0 && config != nil) {
|
|
1183
1214
|
UINavigationItem *prevNavigationItem =
|
|
1184
1215
|
[self.navigationController.viewControllers objectAtIndex:currentIndex - 1].navigationItem;
|
|
1185
|
-
RNSScreenStackHeaderConfig *config = ((RNSScreenStackHeaderConfig *)self.screenView.reactSubviews[0]);
|
|
1186
|
-
|
|
1187
1216
|
BOOL wasSearchBarActive = prevNavigationItem.searchController.active;
|
|
1188
1217
|
|
|
1189
1218
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
@@ -1275,6 +1304,7 @@ RCT_EXPORT_VIEW_PROPERTY(onNativeDismissCancelled, RCTDirectEventBlock);
|
|
|
1275
1304
|
RCT_EXPORT_VIEW_PROPERTY(onTransitionProgress, RCTDirectEventBlock);
|
|
1276
1305
|
RCT_EXPORT_VIEW_PROPERTY(onWillAppear, RCTDirectEventBlock);
|
|
1277
1306
|
RCT_EXPORT_VIEW_PROPERTY(onWillDisappear, RCTDirectEventBlock);
|
|
1307
|
+
RCT_EXPORT_VIEW_PROPERTY(onGestureCancel, RCTDirectEventBlock);
|
|
1278
1308
|
|
|
1279
1309
|
#if !TARGET_OS_TV
|
|
1280
1310
|
RCT_EXPORT_VIEW_PROPERTY(screenOrientation, UIInterfaceOrientationMask)
|
package/ios/RNSScreenContainer.h
CHANGED
|
@@ -14,11 +14,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
14
14
|
|
|
15
15
|
@end
|
|
16
16
|
|
|
17
|
-
@protocol
|
|
17
|
+
@protocol RNSViewControllerDelegate
|
|
18
18
|
|
|
19
19
|
@end
|
|
20
20
|
|
|
21
|
-
@interface
|
|
21
|
+
@interface RNSViewController : UIViewController <RNSViewControllerDelegate>
|
|
22
22
|
|
|
23
23
|
- (UIViewController *)findActiveChildVC;
|
|
24
24
|
|
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
|
|
8
8
|
#import <react/renderer/components/rnscreens/Props.h>
|
|
9
|
-
#endif
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
namespace react = facebook::react;
|
|
11
|
+
|
|
12
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
13
|
+
|
|
14
|
+
@implementation RNSViewController
|
|
12
15
|
|
|
13
16
|
#if !TARGET_OS_TV
|
|
14
17
|
- (UIViewController *)childViewControllerForStatusBarStyle
|
|
@@ -59,7 +62,7 @@
|
|
|
59
62
|
{
|
|
60
63
|
if (self = [super init]) {
|
|
61
64
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
62
|
-
static const auto defaultProps = std::make_shared<const
|
|
65
|
+
static const auto defaultProps = std::make_shared<const react::RNSScreenContainerProps>();
|
|
63
66
|
_props = defaultProps;
|
|
64
67
|
#endif
|
|
65
68
|
_activeScreens = [NSMutableSet new];
|
|
@@ -72,7 +75,7 @@
|
|
|
72
75
|
|
|
73
76
|
- (void)setupController
|
|
74
77
|
{
|
|
75
|
-
_controller = [[
|
|
78
|
+
_controller = [[RNSViewController alloc] init];
|
|
76
79
|
[self addSubview:_controller.view];
|
|
77
80
|
}
|
|
78
81
|
|
|
@@ -235,7 +238,7 @@
|
|
|
235
238
|
_controller.view.frame = self.bounds;
|
|
236
239
|
for (RNSScreenView *subview in _reactSubviews) {
|
|
237
240
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
238
|
-
|
|
241
|
+
react::LayoutMetrics screenLayoutMetrics = subview.newLayoutMetrics;
|
|
239
242
|
screenLayoutMetrics.frame = RCTRectFromCGRect(CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height));
|
|
240
243
|
[subview updateLayoutMetrics:screenLayoutMetrics oldLayoutMetrics:subview.oldLayoutMetrics];
|
|
241
244
|
#else
|
|
@@ -267,7 +270,7 @@
|
|
|
267
270
|
|
|
268
271
|
[_reactSubviews insertObject:screenView atIndex:index];
|
|
269
272
|
screenView.reactSuperview = self;
|
|
270
|
-
|
|
273
|
+
react::LayoutMetrics screenLayoutMetrics = screenView.newLayoutMetrics;
|
|
271
274
|
screenLayoutMetrics.frame = RCTRectFromCGRect(CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height));
|
|
272
275
|
[screenView updateLayoutMetrics:screenLayoutMetrics oldLayoutMetrics:screenView.oldLayoutMetrics];
|
|
273
276
|
[self markChildUpdated];
|
|
@@ -295,9 +298,9 @@
|
|
|
295
298
|
[self markChildUpdated];
|
|
296
299
|
}
|
|
297
300
|
|
|
298
|
-
+ (
|
|
301
|
+
+ (react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
299
302
|
{
|
|
300
|
-
return
|
|
303
|
+
return react::concreteComponentDescriptorProvider<react::RNSScreenContainerComponentDescriptor>();
|
|
301
304
|
}
|
|
302
305
|
|
|
303
306
|
- (void)prepareForRecycle
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
|
|
8
8
|
#import <react/renderer/components/rnscreens/Props.h>
|
|
9
|
-
#endif
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
namespace react = facebook::react;
|
|
11
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
12
|
+
|
|
13
|
+
@implementation RNSContainerNavigationController
|
|
12
14
|
|
|
13
15
|
@end
|
|
14
16
|
|
|
@@ -16,8 +18,8 @@
|
|
|
16
18
|
|
|
17
19
|
- (void)setupController
|
|
18
20
|
{
|
|
19
|
-
self.controller = [[
|
|
20
|
-
[(
|
|
21
|
+
self.controller = [[RNSContainerNavigationController alloc] init];
|
|
22
|
+
[(RNSContainerNavigationController *)self.controller setNavigationBarHidden:YES animated:NO];
|
|
21
23
|
[self addSubview:self.controller.view];
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -27,7 +29,7 @@
|
|
|
27
29
|
if (screen.activityState == RNSActivityStateOnTop) {
|
|
28
30
|
// there should never be more than one screen with `RNSActivityStateOnTop`
|
|
29
31
|
// since this component should be used for `tabs` and `drawer` navigators
|
|
30
|
-
[(
|
|
32
|
+
[(RNSContainerNavigationController *)self.controller setViewControllers:@[ screen.controller ] animated:NO];
|
|
31
33
|
[screen notifyFinishTransitioning];
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -37,10 +39,9 @@
|
|
|
37
39
|
|
|
38
40
|
#pragma mark-- Fabric specific
|
|
39
41
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
40
|
-
+ (
|
|
42
|
+
+ (react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
41
43
|
{
|
|
42
|
-
return
|
|
43
|
-
facebook::react::RNSScreenNavigationContainerComponentDescriptor>();
|
|
44
|
+
return react::concreteComponentDescriptorProvider<react::RNSScreenNavigationContainerComponentDescriptor>();
|
|
44
45
|
}
|
|
45
46
|
#endif
|
|
46
47
|
|
package/ios/RNSScreenStack.h
CHANGED
package/ios/RNSScreenStack.mm
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
2
3
|
#import <React/RCTMountingTransactionObserving.h>
|
|
3
4
|
#import <React/RCTSurfaceTouchHandler.h>
|
|
4
5
|
#import <React/UIView+React.h>
|
|
@@ -6,9 +7,6 @@
|
|
|
6
7
|
#import <react/renderer/components/rnscreens/EventEmitters.h>
|
|
7
8
|
#import <react/renderer/components/rnscreens/Props.h>
|
|
8
9
|
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
|
|
9
|
-
|
|
10
|
-
#import <React/RCTFabricComponentsPlugins.h>
|
|
11
|
-
|
|
12
10
|
#else
|
|
13
11
|
#import <React/RCTBridge.h>
|
|
14
12
|
#import <React/RCTRootContentView.h>
|
|
@@ -24,6 +22,10 @@
|
|
|
24
22
|
#import "RNSScreenStackHeaderConfig.h"
|
|
25
23
|
#import "RNSScreenWindowTraits.h"
|
|
26
24
|
|
|
25
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
26
|
+
namespace react = facebook::react;
|
|
27
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
28
|
+
|
|
27
29
|
@interface RNSScreenStackView () <
|
|
28
30
|
UINavigationControllerDelegate,
|
|
29
31
|
UIAdaptivePresentationControllerDelegate,
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
|
|
42
44
|
@end
|
|
43
45
|
|
|
44
|
-
@implementation
|
|
46
|
+
@implementation RNSNavigationController
|
|
45
47
|
|
|
46
48
|
#if !TARGET_OS_TV
|
|
47
49
|
- (UIViewController *)childViewControllerForStatusBarStyle
|
|
@@ -104,7 +106,7 @@
|
|
|
104
106
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
105
107
|
{
|
|
106
108
|
if (self = [super initWithFrame:frame]) {
|
|
107
|
-
static const auto defaultProps = std::make_shared<const
|
|
109
|
+
static const auto defaultProps = std::make_shared<const react::RNSScreenStackProps>();
|
|
108
110
|
_props = defaultProps;
|
|
109
111
|
[self initCommonProps];
|
|
110
112
|
}
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
{
|
|
129
131
|
_reactSubviews = [NSMutableArray new];
|
|
130
132
|
_presentedModals = [NSMutableArray new];
|
|
131
|
-
_controller = [
|
|
133
|
+
_controller = [RNSNavigationController new];
|
|
132
134
|
_controller.delegate = self;
|
|
133
135
|
#if !TARGET_OS_TV
|
|
134
136
|
[self setupGestureHandlers];
|
|
@@ -161,8 +163,8 @@
|
|
|
161
163
|
{
|
|
162
164
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
163
165
|
if (_eventEmitter != nullptr) {
|
|
164
|
-
std::dynamic_pointer_cast<const
|
|
165
|
-
->onFinishTransitioning(
|
|
166
|
+
std::dynamic_pointer_cast<const react::RNSScreenStackEventEmitter>(_eventEmitter)
|
|
167
|
+
->onFinishTransitioning(react::RNSScreenStackEventEmitter::OnFinishTransitioning{});
|
|
166
168
|
}
|
|
167
169
|
#else
|
|
168
170
|
if (self.onFinishTransitioning) {
|
|
@@ -1005,12 +1007,11 @@
|
|
|
1005
1007
|
_snapshot = [_controller.visibleViewController.view snapshotViewAfterScreenUpdates:NO];
|
|
1006
1008
|
}
|
|
1007
1009
|
|
|
1008
|
-
- (void)mountingTransactionWillMount:(
|
|
1009
|
-
withSurfaceTelemetry:(
|
|
1010
|
+
- (void)mountingTransactionWillMount:(react::MountingTransaction const &)transaction
|
|
1011
|
+
withSurfaceTelemetry:(react::SurfaceTelemetry const &)surfaceTelemetry
|
|
1010
1012
|
{
|
|
1011
1013
|
for (auto &mutation : transaction.getMutations()) {
|
|
1012
|
-
if (mutation.type ==
|
|
1013
|
-
mutation.parentShadowView.componentName != nil &&
|
|
1014
|
+
if (mutation.type == react::ShadowViewMutation::Type::Remove && mutation.parentShadowView.componentName != nil &&
|
|
1014
1015
|
strcmp(mutation.parentShadowView.componentName, "RNSScreenStack") == 0) {
|
|
1015
1016
|
[self takeSnapshot];
|
|
1016
1017
|
return;
|
|
@@ -1034,9 +1035,9 @@
|
|
|
1034
1035
|
[_controller setViewControllers:@[ [UIViewController new] ]];
|
|
1035
1036
|
}
|
|
1036
1037
|
|
|
1037
|
-
+ (
|
|
1038
|
+
+ (react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
1038
1039
|
{
|
|
1039
|
-
return
|
|
1040
|
+
return react::concreteComponentDescriptorProvider<react::RNSScreenStackComponentDescriptor>();
|
|
1040
1041
|
}
|
|
1041
1042
|
#else
|
|
1042
1043
|
#pragma mark - Paper specific
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
#import "RNSUIBarButtonItem.h"
|
|
26
26
|
|
|
27
27
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
28
|
-
namespace
|
|
28
|
+
namespace react = facebook::react;
|
|
29
29
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
30
30
|
|
|
31
31
|
#ifndef RCT_NEW_ARCH_ENABLED
|
|
@@ -64,7 +64,7 @@ namespace rct = facebook::react;
|
|
|
64
64
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
65
65
|
{
|
|
66
66
|
if (self = [super initWithFrame:frame]) {
|
|
67
|
-
static const auto defaultProps = std::make_shared<const
|
|
67
|
+
static const auto defaultProps = std::make_shared<const react::RNSScreenStackHeaderConfigProps>();
|
|
68
68
|
_props = defaultProps;
|
|
69
69
|
_show = YES;
|
|
70
70
|
_translucent = NO;
|
|
@@ -315,7 +315,7 @@ namespace rct = facebook::react;
|
|
|
315
315
|
scale:imageSource.scale
|
|
316
316
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
317
317
|
resizeMode:resizeModeFromCppEquiv(
|
|
318
|
-
std::static_pointer_cast<const
|
|
318
|
+
std::static_pointer_cast<const react::ImageProps>(imageView.props)->resizeMode)];
|
|
319
319
|
#else
|
|
320
320
|
resizeMode:imageView.resizeMode];
|
|
321
321
|
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -606,8 +606,14 @@ namespace rct = facebook::react;
|
|
|
606
606
|
RNSSearchBar *searchBar = subview.subviews[0];
|
|
607
607
|
navitem.searchController = searchBar.controller;
|
|
608
608
|
navitem.hidesSearchBarWhenScrolling = searchBar.hideWhenScrolling;
|
|
609
|
+
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \
|
|
610
|
+
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0
|
|
611
|
+
if (@available(iOS 16.0, *)) {
|
|
612
|
+
navitem.preferredSearchBarPlacement = [searchBar placementAsUINavigationItemSearchBarPlacement];
|
|
613
|
+
}
|
|
614
|
+
#endif /* Check for iOS 16.0 */
|
|
609
615
|
}
|
|
610
|
-
#endif
|
|
616
|
+
#endif /* !TARGET_OS_TV */
|
|
611
617
|
}
|
|
612
618
|
break;
|
|
613
619
|
}
|
|
@@ -698,18 +704,18 @@ namespace rct = facebook::react;
|
|
|
698
704
|
[childComponentView removeFromSuperview];
|
|
699
705
|
}
|
|
700
706
|
|
|
701
|
-
static RCTResizeMode resizeModeFromCppEquiv(
|
|
707
|
+
static RCTResizeMode resizeModeFromCppEquiv(react::ImageResizeMode resizeMode)
|
|
702
708
|
{
|
|
703
709
|
switch (resizeMode) {
|
|
704
|
-
case
|
|
710
|
+
case react::ImageResizeMode::Cover:
|
|
705
711
|
return RCTResizeModeCover;
|
|
706
|
-
case
|
|
712
|
+
case react::ImageResizeMode::Contain:
|
|
707
713
|
return RCTResizeModeContain;
|
|
708
|
-
case
|
|
714
|
+
case react::ImageResizeMode::Stretch:
|
|
709
715
|
return RCTResizeModeStretch;
|
|
710
|
-
case
|
|
716
|
+
case react::ImageResizeMode::Center:
|
|
711
717
|
return RCTResizeModeCenter;
|
|
712
|
-
case
|
|
718
|
+
case react::ImageResizeMode::Repeat:
|
|
713
719
|
return RCTResizeModeRepeat;
|
|
714
720
|
}
|
|
715
721
|
}
|
|
@@ -720,8 +726,8 @@ static RCTResizeMode resizeModeFromCppEquiv(rct::ImageResizeMode resizeMode)
|
|
|
720
726
|
*/
|
|
721
727
|
+ (RCTImageSource *)imageSourceFromImageView:(RCTImageComponentView *)view
|
|
722
728
|
{
|
|
723
|
-
auto const imageProps = *std::static_pointer_cast<const
|
|
724
|
-
|
|
729
|
+
auto const imageProps = *std::static_pointer_cast<const react::ImageProps>(view.props);
|
|
730
|
+
react::ImageSource cppImageSource = imageProps.sources.at(0);
|
|
725
731
|
auto imageSize = CGSize{cppImageSource.size.width, cppImageSource.size.height};
|
|
726
732
|
NSURLRequest *request =
|
|
727
733
|
[NSURLRequest requestWithURL:[NSURL URLWithString:RCTNSStringFromStringNilIfEmpty(cppImageSource.uri)]];
|
|
@@ -739,9 +745,9 @@ static RCTResizeMode resizeModeFromCppEquiv(rct::ImageResizeMode resizeMode)
|
|
|
739
745
|
_initialPropsSet = NO;
|
|
740
746
|
}
|
|
741
747
|
|
|
742
|
-
+ (
|
|
748
|
+
+ (react::ComponentDescriptorProvider)componentDescriptorProvider
|
|
743
749
|
{
|
|
744
|
-
return
|
|
750
|
+
return react::concreteComponentDescriptorProvider<react::RNSScreenStackHeaderConfigComponentDescriptor>();
|
|
745
751
|
}
|
|
746
752
|
|
|
747
753
|
- (NSNumber *)getFontSizePropValue:(int)value
|
|
@@ -751,20 +757,20 @@ static RCTResizeMode resizeModeFromCppEquiv(rct::ImageResizeMode resizeMode)
|
|
|
751
757
|
return nil;
|
|
752
758
|
}
|
|
753
759
|
|
|
754
|
-
- (UISemanticContentAttribute)getDirectionPropValue:(
|
|
760
|
+
- (UISemanticContentAttribute)getDirectionPropValue:(react::RNSScreenStackHeaderConfigDirection)direction
|
|
755
761
|
{
|
|
756
762
|
switch (direction) {
|
|
757
|
-
case
|
|
763
|
+
case react::RNSScreenStackHeaderConfigDirection::Rtl:
|
|
758
764
|
return UISemanticContentAttributeForceRightToLeft;
|
|
759
|
-
case
|
|
765
|
+
case react::RNSScreenStackHeaderConfigDirection::Ltr:
|
|
760
766
|
return UISemanticContentAttributeForceLeftToRight;
|
|
761
767
|
}
|
|
762
768
|
}
|
|
763
769
|
|
|
764
|
-
- (void)updateProps:(
|
|
770
|
+
- (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::Shared const &)oldProps
|
|
765
771
|
{
|
|
766
|
-
const auto &oldScreenProps = *std::static_pointer_cast<const
|
|
767
|
-
const auto &newScreenProps = *std::static_pointer_cast<const
|
|
772
|
+
const auto &oldScreenProps = *std::static_pointer_cast<const react::RNSScreenStackHeaderConfigProps>(_props);
|
|
773
|
+
const auto &newScreenProps = *std::static_pointer_cast<const react::RNSScreenStackHeaderConfigProps>(props);
|
|
768
774
|
|
|
769
775
|
BOOL needsNavigationControllerLayout = !_initialPropsSet;
|
|
770
776
|
|
|
@@ -826,7 +832,7 @@ static RCTResizeMode resizeModeFromCppEquiv(rct::ImageResizeMode resizeMode)
|
|
|
826
832
|
}
|
|
827
833
|
|
|
828
834
|
_initialPropsSet = YES;
|
|
829
|
-
_props = std::static_pointer_cast<
|
|
835
|
+
_props = std::static_pointer_cast<react::RNSScreenStackHeaderConfigProps const>(props);
|
|
830
836
|
|
|
831
837
|
[super updateProps:props oldProps:oldProps];
|
|
832
838
|
}
|