2020-08-09 10:28:43 +08:00
|
|
|
|
// 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 System;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Dashboard.Home.News
|
|
|
|
|
{
|
2020-08-12 16:24:26 +08:00
|
|
|
|
public class NewsGroupItem : CompositeDrawable
|
2020-08-09 10:28:43 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly APINewsPost post;
|
|
|
|
|
|
2020-08-12 16:24:26 +08:00
|
|
|
|
public NewsGroupItem(APINewsPost post)
|
2020-08-09 10:28:43 +08:00
|
|
|
|
{
|
|
|
|
|
this.post = post;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
InternalChild = new GridContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize)
|
|
|
|
|
},
|
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, size: 60),
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, size: 20),
|
|
|
|
|
new Dimension()
|
|
|
|
|
},
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Date(post.PublishedAt),
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Width = 1,
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Colour = colourProvider.Light1
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Padding = new MarginPadding { Right = 10 },
|
|
|
|
|
Child = new NewsTitleLink(post)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-29 00:09:37 +08:00
|
|
|
|
private class Date : CompositeDrawable, IHasCustomTooltip<DateTimeOffset>
|
2020-08-09 10:28:43 +08:00
|
|
|
|
{
|
2021-09-01 01:06:34 +08:00
|
|
|
|
private readonly DateTimeOffset date;
|
2020-08-09 10:28:43 +08:00
|
|
|
|
|
|
|
|
|
public Date(DateTimeOffset date)
|
|
|
|
|
{
|
2021-09-01 01:06:34 +08:00
|
|
|
|
this.date = date;
|
2020-08-09 10:28:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
TextFlowContainer textFlow;
|
|
|
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Anchor = Anchor.TopRight;
|
|
|
|
|
Origin = Anchor.TopRight;
|
|
|
|
|
InternalChild = textFlow = new TextFlowContainer(t =>
|
|
|
|
|
{
|
|
|
|
|
t.Colour = colourProvider.Light1;
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Margin = new MarginPadding { Vertical = 5 }
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-01 01:06:34 +08:00
|
|
|
|
textFlow.AddText($"{date:dd}", t =>
|
2020-08-09 10:28:43 +08:00
|
|
|
|
{
|
|
|
|
|
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
|
|
|
|
|
});
|
|
|
|
|
|
2021-09-01 01:06:34 +08:00
|
|
|
|
textFlow.AddText($"{date: MMM}", t =>
|
2020-08-09 10:28:43 +08:00
|
|
|
|
{
|
|
|
|
|
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-09-01 01:06:34 +08:00
|
|
|
|
|
|
|
|
|
ITooltip<DateTimeOffset> IHasCustomTooltip<DateTimeOffset>.GetCustomTooltip() => new DateTooltip();
|
|
|
|
|
|
|
|
|
|
DateTimeOffset IHasCustomTooltip<DateTimeOffset>.TooltipContent => date;
|
2020-08-09 10:28:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|