fi.evolver.ai.vaadin.component.ChatAvatarLoadingItem Maven / Gradle / Ivy
package fi.evolver.ai.vaadin.component;
import java.io.Serial;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.progressbar.ProgressBar;
import fi.evolver.utils.string.StringUtils;
public class ChatAvatarLoadingItem extends ChatAvatarItem {
@Serial
private static final long serialVersionUID = 1L;
public ChatAvatarLoadingItem(String user) {
this(user, null);
}
public ChatAvatarLoadingItem(String user, String message) {
super(user, generateContent(message));
}
protected static Component generateContent(String message) {
ProgressBar progressBar = new ProgressBar();
progressBar.setIndeterminate(true);
progressBar.setWidthFull();
Div content = new Div();
if (StringUtils.hasText(message))
content.add(new Paragraph(message));
content.add(progressBar);
content.setWidthFull();
return content;
}
}