Search in sources :

Example 1 with ProfileAvatarView

use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodeRAD by shannah.

the class ProfileAvatarsTitleComponent method initUI.

private void initUI() {
    setLayout(new BorderLayout());
    wrapper = new Container(new FanLayout(FanLayout.X_AXIS));
    avatarWrapperViewController.setView(wrapper);
    $(wrapper).selectAllStyles().setPadding(0).setMargin(0).setBorder(Border.createEmpty());
    int len = getEntity().size();
    for (int i = len - 1; i >= 0; i--) {
        // for (Entity child : getEntity()) {
        Entity child = getEntity().get(i);
        ProfileAvatarView v = createAvatar(child);
        wrapper.add(v);
    }
    add(CENTER, wrapper);
    StringBuilder text = new StringBuilder();
    Property nameProp = getEntity().getRowType().findProperty(Thing.name);
    if (getEntity().size() > 0) {
        if (nameProp != null) {
            text.append(getEntity().get(0).getEntity().getText(nameProp));
        }
    }
    if (getEntity().size() == 2) {
        if (nameProp != null) {
            text.append(" & ").append(getEntity().get(1).getEntity().getText(nameProp));
        }
    }
    if (getEntity().size() > 2) {
        if (text.length() == 0) {
            text.append(getEntity().size()).append(" People");
        } else {
            text.append(" and ").append(getEntity().size() - 1).append(" others");
        }
    }
    Label lbl = new Label(text.toString());
    lbl.setUIID("AccountAvatarsTitleComponentText");
    add(SOUTH, FlowLayout.encloseCenter(lbl));
}
Also used : Entity(com.codename1.rad.models.Entity) Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) FanLayout(com.codename1.rad.layouts.FanLayout) Label(com.codename1.ui.Label) Property(com.codename1.rad.models.Property)

Example 2 with ProfileAvatarView

use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodeRAD by shannah.

the class ProfileAvatarsTitleComponent method createAvatar.

/**
 * Creates individual avatar component.
 * @param row
 * @return
 */
private ProfileAvatarView createAvatar(Entity row) {
    // We will intercept the individual avatar actions by inserting our own actions here.
    // We will then handle the clicks and long presses ourselves, because
    // we may need to expand the list of avatars and allow the user to
    // choose an avatar from the list.
    ViewNode childNode = new ViewNode(UI.actions(ProfileAvatarView.PROFILE_AVATAR_CLICKED, interceptAvatarClicked), UI.actions(ProfileAvatarView.PROFILE_AVATAR_LONG_PRESS, interceptAvatarLongPress));
    childNode.setParent(getViewNode());
    ProfileAvatarView v = new ProfileAvatarView(row, childNode, avatarSizeMM);
    return v;
}
Also used : ViewNode(com.codename1.rad.nodes.ViewNode)

Example 3 with ProfileAvatarView

use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodenameOne by codenameone.

the class ProfileAvatarViewSample method start.

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Form hi = new Form("Hi World", BoxLayout.y());
    Profile profile = new Profile();
    profile.set(Profile.name, "Steve");
    profile.set(Profile.icon, "https://www.codenameone.com/img/steve.jpg");
    ProfileAvatarView avatar = new ProfileAvatarView(profile, 30f);
    hi.add("Avatar with Name and Icon");
    hi.add(FlowLayout.encloseCenter(avatar));
    profile = new Profile();
    profile.set(Profile.name, "Steve");
    avatar = new ProfileAvatarView(profile, 30f);
    hi.add("Avatar with only Name");
    hi.add(FlowLayout.encloseCenter(avatar));
    profile = new Profile();
    avatar = new ProfileAvatarView(profile, 30f);
    hi.add("Avatar with no name or icon");
    hi.add(FlowLayout.encloseCenter(avatar));
    profile = new Profile();
    profile.set(Profile.name, "Steve");
    profile.set(Profile.icon, "https://www.codenameone.com/img/steve.jpg");
    hi.add("Avatar with view controller");
    hi.add(FlowLayout.encloseCenter(new ProfileViewController(null, profile).getView()));
    hi.show();
}
Also used : Form(com.codename1.ui.Form) ProfileAvatarView(com.codename1.rad.ui.entityviews.ProfileAvatarView)

Example 4 with ProfileAvatarView

use of com.codename1.rad.ui.entityviews.ProfileAvatarView in project CodeRAD by shannah.

the class ProfileAvatarBuilder method build.

@Override
public ProfileAvatarView build() {
    ViewNode n = new ViewNode();
    n.setParent(node);
    if (nameTag != null) {
        n.setAttributes(UI.param(ProfileAvatarView.NAME_PROPERTY_TAGS, nameTag));
    }
    if (iconTag != null) {
        n.setAttributes(UI.param(ProfileAvatarView.ICON_PROPERTY_TAGS, iconTag));
    }
    return new ProfileAvatarView(entity, n, size);
}
Also used : ProfileAvatarView(com.codename1.rad.ui.entityviews.ProfileAvatarView) ViewNode(com.codename1.rad.nodes.ViewNode)

Aggregations

ViewNode (com.codename1.rad.nodes.ViewNode)2 ProfileAvatarView (com.codename1.rad.ui.entityviews.ProfileAvatarView)2 FanLayout (com.codename1.rad.layouts.FanLayout)1 Entity (com.codename1.rad.models.Entity)1 Property (com.codename1.rad.models.Property)1 Container (com.codename1.ui.Container)1 Form (com.codename1.ui.Form)1 Label (com.codename1.ui.Label)1 BorderLayout (com.codename1.ui.layouts.BorderLayout)1