Skip to content

ProfileAvatarView

Steve Hannah edited this page Jul 6, 2021 · 1 revision

ProfileAvatarView

<profileAvatarView>javadoc

Synopsis

A view that shows a profile’s avatar filled in a circle.

Usage

Example where the view model is from a variable named profile and the size is 25% of the view width.
<profileAvatar view-model="profile" size="25vw"/>

Attributes

size

The size of the profile photo in scalar units. If no units applied, then it defaults to pixels.

nameTag

The tag to use for the name lookup. Default is Thing.name

iconTag

The tag to use for the photo. Default is Thing.thumbnailUrl.

view-model

A reference to the Entity to use for the view model.

Actions

PROFILE_AVATAR_CLICKED

Fired when avatar is clicked.

PROFILE_AVATAR_LONG_PRESS

Fired when there is a long press on the avatar.

PROFILE_AVATAR_CLICKED_MENU

Category for actions that should appear in a popup menu when the avatar is clicked. The popup menu is not shown if the PROFILE_AVATAR_CLICKED is consumed.

PROFILE_AVATAR_LONG_PRESS_MENU

Category for actions that should appear in a popup menu when the avatar is long pressed. The popup menu is not shown if the PROFILE_AVATAR_LONG_PRESS event is consumed.

Styles

ProfileAvatarView

The UIID for the ProfileAvatarView component.

View Model

The view model should Thing.name and Thing.thumbnailUrl tagged properties. If it is missing both of these, it will default to a material icon of a user account. If the Thing.name is available but not Thing.thumbnailUrl, then it will render the first letter of the name in a colored filled circle.

Example

<?xml version="1.0"?>
<y xsi:noNamespaceSchemaLocation="ProfileAvatarSample.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <title>Profile Avatar Sample</title>
    <import>
        import com.codename1.rad.sampler.models.*;
    </import>
    <var name="profile" type="UserProfile"/>
    <script>
        profile = new UserProfileImpl();
        profile.setName("George");
        profile.setPhotoUrl("https://weblite.ca/cn1tests/radchat/george.jpg");
    </script>
    <center><profileAvatar view-model="profile" size="25vw"/></center>

</y>
Note
In the above example we construct the view model in a script tag. This is a bad practice and is used only for clarity of the example. It is better to construct models in your controllers and pass them to the view in either the view models or via a lookup.
ProfileAvatarView
Clone this wiki locally