Skip to content

Commit

Permalink
✨ Support multiple speaker profile pictures per session #43
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Sep 27, 2024
1 parent 5b4a0c8 commit 985233a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
4 changes: 2 additions & 2 deletions frontend/themes/apus/views/room-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@
}

.room-view .track svg,
.room-view .avatar vaadin-avatar {
.room-view vaadin-avatar-group vaadin-avatar {
position: absolute;
bottom: 0;
right: 0;
height: 40px;
width: 40px;
}

.room-view .avatar vaadin-avatar {
.room-view vaadin-avatar-group vaadin-avatar {
background-color: var(--speaker-avatar-background-color);
border: var(--speaker-avatar-border);
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/swiss/fihlon/apus/event/Speaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package swiss.fihlon.apus.event;

import com.vaadin.flow.component.avatar.Avatar;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -27,8 +26,4 @@ public Speaker(@NotNull final String fullName) {
this(fullName, null);
}

public Avatar avatar() {
return new Avatar(fullName, imageUrl);
}

}
19 changes: 11 additions & 8 deletions src/main/java/swiss/fihlon/apus/ui/view/RoomView.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.Svg;
import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.avatar.AvatarGroup;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.H3;
Expand All @@ -44,6 +45,8 @@
@CssImport(value = "./themes/apus/views/room-view.css")
public final class RoomView extends Div {

private static final int MAX_SPEAKER_AVATARS_PER_ROOM = 3;

private final transient Room room;
private final String title;
private final transient List<Speaker> speakers;
Expand Down Expand Up @@ -164,18 +167,18 @@ private Component createTimeComponent() {
@NotNull
private Component createImageComponent() {
final var speakerAvatars = speakers.stream()
.filter(s -> s.imageUrl() != null && !s.imageUrl().isBlank())
.map(Speaker::avatar)
.toList();
.filter(speaker -> speaker.imageUrl() != null && !speaker.imageUrl().isBlank())
.map(speaker -> new AvatarGroup.AvatarGroupItem(speaker.fullName(), speaker.imageUrl()))
.toArray(AvatarGroup.AvatarGroupItem[]::new);

if (speakerAvatars.isEmpty()) {
if (speakerAvatars.length == 0) {
return createTrackComponent();
}

final var imageComponent = new Div();
imageComponent.addClassName("avatar");
imageComponent.add(speakerAvatars.getFirst());
return imageComponent;
final var avatarGroup = new AvatarGroup();
avatarGroup.setMaxItemsVisible(MAX_SPEAKER_AVATARS_PER_ROOM);
avatarGroup.add(speakerAvatars);
return avatarGroup;
}

@NotNull
Expand Down
7 changes: 0 additions & 7 deletions src/test/java/swiss/fihlon/apus/event/SpeakerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package swiss.fihlon.apus.event;

import com.vaadin.flow.component.avatar.Avatar;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -39,10 +38,4 @@ void imageUrl() {
assertEquals("https://foo.bar/test.png", new Speaker("", "https://foo.bar/test.png").imageUrl());
}

@Test
void avatar() {
final Avatar avatar = new Speaker("Speaker 1", "https://foo.bar/test.png").avatar();
assertEquals("Speaker 1", avatar.getName());
assertEquals("https://foo.bar/test.png", avatar.getImage());
}
}

0 comments on commit 985233a

Please sign in to comment.