Search in sources :

Example 1 with ParentController

use of com.reactnativenavigation.viewcontrollers.parent.ParentController in project react-native-navigation by wix.

the class Presenter method applyBackgroundColor.

private void applyBackgroundColor(ViewController view, Options options) {
    if (options.layout.backgroundColor.hasValue()) {
        if (view instanceof Navigator)
            return;
        LayerDrawable ld = new LayerDrawable(new Drawable[] { new ColorDrawable(options.layout.backgroundColor.get()) });
        int top = view.resolveCurrentOptions().statusBar.drawBehind.isTrue() ? 0 : SystemUiUtils.getStatusBarHeight(view.getActivity());
        if (!(view instanceof ParentController)) {
            MarginLayoutParams lp = (MarginLayoutParams) view.getView().getLayoutParams();
            if (lp.topMargin != 0)
                top = 0;
        }
        ld.setLayerInset(0, 0, top, 0, 0);
        view.getView().setBackground(ld);
    }
}
Also used : ParentController(com.reactnativenavigation.viewcontrollers.parent.ParentController) ColorDrawable(android.graphics.drawable.ColorDrawable) Navigator(com.reactnativenavigation.viewcontrollers.navigator.Navigator) LayerDrawable(android.graphics.drawable.LayerDrawable) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)1 LayerDrawable (android.graphics.drawable.LayerDrawable)1 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)1 Navigator (com.reactnativenavigation.viewcontrollers.navigator.Navigator)1 ParentController (com.reactnativenavigation.viewcontrollers.parent.ParentController)1