1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
@ -44,41 +45,51 @@ namespace osu.Game.Overlays.Dashboard.Home.News
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
private class Date : CompositeDrawable, IHasCustomTooltip
{
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date;
public Date(DateTimeOffset date)
{
public Date(DateTimeOffset date)
: base(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 =>
{
}
protected override Drawable CreateDate(DateTimeOffset date, OverlayColourProvider colourProvider)
t.Colour = colourProvider.Light1;
})
{
var drawableDate = new TextFlowContainer(t =>
{
t.Colour = colourProvider.Light1;
})
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Vertical = 5 }
};
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Vertical = 5 }
};
drawableDate.AddText($"{date:dd} ", t =>
{
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
});
textFlow.AddText($"{date:dd}", t =>
{
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
});
drawableDate.AddText($"{date:MMM}", t =>
{
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
});
return drawableDate;
}
textFlow.AddText($"{date: MMM}", t =>
{
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
});
}
}
}

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Platform;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@ -84,14 +85,14 @@ namespace osu.Game.Overlays.Dashboard.Home.News
private class Footer : HomeNewsPanelFooter
{
protected override float BarPading => 10;
protected override float BarPadding => 10;
public Footer(APINewsPost 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
{
@ -114,16 +115,29 @@ namespace osu.Game.Overlays.Dashboard.Home.News
}
}
};
}
private class Date : NewsPostDrawableDate
private class Date : CompositeDrawable, IHasCustomTooltip
{
public ITooltip GetCustomTooltip() => new DateTooltip();
public object TooltipContent => date;
private readonly DateTimeOffset date;
public Date(DateTimeOffset date)
{
public Date(DateTimeOffset date)
: base(date)
{
Margin = new MarginPadding { Top = 10 };
}
this.date = date;
}
protected override Drawable CreateDate(DateTimeOffset date, OverlayColourProvider colourProvider) => new FillFlowContainer
[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,
Direction = FillDirection.Vertical,
@ -137,7 +151,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
Origin = Anchor.TopRight,
Font = OsuFont.GetFont(weight: FontWeight.Bold), // using Bold since there is no 800 weight alternative
Colour = colourProvider.Light1,
Text = $"{date: dd}"
Text = $"{date:dd}"
},
new TextFlowContainer(f =>
{

View File

@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
{
public abstract class HomeNewsPanelFooter : CompositeDrawable
{
protected virtual float BarPading { get; } = 0;
protected virtual float BarPadding { get; } = 0;
private readonly APINewsPost post;
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Vertical = BarPading },
Padding = new MarginPadding { Vertical = BarPadding },
Child = new Box
{
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);
}

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);
}
}