From b947e89a6b11946110ec66709657fc70bfbe73ec Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 28 Jan 2020 16:53:22 +0300 Subject: [PATCH] Add placeholder for no comments case in CommentsContainer --- .../Online/TestSceneCommentsContainer.cs | 1 + .../Overlays/Comments/CommentsContainer.cs | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs index 3d63e2b07e..2af191945c 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneCommentsContainer.cs @@ -48,6 +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("Idle state", () => { scroll.Clear(); diff --git a/osu.Game/Overlays/Comments/CommentsContainer.cs b/osu.Game/Overlays/Comments/CommentsContainer.cs index 78df73eb0d..fd5c390f0f 100644 --- a/osu.Game/Overlays/Comments/CommentsContainer.cs +++ b/osu.Game/Overlays/Comments/CommentsContainer.cs @@ -12,6 +12,7 @@ using osu.Game.Online.API.Requests.Responses; using System.Threading; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Comments { @@ -34,6 +35,7 @@ namespace osu.Game.Overlays.Comments private DeletedChildrenPlaceholder deletedChildrenPlaceholder; private CommentsShowMoreButton moreButton; private TotalCommentsCounter commentCounter; + private Container noCommentsPlaceholder; [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider) @@ -60,6 +62,27 @@ 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, @@ -68,6 +91,7 @@ namespace osu.Game.Overlays.Comments }, new Container { + Name = @"Footer", RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] @@ -154,12 +178,21 @@ namespace osu.Game.Overlays.Comments { currentPage = 1; deletedChildrenPlaceholder.DeletedCount.Value = 0; + moreButton.Show(); moreButton.IsLoading = true; content.Clear(); + noCommentsPlaceholder.Hide(); } private void onSuccess(CommentBundle response) { + if (!response.Comments.Any()) + { + noCommentsPlaceholder.Show(); + moreButton.Hide(); + return; + } + loadCancellation = new CancellationTokenSource(); var page = new FillFlowContainer