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

@ -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."
}
});
}
}
}
}