From 53bd22cf9c1a0037a50366d23faebd422669df34 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Thu, 15 Jun 2017 20:01:46 +0800 Subject: [PATCH] Update usage design. --- .../Tests/TestCaseUserProfile.cs | 28 +++++++++++++------ osu.Game/Overlays/UserProfileOverlay.cs | 5 +++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs index 6939692bff..e55d881d93 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -16,21 +16,31 @@ namespace osu.Desktop.VisualTests.Tests public override void Reset() { base.Reset(); - var userpage = new UserProfileOverlay(new User - { - Username = @"peppy", - Id = 2, - Country = new Country { FullName = @"Australia", FlagName = @"AU" }, - CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" - }) + var profile = new UserProfileOverlay { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = 50 }, - State = Visibility.Visible }; - Add(userpage); + Add(profile); + + AddStep("Show ppy", () => profile.ShowUser(new User + { + Username = @"peppy", + Id = 2, + Country = new Country { FullName = @"Australia", FlagName = @"AU" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" + })); + AddStep("Show flyte", () => profile.ShowUser(new User + { + Username = @"flyte", + Id = 3103765, + Country = new Country { FullName = @"Japan", FlagName = @"JP" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" + })); + AddStep("Hide", profile.Hide); + AddStep("Show without reload", profile.Show); } } } diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 6bdf847d67..d0c5726cdc 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -22,8 +22,10 @@ namespace osu.Game.Overlays public const float CONTENT_X_MARGIN = 50; - public UserProfileOverlay(User user) + public void ShowUser(User user) { + Clear(); + lastSection = null; var sections = new ProfileSection[] { new AboutSection(), @@ -87,6 +89,7 @@ namespace osu.Game.Overlays sectionsContainer.ScrollContainer.ScrollIntoView(lastSection); } }; + Show(); } private class ProfileTabControl : PageTabControl