Remove NewsPostDrawableDate

This commit is contained in:
Andrei Zavatski 2020-08-09 05:16:08 +03:00
parent cddd4f0a97
commit a72a48624d
4 changed files with 67 additions and 79 deletions

View File

@ -7,6 +7,7 @@ using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
@ -44,18 +45,31 @@ namespace osu.Game.Overlays.Dashboard.Home.News
protected override Drawable CreateContent(APINewsPost post) => new NewsTitleLink(post); protected override Drawable CreateContent(APINewsPost post) => new NewsTitleLink(post);
protected override NewsPostDrawableDate CreateDate(DateTimeOffset date) => new Date(date); protected override Drawable CreateDate(DateTimeOffset date) => new Date(date);
private class Date : NewsPostDrawableDate
{
public Date(DateTimeOffset date)
: base(date)
{
} }
protected override Drawable CreateDate(DateTimeOffset date, OverlayColourProvider colourProvider) private class Date : CompositeDrawable, IHasCustomTooltip
{ {
var drawableDate = new TextFlowContainer(t => public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date;
public Date(DateTimeOffset date)
{
this.date = date;
}
[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; t.Colour = colourProvider.Light1;
}) })
@ -67,18 +81,15 @@ namespace osu.Game.Overlays.Dashboard.Home.News
Margin = new MarginPadding { Vertical = 5 } Margin = new MarginPadding { Vertical = 5 }
}; };
drawableDate.AddText($"{date:dd} ", t => textFlow.AddText($"{date:dd}", t =>
{ {
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold); t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
}); });
drawableDate.AddText($"{date:MMM}", t => textFlow.AddText($"{date: MMM}", t =>
{ {
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular); t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
}); });
return drawableDate;
}
} }
} }
} }

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -84,14 +85,14 @@ namespace osu.Game.Overlays.Dashboard.Home.News
private class Footer : HomeNewsPanelFooter private class Footer : HomeNewsPanelFooter
{ {
protected override float BarPading => 10; protected override float BarPadding => 10;
public Footer(APINewsPost post) public Footer(APINewsPost post)
: base(post) : base(post)
{ {
} }
protected override NewsPostDrawableDate CreateDate(DateTimeOffset date) => new Date(date); protected override Drawable CreateDate(DateTimeOffset date) => new Date(date);
protected override Drawable CreateContent(APINewsPost post) => new FillFlowContainer protected override Drawable CreateContent(APINewsPost post) => new FillFlowContainer
{ {
@ -114,16 +115,29 @@ namespace osu.Game.Overlays.Dashboard.Home.News
} }
} }
}; };
private class Date : NewsPostDrawableDate
{
public Date(DateTimeOffset date)
: base(date)
{
Margin = new MarginPadding { Top = 10 };
} }
protected override Drawable CreateDate(DateTimeOffset date, OverlayColourProvider colourProvider) => new FillFlowContainer private class Date : CompositeDrawable, IHasCustomTooltip
{
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date;
public Date(DateTimeOffset date)
{
this.date = date;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
AutoSizeAxes = Axes.Both;
Anchor = Anchor.TopRight;
Origin = Anchor.TopRight;
Margin = new MarginPadding { Top = 10 };
InternalChild = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,

View File

@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
{ {
public abstract class HomeNewsPanelFooter : CompositeDrawable public abstract class HomeNewsPanelFooter : CompositeDrawable
{ {
protected virtual float BarPading { get; } = 0; protected virtual float BarPadding { get; } = 0;
private readonly APINewsPost post; private readonly APINewsPost post;
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Vertical = BarPading }, Padding = new MarginPadding { Vertical = BarPadding },
Child = new Box Child = new Box
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
@ -72,7 +72,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
}; };
} }
protected abstract NewsPostDrawableDate CreateDate(DateTimeOffset date); protected abstract Drawable CreateDate(DateTimeOffset date);
protected abstract Drawable CreateContent(APINewsPost post); protected abstract Drawable CreateContent(APINewsPost post);
} }

View File

@ -1,37 +0,0 @@
// 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.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics;
using osu.Framework.Graphics;
namespace osu.Game.Overlays.Dashboard.Home.News
{
public abstract class NewsPostDrawableDate : CompositeDrawable, IHasCustomTooltip
{
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date;
protected NewsPostDrawableDate(DateTimeOffset date)
{
this.date = date;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
AutoSizeAxes = Axes.Both;
Anchor = Anchor.TopRight;
Origin = Anchor.TopRight;
InternalChild = CreateDate(date, colourProvider);
}
protected abstract Drawable CreateDate(DateTimeOffset date, OverlayColourProvider colourProvider);
}
}