mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-10 09:13:43 +08:00
Fix header transition on Android. (#284)
This change prevents toolbar from updating when there is a transition happening to the view. This fixes the issue where header subviews would disappear when going back from a given screen. The root cause was that the config view manager would trigger subviews removal and re-layout itself. As aresult if we had a custom back button that back button would get removed and the title would move into its place while the screen animation is running. In order to prevent that we hook into View Manager's onDropViewInstance to notify header config that it is about to be destroyed. This in turn prevents any updates to be made to the toolbar config.
This commit is contained in:
committed by
GitHub
parent
27ef6dc900
commit
f21ec66cb4
@@ -33,6 +33,7 @@ public class ScreenStackHeaderConfig extends ViewGroup {
|
||||
private boolean mGestureEnabled = true;
|
||||
private boolean mIsBackButtonHidden;
|
||||
private boolean mIsShadowHidden;
|
||||
private boolean mDestroyed;
|
||||
private int mTintColor;
|
||||
private final Toolbar mToolbar;
|
||||
|
||||
@@ -63,6 +64,10 @@ public class ScreenStackHeaderConfig extends ViewGroup {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
mDestroyed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
@@ -116,7 +121,7 @@ public class ScreenStackHeaderConfig extends ViewGroup {
|
||||
boolean isRoot = stack == null ? true : stack.getRootScreen() == parent;
|
||||
boolean isTop = stack == null ? true : stack.getTopScreen() == parent;
|
||||
|
||||
if (!mIsAttachedToWindow || !isTop) {
|
||||
if (!mIsAttachedToWindow || !isTop || mDestroyed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -225,7 +230,7 @@ public class ScreenStackHeaderConfig extends ViewGroup {
|
||||
}
|
||||
|
||||
private void maybeUpdate() {
|
||||
if (getParent() != null) {
|
||||
if (getParent() != null && !mDestroyed) {
|
||||
onUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user