react-native-screens 3.13.1 → 3.14.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/README.md +2 -2
- package/RNScreens.podspec +5 -4
- package/android/build.gradle +18 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.kt +8 -4
- package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.kt +24 -6
- package/android/src/main/java/com/swmansion/rnscreens/ScreenWindowTraits.kt +14 -18
- package/android/src/main/jni/Android.mk +1 -2
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerDelegate.java +39 -14
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenManagerInterface.java +15 -6
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerDelegate.java +3 -3
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNSScreenStackHeaderConfigManagerInterface.java +1 -1
- package/common/cpp/Android.mk +1 -2
- package/createNativeStackNavigator/README.md +4 -0
- package/ios/RNSConvert.h +30 -0
- package/ios/RNSConvert.mm +120 -0
- package/ios/RNSEnums.h +59 -0
- package/ios/RNSFullWindowOverlay.h +17 -2
- package/ios/RNSFullWindowOverlay.mm +199 -0
- package/ios/RNSScreen.h +70 -79
- package/ios/{RNSScreen.m → RNSScreen.mm} +679 -302
- package/ios/RNSScreenContainer.h +15 -1
- package/ios/{RNSScreenContainer.m → RNSScreenContainer.mm} +99 -8
- package/ios/{RNSScreenNavigationContainer.m → RNSScreenNavigationContainer.mm} +22 -0
- package/ios/RNSScreenStack.h +19 -3
- package/ios/{RNSScreenStack.m → RNSScreenStack.mm} +377 -126
- package/ios/{RNSScreenStackAnimator.m → RNSScreenStackAnimator.mm} +19 -14
- package/ios/RNSScreenStackHeaderConfig.h +20 -21
- package/ios/{RNSScreenStackHeaderConfig.m → RNSScreenStackHeaderConfig.mm} +232 -117
- package/ios/RNSScreenStackHeaderSubview.h +45 -0
- package/ios/RNSScreenStackHeaderSubview.mm +137 -0
- package/ios/RNSScreenViewEvent.h +12 -0
- package/ios/RNSScreenViewEvent.mm +59 -0
- package/ios/{RNSScreenWindowTraits.m → RNSScreenWindowTraits.mm} +3 -2
- package/ios/RNSSearchBar.h +14 -1
- package/ios/RNSSearchBar.mm +351 -0
- package/ios/{UIViewController+RNScreens.m → UIViewController+RNScreens.mm} +0 -0
- package/ios/{UIWindow+RNScreens.m → UIWindow+RNScreens.mm} +0 -0
- package/lib/commonjs/fabric/FullWindowOverlay.js +26 -0
- package/lib/commonjs/fabric/FullWindowOverlay.js.map +1 -0
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js +21 -0
- package/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/ScreenContainer.js +28 -0
- package/lib/commonjs/fabric/ScreenContainer.js.map +1 -0
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js +21 -0
- package/lib/commonjs/fabric/ScreenContainerNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenNavigationContainer.js +28 -0
- package/lib/commonjs/fabric/ScreenNavigationContainer.js.map +1 -0
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js +21 -0
- package/lib/commonjs/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/SearchBar.js +37 -0
- package/lib/commonjs/fabric/SearchBar.js.map +1 -0
- package/lib/commonjs/fabric/SearchBarNativeComponent.js +25 -0
- package/lib/commonjs/fabric/SearchBarNativeComponent.js.map +1 -0
- package/lib/commonjs/fabric/index.js +32 -0
- package/lib/commonjs/fabric/index.js.map +1 -1
- package/lib/commonjs/index.native.js +5 -18
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-stack/views/NativeStackView.js +30 -0
- package/lib/commonjs/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js +8 -2
- package/lib/commonjs/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/module/fabric/FullWindowOverlay.js +15 -0
- package/lib/module/fabric/FullWindowOverlay.js.map +1 -0
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js +9 -0
- package/lib/module/fabric/FullWindowOverlayNativeComponent.js.map +1 -0
- package/lib/module/fabric/ScreenContainer.js +17 -0
- package/lib/module/fabric/ScreenContainer.js.map +1 -0
- package/lib/module/fabric/ScreenContainerNativeComponent.js +9 -0
- package/lib/module/fabric/ScreenContainerNativeComponent.js.map +1 -0
- package/lib/module/fabric/ScreenNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenNavigationContainer.js +17 -0
- package/lib/module/fabric/ScreenNavigationContainer.js.map +1 -0
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js +9 -0
- package/lib/module/fabric/ScreenNavigationContainerNativeComponent.js.map +1 -0
- package/lib/module/fabric/ScreenStackHeaderConfigNativeComponent.js.map +1 -1
- package/lib/module/fabric/ScreenStackNativeComponent.js.map +1 -1
- package/lib/module/fabric/SearchBar.js +24 -0
- package/lib/module/fabric/SearchBar.js.map +1 -0
- package/lib/module/fabric/SearchBarNativeComponent.js +11 -0
- package/lib/module/fabric/SearchBarNativeComponent.js.map +1 -0
- package/lib/module/fabric/index.js +5 -1
- package/lib/module/fabric/index.js.map +1 -1
- package/lib/module/index.native.js +6 -20
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-stack/views/NativeStackView.js +30 -0
- package/lib/module/native-stack/views/NativeStackView.js.map +1 -1
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js +7 -2
- package/lib/module/reanimated/ReanimatedNativeStackScreen.js.map +1 -1
- package/lib/typescript/native-stack/types.d.ts +12 -0
- package/lib/typescript/reanimated/ReanimatedNativeStackScreen.d.ts +1 -1
- package/lib/typescript/reanimated/ReanimatedScreen.d.ts +1 -1
- package/lib/typescript/types.d.ts +24 -0
- package/native-stack/README.md +21 -0
- package/package.json +2 -2
- package/src/fabric/FullWindowOverlay.js +13 -0
- package/src/fabric/FullWindowOverlayNativeComponent.js +19 -0
- package/src/fabric/ScreenContainer.js +16 -0
- package/src/fabric/ScreenContainerNativeComponent.js +19 -0
- package/src/fabric/ScreenNativeComponent.js +41 -8
- package/src/fabric/ScreenNavigationContainer.js +16 -0
- package/src/fabric/ScreenNavigationContainerNativeComponent.js +19 -0
- package/src/fabric/ScreenStackHeaderConfigNativeComponent.js +1 -1
- package/src/fabric/ScreenStackNativeComponent.js +4 -0
- package/src/fabric/SearchBar.js +20 -0
- package/src/fabric/SearchBarNativeComponent.js +62 -0
- package/src/fabric/index.js +8 -0
- package/src/index.native.tsx +13 -19
- package/src/native-stack/types.tsx +12 -0
- package/src/native-stack/views/NativeStackView.tsx +27 -0
- package/src/reanimated/ReanimatedNativeStackScreen.tsx +6 -0
- package/src/types.tsx +25 -0
- package/ios/RNSFullWindowOverlay.m +0 -105
- package/ios/RNSScreenComponentView.h +0 -23
- package/ios/RNSScreenComponentView.mm +0 -159
- package/ios/RNSScreenController.h +0 -10
- package/ios/RNSScreenController.mm +0 -79
- package/ios/RNSScreenStackComponentView.h +0 -15
- package/ios/RNSScreenStackComponentView.mm +0 -295
- package/ios/RNSScreenStackHeaderConfigComponentView.h +0 -42
- package/ios/RNSScreenStackHeaderConfigComponentView.mm +0 -662
- package/ios/RNSScreenStackHeaderSubviewComponentView.h +0 -14
- package/ios/RNSScreenStackHeaderSubviewComponentView.mm +0 -77
- package/ios/RNSSearchBar.m +0 -198
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
|
|
2
|
-
#import "RNSScreenComponentView.h"
|
|
3
|
-
|
|
4
|
-
@implementation RNSScreenController {
|
|
5
|
-
CGRect _lastViewFrame;
|
|
6
|
-
RNSScreenComponentView *_initialView;
|
|
7
|
-
UIView *_snapshot;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
- (instancetype)initWithView:(UIView *)view
|
|
11
|
-
{
|
|
12
|
-
if (self = [super init]) {
|
|
13
|
-
self.view = view;
|
|
14
|
-
if ([view isKindOfClass:[RNSScreenComponentView class]]) {
|
|
15
|
-
_initialView = (RNSScreenComponentView *)view;
|
|
16
|
-
} else {
|
|
17
|
-
RCTLogError(@"ScreenController can only be initialized with ScreenComponentView");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return self;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
- (void)takeSnapshot
|
|
24
|
-
{
|
|
25
|
-
_snapshot = [self.view snapshotViewAfterScreenUpdates:NO];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
- (void)setViewToSnapshot
|
|
29
|
-
{
|
|
30
|
-
[self.view removeFromSuperview];
|
|
31
|
-
self.view = _snapshot;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
- (void)resetViewToScreen
|
|
35
|
-
{
|
|
36
|
-
[self.view removeFromSuperview];
|
|
37
|
-
self.view = _initialView;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// TODO: Find out why this is executed when screen is going out
|
|
41
|
-
- (void)viewWillAppear:(BOOL)animated
|
|
42
|
-
{
|
|
43
|
-
[super viewWillAppear:animated];
|
|
44
|
-
[_initialView notifyWillAppear];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
- (void)viewWillDisappear:(BOOL)animated
|
|
48
|
-
{
|
|
49
|
-
[super viewWillDisappear:animated];
|
|
50
|
-
[_initialView notifyWillDisappear];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (void)viewDidAppear:(BOOL)animated
|
|
54
|
-
{
|
|
55
|
-
[super viewDidAppear:animated];
|
|
56
|
-
[_initialView notifyAppear];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
- (void)viewDidDisappear:(BOOL)animated
|
|
60
|
-
{
|
|
61
|
-
[super viewDidDisappear:animated];
|
|
62
|
-
[_initialView notifyDisappear];
|
|
63
|
-
if (self.parentViewController == nil && self.presentingViewController == nil) {
|
|
64
|
-
// screen dismissed, send event
|
|
65
|
-
[_initialView notifyDismissedWithCount:1];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
- (void)viewDidLayoutSubviews
|
|
70
|
-
{
|
|
71
|
-
[super viewDidLayoutSubviews];
|
|
72
|
-
BOOL isDisplayedWithinUINavController = [self.parentViewController isKindOfClass:[UINavigationController class]];
|
|
73
|
-
if (isDisplayedWithinUINavController && !CGRectEqualToRect(_lastViewFrame, self.view.frame)) {
|
|
74
|
-
_lastViewFrame = self.view.frame;
|
|
75
|
-
[_initialView updateBounds];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
#import <React/RCTViewComponentView.h>
|
|
4
|
-
|
|
5
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
-
|
|
7
|
-
@interface RNSScreenStackComponentView : RCTViewComponentView
|
|
8
|
-
|
|
9
|
-
@end
|
|
10
|
-
|
|
11
|
-
@interface RNSScreenStackView : UIView
|
|
12
|
-
- (instancetype)initWithComponentView:(RNSScreenStackComponentView *)component;
|
|
13
|
-
@end
|
|
14
|
-
|
|
15
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
#import "RNSScreenStackComponentView.h"
|
|
2
|
-
#import "RNSScreenComponentView.h"
|
|
3
|
-
#import "RNSScreenStackHeaderConfigComponentView.h"
|
|
4
|
-
|
|
5
|
-
#import <React/UIView+React.h>
|
|
6
|
-
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
|
|
7
|
-
#import <react/renderer/components/rnscreens/EventEmitters.h>
|
|
8
|
-
#import <react/renderer/components/rnscreens/Props.h>
|
|
9
|
-
#import <react/renderer/components/rnscreens/RCTComponentViewHelpers.h>
|
|
10
|
-
|
|
11
|
-
#import "RCTFabricComponentsPlugins.h"
|
|
12
|
-
|
|
13
|
-
using namespace facebook::react;
|
|
14
|
-
|
|
15
|
-
@interface RNSScreenStackComponentView () <
|
|
16
|
-
UINavigationControllerDelegate,
|
|
17
|
-
UIAdaptivePresentationControllerDelegate,
|
|
18
|
-
UIGestureRecognizerDelegate,
|
|
19
|
-
UIViewControllerTransitioningDelegate>
|
|
20
|
-
@end
|
|
21
|
-
|
|
22
|
-
@implementation RNSScreenStackComponentView {
|
|
23
|
-
UINavigationController *_controller;
|
|
24
|
-
NSMutableArray<RNSScreenComponentView *> *_reactSubviews;
|
|
25
|
-
BOOL _invalidated;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
- (instancetype)initWithFrame:(CGRect)frame
|
|
29
|
-
{
|
|
30
|
-
if (self = [super initWithFrame:frame]) {
|
|
31
|
-
static const auto defaultProps = std::make_shared<const RNSScreenStackProps>();
|
|
32
|
-
_props = defaultProps;
|
|
33
|
-
_reactSubviews = [NSMutableArray new];
|
|
34
|
-
_controller = [[UINavigationController alloc] init];
|
|
35
|
-
_controller.delegate = self;
|
|
36
|
-
[_controller setViewControllers:@[ [UIViewController new] ]];
|
|
37
|
-
_invalidated = NO;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return self;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
- (void)markChildUpdated
|
|
44
|
-
{
|
|
45
|
-
// do nothing
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
- (void)didUpdateChildren
|
|
49
|
-
{
|
|
50
|
-
// do nothing
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
54
|
-
{
|
|
55
|
-
if (![childComponentView isKindOfClass:[RNSScreenComponentView class]]) {
|
|
56
|
-
RCTLogError(@"ScreenStack only accepts children of type Screen");
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
RCTAssert(
|
|
61
|
-
childComponentView.reactSuperview == nil,
|
|
62
|
-
@"Attempt to mount already mounted component view. (parent: %@, child: %@, index: %@, existing parent: %@)",
|
|
63
|
-
self,
|
|
64
|
-
childComponentView,
|
|
65
|
-
@(index),
|
|
66
|
-
@([childComponentView.superview tag]));
|
|
67
|
-
|
|
68
|
-
[_reactSubviews insertObject:(RNSScreenComponentView *)childComponentView atIndex:index];
|
|
69
|
-
((RNSScreenComponentView *)childComponentView).reactSuperview = self;
|
|
70
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
71
|
-
[self maybeAddToParentAndUpdateContainer];
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
76
|
-
{
|
|
77
|
-
RNSScreenComponentView *screenChildComponent = (RNSScreenComponentView *)childComponentView;
|
|
78
|
-
RCTAssert(
|
|
79
|
-
screenChildComponent.reactSuperview == self,
|
|
80
|
-
@"Attempt to unmount a view which is mounted inside different view. (parent: %@, child: %@, index: %@)",
|
|
81
|
-
self,
|
|
82
|
-
screenChildComponent,
|
|
83
|
-
@(index));
|
|
84
|
-
RCTAssert(
|
|
85
|
-
(_reactSubviews.count > index) && [_reactSubviews objectAtIndex:index] == childComponentView,
|
|
86
|
-
@"Attempt to unmount a view which has a different index. (parent: %@, child: %@, index: %@, actual index: %@, tag at index: %@)",
|
|
87
|
-
self,
|
|
88
|
-
screenChildComponent,
|
|
89
|
-
@(index),
|
|
90
|
-
@([_reactSubviews indexOfObject:screenChildComponent]),
|
|
91
|
-
@([[_reactSubviews objectAtIndex:index] tag]));
|
|
92
|
-
screenChildComponent.reactSuperview = nil;
|
|
93
|
-
[_reactSubviews removeObject:screenChildComponent];
|
|
94
|
-
[screenChildComponent removeFromSuperview];
|
|
95
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
96
|
-
[self maybeAddToParentAndUpdateContainer];
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
- (NSArray<UIView *> *)reactSubviews
|
|
101
|
-
{
|
|
102
|
-
return _reactSubviews;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
- (void)didMoveToWindow
|
|
106
|
-
{
|
|
107
|
-
[super didMoveToWindow];
|
|
108
|
-
if (!_invalidated) {
|
|
109
|
-
// We check whether the view has been invalidated before running side-effects in didMoveToWindow
|
|
110
|
-
// This is needed because when LayoutAnimations are used it is possible for view to be re-attached
|
|
111
|
-
// to a window despite the fact it has been removed from the React Native view hierarchy.
|
|
112
|
-
// See https://github.com/software-mansion/react-native-screens/pull/700
|
|
113
|
-
[self maybeAddToParentAndUpdateContainer];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
- (void)navigationController:(UINavigationController *)navigationController
|
|
118
|
-
willShowViewController:(UIViewController *)viewController
|
|
119
|
-
animated:(BOOL)animated
|
|
120
|
-
{
|
|
121
|
-
UIView *view = viewController.view;
|
|
122
|
-
if ([view isKindOfClass:RNSScreenComponentView.class]) {
|
|
123
|
-
RNSScreenStackHeaderConfigComponentView *config =
|
|
124
|
-
(RNSScreenStackHeaderConfigComponentView *)((RNSScreenComponentView *)view).config;
|
|
125
|
-
[RNSScreenStackHeaderConfigComponentView willShowViewController:viewController animated:animated withConfig:config];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
- (void)maybeAddToParentAndUpdateContainer
|
|
130
|
-
{
|
|
131
|
-
BOOL wasScreenMounted = _controller.parentViewController != nil;
|
|
132
|
-
BOOL isScreenReadyForShowing = self.window;
|
|
133
|
-
if (!isScreenReadyForShowing && !wasScreenMounted) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
[self updateContainer];
|
|
137
|
-
if (!wasScreenMounted) {
|
|
138
|
-
// when stack hasn't been added to parent VC yet we do two things:
|
|
139
|
-
// 1) we run updateContainer (the one above) – we do this because we want push view controllers to
|
|
140
|
-
// be installed before the VC is mounted. If we do that after it is added to parent the push
|
|
141
|
-
// updates operations are going to be blocked by UIKit.
|
|
142
|
-
// 2) we add navigation VS to parent – this is needed for the VC lifecycle events to be dispatched
|
|
143
|
-
// properly
|
|
144
|
-
// 3) we again call updateContainer – this time we do this to open modal controllers. Modals
|
|
145
|
-
// won't open in (1) because they require navigator to be added to parent. We handle that case
|
|
146
|
-
// gracefully in setModalViewControllers and can retry opening at any point.
|
|
147
|
-
[self reactAddControllerToClosestParent:_controller];
|
|
148
|
-
[self updateContainer];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
- (void)reactAddControllerToClosestParent:(UIViewController *)controller
|
|
153
|
-
{
|
|
154
|
-
if (!controller.parentViewController) {
|
|
155
|
-
UIView *parentView = (UIView *)self.reactSuperview;
|
|
156
|
-
while (parentView) {
|
|
157
|
-
if ([parentView reactViewController]) {
|
|
158
|
-
[parentView.reactViewController addChildViewController:controller];
|
|
159
|
-
[self addSubview:controller.view];
|
|
160
|
-
#if !TARGET_OS_TV
|
|
161
|
-
_controller.interactivePopGestureRecognizer.delegate = self;
|
|
162
|
-
#endif
|
|
163
|
-
[self navigationController:_controller willShowViewController:_controller.topViewController animated:NO];
|
|
164
|
-
}
|
|
165
|
-
parentView = (UIView *)parentView.reactSuperview;
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
- (void)setPushViewControllers:(NSArray<UIViewController *> *)controllers
|
|
172
|
-
{
|
|
173
|
-
// when there is no change we return immediately
|
|
174
|
-
if ([_controller.viewControllers isEqualToArray:controllers]) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// if view controller is not yet attached to window we skip updates now and run them when view
|
|
179
|
-
// is attached
|
|
180
|
-
if (self.window == nil) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
UIViewController *top = controllers.lastObject;
|
|
185
|
-
UIViewController *lastTop = _controller.viewControllers.lastObject;
|
|
186
|
-
|
|
187
|
-
// at the start we set viewControllers to contain a single UIVIewController
|
|
188
|
-
// instance. This is a workaround for header height adjustment bug (see comment
|
|
189
|
-
// in the init function). Here, we need to detect if the initial empty
|
|
190
|
-
// controller is still there
|
|
191
|
-
BOOL firstTimePush = ![lastTop isKindOfClass:[RNSScreenController class]];
|
|
192
|
-
|
|
193
|
-
BOOL shouldAnimate = YES;
|
|
194
|
-
|
|
195
|
-
if (firstTimePush) {
|
|
196
|
-
// nothing pushed yet
|
|
197
|
-
[_controller setViewControllers:controllers animated:NO];
|
|
198
|
-
} else if (top != lastTop) {
|
|
199
|
-
if (![controllers containsObject:lastTop]) {
|
|
200
|
-
// if the previous top screen does not exist anymore and the new top was not on the stack before, probably replace
|
|
201
|
-
// was called, so we check the animation
|
|
202
|
-
if (![_controller.viewControllers containsObject:top]) {
|
|
203
|
-
// setting new controllers with animation does `push` animation by default
|
|
204
|
-
auto screenController = (RNSScreenController *)top;
|
|
205
|
-
[screenController resetViewToScreen];
|
|
206
|
-
[_controller setViewControllers:controllers animated:YES];
|
|
207
|
-
} else {
|
|
208
|
-
// last top controller is no longer on stack
|
|
209
|
-
// in this case we set the controllers stack to the new list with
|
|
210
|
-
// added the last top element to it and perform (animated) pop
|
|
211
|
-
NSMutableArray *newControllers = [NSMutableArray arrayWithArray:controllers];
|
|
212
|
-
[newControllers addObject:lastTop];
|
|
213
|
-
[_controller setViewControllers:newControllers animated:NO];
|
|
214
|
-
[_controller popViewControllerAnimated:shouldAnimate];
|
|
215
|
-
}
|
|
216
|
-
} else if (![_controller.viewControllers containsObject:top]) {
|
|
217
|
-
// new top controller is not on the stack
|
|
218
|
-
// in such case we update the stack except from the last element with
|
|
219
|
-
// no animation and do animated push of the last item
|
|
220
|
-
NSMutableArray *newControllers = [NSMutableArray arrayWithArray:controllers];
|
|
221
|
-
[newControllers removeLastObject];
|
|
222
|
-
[_controller setViewControllers:newControllers animated:NO];
|
|
223
|
-
auto screenController = (RNSScreenController *)top;
|
|
224
|
-
[screenController resetViewToScreen];
|
|
225
|
-
[_controller pushViewController:top animated:shouldAnimate];
|
|
226
|
-
} else {
|
|
227
|
-
// don't really know what this case could be, but may need to handle it
|
|
228
|
-
// somehow
|
|
229
|
-
[_controller setViewControllers:controllers animated:shouldAnimate];
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
// change wasn't on the top of the stack. We don't need animation.
|
|
233
|
-
[_controller setViewControllers:controllers animated:NO];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
- (void)updateContainer
|
|
238
|
-
{
|
|
239
|
-
NSMutableArray<UIViewController *> *pushControllers = [NSMutableArray new];
|
|
240
|
-
for (RNSScreenComponentView *screen in _reactSubviews) {
|
|
241
|
-
if (screen.controller != nil) {
|
|
242
|
-
if (pushControllers.count == 0) {
|
|
243
|
-
// first screen on the list needs to be places as "push controller"
|
|
244
|
-
[pushControllers addObject:screen.controller];
|
|
245
|
-
} else {
|
|
246
|
-
[pushControllers addObject:screen.controller];
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
[self setPushViewControllers:pushControllers];
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
- (void)layoutSubviews
|
|
255
|
-
{
|
|
256
|
-
[super layoutSubviews];
|
|
257
|
-
_controller.view.frame = self.bounds;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
- (void)dismissOnReload
|
|
261
|
-
{
|
|
262
|
-
auto screenController = (RNSScreenController *)_controller.viewControllers.lastObject;
|
|
263
|
-
[screenController resetViewToScreen];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
#pragma mark methods connected to transitioning
|
|
267
|
-
|
|
268
|
-
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
|
269
|
-
{
|
|
270
|
-
return YES;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
#pragma mark - RCTComponentViewProtocol
|
|
274
|
-
|
|
275
|
-
- (void)prepareForRecycle
|
|
276
|
-
{
|
|
277
|
-
[super prepareForRecycle];
|
|
278
|
-
_reactSubviews = [NSMutableArray new];
|
|
279
|
-
[self dismissOnReload];
|
|
280
|
-
_invalidated = YES;
|
|
281
|
-
[_controller willMoveToParentViewController:nil];
|
|
282
|
-
[_controller removeFromParentViewController];
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
286
|
-
{
|
|
287
|
-
return concreteComponentDescriptorProvider<RNSScreenStackComponentDescriptor>();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
@end
|
|
291
|
-
|
|
292
|
-
Class<RCTComponentViewProtocol> RNSScreenStackCls(void)
|
|
293
|
-
{
|
|
294
|
-
return RNSScreenStackComponentView.class;
|
|
295
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#import <UIKit/UIKit.h>
|
|
2
|
-
|
|
3
|
-
#import <React/RCTViewComponentView.h>
|
|
4
|
-
|
|
5
|
-
#import "RNSScreenComponentView.h"
|
|
6
|
-
#import "RNSScreenStackHeaderSubviewComponentView.h"
|
|
7
|
-
|
|
8
|
-
@interface RNSScreenStackHeaderConfigComponentView : RCTViewComponentView
|
|
9
|
-
|
|
10
|
-
@property (nonatomic, weak) RNSScreenComponentView *screenView;
|
|
11
|
-
@property (nonatomic) NSMutableArray<RNSScreenStackHeaderSubviewComponentView *> *reactSubviews;
|
|
12
|
-
|
|
13
|
-
// Properties from props
|
|
14
|
-
@property (nonatomic) BOOL show;
|
|
15
|
-
@property (nonatomic) BOOL translucent;
|
|
16
|
-
@property (nonatomic) BOOL hideShadow;
|
|
17
|
-
@property (nonatomic, retain) NSString *title;
|
|
18
|
-
@property (nonatomic, retain) NSString *titleFontFamily;
|
|
19
|
-
@property (nonatomic, retain) NSNumber *titleFontSize;
|
|
20
|
-
@property (nonatomic, retain) NSString *titleFontWeight;
|
|
21
|
-
@property (nonatomic, retain) UIColor *titleColor;
|
|
22
|
-
@property (nonatomic) BOOL largeTitle;
|
|
23
|
-
@property (nonatomic, retain) NSString *largeTitleFontFamily;
|
|
24
|
-
@property (nonatomic, retain) NSNumber *largeTitleFontSize;
|
|
25
|
-
@property (nonatomic, retain) NSString *largeTitleFontWeight;
|
|
26
|
-
@property (nonatomic, retain) UIColor *largeTitleBackgroundColor;
|
|
27
|
-
@property (nonatomic) BOOL largeTitleHideShadow;
|
|
28
|
-
@property (nonatomic, retain) UIColor *largeTitleColor;
|
|
29
|
-
@property (nonatomic, retain) UIColor *backgroundColor;
|
|
30
|
-
@property (nonatomic, retain) UIColor *color;
|
|
31
|
-
@property (nonatomic) UISemanticContentAttribute direction;
|
|
32
|
-
@property (nonatomic, retain) NSString *backTitle;
|
|
33
|
-
@property (nonatomic, retain) NSString *backTitleFontFamily;
|
|
34
|
-
@property (nonatomic, retain) NSNumber *backTitleFontSize;
|
|
35
|
-
@property (nonatomic) BOOL disableBackButtonMenu;
|
|
36
|
-
@property (nonatomic) BOOL hideBackButton;
|
|
37
|
-
|
|
38
|
-
+ (void)willShowViewController:(UIViewController *)vc
|
|
39
|
-
animated:(BOOL)animated
|
|
40
|
-
withConfig:(RNSScreenStackHeaderConfigComponentView *)config;
|
|
41
|
-
|
|
42
|
-
@end
|