mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-30 22:50:22 +08:00
* Let UINavController control subcontroller view's frames. This PR changes the way we've been handling yoga <> NavController layout interactions. Now we ignore frame updates coming from react for the main Screen view to allow NavController take the controll. In order to keep yoga working we now use `setSize` to pass the dimensions of the view back to yoga such that it can properly calculate layout of the views under Screen component. * Header resizing fixes for Android. In this change we use CoordinatorLayout as a stack screen container to handle rendering of toolbar and screen content. Thanks to this approach we can support collapsable bars in the future. Instead of relying on RN to layout screen container when renered under ScreenStack we rely on Android native layout to measure and position screen content and then use UIManager.setNodeSize to communicate that back to react.
68 lines
1.8 KiB
Java
68 lines
1.8 KiB
Java
package com.swmansion.rnscreens;
|
|
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import com.facebook.react.module.annotations.ReactModule;
|
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
|
|
@ReactModule(name = ScreenStackViewManager.REACT_CLASS)
|
|
public class ScreenStackViewManager extends ViewGroupManager<ScreenStack> {
|
|
|
|
protected static final String REACT_CLASS = "RNSScreenStack";
|
|
|
|
@Override
|
|
public String getName() {
|
|
return REACT_CLASS;
|
|
}
|
|
|
|
@Override
|
|
protected ScreenStack createViewInstance(ThemedReactContext reactContext) {
|
|
return new ScreenStack(reactContext);
|
|
}
|
|
|
|
@Override
|
|
public void addView(ScreenStack parent, View child, int index) {
|
|
if (!(child instanceof Screen)) {
|
|
throw new IllegalArgumentException("Attempt attach child that is not of type RNScreen");
|
|
}
|
|
parent.addScreen((Screen) child, index);
|
|
}
|
|
|
|
@Override
|
|
public void removeViewAt(ScreenStack parent, int index) {
|
|
prepareOutTransition(parent.getScreenAt(index));
|
|
parent.removeScreenAt(index);
|
|
}
|
|
|
|
private void prepareOutTransition(Screen screen) {
|
|
startTransitionRecursive(screen);
|
|
}
|
|
|
|
private void startTransitionRecursive(ViewGroup parent) {
|
|
for (int i = 0, size = parent.getChildCount(); i < size; i++) {
|
|
View child = parent.getChildAt(i);
|
|
parent.startViewTransition(child);
|
|
if (child instanceof ViewGroup) {
|
|
startTransitionRecursive((ViewGroup) child);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getChildCount(ScreenStack parent) {
|
|
return parent.getScreenCount();
|
|
}
|
|
|
|
@Override
|
|
public View getChildAt(ScreenStack parent, int index) {
|
|
return parent.getScreenAt(index);
|
|
}
|
|
|
|
@Override
|
|
public boolean needsCustomLayoutForChildren() {
|
|
return true;
|
|
}
|
|
}
|