Search in sources :

Example 1 with BottomTabOptions

use of com.reactnativenavigation.options.BottomTabOptions in project react-native-navigation by wix.

the class BottomTabsController method onTabSelected.

@Override
public boolean onTabSelected(int index, boolean wasSelected) {
    ViewController<?> stack = tabs.get(index);
    BottomTabOptions options = stack.resolveCurrentOptions().bottomTabOptions;
    eventEmitter.emitBottomTabPressed(index);
    if (options.selectTabOnPress.get(true)) {
        eventEmitter.emitBottomTabSelected(bottomTabs.getCurrentItem(), index);
        if (!wasSelected) {
            selectTab(index);
        }
    }
    if (options.popToRoot.get(false) && wasSelected && stack instanceof StackController) {
        ((StackController) stack).popToRoot(Options.EMPTY, new CommandListenerAdapter());
    }
    return false;
}
Also used : StackController(com.reactnativenavigation.viewcontrollers.stack.StackController) BottomTabOptions(com.reactnativenavigation.options.BottomTabOptions) CommandListenerAdapter(com.reactnativenavigation.react.CommandListenerAdapter)

Example 2 with BottomTabOptions

use of com.reactnativenavigation.options.BottomTabOptions in project react-native-navigation by wix.

the class BottomTabPresenter method onConfigurationChanged.

public void onConfigurationChanged(Options options) {
    bottomTabs.perform(bottomTabs -> {
        for (int i = 0; i < tabs.size(); i++) {
            BottomTabOptions tab = tabs.get(i).resolveCurrentOptions(defaultOptions).bottomTabOptions;
            if (tab.selectedIconColor.canApplyValue())
                bottomTabs.setIconActiveColor(i, tab.selectedIconColor.get(null));
            if (tab.iconColor.canApplyValue())
                bottomTabs.setIconInactiveColor(i, tab.iconColor.get(null));
            bottomTabs.setTitleActiveColor(i, tab.selectedTextColor.get(null));
            bottomTabs.setTitleInactiveColor(i, tab.textColor.get(null));
            if (shouldApplyDot(tab))
                applyDotIndicator(i, tab.dotIndicator);
            if (tab.badge.hasValue())
                applyBadge(i, tab);
        }
    });
}
Also used : BottomTabOptions(com.reactnativenavigation.options.BottomTabOptions)

Example 3 with BottomTabOptions

use of com.reactnativenavigation.options.BottomTabOptions in project react-native-navigation by wix.

the class BottomTabPresenter method applyOptions.

public void applyOptions() {
    bottomTabs.perform(bottomTabs -> {
        for (int i = 0; i < tabs.size(); i++) {
            BottomTabOptions tab = tabs.get(i).resolveCurrentOptions(defaultOptions).bottomTabOptions;
            bottomTabs.setIconWidth(i, tab.iconWidth.get(null));
            bottomTabs.setIconHeight(i, tab.iconHeight.get(null));
            bottomTabs.setTitleTypeface(i, tab.font.getTypeface(typefaceLoader, defaultTypeface));
            if (tab.selectedIconColor.canApplyValue())
                bottomTabs.setIconActiveColor(i, tab.selectedIconColor.get(null));
            if (tab.iconColor.canApplyValue())
                bottomTabs.setIconInactiveColor(i, tab.iconColor.get(null));
            bottomTabs.setTitleActiveColor(i, tab.selectedTextColor.get(null));
            bottomTabs.setTitleInactiveColor(i, tab.textColor.get(null));
            if (tab.fontSize.hasValue())
                bottomTabs.setTitleInactiveTextSizeInSp(i, Float.valueOf(tab.fontSize.get()));
            if (tab.selectedFontSize.hasValue())
                bottomTabs.setTitleActiveTextSizeInSp(i, Float.valueOf(tab.selectedFontSize.get()));
            if (tab.testId.hasValue())
                bottomTabs.setTag(i, tab.testId.get());
            if (shouldApplyDot(tab))
                applyDotIndicator(i, tab.dotIndicator);
            if (tab.badge.hasValue())
                applyBadge(i, tab);
        }
    });
}
Also used : BottomTabOptions(com.reactnativenavigation.options.BottomTabOptions)

Aggregations

BottomTabOptions (com.reactnativenavigation.options.BottomTabOptions)3 CommandListenerAdapter (com.reactnativenavigation.react.CommandListenerAdapter)1 StackController (com.reactnativenavigation.viewcontrollers.stack.StackController)1