Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions fluXis/Overlay/User/ProfileHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using fluXis.Graphics.UserInterface.Color;
using fluXis.Online.API.Models.Groups;
using fluXis.Online.API.Models.Users;
using fluXis.Online.Chat;
using fluXis.Online.Drawables.Clubs;
using fluXis.Online.Drawables.Images;
using fluXis.Online.Fluxel;
Expand All @@ -23,15 +24,22 @@ namespace fluXis.Overlay.User;

public partial class ProfileHeader : Container
{
[CanBeNull]
[Resolved(CanBeNull = true)]
private ChatClient chat { get; set; }

private APIUser user { get; }

private bool showUsername => user.Username != user.PreferredName;
private bool showPronouns => !string.IsNullOrEmpty(user.Pronouns);
private bool showBottomRow => showUsername || showPronouns;

public ProfileHeader(APIUser user)
private UserProfileOverlay overlay;

public ProfileHeader(APIUser user, UserProfileOverlay overlay)
{
this.user = user;
this.overlay = overlay;
}

[BackgroundDependencyLoader(true)]
Expand Down Expand Up @@ -235,17 +243,7 @@ private void load(IAPIClient api, [CanBeNull] FluXisGame game)
Spacing = new Vector2(10),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Children = new Drawable[]
{
new HeaderButton
{
Icon = FontAwesome6.Solid.ShareNodes,
Action = () => game?.OpenLink($"{api.Endpoint.WebsiteRootUrl}/u/{user.ID}"),
},
api.User.Value?.ID == user.ID
? new HeaderEditButton()
: new HeaderFollowButton(user)
}
ChildrenEnumerable = createHeaderButtons(api, game)
}
}
}
Expand All @@ -259,6 +257,27 @@ protected override void Update()
Height = DrawWidth / 3f; // 3:1 aspect ratio
}

private IEnumerable<Drawable> createHeaderButtons(IAPIClient api, [CanBeNull] FluXisGame game)
{
yield return new HeaderButton
{
Icon = FontAwesome6.Solid.ShareNodes,
Action = () => game?.OpenLink($"{api.Endpoint.WebsiteRootUrl}/u/{user.ID}"),
};

if (user.Following is UserFollowState.Mutual && api.User.Value?.ID != user.ID)
yield return new HeaderButton
{
Icon = FontAwesome6.Solid.Message,
Text = "Message",
Action = () => { chat?.CreatePrivateChannel(user.ID); overlay.Hide(); },
};

yield return api.User.Value?.ID == user.ID
? new HeaderEditButton()
: new HeaderFollowButton(user);
}

private IEnumerable<Drawable> createGroups()
{
if (user.IsSupporter)
Expand Down
2 changes: 1 addition & 1 deletion fluXis/Overlay/User/UserProfileOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void displayData(APIUser user)
flow.Show();
flow.Children = new Drawable[]
{
new ProfileHeader(user),
new ProfileHeader(user, this),
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
Expand Down