Skip to content

Commit

Permalink
Added sample using ChatBubbleView.USE_OVERFLOW_CONTAINER view propert…
Browse files Browse the repository at this point in the history
…y to disable swipe left to reveal post time of bubbles in ChatRoomView. shannah/RADChatApp#18
  • Loading branch information
shannah committed Apr 29, 2020
1 parent cc5186d commit 9761ba3
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Samples/samples/RADChatRoomTest3/RADChatRoomTest3.java
Expand Up @@ -4,17 +4,7 @@


import static com.codename1.ui.CN.*;
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.Dialog;
import com.codename1.ui.Label;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.io.Log;
import com.codename1.ui.Toolbar;
import java.io.IOException;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.io.NetworkEvent;
import com.codename1.rad.controllers.ApplicationController;
import com.codename1.rad.controllers.Controller;
import com.codename1.rad.controllers.FormController;
Expand All @@ -25,16 +15,18 @@
import com.codename1.rad.nodes.ViewNode;
import com.codename1.rad.schemas.ChatMessage;
import com.codename1.rad.schemas.ChatRoom;
import com.codename1.rad.schemas.Person;
import com.codename1.rad.schemas.Thing;
import static com.codename1.rad.ui.UI.action;
import static com.codename1.rad.ui.UI.actions;
import static com.codename1.rad.ui.UI.enabledCondition;
import static com.codename1.rad.ui.UI.icon;
import static com.codename1.rad.ui.UI.param;
import com.codename1.rad.ui.chatroom.ChatBubbleView;
import com.codename1.rad.ui.chatroom.ChatRoomView;
import com.codename1.rad.ui.entityviews.ProfileAvatarView;
import com.codename1.ui.FontImage;
import com.codename1.ui.layouts.BorderLayout;
import java.util.Date;

/**
* This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
Expand Down Expand Up @@ -80,6 +72,7 @@ void addParticipant(ParticipantModel participant) {
static class MessageModel extends Entity {
public static final EntityType TYPE = new EntityType(){{
string(ChatMessage.text);
date(ChatMessage.datePublished);
}};
{
setEntityType(TYPE);
Expand Down Expand Up @@ -117,16 +110,26 @@ public ChatFormController(Controller parent) {
addActionListener(send, evt->{
MessageModel msg = new MessageModel();
msg.set(ChatMessage.text, evt.getEntity().getText(ChatRoom.inputBuffer));
msg.setDate(ChatMessage.datePublished, new Date());
evt.getEntity().getEntityList(ChatRoom.messages).add(msg);
evt.getEntity().setText(ChatRoom.inputBuffer, "");
});

}

@Override
protected ViewNode createViewNode() {
return new ViewNode(
//Uncomment to prevent use of overflow container (swipe left)
// to see the time of a chat bubble.
// param(ChatBubbleView.USE_OVERFLOW_CONTAINER, false),

// Add "send" action so that the user can post messages
actions(ChatRoomView.SEND_ACTION, send),
actions(ProfileAvatarView.PROFILE_AVATAR_CLICKED_MENU, videoConference)

// Add action to appear in the menu when a user avatar is clicked
actions(ProfileAvatarView.PROFILE_AVATAR_CLICKED_MENU, videoConference)

);
}

Expand Down

0 comments on commit 9761ba3

Please sign in to comment.