mirror of
https://github.com/ppy/osu.git
synced 2026-05-17 08:42:35 +08:00
2006485d60
This PR refactors the report popover to have an optional confirmation message after completing the request. This was initially meant for #32584, but then I realized I can first test it out on the user profiles, so I've implemented it here as well. Can be reviewed commit by commit. https://github.com/user-attachments/assets/cd59c560-c824-4a5e-bab6-5ecbf5125af1 --------- Co-authored-by: Dean Herbert <pe@ppy.sh>
91 lines
2.6 KiB
C#
91 lines
2.6 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.Extensions;
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
|
using osu.Framework.Graphics;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Cursor;
|
|
using osu.Framework.Graphics.Sprites;
|
|
using osu.Framework.Graphics.UserInterface;
|
|
using osu.Framework.Testing;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Containers;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
using osu.Game.Resources.Localisation.Web;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Overlays.Comments
|
|
{
|
|
public partial class CommentReportButton : CompositeDrawable, IHasPopover, IHasLineBaseHeight
|
|
{
|
|
private readonly Comment comment;
|
|
|
|
private LinkFlowContainer link = null!;
|
|
private LoadingSpinner loading = null!;
|
|
|
|
[Resolved]
|
|
private OverlayColourProvider? colourProvider { get; set; }
|
|
|
|
public CommentReportButton(Comment comment)
|
|
{
|
|
this.comment = comment;
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
InternalChildren = new Drawable[]
|
|
{
|
|
link = new LinkFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold))
|
|
{
|
|
AutoSizeAxes = Axes.Both,
|
|
},
|
|
loading = new LoadingSpinner
|
|
{
|
|
Size = new Vector2(12f),
|
|
}
|
|
};
|
|
|
|
link.AddLink(ReportStrings.CommentButton.ToLower(), this.ShowPopover);
|
|
}
|
|
|
|
public Popover GetPopover()
|
|
{
|
|
var popover = new ReportCommentPopover(comment);
|
|
|
|
popover.Submitted += () =>
|
|
{
|
|
link.Hide();
|
|
loading.Show();
|
|
};
|
|
|
|
popover.Success += () => Schedule(() =>
|
|
{
|
|
loading.Hide();
|
|
|
|
link.Clear(true);
|
|
link.AddText(UsersStrings.ReportThanks, s => s.Colour = colourProvider?.Content2 ?? Colour4.White);
|
|
link.Show();
|
|
|
|
this.FadeOut(2000, Easing.InQuint).Expire();
|
|
});
|
|
|
|
popover.Failure += () => Schedule(() =>
|
|
{
|
|
loading.Hide();
|
|
link.Show();
|
|
});
|
|
|
|
return popover;
|
|
}
|
|
|
|
public float LineBaseHeight => link.ChildrenOfType<IHasLineBaseHeight>().FirstOrDefault()?.LineBaseHeight ?? DrawHeight;
|
|
}
|
|
}
|