Search in sources :

Example 1 with User

use of com.dala.data.user.User in project DoodleVerse by davidemarcoli.

the class MainLayout method createFooter.

private Footer createFooter() {
    Footer layout = new Footer();
    layout.addClassNames("footer");
    Optional<User> maybeUser = authenticatedUser.get();
    if (maybeUser.isPresent()) {
        User user = maybeUser.get();
        Avatar avatar = new Avatar(user.getName(), user.getProfilePictureUrl());
        avatar.addClassNames("me-xs");
        ContextMenu userMenu = new ContextMenu(avatar);
        userMenu.setOpenOnClick(true);
        userMenu.addItem("Logout", e -> {
            authenticatedUser.logout();
        });
        Span name = new Span(user.getName());
        name.addClassNames("font-medium", "text-s", "text-secondary");
        layout.add(avatar, name);
    } else {
        Anchor loginLink = new Anchor("login", "Sign in");
        layout.add(loginLink);
    }
    return layout;
}
Also used : AuthenticatedUser(com.dala.security.AuthenticatedUser) User(com.dala.data.user.User) ContextMenu(com.vaadin.flow.component.contextmenu.ContextMenu) Avatar(com.vaadin.flow.component.avatar.Avatar)

Aggregations

User (com.dala.data.user.User)1 AuthenticatedUser (com.dala.security.AuthenticatedUser)1 Avatar (com.vaadin.flow.component.avatar.Avatar)1 ContextMenu (com.vaadin.flow.component.contextmenu.ContextMenu)1