From c5e0c77bcadb98cd252684dcb5adbb6c4fff9886 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Wed, 29 Jan 2020 06:08:11 +0300 Subject: [PATCH] Refactor NoCommentsPlaceholder --- .../Online/TestSceneCommentsContainer.cs | 2 +- .../Overlays/Comments/CommentsContainer.cs | 50 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs index 2af191945c..c81e850cc9 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs @@ -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(); diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index fd5c390f0f..6abb85088f 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -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." + } + }); + } + } } }