Search in sources :

Example 1 with SwipeableContainer

use of com.codename1.ui.SwipeableContainer in project CodenameOne by codenameone.

the class SwipableContainerTest2766 method start.

public void start() {
    // TEST: SWIPEABLE CONTAINER ALSO SWIPES UNDERLYING CONTAINER AS WELL
    Form hi = new Form("Welcome", new BorderLayout());
    Container list = new Container(BoxLayout.y());
    for (int i = 0; i < 20; i++) {
        SwipeableContainer swip = new SwipeableContainer(null, new Label("SWIPE"), new Label("ListElement " + i + " + a lot of fill text to make the element span over several lines so the dragging of the underlying Swipeable is normally noticeable"));
        list.add(swip);
    }
    list.setScrollableY(true);
    Container cont = hi.getContentPane();
    cont.add(BorderLayout.CENTER, list);
    SwipeableContainer swip = new SwipeableContainer(null, new SpanLabel("SOUTHSWIPE"), new SpanLabel("SOUTH CONTAINER"));
    cont.add(BorderLayout.SOUTH, swip);
    hi.show();
}
Also used : Container(com.codename1.ui.Container) SwipeableContainer(com.codename1.ui.SwipeableContainer) BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) SpanLabel(com.codename1.components.SpanLabel) Label(com.codename1.ui.Label) SwipeableContainer(com.codename1.ui.SwipeableContainer) SpanLabel(com.codename1.components.SpanLabel)

Example 2 with SwipeableContainer

use of com.codename1.ui.SwipeableContainer in project CodenameOne by codenameone.

the class LeadComponentScrollingTest3079 method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    int len = 100;
    for (int i = 0; i < len; i++) {
        Container cnt = new Container(new FlowLayout());
        $(cnt).selectAllStyles().setBgTransparency(0xff).setBgColor(0xffffff);
        SwipeableContainer sc = new SwipeableContainer(BoxLayout.encloseX(new Button("This is a button")), BoxLayout.encloseX(new Button("This is another button")), cnt);
        Button b = new Button("Button " + i);
        b.addActionListener(evt -> {
            System.out.println("button pressed");
        });
        cnt.add(b);
        cnt.setLeadComponent(b);
        hi.add(sc);
    }
    hi.setScrollableY(true);
    hi.add(new Label("Hi World"));
    hi.show();
}
Also used : Container(com.codename1.ui.Container) SwipeableContainer(com.codename1.ui.SwipeableContainer) FlowLayout(com.codename1.ui.layouts.FlowLayout) Form(com.codename1.ui.Form) Button(com.codename1.ui.Button) Label(com.codename1.ui.Label) SwipeableContainer(com.codename1.ui.SwipeableContainer)

Example 3 with SwipeableContainer

use of com.codename1.ui.SwipeableContainer in project CodeRAD by shannah.

the class DefaultEntityListCellRenderer method makeSwipeable.

private EntityView makeSwipeable(Entity entity, ViewNode node, Component view) {
    // Check for swipeable container
    SwipeContainer swipe = (SwipeContainer) node.findAttribute(SwipeContainer.class);
    if (swipe != null) {
        EntityView leftCnt = null;
        EntityView rightCnt = null;
        ViewNode leftNode = swipe.getLeft();
        if (leftNode != null) {
            leftCnt = leftNode.createView(entity);
        }
        ViewNode rightNode = swipe.getRight();
        if (rightNode != null) {
            rightCnt = rightNode.createView(entity);
        }
        SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
        return new WrapperEntityView(swipeWrapper, entity, node);
    }
    ActionNode deleteAction = node.getInheritedAction(ActionCategories.LIST_REMOVE_ACTION);
    Actions leftSwipeActions = node.getActions(ActionCategories.LEFT_SWIPE_MENU);
    if (deleteAction != null) {
        leftSwipeActions.add(deleteAction);
    }
    Actions rightSwipeActions = node.getActions(ActionCategories.RIGHT_SWIPE_MENU);
    if (!leftSwipeActions.isEmpty() || !rightSwipeActions.isEmpty()) {
        Container leftCnt = null;
        Container rightCnt = null;
        if (!leftSwipeActions.isEmpty()) {
            leftCnt = new Container(new GridLayout(leftSwipeActions.size()));
            for (ActionNode action : leftSwipeActions) {
                leftCnt.add(action.getViewFactory().createActionView(entity, action));
            }
        }
        if (!rightSwipeActions.isEmpty()) {
            rightCnt = new Container(new GridLayout(rightSwipeActions.size()));
            for (ActionNode action : rightSwipeActions) {
                rightCnt.add(action.getViewFactory().createActionView(entity, action));
            }
        }
        SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
        return new WrapperEntityView(swipeWrapper, entity, node);
    } else {
    // System.out.println("Swipe actions not present");
    }
    return (EntityView) view;
}
Also used : WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) SwipeContainer(com.codename1.rad.nodes.SwipeContainer) SwipeableContainer(com.codename1.ui.SwipeableContainer) Container(com.codename1.ui.Container) GridLayout(com.codename1.ui.layouts.GridLayout) WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) MultiButtonEntityView(com.codename1.rad.ui.entityviews.MultiButtonEntityView) ActionNode(com.codename1.rad.nodes.ActionNode) ViewNode(com.codename1.rad.nodes.ViewNode) SwipeableContainer(com.codename1.ui.SwipeableContainer) SwipeContainer(com.codename1.rad.nodes.SwipeContainer)

