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 @@ public TestSceneUserCard()
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{
new UserGridCard(new User
new FillFlowContainer
{
Username = @"flyte",
Id = 3103765,
Country = new Country { FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
})
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10),
Children = new Drawable[]
{
new UserGridCard(new User
{
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
{
@ -57,11 +74,15 @@ public TestSceneUserCard()
SupportLevel = 3,
IsOnline = false,
LastVisit = DateTimeOffset.Now
})
}),
new UserListCard(new User
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
Username = @"chocomint",
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 @@ private void load(OverlayColourProvider colourProvider)
protected UpdateableAvatar CreateAvatar() => new UpdateableAvatar
{
User = User,
Masking = true,
OpenOnClick = { Value = false }
};

View File

@ -1,8 +1,10 @@
// 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.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Users;
using osuTK;
@ -10,6 +12,8 @@ namespace osu.Game.Graphics.UserInterfaceV2.Users
{
public class UserGridCard : UserCard
{
private const int margin = 10;
public UserGridCard(User user)
: base(user)
{
@ -17,9 +21,94 @@ public UserGridCard(User user)
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 @@ protected override Drawable CreateLayout()
avatar.Anchor = Anchor.CentreLeft;
avatar.Origin = Anchor.CentreLeft;
avatar.Size = new Vector2(40);
avatar.Masking = false;
}),
CreateFlag().With(flag =>
{