Implement layout for UserGridCard

This commit is contained in:
Andrei Zavatski 2020-03-04 12:20:49 +03:00
parent 6ea3af1951
commit 15e47d8432
4 changed files with 126 additions and 18 deletions

View File

@ -36,16 +36,33 @@ namespace osu.Game.Tests.Visual.UserInterface
Spacing = new Vector2(0, 10), Spacing = new Vector2(0, 10),
Children = new Drawable[] Children = new Drawable[]
{ {
new UserGridCard(new User new FillFlowContainer
{ {
Username = @"flyte", AutoSizeAxes = Axes.Both,
Id = 3103765, Direction = FillDirection.Horizontal,
Country = new Country { FlagName = @"JP" }, Spacing = new Vector2(10),
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" Children = new Drawable[]
}) {
{ new UserGridCard(new User
Anchor = Anchor.Centre, {
Origin = Anchor.Centre, Username = @"flyte",
Id = 3103765,
Country = new Country { FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg",
IsOnline = true,
IsSupporter = true,
SupportLevel = 3,
}),
new UserGridCard(new User
{
Username = @"Evast",
Id = 8195163,
Country = new Country { FlagName = @"BY" },
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
IsOnline = false,
LastVisit = DateTimeOffset.Now
})
}
}, },
new UserListCard(new User new UserListCard(new User
{ {
@ -57,11 +74,15 @@ namespace osu.Game.Tests.Visual.UserInterface
SupportLevel = 3, SupportLevel = 3,
IsOnline = false, IsOnline = false,
LastVisit = DateTimeOffset.Now LastVisit = DateTimeOffset.Now
}) }),
new UserListCard(new User
{ {
Anchor = Anchor.Centre, Username = @"chocomint",
Origin = Anchor.Centre, Id = 124493,
} Country = new Country { FlagName = @"KR" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c5.jpg",
IsOnline = true,
}),
} }
}); });
} }

View File

@ -83,7 +83,6 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
protected UpdateableAvatar CreateAvatar() => new UpdateableAvatar protected UpdateableAvatar CreateAvatar() => new UpdateableAvatar
{ {
User = User, User = User,
Masking = true,
OpenOnClick = { Value = false } OpenOnClick = { Value = false }
}; };

View File

@ -1,8 +1,10 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
@ -10,6 +12,8 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
{ {
public class UserGridCard : UserCard public class UserGridCard : UserCard
{ {
private const int margin = 10;
public UserGridCard(User user) public UserGridCard(User user)
: base(user) : base(user)
{ {
@ -17,9 +21,94 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
CornerRadius = 10; CornerRadius = 10;
} }
protected override Drawable CreateLayout() => new Container [BackgroundDependencyLoader]
private void load()
{ {
RelativeSizeAxes = Axes.Both, Background.FadeTo(User.IsOnline ? 0.6f : 0.7f);
}; }
protected override Drawable CreateLayout()
{
FillFlowContainer details;
var layout = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(margin),
Child = new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
Content = new[]
{
new Drawable[]
{
CreateAvatar().With(avatar =>
{
avatar.Size = new Vector2(60);
avatar.Margin = new MarginPadding { Bottom = margin };
avatar.Masking = true;
avatar.CornerRadius = 6;
}),
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 7),
Margin = new MarginPadding { Left = margin },
Children = new Drawable[]
{
details = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(6),
Children = new Drawable[]
{
CreateFlag(),
}
},
CreateUsername(),
}
}
},
new Drawable[]
{
CreateStatusIcon().With(icon =>
{
icon.Anchor = Anchor.Centre;
icon.Origin = Anchor.Centre;
}),
CreateStatusMessage(false).With(message =>
{
message.Anchor = Anchor.CentreLeft;
message.Origin = Anchor.CentreLeft;
message.Margin = new MarginPadding { Left = margin };
})
}
}
}
};
if (User.IsSupporter)
{
details.Add(new SupporterIcon
{
Height = 26,
SupportLevel = User.SupportLevel
});
}
return layout;
}
} }
} }

View File

@ -53,7 +53,6 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
avatar.Anchor = Anchor.CentreLeft; avatar.Anchor = Anchor.CentreLeft;
avatar.Origin = Anchor.CentreLeft; avatar.Origin = Anchor.CentreLeft;
avatar.Size = new Vector2(40); avatar.Size = new Vector2(40);
avatar.Masking = false;
}), }),
CreateFlag().With(flag => CreateFlag().With(flag =>
{ {