diff --git a/fluXis/Overlay/User/ProfileHeader.cs b/fluXis/Overlay/User/ProfileHeader.cs index 36262b6a2..96d93695c 100644 --- a/fluXis/Overlay/User/ProfileHeader.cs +++ b/fluXis/Overlay/User/ProfileHeader.cs @@ -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; @@ -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 readonly UserProfileOverlay overlay; + + public ProfileHeader(APIUser user, UserProfileOverlay overlay) { this.user = user; + this.overlay = overlay; } [BackgroundDependencyLoader(true)] @@ -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) } } } @@ -259,6 +257,33 @@ protected override void Update() Height = DrawWidth / 3f; // 3:1 aspect ratio } + private IEnumerable 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 createGroups() { if (user.IsSupporter) diff --git a/fluXis/Overlay/User/UserProfileOverlay.cs b/fluXis/Overlay/User/UserProfileOverlay.cs index 29e0fa31b..864b33653 100644 --- a/fluXis/Overlay/User/UserProfileOverlay.cs +++ b/fluXis/Overlay/User/UserProfileOverlay.cs @@ -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,