use of com.codename1.rad.controllers.ViewController in project CodeRAD by shannah.
the class FloatingActionButtonBuilder method build.
@Override
public FloatingActionButton build() {
if (icon == 0)
icon = FontImage.MATERIAL_ADD;
FloatingActionButton out;
if (uiid == null) {
out = FloatingActionButton.createFAB(icon);
} else {
out = FloatingActionButton.createFAB(icon, uiid);
}
// We don't want the fab added to the direct parent.
doNotAddToParentContainer(out);
EntityView ev = getContext().getEntityView();
if (ev != null) {
// Register a decorator that will be executed when the ViewController calls setView()
// This is when we will wrap the target element
getContext().getController().addViewDecorator(cmp -> {
if (done)
return cmp;
done = true;
Component parentContainer = getParentContainer();
if (target != null) {
Component targetComponent = $(target, (Container) getContext().getEntityView()).asComponent();
if (targetComponent != null) {
parentContainer = targetComponent;
}
}
// TODO: We have problems here due to new structure of a Root ViewController
Container parentParent = parentContainer.getParent();
if (parentParent != null) {
Container dummy = new Container();
parentParent.replace(parentContainer, dummy, null);
Container wrapped = out.bindFabToContainer(parentContainer);
parentParent.replace(dummy, wrapped, null);
} else {
Container bound = out.bindFabToContainer(parentContainer);
if (parentContainer == cmp) {
return bound;
}
}
return cmp;
});
}
return out;
}
Aggregations