1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:07:52 +08:00

Merge pull request #26924 from EVAST9919/user-card-containers

Rework `UserPanel`s to reduce container nesting
This commit is contained in:
Bartłomiej Dach 2024-02-05 18:46:42 +01:00 committed by GitHub
commit 1582536f04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 136 additions and 147 deletions

View File

@ -2,14 +2,15 @@
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Online
{
public partial class TestSceneDashboardOverlay : OsuTestScene
{
protected override bool UseOnlineAPI => true;
private readonly DashboardOverlay overlay;
public TestSceneDashboardOverlay()
@ -17,6 +18,30 @@ namespace osu.Game.Tests.Visual.Online
Add(overlay = new DashboardOverlay());
}
[BackgroundDependencyLoader]
private void load()
{
int supportLevel = 0;
for (int i = 0; i < 1000; i++)
{
supportLevel++;
if (supportLevel > 3)
supportLevel = 0;
((DummyAPIAccess)API).Friends.Add(new APIUser
{
Username = @"peppy",
Id = 2,
Colour = "99EB47",
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = supportLevel > 0,
SupportLevel = supportLevel
});
}
}
[Test]
public void TestShow()
{

View File

@ -35,13 +35,10 @@ namespace osu.Game.Users
{
FillFlowContainer details;
var layout = new Container
var layout = new GridContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(margin),
Child = new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
@ -50,7 +47,6 @@ namespace osu.Game.Users
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.Absolute, margin),
new Dimension()
},
Content = new[]
@ -62,14 +58,12 @@ namespace osu.Game.Users
avatar.Size = new Vector2(60);
avatar.Masking = true;
avatar.CornerRadius = 6;
avatar.Margin = new MarginPadding { Bottom = margin };
}),
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = margin },
Child = new GridContainer
new GridContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = margin, Bottom = margin },
ColumnDimensions = new[]
{
new Dimension()
@ -105,13 +99,6 @@ namespace osu.Game.Users
}
}
}
}
},
new[]
{
// padding
Empty(),
Empty()
},
new Drawable[]
{
@ -128,7 +115,6 @@ namespace osu.Game.Users
})
}
}
}
};
if (User.IsSupporter)

View File

@ -81,46 +81,31 @@ namespace osu.Game.Users
},
new GridContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(padding),
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, padding),
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
new Dimension(GridSizeMode.Absolute, padding),
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.Absolute, padding),
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
Content = new[]
{
new[]
new Drawable[]
{
// padding
Empty(),
Empty(),
Empty(),
Empty()
},
new[]
{
Empty(), // padding
CreateAvatar().With(avatar =>
{
avatar.Size = new Vector2(60);
avatar.Masking = true;
avatar.CornerRadius = 6;
}),
new Container
new GridContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = padding },
Child = new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension()
@ -156,24 +141,18 @@ namespace osu.Game.Users
}
}
}
},
Empty() // padding
}
}
}
}
},
new Container
new GridContainer
{
Name = "Bottom content",
Margin = new MarginPadding { Top = main_content_height },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Left = 80, Vertical = padding },
Child = new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
ColumnDimensions = new[]
{
new Dimension(),
@ -196,7 +175,6 @@ namespace osu.Game.Users
}
}
}
}
};
if (User.IsSupporter)