mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Remove overcomplicated date logic in MonthPanel
This commit is contained in:
parent
fbf8b198cd
commit
220eef0351
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -33,7 +34,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colourProvider.Background2,
|
Colour = colourProvider.Background2,
|
||||||
},
|
},
|
||||||
new MonthPanel(DateTime.Now, posts),
|
new MonthPanel(posts),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colourProvider.Background2,
|
Colour = colourProvider.Background2,
|
||||||
},
|
},
|
||||||
new MonthPanel(DateTime.Now, posts)
|
new MonthPanel(posts)
|
||||||
{
|
{
|
||||||
IsOpen = { Value = true }
|
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
|
new APINewsPost
|
||||||
{
|
{
|
||||||
Title = "Short title"
|
Title = "Short title",
|
||||||
|
PublishedAt = DateTimeOffset.Now
|
||||||
},
|
},
|
||||||
new APINewsPost
|
new APINewsPost
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.News.Sidebar
|
|||||||
|
|
||||||
private readonly FillFlowContainer postsFlow;
|
private readonly FillFlowContainer postsFlow;
|
||||||
|
|
||||||
public MonthPanel(DateTime date, APINewsPost[] posts)
|
public MonthPanel(List<APINewsPost> posts)
|
||||||
{
|
{
|
||||||
Width = 160;
|
Width = 160;
|
||||||
AutoSizeDuration = 250;
|
AutoSizeDuration = 250;
|
||||||
@ -36,7 +36,7 @@ namespace osu.Game.Overlays.News.Sidebar
|
|||||||
Spacing = new Vector2(0, 5),
|
Spacing = new Vector2(0, 5),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DropdownButton(date)
|
new DropdownButton(posts[0].PublishedAt)
|
||||||
{
|
{
|
||||||
IsOpen = { BindTarget = IsOpen }
|
IsOpen = { BindTarget = IsOpen }
|
||||||
},
|
},
|
||||||
@ -87,7 +87,7 @@ namespace osu.Game.Overlays.News.Sidebar
|
|||||||
|
|
||||||
private readonly SpriteIcon icon;
|
private readonly SpriteIcon icon;
|
||||||
|
|
||||||
public DropdownButton(DateTime date)
|
public DropdownButton(DateTimeOffset date)
|
||||||
{
|
{
|
||||||
Size = new Vector2(160, 15);
|
Size = new Vector2(160, 15);
|
||||||
Action = IsOpen.Toggle;
|
Action = IsOpen.Toggle;
|
||||||
|
@ -9,7 +9,6 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.News.Sidebar
|
namespace osu.Game.Overlays.News.Sidebar
|
||||||
{
|
{
|
||||||
@ -100,7 +99,7 @@ namespace osu.Game.Overlays.News.Sidebar
|
|||||||
|
|
||||||
foreach (var keyValuePair in dict)
|
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 }
|
IsOpen = { Value = isFirst }
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user