Skip to content

Commit

Permalink
Revert "Fix navbar window fitting on Android. (#235)"
Browse files Browse the repository at this point in the history
This reverts commit 0927e03.
  • Loading branch information
kmagiera committed Nov 27, 2019
1 parent cbc86bb commit 4f8efd2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
31 changes: 1 addition & 30 deletions android/src/main/java/com/swmansion/rnscreens/ScreenStack.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.swmansion.rnscreens;

import android.content.Context;
import android.view.View;

import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
Expand Down Expand Up @@ -45,15 +42,6 @@ public void onFragmentResumed(FragmentManager fm, Fragment f) {

public ScreenStack(Context context) {
super(context);

ViewCompat.setOnApplyWindowInsetsListener(this,
new androidx.core.view.OnApplyWindowInsetsListener() {
@Override
public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
setWindowInsets(insets);
return insets;
}
});
}

public void dismiss(ScreenStackFragment screenFragment) {
Expand All @@ -75,24 +63,6 @@ public Screen getRootScreen() {
throw new IllegalStateException("Stack has no root screen set");
}

private void setWindowInsets(WindowInsetsCompat insets) {
// we allow each screen to handle insets separately as they are all attached to the same parent
// and take up full screen. Therefore we make a copy of each inset object before passing it down
// to views.
boolean consumed = false;
for (int i = mScreenFragments.size() - 1; i >= 0; i--) {
ScreenStackFragment screen = mScreenFragments.get(i);
if (!mDismissed.contains(screen) && screen.getView() != null) {
if (ViewCompat.dispatchApplyWindowInsets(screen.getView(), new WindowInsetsCompat(insets)).isConsumed()) {
consumed = true;
}
}
}
if (consumed) {
insets.consumeSystemWindowInsets();
}
}

@Override
protected ScreenStackFragment adapt(Screen screen) {
return new ScreenStackFragment(screen);
Expand All @@ -111,6 +81,7 @@ protected void onDetachedFromWindow() {
// longer attached.
fm.popBackStack(BACK_STACK_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,20 @@ public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
CoordinatorLayout view = new CoordinatorLayout(getContext());
view.setFitsSystemWindows(true);
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
mScreenView.setLayoutParams(params);
view.addView(mScreenView);

mAppBarLayout = new AppBarLayout(getContext());
mAppBarLayout.setFitsSystemWindows(true);
// By default AppBarLayout will have a background color set but since we cover the whole layout
// with toolbar (that can be semi-transparent) the bar layout background color does not pay a
// role. On top of that it breaks screens animations when alfa offscreen compositing is off
// (which is the default)
mAppBarLayout.setBackgroundColor(Color.TRANSPARENT);
mAppBarLayout.setLayoutParams(new AppBarLayout.LayoutParams(
AppBarLayout.LayoutParams.MATCH_PARENT,
AppBarLayout.LayoutParams.WRAP_CONTENT));
AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.WRAP_CONTENT));
view.addView(mAppBarLayout);

if (mToolbar != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public ScreenStackHeaderConfig(Context context) {
setVisibility(View.GONE);

mToolbar = new Toolbar(context);
mToolbar.setFitsSystemWindows(true);

// set primary color as background by default
TypedValue tv = new TypedValue();
Expand Down

1 comment on commit 4f8efd2

@tankers746
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this reverted?

Please sign in to comment.