Implement PaginatedContainerWithHeader component

This commit is contained in:
Andrei Zavatski
2020-09-07 23:08:50 +03:00
parent b7bd084296
commit e39609d3ca
11 changed files with 147 additions and 37 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Online.API;
@ -13,21 +14,49 @@ using osuTK;
namespace osu.Game.Overlays.Profile.Sections.Beatmaps
{
public class PaginatedBeatmapContainer : PaginatedContainer<APIBeatmapSet>
public class PaginatedBeatmapContainer : PaginatedContainerWithHeader<APIBeatmapSet>
{
private const float panel_padding = 10f;
private readonly BeatmapSetType type;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user)
: base(user)
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string headerText)
: base(user, headerText, CounterVisibilityState.AlwaysVisible)
{
this.type = type;
ItemsPerPage = 6;
}
[BackgroundDependencyLoader]
private void load()
{
ItemsContainer.Spacing = new Vector2(panel_padding);
}
protected override int GetCount(User user)
{
switch (type)
{
case BeatmapSetType.Favourite:
return user.FavouriteBeatmapsetCount;
case BeatmapSetType.Graveyard:
return user.GraveyardBeatmapsetCount;
case BeatmapSetType.Loved:
return user.LovedBeatmapsetCount;
case BeatmapSetType.RankedAndApproved:
return user.RankedAndApprovedBeatmapsetCount;
case BeatmapSetType.Unranked:
return user.UnrankedBeatmapsetCount;
default:
return 0;
}
}
protected override APIRequest<List<APIBeatmapSet>> CreateRequest() =>
new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++, ItemsPerPage);