mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 03:15:45 +08:00
Implement MappingSubscribersButton component
This commit is contained in:
parent
966440f109
commit
a7c22ebe88
@ -49,9 +49,12 @@ namespace osu.Game.Overlays.Profile.Header
|
||||
Spacing = new Vector2(10, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new AddFriendButton
|
||||
new FriendsButton
|
||||
{
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
new MappingSubscribersButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
User = { BindTarget = User }
|
||||
},
|
||||
new MessageUserButton
|
||||
|
@ -8,7 +8,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class AddFriendButton : ProfileHeaderStatisticsButton
|
||||
public class FriendsButton : ProfileHeaderStatisticsButton
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
@ -20,9 +20,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
private void load()
|
||||
{
|
||||
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
|
||||
User.BindValueChanged(user => updateFollowers(user.NewValue), true);
|
||||
User.BindValueChanged(user => SetValue(user.NewValue?.FollowerCount ?? 0), true);
|
||||
}
|
||||
|
||||
private void updateFollowers(User user) => SetValue(user?.FollowerCount.ToString("#,##0"));
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class MappingSubscribersButton : ProfileHeaderStatisticsButton
|
||||
{
|
||||
public readonly Bindable<User> User = new Bindable<User>();
|
||||
|
||||
public override string TooltipText => "mapping subscribers";
|
||||
|
||||
protected override IconUsage CreateIcon() => FontAwesome.Solid.Bell;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
User.BindValueChanged(user => SetValue(user.NewValue?.MappingFollowerCount ?? 0), true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -17,13 +16,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
|
||||
protected ProfileHeaderStatisticsButton()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Child = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteIcon
|
||||
@ -38,15 +38,15 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
protected abstract IconUsage CreateIcon();
|
||||
|
||||
protected void SetValue(string value) => drawableText.Text = value;
|
||||
protected void SetValue(int value) => drawableText.Text = value.ToString("#,##0");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user