1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-23 19:40:09 +08:00
Files
osu-lazer/osu.Game/Overlays/Profile/Header/Components/UserActionsButton.cs
T
Krzysztof Gutkowski 054ae2983d Extract user overlay actions button component (#36236)
This PR extracts the classes used for the actions dropdown on the user
profile overlay to separate components, in preparation to be used on the
team overlay (#32584).

Kinda RFC since I'm not sure if this is the best way to do this.

Co-authored-by: Dean Herbert <pe@ppy.sh>
2026-03-10 16:28:06 +09:00

62 lines
2.1 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class UserActionsButton : ProfileActionsButton
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
[Resolved]
private IAPIProvider api { get; set; } = null!;
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(_ => Alpha = User.Value?.User.OnlineID == api.LocalUser.Value.OnlineID ? 0 : 1, true);
}
public override Popover GetPopover() => new UserActionPopover(User.Value!.User);
private partial class UserActionPopover : ProfileActionPopover
{
private readonly APIUser user;
public UserActionPopover(APIUser user)
{
this.user = user;
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api, IDialogOverlay? dialogOverlay)
{
bool userBlocked = api.LocalUserState.Blocks.Any(b => b.TargetID == user.Id);
Actions = new[]
{
new ProfilePopoverAction(FontAwesome.Solid.Ban, userBlocked ? UsersStrings.BlocksButtonUnblock : UsersStrings.BlocksButtonBlock)
{
Action = () =>
{
dialogOverlay?.Push(userBlocked ? ConfirmBlockActionDialog.Unblock(user) : ConfirmBlockActionDialog.Block(user));
this.HidePopover();
}
}
};
}
}
}
}