Search in sources :

Example 11 with ViewController

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;
}
Also used : Container(com.codename1.ui.Container) EntityView(com.codename1.rad.ui.EntityView) FloatingActionButton(com.codename1.components.FloatingActionButton) Component(com.codename1.ui.Component)

Aggregations

Form (com.codename1.ui.Form)5 Component (com.codename1.ui.Component)4 Entity (com.codename1.rad.models.Entity)3 Log (com.codename1.io.Log)2 NetworkEvent (com.codename1.io.NetworkEvent)2 ViewController (com.codename1.rad.controllers.ViewController)2 EntityList (com.codename1.rad.models.EntityList)2 EntityTypeBuilder.entityTypeBuilder (com.codename1.rad.models.EntityTypeBuilder.entityTypeBuilder)2 ActionNode (com.codename1.rad.nodes.ActionNode)2 ListNode (com.codename1.rad.nodes.ListNode)2 Thing (com.codename1.rad.schemas.Thing)2 UI (com.codename1.rad.ui.UI)2 ProfileListView (com.codename1.rad.ui.entityviews.ProfileListView)2 CN (com.codename1.ui.CN)2 Dialog (com.codename1.ui.Dialog)2 Display (com.codename1.ui.Display)2 FontImage (com.codename1.ui.FontImage)2 Label (com.codename1.ui.Label)2 Toolbar (com.codename1.ui.Toolbar)2 BorderLayout (com.codename1.ui.layouts.BorderLayout)2