Compare commits

..

3 Commits

Author SHA1 Message Date
Krzysztof Magiera
953b3b30db Bump version -> 2.0.0-beta.8 2020-02-19 15:37:10 +01:00
Grzegorz Mandziak
e50b7eae72 check object instance of before calling detachScreen (#344)
Fixes #343 

This change filters out non ScreenFragment instances when iterating through the list of installed fragments. The reason why other fragments can be added to the manager is that some libraries (e.g. glide) use fragment manager to store screen local data and attach to the screen lifecycle.
2020-02-19 15:30:58 +01:00
Krzysztof Magiera
0e00f49e69 Fix updating push native stack to avoid mid-transition related b… (#347)
This change addresses two problem. First was related to header subviews that were not laid out properly before we installed them in the header. This was causing occasional bugs where the header subviews were misplaced. The fix was to enforce container update run after layout is done (we enqueue update on ui thread directly from didUpdateReactSubviews).

The second problem was related to UINavController nlifecycle methods not triggering correctly in case when updates are being made to the nav controller which isn't mounted. Previously we fixed similar issue for modal controllers where because of the fact container wasn't mounted we couldn't run modal screen updates. With push controllers the problem is very similar however the VC do update just stop getting proper lifecycle updates and warning "Unbalanced calls to begin/end appearance transitions" is displayed. The fix was similar as in the modal case, that is, we wait until container is installed in window.
2020-02-19 15:22:55 +01:00
3 changed files with 16 additions and 5 deletions

View File

@@ -252,7 +252,9 @@ public class ScreenContainer<T extends ScreenFragment> extends ViewGroup {
if (!orphaned.isEmpty()) {
Object[] orphanedAry = orphaned.toArray();
for (int i = 0; i < orphanedAry.length; i++) {
detachScreen((ScreenFragment) orphanedAry[i]);
if (orphanedAry[i] instanceof ScreenFragment) {
detachScreen((ScreenFragment) orphanedAry[i]);
}
}
}

View File

@@ -22,7 +22,6 @@
@end
@implementation RNSScreenStackView {
BOOL _needUpdate;
UINavigationController *_controller;
NSMutableArray<RNSScreenView *> *_reactSubviews;
NSMutableSet<RNSScreenView *> *_dismissedScreens;
@@ -38,7 +37,6 @@
_dismissedScreens = [NSMutableSet new];
_controller = [[UINavigationController alloc] init];
_controller.delegate = self;
_needUpdate = NO;
[self addSubview:_controller.view];
_controller.interactivePopGestureRecognizer.delegate = self;
@@ -164,7 +162,12 @@
- (void)didUpdateReactSubviews
{
[self updateContainer];
// we need to wait until children have their layout set. At this point they don't have the layout
// set yet, however the layout call is already enqueued on ui thread. Enqueuing update call on the
// ui queue will guarantee that the update will run after layout.
dispatch_async(dispatch_get_main_queue(), ^{
[self updateContainer];
});
}
- (void)didMoveToWindow
@@ -281,6 +284,12 @@
return;
}
// if view controller is not yet attached to window we skip updates now and run them when view
// is attached
if (self.window == nil) {
return;
}
UIViewController *top = controllers.lastObject;
UIViewController *lastTop = _controller.viewControllers.lastObject;

View File

@@ -1,6 +1,6 @@
{
"name": "react-native-screens",
"version": "2.0.0-beta.7",
"version": "2.0.0-beta.8",
"description": "First incomplete navigation solution for your react-native app.",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",