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

Remove overcomplicated date logic in MonthPanel

This commit is contained in:
Andrei Zavatski 2021-05-10 17:00:18 +03:00
parent fbf8b198cd
commit 220eef0351
3 changed files with 10 additions and 9 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
@ -33,7 +34,7 @@ namespace osu.Game.Tests.Visual.Online
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background2,
},
new MonthPanel(DateTime.Now, posts),
new MonthPanel(posts),
}
});
}
@ -53,7 +54,7 @@ namespace osu.Game.Tests.Visual.Online
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background2,
},
new MonthPanel(DateTime.Now, posts)
new MonthPanel(posts)
{
IsOpen = { Value = true }
},
@ -61,11 +62,12 @@ namespace osu.Game.Tests.Visual.Online
});
}
private static APINewsPost[] posts => new[]
private static List<APINewsPost> posts => new List<APINewsPost>
{
new APINewsPost
{
Title = "Short title"
Title = "Short title",
PublishedAt = DateTimeOffset.Now
},
new APINewsPost
{

View File

@ -23,7 +23,7 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly FillFlowContainer postsFlow;
public MonthPanel(DateTime date, APINewsPost[] posts)
public MonthPanel(List<APINewsPost> posts)
{
Width = 160;
AutoSizeDuration = 250;
@ -36,7 +36,7 @@ namespace osu.Game.Overlays.News.Sidebar
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new DropdownButton(date)
new DropdownButton(posts[0].PublishedAt)
{
IsOpen = { BindTarget = IsOpen }
},
@ -87,7 +87,7 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly SpriteIcon icon;
public DropdownButton(DateTime date)
public DropdownButton(DateTimeOffset date)
{
Size = new Vector2(160, 15);
Action = IsOpen.Toggle;

View File

@ -9,7 +9,6 @@ using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Graphics.Shapes;
using osuTK;
using System.Collections.Generic;
using System;
namespace osu.Game.Overlays.News.Sidebar
{
@ -100,7 +99,7 @@ namespace osu.Game.Overlays.News.Sidebar
foreach (var keyValuePair in dict)
{
monthsFlow.Add(new MonthPanel(new DateTime(metadata.NewValue.CurrentYear, keyValuePair.Key, 1), keyValuePair.Value.ToArray())
monthsFlow.Add(new MonthPanel(keyValuePair.Value)
{
IsOpen = { Value = isFirst }
});