use of com.reactnativenavigation.views.stack.fab.Fab in project react-native-navigation by wix.
the class FabPresenter method createFab.
private void createFab(ViewController<?> component, FabOptions options) {
ViewExtensionsKt.removeFromParent(fabMenu);
ViewExtensionsKt.removeFromParent(fab);
if (options.actionsArray.size() > 0) {
fabMenu = new FabMenu(viewGroup.getContext(), options.id.get());
setParams(component, fabMenu, options);
applyFabMenuOptions(component, fabMenu, options);
viewGroup.addView(fabMenu);
} else {
fab = new Fab(viewGroup.getContext(), options.id.get());
setParams(component, fab, options);
applyFabOptions(component, fab, options);
viewGroup.addView(fab);
fab.setOnClickListener(v -> component.sendOnNavigationButtonPressed(options.id.get()));
UiUtils.doOnLayout(fab, () -> {
fab.setPivotX(fab.getWidth() / 2f);
fab.setPivotY(fab.getHeight() / 2f);
});
}
}
use of com.reactnativenavigation.views.stack.fab.Fab in project react-native-navigation by wix.
the class FabPresenter method applyFabMenuOptions.
private void applyFabMenuOptions(ViewController<?> component, FabMenu fabMenu, FabOptions options) {
if (options.visible.isTrueOrUndefined()) {
fabMenu.showMenuButton(true);
}
if (options.visible.isFalse()) {
fabMenu.hideMenuButton(true);
}
if (options.backgroundColor.hasValue()) {
fabMenu.setMenuButtonColorNormal(options.backgroundColor.get());
}
if (options.clickColor.hasValue()) {
fabMenu.setMenuButtonColorPressed(options.clickColor.get());
}
if (options.rippleColor.hasValue()) {
fabMenu.setMenuButtonColorRipple(options.rippleColor.get());
}
for (Fab fabStored : fabMenu.getActions()) {
fabMenu.removeMenuButton(fabStored);
}
fabMenu.getActions().clear();
for (FabOptions fabOption : options.actionsArray) {
Fab fab = new Fab(viewGroup.getContext(), fabOption.id.get());
applyFabOptions(component, fab, fabOption);
fab.setOnClickListener(v -> component.sendOnNavigationButtonPressed(options.id.get()));
fabMenu.getActions().add(fab);
fabMenu.addMenuButton(fab);
}
if (options.hideOnScroll.isTrue()) {
fabMenu.enableCollapse(component.getScrollEventListener());
}
if (options.hideOnScroll.isFalseOrUndefined()) {
fabMenu.disableCollapse();
}
}
use of com.reactnativenavigation.views.stack.fab.Fab in project react-native-navigation by wix.
the class FabPresenter method mergeFabMenuOptions.
private void mergeFabMenuOptions(ViewController<?> component, FabMenu fabMenu, FabOptions options) {
if (options.visible.isTrue()) {
fabMenu.showMenuButton(true);
}
if (options.visible.isFalse()) {
fabMenu.hideMenuButton(true);
}
if (options.backgroundColor.hasValue()) {
fabMenu.setMenuButtonColorNormal(options.backgroundColor.get());
}
if (options.clickColor.hasValue()) {
fabMenu.setMenuButtonColorPressed(options.clickColor.get());
}
if (options.rippleColor.hasValue()) {
fabMenu.setMenuButtonColorRipple(options.rippleColor.get());
}
if (options.actionsArray.size() > 0) {
for (Fab fabStored : fabMenu.getActions()) {
fabMenu.removeMenuButton(fabStored);
}
fabMenu.getActions().clear();
for (FabOptions fabOption : options.actionsArray) {
Fab fab = new Fab(viewGroup.getContext(), fabOption.id.get());
applyFabOptions(component, fab, fabOption);
fab.setOnClickListener(v -> component.sendOnNavigationButtonPressed(options.id.get()));
fabMenu.getActions().add(fab);
fabMenu.addMenuButton(fab);
}
}
if (options.hideOnScroll.isTrue()) {
fabMenu.enableCollapse(component.getScrollEventListener());
}
if (options.hideOnScroll.isFalse()) {
fabMenu.disableCollapse();
}
}
Aggregations