mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Implement PaginatedContainerWithHeader component
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user