Example 4 with SwipeableContainer

use of com.codename1.ui.SwipeableContainer in project CodeRAD by shannah.

the class DefaultEntityViewFactory method makeSwipeable.

private EntityView makeSwipeable(Entity entity, ViewNode node, Component view) {
    // Check for swipeable container
    SwipeContainer swipe = (SwipeContainer) node.findAttribute(SwipeContainer.class);
    if (swipe != null) {
        EntityView leftCnt = null;
        EntityView rightCnt = null;
        ViewNode leftNode = swipe.getLeft();
        if (leftNode != null) {
            leftCnt = leftNode.createView(entity, this);
        }
        ViewNode rightNode = swipe.getRight();
        if (rightNode != null) {
            rightCnt = rightNode.createView(entity, this);
        }
        SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
        return new WrapperEntityView(swipeWrapper, entity, node);
    }
    Actions leftSwipeActions = node.getActions(ActionCategories.LEFT_SWIPE_MENU);
    Actions rightSwipeActions = node.getActions(ActionCategories.RIGHT_SWIPE_MENU);
    if (!leftSwipeActions.isEmpty() || !rightSwipeActions.isEmpty()) {
        Container leftCnt = null;
        Container rightCnt = null;
        if (!leftSwipeActions.isEmpty()) {
            leftCnt = new Container(BoxLayout.y());
            NodeUtilFunctions.buildActionsBar(node, leftCnt, entity, null, leftSwipeActions, null);
        }
        if (!rightSwipeActions.isEmpty()) {
            rightCnt = new Container(BoxLayout.y());
            NodeUtilFunctions.buildActionsBar(node, leftCnt, entity, rightSwipeActions, null, null);
        }
        SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
        return new WrapperEntityView(swipeWrapper, entity, node);
    }
    return (EntityView) view;
}
Also used : WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) Container(com.codename1.ui.Container) SwipeContainer(com.codename1.rad.nodes.SwipeContainer) SwipeableContainer(com.codename1.ui.SwipeableContainer) WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) MultiButtonEntityView(com.codename1.rad.ui.entityviews.MultiButtonEntityView) ViewNode(com.codename1.rad.nodes.ViewNode) SwipeableContainer(com.codename1.ui.SwipeableContainer) SwipeContainer(com.codename1.rad.nodes.SwipeContainer)

Aggregations

Container (com.codename1.ui.Container)4 SwipeableContainer (com.codename1.ui.SwipeableContainer)4 SwipeContainer (com.codename1.rad.nodes.SwipeContainer)2 ViewNode (com.codename1.rad.nodes.ViewNode)2 MultiButtonEntityView (com.codename1.rad.ui.entityviews.MultiButtonEntityView)2 WrapperEntityView (com.codename1.rad.ui.entityviews.WrapperEntityView)2 Form (com.codename1.ui.Form)2 Label (com.codename1.ui.Label)2 SpanLabel (com.codename1.components.SpanLabel)1 ActionNode (com.codename1.rad.nodes.ActionNode)1 Button (com.codename1.ui.Button)1 BorderLayout (com.codename1.ui.layouts.BorderLayout)1 FlowLayout (com.codename1.ui.layouts.FlowLayout)1 GridLayout (com.codename1.ui.layouts.GridLayout)1