mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Make report button a separate component
This commit is contained in:
parent
da4f04ace7
commit
0ef903230c
@ -34,7 +34,8 @@ using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class DrawableComment : CompositeDrawable, IHasPopover
|
||||
[Cached]
|
||||
public class DrawableComment : CompositeDrawable
|
||||
{
|
||||
private const int avatar_size = 40;
|
||||
|
||||
@ -64,6 +65,7 @@ namespace osu.Game.Overlays.Comments
|
||||
private ShowRepliesButton showRepliesButton = null!;
|
||||
private ChevronButton chevronButton = null!;
|
||||
private LinkFlowContainer actionsContainer = null!;
|
||||
private ReportButton? reportButton;
|
||||
private LoadingSpinner actionsLoading = null!;
|
||||
private DeletedCommentsCounter deletedCommentsCounter = null!;
|
||||
private OsuSpriteText deletedLabel = null!;
|
||||
@ -334,12 +336,12 @@ namespace osu.Game.Overlays.Comments
|
||||
makeDeleted();
|
||||
|
||||
actionsContainer.AddLink("Copy link", copyUrl);
|
||||
actionsContainer.AddArbitraryDrawable(new Container { Width = 10 });
|
||||
actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
|
||||
|
||||
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
|
||||
actionsContainer.AddLink("Delete", deleteComment);
|
||||
else
|
||||
actionsContainer.AddLink(UsersStrings.ReportButtonText, this.ShowPopover);
|
||||
actionsContainer.AddArbitraryDrawable(reportButton = new ReportButton());
|
||||
|
||||
if (Comment.IsTopLevel)
|
||||
{
|
||||
@ -424,6 +426,8 @@ namespace osu.Game.Overlays.Comments
|
||||
request.Success += () => Schedule(() =>
|
||||
{
|
||||
actionsLoading.Hide();
|
||||
reportButton?.Expire();
|
||||
actionsContainer.Show();
|
||||
onScreenDisplay?.Display(new ReportToast());
|
||||
});
|
||||
request.Failure += _ => Schedule(() =>
|
||||
@ -582,8 +586,6 @@ namespace osu.Game.Overlays.Comments
|
||||
}
|
||||
}
|
||||
|
||||
public Popover GetPopover() => new ReportCommentPopover(this);
|
||||
|
||||
private class ReportToast : Toast
|
||||
{
|
||||
public ReportToast()
|
||||
@ -591,5 +593,25 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class ReportButton : LinkFlowContainer, IHasPopover
|
||||
{
|
||||
public ReportButton()
|
||||
: base(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold))
|
||||
{
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private DrawableComment comment { get; set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
AddLink(UsersStrings.ReportButtonText, this.ShowPopover);
|
||||
}
|
||||
|
||||
public Popover GetPopover() => new ReportCommentPopover(comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user