1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-16 06:53:22 +08:00

Apply suggestions for MonthPanel

This commit is contained in:
Andrei Zavatski 2021-05-11 14:43:23 +03:00
parent 69f01e82db
commit 711e7ba860

View File

@ -19,6 +19,9 @@ namespace osu.Game.Overlays.News.Sidebar
{ {
public class MonthPanel : CompositeDrawable public class MonthPanel : CompositeDrawable
{ {
private const int header_height = 15;
private const int animation_duration = 250;
public readonly BindableBool IsOpen = new BindableBool(); public readonly BindableBool IsOpen = new BindableBool();
private readonly FillFlowContainer postsFlow; private readonly FillFlowContainer postsFlow;
@ -26,8 +29,7 @@ namespace osu.Game.Overlays.News.Sidebar
public MonthPanel(List<APINewsPost> posts) public MonthPanel(List<APINewsPost> posts)
{ {
Width = 160; Width = 160;
AutoSizeDuration = 250; Masking = true;
AutoSizeEasing = Easing.OutQuint;
InternalChild = new FillFlowContainer InternalChild = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
@ -63,33 +65,46 @@ namespace osu.Game.Overlays.News.Sidebar
if (open.NewValue) if (open.NewValue)
{ {
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;
postsFlow.FadeIn(250, Easing.OutQuint); postsFlow.FadeIn(animation_duration, Easing.OutQuint);
} }
else else
{ {
AutoSizeAxes = Axes.None; AutoSizeAxes = Axes.None;
this.ResizeHeightTo(15, 250, Easing.OutQuint); this.ResizeHeightTo(header_height, animation_duration, Easing.OutQuint);
postsFlow.FadeOut(250, Easing.OutQuint); postsFlow.FadeOut(animation_duration, Easing.OutQuint);
} }
}, true); }, true);
// First state change should be instant. // First state change should be instant.
FinishTransforms(); FinishTransforms(true);
postsFlow.FinishTransforms();
} }
private class DropdownButton : OsuHoverContainer private bool shouldUpdateAutosize = true;
// Workaround to allow the dropdown to be opened immediately since FinishTransforms doesn't work for AutosizeDuration.
protected override void UpdateAfterAutoSize()
{
base.UpdateAfterAutoSize();
if (shouldUpdateAutosize)
{
AutoSizeDuration = animation_duration;
AutoSizeEasing = Easing.OutQuint;
shouldUpdateAutosize = false;
}
}
private class DropdownButton : OsuClickableContainer
{ {
public readonly BindableBool IsOpen = new BindableBool(); public readonly BindableBool IsOpen = new BindableBool();
protected override IEnumerable<Drawable> EffectTargets => null;
private readonly SpriteIcon icon; private readonly SpriteIcon icon;
public DropdownButton(DateTimeOffset date) public DropdownButton(DateTimeOffset date)
{ {
Size = new Vector2(160, 15); Size = new Vector2(160, header_height);
Action = IsOpen.Toggle; Action = IsOpen.Toggle;
Children = new Drawable[] Children = new Drawable[]
{ {