1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Tidy up content and bind event code

This commit is contained in:
Dean Herbert 2021-05-19 15:45:24 +09:00
parent d70d37b7f4
commit 539e5179fe
2 changed files with 12 additions and 14 deletions

View File

@ -117,10 +117,10 @@ namespace osu.Game.Overlays.News.Sidebar
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, GameHost host)
private void load(OverlayColourProvider overlayColours, GameHost host)
{
IdleColour = colourProvider.Light2;
HoverColour = colourProvider.Light1;
IdleColour = overlayColours.Light2;
HoverColour = overlayColours.Light1;
TooltipText = "view in browser";
Action = () => host.OpenUrlExternally("https://osu.ppy.sh/home/news/" + post.Slug);
@ -131,9 +131,7 @@ namespace osu.Game.Overlays.News.Sidebar
{
public readonly BindableBool IsOpen = new BindableBool();
protected override Container<Drawable> Content => content;
private readonly FillFlowContainer content;
protected override Container<Drawable> Content { get; }
public PostsContainer()
{
@ -141,7 +139,7 @@ namespace osu.Game.Overlays.News.Sidebar
AutoSizeAxes = Axes.Y;
AutoSizeDuration = animation_duration;
AutoSizeEasing = Easing.Out;
InternalChild = content = new FillFlowContainer
InternalChild = Content = new FillFlowContainer
{
Margin = new MarginPadding { Top = 5 },
RelativeSizeAxes = Axes.X,
@ -155,24 +153,24 @@ namespace osu.Game.Overlays.News.Sidebar
protected override void LoadComplete()
{
base.LoadComplete();
IsOpen.BindValueChanged(_ => updateState(), true);
IsOpen.BindValueChanged(updateState, true);
}
private void updateState()
private void updateState(ValueChangedEvent<bool> isOpen)
{
ClearTransforms(true);
if (IsOpen.Value)
if (isOpen.NewValue)
{
AutoSizeAxes = Axes.Y;
content.FadeIn(animation_duration, Easing.OutQuint);
Content.FadeIn(animation_duration, Easing.OutQuint);
}
else
{
AutoSizeAxes = Axes.None;
this.ResizeHeightTo(0, animation_duration, Easing.OutQuint);
content.FadeOut(animation_duration, Easing.OutQuint);
Content.FadeOut(animation_duration, Easing.OutQuint);
}
}
}

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.News.Sidebar
private FillFlowContainer yearsFlow;
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, Bindable<APINewsSidebar> metadata)
private void load(OverlayColourProvider overlayColours, Bindable<APINewsSidebar> metadata)
{
this.metadata.BindTo(metadata);
@ -35,7 +35,7 @@ namespace osu.Game.Overlays.News.Sidebar
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background3
Colour = overlayColours.Background3
},
new Container
{