1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 14:42:56 +08:00

Refactor NoCommentsPlaceholder

This commit is contained in:
Andrei Zavatski 2020-01-29 06:08:11 +03:00
parent b947e89a6b
commit c5e0c77bca
2 changed files with 27 additions and 25 deletions

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("Airman comments", () => comments.ShowComments(CommentableType.Beatmapset, 24313));
AddStep("Lazer build comments", () => comments.ShowComments(CommentableType.Build, 4772));
AddStep("News comments", () => comments.ShowComments(CommentableType.NewsPost, 715));
AddStep("Beatmap with no comments", () => comments.ShowComments(CommentableType.Beatmapset, 1291));
AddStep("Beatmap with no comments", () => comments.ShowComments(CommentableType.Beatmapset, 1288));
AddStep("Idle state", () =>
{
scroll.Clear();

View File

@ -35,7 +35,6 @@ namespace osu.Game.Overlays.Comments
private DeletedChildrenPlaceholder deletedChildrenPlaceholder;
private CommentsShowMoreButton moreButton;
private TotalCommentsCounter commentCounter;
private Container noCommentsPlaceholder;
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
@ -62,27 +61,6 @@ namespace osu.Game.Overlays.Comments
Sort = { BindTarget = Sort },
ShowDeleted = { BindTarget = ShowDeleted }
},
noCommentsPlaceholder = new Container
{
Height = 80,
RelativeSizeAxes = Axes.X,
Alpha = 0,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 50 },
Text = @"No comments yet."
}
}
},
content = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
@ -181,14 +159,13 @@ namespace osu.Game.Overlays.Comments
moreButton.Show();
moreButton.IsLoading = true;
content.Clear();
noCommentsPlaceholder.Hide();
}
private void onSuccess(CommentBundle response)
{
if (!response.Comments.Any())
{
noCommentsPlaceholder.Show();
content.Add(new NoCommentsPlaceholder());
moreButton.Hide();
return;
}
@ -240,5 +217,30 @@ namespace osu.Game.Overlays.Comments
loadCancellation?.Cancel();
base.Dispose(isDisposing);
}
private class NoCommentsPlaceholder : CompositeDrawable
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Height = 80;
RelativeSizeAxes = Axes.X;
AddRangeInternal(new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4
},
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 50 },
Text = @"No comments yet."
}
});
}
}
}
}