2020-11-21 00:18:24 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-11-21 00:18:24 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using JetBrains.Annotations;
|
2021-07-17 13:45:17 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-11-04 09:02:44 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-11-21 00:18:24 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Sections
|
|
|
|
|
{
|
|
|
|
|
public abstract class ProfileSubsection : FillFlowContainer
|
|
|
|
|
{
|
2021-11-04 09:02:44 +00:00
|
|
|
|
protected readonly Bindable<APIUser> User = new Bindable<APIUser>();
|
2020-11-21 00:18:24 +00:00
|
|
|
|
|
2021-07-17 13:45:17 +00:00
|
|
|
|
private readonly LocalisableString headerText;
|
2020-11-21 00:18:24 +00:00
|
|
|
|
private readonly CounterVisibilityState counterVisibilityState;
|
|
|
|
|
|
|
|
|
|
private ProfileSubsectionHeader header;
|
|
|
|
|
|
2021-11-04 09:02:44 +00:00
|
|
|
|
protected ProfileSubsection(Bindable<APIUser> user, LocalisableString? headerText = null, CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
|
2020-11-21 00:18:24 +00:00
|
|
|
|
{
|
2021-07-17 14:13:33 +00:00
|
|
|
|
this.headerText = headerText ?? string.Empty;
|
2020-11-21 00:18:24 +00:00
|
|
|
|
this.counterVisibilityState = counterVisibilityState;
|
|
|
|
|
User.BindTo(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-11-21 19:49:56 +00:00
|
|
|
|
private void load()
|
2020-11-21 00:18:24 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Direction = FillDirection.Vertical;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
header = new ProfileSubsectionHeader(headerText, counterVisibilityState)
|
|
|
|
|
{
|
2021-07-17 14:13:33 +00:00
|
|
|
|
Alpha = string.IsNullOrEmpty(headerText.ToString()) ? 0 : 1
|
2020-11-21 00:18:24 +00:00
|
|
|
|
},
|
2020-11-21 20:03:54 +00:00
|
|
|
|
CreateContent()
|
2020-11-21 00:18:24 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
protected abstract Drawable CreateContent();
|
|
|
|
|
|
|
|
|
|
protected void SetCount(int value) => header.Current.Value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|