react-native-screens 1.0.0-alpha.2 → 1.0.0-alpha.23
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 +163 -1
- package/RNScreens.podspec +24 -0
- package/android/build.gradle +17 -10
- package/android/src/main/java/com/swmansion/rnscreens/LifecycleHelper.java +4 -8
- package/android/src/main/java/com/swmansion/rnscreens/{RNScreenPackage.java → RNScreensPackage.java} +1 -2
- package/android/src/main/java/com/swmansion/rnscreens/Screen.java +44 -3
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.java +61 -18
- package/android/src/main/java/com/swmansion/rnscreens/ScreenContainerViewManager.java +1 -1
- package/android/src/main/java/com/swmansion/rnscreens/ScreenViewManager.java +3 -3
- package/ios/RNSScreen.h +2 -0
- package/ios/RNSScreen.m +51 -7
- package/ios/RNSScreenContainer.h +0 -8
- package/ios/RNSScreenContainer.m +93 -24
- package/ios/RNScreens.xcodeproj/project.pbxproj +170 -7
- package/package.json +11 -6
- package/src/screens.d.ts +22 -0
- package/src/screens.native.js +120 -0
- package/src/screens.web.js +113 -0
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStack.java +0 -35
- package/android/src/main/java/com/swmansion/rnscreens/ScreenStackViewManager.java +0 -24
- package/ios/RNSScreenStack.h +0 -14
- package/ios/RNSScreenStack.m +0 -245
- package/ios/RNScreens.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNScreens.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RNScreens.xcodeproj/project.xcworkspace/xcuserdata/mdk.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNScreens.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -24
- package/src/screens.js +0 -14
package/ios/RNSScreenContainer.m
CHANGED
|
@@ -1,25 +1,39 @@
|
|
|
1
1
|
#import "RNSScreenContainer.h"
|
|
2
2
|
#import "RNSScreen.h"
|
|
3
3
|
|
|
4
|
+
#import <React/RCTUIManager.h>
|
|
5
|
+
#import <React/RCTUIManagerObserverCoordinator.h>
|
|
6
|
+
#import <React/RCTUIManagerUtils.h>
|
|
7
|
+
|
|
8
|
+
@interface RNSScreenContainerManager : RCTViewManager
|
|
9
|
+
|
|
10
|
+
- (void)markUpdated:(RNSScreenContainerView *)screen;
|
|
11
|
+
|
|
12
|
+
@end
|
|
13
|
+
|
|
4
14
|
@interface RNSScreenContainerView ()
|
|
5
15
|
|
|
6
16
|
@property (nonatomic, retain) UIViewController *controller;
|
|
7
17
|
@property (nonatomic, retain) NSMutableSet<RNSScreenView *> *activeScreens;
|
|
8
18
|
@property (nonatomic, retain) NSMutableArray<RNSScreenView *> *reactSubviews;
|
|
9
19
|
|
|
20
|
+
- (void)updateContainer;
|
|
21
|
+
|
|
10
22
|
@end
|
|
11
23
|
|
|
12
24
|
@implementation RNSScreenContainerView {
|
|
13
25
|
BOOL _needUpdate;
|
|
26
|
+
__weak RNSScreenContainerManager *_manager;
|
|
14
27
|
}
|
|
15
28
|
|
|
16
|
-
- (instancetype)
|
|
29
|
+
- (instancetype)initWithManager:(RNSScreenContainerManager *)manager
|
|
17
30
|
{
|
|
18
31
|
if (self = [super init]) {
|
|
19
32
|
_activeScreens = [NSMutableSet new];
|
|
20
33
|
_reactSubviews = [NSMutableArray new];
|
|
21
34
|
_controller = [[UIViewController alloc] init];
|
|
22
35
|
_needUpdate = NO;
|
|
36
|
+
_manager = manager;
|
|
23
37
|
[self addSubview:_controller.view];
|
|
24
38
|
}
|
|
25
39
|
return self;
|
|
@@ -27,24 +41,23 @@
|
|
|
27
41
|
|
|
28
42
|
- (void)markChildUpdated
|
|
29
43
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
// We want 'updateContainer' to be executed on main thread after all enqueued operations in
|
|
45
|
+
// uimanager are complete. For that we collect all marked containers in manager class and enqueue
|
|
46
|
+
// operation on ui thread that should run once all the updates are completed.
|
|
47
|
+
if (!_needUpdate) {
|
|
48
|
+
_needUpdate = YES;
|
|
49
|
+
[_manager markUpdated:self];
|
|
50
|
+
}
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
- (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex
|
|
39
54
|
{
|
|
40
|
-
_needUpdate = YES;
|
|
41
55
|
subview.reactSuperview = self;
|
|
42
56
|
[_reactSubviews insertObject:subview atIndex:atIndex];
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
- (void)removeReactSubview:(RNSScreenView *)subview
|
|
46
60
|
{
|
|
47
|
-
_needUpdate = YES;
|
|
48
61
|
subview.reactSuperview = nil;
|
|
49
62
|
[_reactSubviews removeObject:subview];
|
|
50
63
|
}
|
|
@@ -64,46 +77,81 @@
|
|
|
64
77
|
|
|
65
78
|
- (void)attachScreen:(RNSScreenView *)screen
|
|
66
79
|
{
|
|
67
|
-
[screen.controller
|
|
80
|
+
[_controller addChildViewController:screen.controller];
|
|
68
81
|
[_controller.view addSubview:screen.controller.view];
|
|
69
82
|
[screen.controller didMoveToParentViewController:_controller];
|
|
70
83
|
[_activeScreens addObject:screen];
|
|
71
84
|
}
|
|
72
85
|
|
|
73
|
-
- (void)
|
|
86
|
+
- (void)updateContainer
|
|
74
87
|
{
|
|
75
|
-
if (!_needUpdate) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
88
|
_needUpdate = NO;
|
|
79
|
-
|
|
89
|
+
BOOL activeScreenRemoved = NO;
|
|
80
90
|
// remove screens that are no longer active
|
|
81
91
|
NSMutableSet *orphaned = [NSMutableSet setWithSet:_activeScreens];
|
|
82
92
|
for (RNSScreenView *screen in _reactSubviews) {
|
|
83
93
|
if (!screen.active && [_activeScreens containsObject:screen]) {
|
|
94
|
+
activeScreenRemoved = YES;
|
|
84
95
|
[self detachScreen:screen];
|
|
85
96
|
}
|
|
86
97
|
[orphaned removeObject:screen];
|
|
87
98
|
}
|
|
88
99
|
for (RNSScreenView *screen in orphaned) {
|
|
100
|
+
activeScreenRemoved = YES;
|
|
89
101
|
[self detachScreen:screen];
|
|
90
102
|
}
|
|
91
103
|
|
|
92
|
-
//
|
|
104
|
+
// detect if new screen is going to be activated
|
|
105
|
+
BOOL activeScreenAdded = NO;
|
|
93
106
|
for (RNSScreenView *screen in _reactSubviews) {
|
|
94
107
|
if (screen.active && ![_activeScreens containsObject:screen]) {
|
|
95
|
-
|
|
96
|
-
} else if (screen.active) {
|
|
97
|
-
// if the view was already there we move it to "front" so that it is in the right
|
|
98
|
-
// order accoring to the subviews array
|
|
99
|
-
[_controller.view bringSubviewToFront:screen.controller.view];
|
|
108
|
+
activeScreenAdded = YES;
|
|
100
109
|
}
|
|
101
110
|
}
|
|
111
|
+
|
|
112
|
+
// if we are adding new active screen, we perform remounting of all already marked as active
|
|
113
|
+
// this is done to mimick the effect UINavigationController has when willMoveToWindow:nil is
|
|
114
|
+
// triggered before the animation starts
|
|
115
|
+
if (activeScreenAdded) {
|
|
116
|
+
for (RNSScreenView *screen in _reactSubviews) {
|
|
117
|
+
if (screen.active && [_activeScreens containsObject:screen]) {
|
|
118
|
+
[self detachScreen:screen];
|
|
119
|
+
// disable interactions for the duration of transition
|
|
120
|
+
screen.userInteractionEnabled = NO;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// add new screens in order they are placed in subviews array
|
|
125
|
+
for (RNSScreenView *screen in _reactSubviews) {
|
|
126
|
+
if (screen.active) {
|
|
127
|
+
[self attachScreen:screen];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// if we are down to one active screen it means the transitioning is over and we want to notify
|
|
133
|
+
// the transition has finished
|
|
134
|
+
if ((activeScreenRemoved || activeScreenAdded) && _activeScreens.count == 1) {
|
|
135
|
+
RNSScreenView *singleActiveScreen = [_activeScreens anyObject];
|
|
136
|
+
// restore interactions
|
|
137
|
+
singleActiveScreen.userInteractionEnabled = YES;
|
|
138
|
+
[singleActiveScreen notifyFinishTransitioning];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if ((activeScreenRemoved || activeScreenAdded) && _controller.presentedViewController == nil) {
|
|
142
|
+
// if user has reachability enabled (one hand use) and the window is slided down the below
|
|
143
|
+
// method will force it to slide back up as it is expected to happen with UINavController when
|
|
144
|
+
// we push or pop views.
|
|
145
|
+
// We only do that if `presentedViewController` is nil, as otherwise it'd mean that modal has
|
|
146
|
+
// been presented on top of recently changed controller in which case the below method would
|
|
147
|
+
// dismiss such a modal (e.g., permission modal or alert)
|
|
148
|
+
[_controller dismissViewControllerAnimated:NO completion:nil];
|
|
149
|
+
}
|
|
102
150
|
}
|
|
103
151
|
|
|
104
152
|
- (void)didUpdateReactSubviews
|
|
105
153
|
{
|
|
106
|
-
[self
|
|
154
|
+
[self markChildUpdated];
|
|
107
155
|
}
|
|
108
156
|
|
|
109
157
|
- (void)layoutSubviews
|
|
@@ -116,13 +164,34 @@
|
|
|
116
164
|
@end
|
|
117
165
|
|
|
118
166
|
|
|
119
|
-
@implementation RNSScreenContainerManager
|
|
167
|
+
@implementation RNSScreenContainerManager {
|
|
168
|
+
NSMutableArray<RNSScreenContainerView *> *_markedContainers;
|
|
169
|
+
}
|
|
120
170
|
|
|
121
171
|
RCT_EXPORT_MODULE()
|
|
122
172
|
|
|
123
173
|
- (UIView *)view
|
|
124
174
|
{
|
|
125
|
-
|
|
175
|
+
if (!_markedContainers) {
|
|
176
|
+
_markedContainers = [NSMutableArray new];
|
|
177
|
+
}
|
|
178
|
+
return [[RNSScreenContainerView alloc] initWithManager:self];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
- (void)markUpdated:(RNSScreenContainerView *)screen
|
|
182
|
+
{
|
|
183
|
+
RCTAssertMainQueue();
|
|
184
|
+
[_markedContainers addObject:screen];
|
|
185
|
+
if ([_markedContainers count] == 1) {
|
|
186
|
+
// we enqueue updates to be run on the main queue in order to make sure that
|
|
187
|
+
// all this updates (new screens attached etc) are executed in one batch
|
|
188
|
+
RCTExecuteOnMainQueue(^{
|
|
189
|
+
for (RNSScreenContainerView *container in _markedContainers) {
|
|
190
|
+
[container updateContainer];
|
|
191
|
+
}
|
|
192
|
+
[_markedContainers removeAllObjects];
|
|
193
|
+
});
|
|
194
|
+
}
|
|
126
195
|
}
|
|
127
196
|
|
|
128
197
|
@end
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
10
|
448078F52114595900280661 /* RNSScreenContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 448078F12114595900280661 /* RNSScreenContainer.m */; };
|
|
11
|
-
448078F62114595900280661 /* RNSScreenStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 448078F32114595900280661 /* RNSScreenStack.m */; };
|
|
12
11
|
448078F72114595900280661 /* RNSScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 448078F42114595900280661 /* RNSScreen.m */; };
|
|
12
|
+
B5C32A47220C6379000FFB8D /* RNSScreen.m in Sources */ = {isa = PBXBuildFile; fileRef = 448078F42114595900280661 /* RNSScreen.m */; };
|
|
13
|
+
B5C32A48220C6379000FFB8D /* RNSScreenContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 448078F12114595900280661 /* RNSScreenContainer.m */; };
|
|
13
14
|
/* End PBXBuildFile section */
|
|
14
15
|
|
|
15
16
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -22,6 +23,15 @@
|
|
|
22
23
|
);
|
|
23
24
|
runOnlyForDeploymentPostprocessing = 0;
|
|
24
25
|
};
|
|
26
|
+
B5C32A4A220C6379000FFB8D /* CopyFiles */ = {
|
|
27
|
+
isa = PBXCopyFilesBuildPhase;
|
|
28
|
+
buildActionMask = 2147483647;
|
|
29
|
+
dstPath = "include/$(PRODUCT_NAME)";
|
|
30
|
+
dstSubfolderSpec = 16;
|
|
31
|
+
files = (
|
|
32
|
+
);
|
|
33
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
34
|
+
};
|
|
25
35
|
/* End PBXCopyFilesBuildPhase section */
|
|
26
36
|
|
|
27
37
|
/* Begin PBXFileReference section */
|
|
@@ -29,9 +39,8 @@
|
|
|
29
39
|
448078EF2114595900280661 /* RNSScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSScreen.h; sourceTree = "<group>"; };
|
|
30
40
|
448078F02114595900280661 /* RNSScreenContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSScreenContainer.h; sourceTree = "<group>"; };
|
|
31
41
|
448078F12114595900280661 /* RNSScreenContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSScreenContainer.m; sourceTree = "<group>"; };
|
|
32
|
-
448078F22114595900280661 /* RNSScreenStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNSScreenStack.h; sourceTree = "<group>"; };
|
|
33
|
-
448078F32114595900280661 /* RNSScreenStack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSScreenStack.m; sourceTree = "<group>"; };
|
|
34
42
|
448078F42114595900280661 /* RNSScreen.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNSScreen.m; sourceTree = "<group>"; };
|
|
43
|
+
B5C32A4F220C6379000FFB8D /* libRNScreens-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libRNScreens-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
35
44
|
/* End PBXFileReference section */
|
|
36
45
|
|
|
37
46
|
/* Begin PBXFrameworksBuildPhase section */
|
|
@@ -42,6 +51,13 @@
|
|
|
42
51
|
);
|
|
43
52
|
runOnlyForDeploymentPostprocessing = 0;
|
|
44
53
|
};
|
|
54
|
+
B5C32A49220C6379000FFB8D /* Frameworks */ = {
|
|
55
|
+
isa = PBXFrameworksBuildPhase;
|
|
56
|
+
buildActionMask = 2147483647;
|
|
57
|
+
files = (
|
|
58
|
+
);
|
|
59
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
60
|
+
};
|
|
45
61
|
/* End PBXFrameworksBuildPhase section */
|
|
46
62
|
|
|
47
63
|
/* Begin PBXGroup section */
|
|
@@ -60,9 +76,8 @@
|
|
|
60
76
|
448078F42114595900280661 /* RNSScreen.m */,
|
|
61
77
|
448078F02114595900280661 /* RNSScreenContainer.h */,
|
|
62
78
|
448078F12114595900280661 /* RNSScreenContainer.m */,
|
|
63
|
-
448078F22114595900280661 /* RNSScreenStack.h */,
|
|
64
|
-
448078F32114595900280661 /* RNSScreenStack.m */,
|
|
65
79
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
80
|
+
B5C32A4F220C6379000FFB8D /* libRNScreens-tvOS.a */,
|
|
66
81
|
);
|
|
67
82
|
sourceTree = "<group>";
|
|
68
83
|
};
|
|
@@ -86,13 +101,30 @@
|
|
|
86
101
|
productReference = 134814201AA4EA6300B7C361 /* libRNScreens.a */;
|
|
87
102
|
productType = "com.apple.product-type.library.static";
|
|
88
103
|
};
|
|
104
|
+
B5C32A45220C6379000FFB8D /* RNScreens-tvOS */ = {
|
|
105
|
+
isa = PBXNativeTarget;
|
|
106
|
+
buildConfigurationList = B5C32A4B220C6379000FFB8D /* Build configuration list for PBXNativeTarget "RNScreens-tvOS" */;
|
|
107
|
+
buildPhases = (
|
|
108
|
+
B5C32A46220C6379000FFB8D /* Sources */,
|
|
109
|
+
B5C32A49220C6379000FFB8D /* Frameworks */,
|
|
110
|
+
B5C32A4A220C6379000FFB8D /* CopyFiles */,
|
|
111
|
+
);
|
|
112
|
+
buildRules = (
|
|
113
|
+
);
|
|
114
|
+
dependencies = (
|
|
115
|
+
);
|
|
116
|
+
name = "RNScreens-tvOS";
|
|
117
|
+
productName = RCTDataManager;
|
|
118
|
+
productReference = B5C32A4F220C6379000FFB8D /* libRNScreens-tvOS.a */;
|
|
119
|
+
productType = "com.apple.product-type.library.static";
|
|
120
|
+
};
|
|
89
121
|
/* End PBXNativeTarget section */
|
|
90
122
|
|
|
91
123
|
/* Begin PBXProject section */
|
|
92
124
|
58B511D31A9E6C8500147676 /* Project object */ = {
|
|
93
125
|
isa = PBXProject;
|
|
94
126
|
attributes = {
|
|
95
|
-
LastUpgradeCheck =
|
|
127
|
+
LastUpgradeCheck = 920;
|
|
96
128
|
ORGANIZATIONNAME = Facebook;
|
|
97
129
|
TargetAttributes = {
|
|
98
130
|
58B511DA1A9E6C8500147676 = {
|
|
@@ -113,6 +145,7 @@
|
|
|
113
145
|
projectRoot = "";
|
|
114
146
|
targets = (
|
|
115
147
|
58B511DA1A9E6C8500147676 /* RNScreens */,
|
|
148
|
+
B5C32A45220C6379000FFB8D /* RNScreens-tvOS */,
|
|
116
149
|
);
|
|
117
150
|
};
|
|
118
151
|
/* End PBXProject section */
|
|
@@ -123,14 +156,38 @@
|
|
|
123
156
|
buildActionMask = 2147483647;
|
|
124
157
|
files = (
|
|
125
158
|
448078F72114595900280661 /* RNSScreen.m in Sources */,
|
|
126
|
-
448078F62114595900280661 /* RNSScreenStack.m in Sources */,
|
|
127
159
|
448078F52114595900280661 /* RNSScreenContainer.m in Sources */,
|
|
128
160
|
);
|
|
129
161
|
runOnlyForDeploymentPostprocessing = 0;
|
|
130
162
|
};
|
|
163
|
+
B5C32A46220C6379000FFB8D /* Sources */ = {
|
|
164
|
+
isa = PBXSourcesBuildPhase;
|
|
165
|
+
buildActionMask = 2147483647;
|
|
166
|
+
files = (
|
|
167
|
+
B5C32A47220C6379000FFB8D /* RNSScreen.m in Sources */,
|
|
168
|
+
B5C32A48220C6379000FFB8D /* RNSScreenContainer.m in Sources */,
|
|
169
|
+
);
|
|
170
|
+
runOnlyForDeploymentPostprocessing = 0;
|
|
171
|
+
};
|
|
131
172
|
/* End PBXSourcesBuildPhase section */
|
|
132
173
|
|
|
133
174
|
/* Begin XCBuildConfiguration section */
|
|
175
|
+
0CE596A6BAEE45CA860361AD /* Testflight */ = {
|
|
176
|
+
isa = XCBuildConfiguration;
|
|
177
|
+
buildSettings = {
|
|
178
|
+
HEADER_SEARCH_PATHS = (
|
|
179
|
+
"$(inherited)",
|
|
180
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
181
|
+
"$(SRCROOT)/../../../React/**",
|
|
182
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
183
|
+
);
|
|
184
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
185
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
186
|
+
PRODUCT_NAME = RNScreens;
|
|
187
|
+
SKIP_INSTALL = YES;
|
|
188
|
+
};
|
|
189
|
+
name = Testflight;
|
|
190
|
+
};
|
|
134
191
|
58B511ED1A9E6C8500147676 /* Debug */ = {
|
|
135
192
|
isa = XCBuildConfiguration;
|
|
136
193
|
buildSettings = {
|
|
@@ -256,6 +313,100 @@
|
|
|
256
313
|
};
|
|
257
314
|
name = Release;
|
|
258
315
|
};
|
|
316
|
+
B5C32A4C220C6379000FFB8D /* Debug */ = {
|
|
317
|
+
isa = XCBuildConfiguration;
|
|
318
|
+
buildSettings = {
|
|
319
|
+
HEADER_SEARCH_PATHS = (
|
|
320
|
+
"$(inherited)",
|
|
321
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
322
|
+
"$(SRCROOT)/../../../React/**",
|
|
323
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
324
|
+
);
|
|
325
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
326
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
327
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
328
|
+
SDKROOT = appletvos;
|
|
329
|
+
SKIP_INSTALL = YES;
|
|
330
|
+
};
|
|
331
|
+
name = Debug;
|
|
332
|
+
};
|
|
333
|
+
B5C32A4D220C6379000FFB8D /* Release */ = {
|
|
334
|
+
isa = XCBuildConfiguration;
|
|
335
|
+
buildSettings = {
|
|
336
|
+
HEADER_SEARCH_PATHS = (
|
|
337
|
+
"$(inherited)",
|
|
338
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
339
|
+
"$(SRCROOT)/../../../React/**",
|
|
340
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
341
|
+
);
|
|
342
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
343
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
344
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
345
|
+
SDKROOT = appletvos;
|
|
346
|
+
SKIP_INSTALL = YES;
|
|
347
|
+
};
|
|
348
|
+
name = Release;
|
|
349
|
+
};
|
|
350
|
+
B5C32A4E220C6379000FFB8D /* Testflight */ = {
|
|
351
|
+
isa = XCBuildConfiguration;
|
|
352
|
+
buildSettings = {
|
|
353
|
+
HEADER_SEARCH_PATHS = (
|
|
354
|
+
"$(inherited)",
|
|
355
|
+
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
|
|
356
|
+
"$(SRCROOT)/../../../React/**",
|
|
357
|
+
"$(SRCROOT)/../../react-native/React/**",
|
|
358
|
+
);
|
|
359
|
+
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
|
360
|
+
OTHER_LDFLAGS = "-ObjC";
|
|
361
|
+
PRODUCT_NAME = "$(TARGET_NAME)";
|
|
362
|
+
SDKROOT = appletvos;
|
|
363
|
+
SKIP_INSTALL = YES;
|
|
364
|
+
};
|
|
365
|
+
name = Testflight;
|
|
366
|
+
};
|
|
367
|
+
C7F03305A3464E75B4F5A6CE /* Testflight */ = {
|
|
368
|
+
isa = XCBuildConfiguration;
|
|
369
|
+
buildSettings = {
|
|
370
|
+
ALWAYS_SEARCH_USER_PATHS = NO;
|
|
371
|
+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
|
372
|
+
CLANG_CXX_LIBRARY = "libc++";
|
|
373
|
+
CLANG_ENABLE_MODULES = YES;
|
|
374
|
+
CLANG_ENABLE_OBJC_ARC = YES;
|
|
375
|
+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
|
376
|
+
CLANG_WARN_BOOL_CONVERSION = YES;
|
|
377
|
+
CLANG_WARN_COMMA = YES;
|
|
378
|
+
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
|
379
|
+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
|
380
|
+
CLANG_WARN_EMPTY_BODY = YES;
|
|
381
|
+
CLANG_WARN_ENUM_CONVERSION = YES;
|
|
382
|
+
CLANG_WARN_INFINITE_RECURSION = YES;
|
|
383
|
+
CLANG_WARN_INT_CONVERSION = YES;
|
|
384
|
+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
|
385
|
+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
|
386
|
+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
|
387
|
+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
|
388
|
+
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
|
389
|
+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
|
390
|
+
CLANG_WARN_UNREACHABLE_CODE = YES;
|
|
391
|
+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
|
392
|
+
COPY_PHASE_STRIP = YES;
|
|
393
|
+
ENABLE_NS_ASSERTIONS = NO;
|
|
394
|
+
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
|
395
|
+
GCC_C_LANGUAGE_STANDARD = gnu99;
|
|
396
|
+
GCC_NO_COMMON_BLOCKS = YES;
|
|
397
|
+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
|
398
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
|
399
|
+
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
|
400
|
+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
|
401
|
+
GCC_WARN_UNUSED_FUNCTION = YES;
|
|
402
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
403
|
+
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
|
404
|
+
MTL_ENABLE_DEBUG_INFO = NO;
|
|
405
|
+
SDKROOT = iphoneos;
|
|
406
|
+
VALIDATE_PRODUCT = YES;
|
|
407
|
+
};
|
|
408
|
+
name = Testflight;
|
|
409
|
+
};
|
|
259
410
|
/* End XCBuildConfiguration section */
|
|
260
411
|
|
|
261
412
|
/* Begin XCConfigurationList section */
|
|
@@ -264,6 +415,7 @@
|
|
|
264
415
|
buildConfigurations = (
|
|
265
416
|
58B511ED1A9E6C8500147676 /* Debug */,
|
|
266
417
|
58B511EE1A9E6C8500147676 /* Release */,
|
|
418
|
+
C7F03305A3464E75B4F5A6CE /* Testflight */,
|
|
267
419
|
);
|
|
268
420
|
defaultConfigurationIsVisible = 0;
|
|
269
421
|
defaultConfigurationName = Release;
|
|
@@ -273,6 +425,17 @@
|
|
|
273
425
|
buildConfigurations = (
|
|
274
426
|
58B511F01A9E6C8500147676 /* Debug */,
|
|
275
427
|
58B511F11A9E6C8500147676 /* Release */,
|
|
428
|
+
0CE596A6BAEE45CA860361AD /* Testflight */,
|
|
429
|
+
);
|
|
430
|
+
defaultConfigurationIsVisible = 0;
|
|
431
|
+
defaultConfigurationName = Release;
|
|
432
|
+
};
|
|
433
|
+
B5C32A4B220C6379000FFB8D /* Build configuration list for PBXNativeTarget "RNScreens-tvOS" */ = {
|
|
434
|
+
isa = XCConfigurationList;
|
|
435
|
+
buildConfigurations = (
|
|
436
|
+
B5C32A4C220C6379000FFB8D /* Debug */,
|
|
437
|
+
B5C32A4D220C6379000FFB8D /* Release */,
|
|
438
|
+
B5C32A4E220C6379000FFB8D /* Testflight */,
|
|
276
439
|
);
|
|
277
440
|
defaultConfigurationIsVisible = 0;
|
|
278
441
|
defaultConfigurationName = Release;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-screens",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"description": "First incomplete navigation solution for your react-native app.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "node node_modules/react-native/local-cli/cli.js start",
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
"lint": "eslint --fix './src/**/*.js'",
|
|
11
11
|
"precommit": "lint-staged"
|
|
12
12
|
},
|
|
13
|
-
"main": "src/screens
|
|
13
|
+
"main": "src/screens",
|
|
14
|
+
"types": "src/screens.d.ts",
|
|
14
15
|
"files": [
|
|
15
16
|
"src/",
|
|
16
17
|
"android/src/main/AndroidManifest.xml",
|
|
17
18
|
"android/src/main/java/",
|
|
18
19
|
"android/build.gradle",
|
|
19
20
|
"ios/",
|
|
21
|
+
"RNScreens.podspec",
|
|
20
22
|
"README.md"
|
|
21
23
|
],
|
|
22
24
|
"repository": {
|
|
@@ -33,10 +35,12 @@
|
|
|
33
35
|
"url": "https://github.com/kmagiera/react-native-screens/issues"
|
|
34
36
|
},
|
|
35
37
|
"homepage": "https://github.com/kmagiera/react-native-screens#readme",
|
|
36
|
-
"dependencies": {
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"debounce": "^1.2.0"
|
|
40
|
+
},
|
|
37
41
|
"peerDependencies": {
|
|
38
|
-
"react": "
|
|
39
|
-
"react-native": "
|
|
42
|
+
"react": "*",
|
|
43
|
+
"react-native": "*"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"babel-eslint": "^8.2.3",
|
|
@@ -45,8 +49,9 @@
|
|
|
45
49
|
"eslint": "^4.19.1",
|
|
46
50
|
"eslint-config-prettier": "^2.9.0",
|
|
47
51
|
"eslint-config-standard": "^11.0.0",
|
|
52
|
+
"eslint-plugin-flowtype": "^2.50.0",
|
|
48
53
|
"eslint-plugin-import": "^2.12.0",
|
|
49
|
-
"eslint-plugin-jest": "^21.
|
|
54
|
+
"eslint-plugin-jest": "^21.22.0",
|
|
50
55
|
"eslint-plugin-node": "^6.0.1",
|
|
51
56
|
"eslint-plugin-promise": "^3.8.0",
|
|
52
57
|
"eslint-plugin-react": "^7.9.1",
|
package/src/screens.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Project: https://github.com/kmagiera/react-native-screens
|
|
2
|
+
// TypeScript Version: 2.8
|
|
3
|
+
|
|
4
|
+
declare module 'react-native-screens' {
|
|
5
|
+
import { ComponentClass } from 'react';
|
|
6
|
+
import { ViewProps, Animated } from 'react-native';
|
|
7
|
+
|
|
8
|
+
export function useScreens(shouldUseScreens?: boolean): void;
|
|
9
|
+
export function screensEnabled(): boolean;
|
|
10
|
+
|
|
11
|
+
export interface ScreenProps extends ViewProps {
|
|
12
|
+
active?: 0 | 1 | Animated.AnimatedInterpolation;
|
|
13
|
+
onComponentRef?: (view: any) => void;
|
|
14
|
+
}
|
|
15
|
+
export const Screen: ComponentClass<ScreenProps>;
|
|
16
|
+
|
|
17
|
+
export type ScreenContainerProps = ViewProps;
|
|
18
|
+
export const ScreenContainer: ComponentClass<ScreenContainerProps>;
|
|
19
|
+
|
|
20
|
+
export const NativeScreen: ComponentClass<ScreenProps>;
|
|
21
|
+
export const NativeScreenContainer: ComponentClass<ScreenContainerProps>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
requireNativeComponent,
|
|
5
|
+
View,
|
|
6
|
+
UIManager,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
import { version } from 'react-native/Libraries/Core/ReactNativeVersion';
|
|
10
|
+
|
|
11
|
+
let USE_SCREENS = false;
|
|
12
|
+
|
|
13
|
+
// UIManager[`${moduleName}`] is deprecated in RN 0.58 and `getViewManagerConfig` is added.
|
|
14
|
+
// We can remove this when we drop support for RN < 0.58.
|
|
15
|
+
const getViewManagerConfigCompat = name =>
|
|
16
|
+
typeof UIManager.getViewManagerConfig !== 'undefined'
|
|
17
|
+
? UIManager.getViewManagerConfig(name)
|
|
18
|
+
: UIManager[name];
|
|
19
|
+
|
|
20
|
+
function useScreens(shouldUseScreens = true) {
|
|
21
|
+
USE_SCREENS = shouldUseScreens;
|
|
22
|
+
if (USE_SCREENS && !getViewManagerConfigCompat('RNSScreen')) {
|
|
23
|
+
console.error(
|
|
24
|
+
`Screen native module hasn't been linked. Please check the react-native-screens README for more details`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function screensEnabled() {
|
|
30
|
+
return USE_SCREENS;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// We initialize these lazily so that importing the module doesn't throw error when not linked
|
|
34
|
+
// This is necessary coz libraries such as React Navigation import the library where it may not be enabled
|
|
35
|
+
let NativeScreenValue;
|
|
36
|
+
let NativeScreenContainerValue;
|
|
37
|
+
let AnimatedNativeScreen;
|
|
38
|
+
|
|
39
|
+
const ScreensNativeModules = {
|
|
40
|
+
get NativeScreen() {
|
|
41
|
+
NativeScreenValue =
|
|
42
|
+
NativeScreenValue || requireNativeComponent('RNSScreen', null);
|
|
43
|
+
return NativeScreenValue;
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
get NativeScreenContainer() {
|
|
47
|
+
NativeScreenContainerValue =
|
|
48
|
+
NativeScreenContainerValue ||
|
|
49
|
+
requireNativeComponent('RNSScreenContainer', null);
|
|
50
|
+
return NativeScreenContainerValue;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
class Screen extends React.Component {
|
|
55
|
+
setNativeProps(props) {
|
|
56
|
+
this._ref.setNativeProps(props);
|
|
57
|
+
}
|
|
58
|
+
setRef = ref => {
|
|
59
|
+
this._ref = ref;
|
|
60
|
+
this.props.onComponentRef && this.props.onComponentRef(ref);
|
|
61
|
+
};
|
|
62
|
+
render() {
|
|
63
|
+
if (!USE_SCREENS) {
|
|
64
|
+
// Filter out active prop in this case because it is unused and
|
|
65
|
+
// can cause problems depending on react-native version:
|
|
66
|
+
// https://github.com/react-navigation/react-navigation/issues/4886
|
|
67
|
+
|
|
68
|
+
/* eslint-disable no-unused-vars */
|
|
69
|
+
const { active, onComponentRef, ...props } = this.props;
|
|
70
|
+
|
|
71
|
+
return <Animated.View {...props} ref={this.setRef} />;
|
|
72
|
+
} else {
|
|
73
|
+
AnimatedNativeScreen =
|
|
74
|
+
AnimatedNativeScreen ||
|
|
75
|
+
Animated.createAnimatedComponent(ScreensNativeModules.NativeScreen);
|
|
76
|
+
|
|
77
|
+
if (version.minor >= 57) {
|
|
78
|
+
return <AnimatedNativeScreen {...this.props} ref={this.setRef} />;
|
|
79
|
+
} else {
|
|
80
|
+
// On RN version below 0.57 we need to wrap screen's children with an
|
|
81
|
+
// additional View because of a bug fixed in react-native/pull/20658 which
|
|
82
|
+
// was preventing a view from having both styles and some other props being
|
|
83
|
+
// "animated" (using Animated native driver)
|
|
84
|
+
const { style, children, ...rest } = this.props;
|
|
85
|
+
return (
|
|
86
|
+
<AnimatedNativeScreen
|
|
87
|
+
{...rest}
|
|
88
|
+
ref={this.setRef}
|
|
89
|
+
style={StyleSheet.absoluteFill}>
|
|
90
|
+
<Animated.View style={style}>{children}</Animated.View>
|
|
91
|
+
</AnimatedNativeScreen>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
class ScreenContainer extends React.Component {
|
|
99
|
+
render() {
|
|
100
|
+
if (!USE_SCREENS) {
|
|
101
|
+
return <View {...this.props} />;
|
|
102
|
+
} else {
|
|
103
|
+
return <ScreensNativeModules.NativeScreenContainer {...this.props} />;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = {
|
|
109
|
+
ScreenContainer,
|
|
110
|
+
Screen,
|
|
111
|
+
get NativeScreen() {
|
|
112
|
+
return ScreensNativeModules.NativeScreen;
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
get NativeScreenContainer() {
|
|
116
|
+
return ScreensNativeModules.NativeScreenContainer;
|
|
117
|
+
},
|
|
118
|
+
useScreens,
|
|
119
|
+
screensEnabled,
|
|
120
|
+
};
|