-
Notifications
You must be signed in to change notification settings - Fork 18
ProfileAvatarView
<profileAvatarView>
• javadoc
<profileAvatar view-model="profile" size="25vw"/>
- 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.
- 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.
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.
<?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. |