mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 10:42:54 +08:00
Remove HomeNewsPanelFooter
This commit is contained in:
parent
a72a48624d
commit
d8f8930691
115
osu.Game/Overlays/Dashboard/Home/News/CollapsedNewsPanel.cs
Normal file
115
osu.Game/Overlays/Dashboard/Home/News/CollapsedNewsPanel.cs
Normal file
@ -0,0 +1,115 @@
|
||||
// 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
|
||||
{
|
||||
public class CollapsedNewsPanel : CompositeDrawable
|
||||
{
|
||||
private readonly APINewsPost post;
|
||||
|
||||
public CollapsedNewsPanel(APINewsPost post)
|
||||
{
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 }
|
||||
};
|
||||
|
||||
textFlow.AddText($"{date:dd}", t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
|
||||
});
|
||||
|
||||
textFlow.AddText($"{date: MMM}", t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,11 @@
|
||||
// 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 System.Collections.Generic;
|
||||
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;
|
||||
|
||||
namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
@ -35,62 +32,5 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
Children = posts.Select(p => new CollapsedNewsPanel(p)).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
private class CollapsedNewsPanel : HomeNewsPanelFooter
|
||||
{
|
||||
public CollapsedNewsPanel(APINewsPost post)
|
||||
: base(post)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent(APINewsPost post) => new NewsTitleLink(post);
|
||||
|
||||
protected override Drawable CreateDate(DateTimeOffset date) => new Date(date);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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 }
|
||||
};
|
||||
|
||||
textFlow.AddText($"{date:dd}", t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold);
|
||||
});
|
||||
|
||||
textFlow.AddText($"{date: MMM}", t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: 14, weight: FontWeight.Regular);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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.Framework.Platform;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@ -27,7 +28,7 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -39,7 +40,63 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new ClickableNewsBackground(post),
|
||||
new Footer(post)
|
||||
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 Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Vertical = 10 },
|
||||
Child = new Box
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopRight,
|
||||
Width = 1,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Colour = colourProvider.Light1
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 10 },
|
||||
Padding = new MarginPadding { Right = 10 },
|
||||
Spacing = new Vector2(0, 10),
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new NewsTitleLink(post),
|
||||
new TextFlowContainer(f =>
|
||||
{
|
||||
f.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular);
|
||||
})
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Text = post.Preview
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -83,40 +140,6 @@ namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
}
|
||||
}
|
||||
|
||||
private class Footer : HomeNewsPanelFooter
|
||||
{
|
||||
protected override float BarPadding => 10;
|
||||
|
||||
public Footer(APINewsPost post)
|
||||
: base(post)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Drawable CreateDate(DateTimeOffset date) => new Date(date);
|
||||
|
||||
protected override Drawable CreateContent(APINewsPost post) => new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 5, Bottom = 10 },
|
||||
Spacing = new Vector2(0, 10),
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new NewsTitleLink(post),
|
||||
new TextFlowContainer(f =>
|
||||
{
|
||||
f.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular);
|
||||
})
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Text = post.Preview
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class Date : CompositeDrawable, IHasCustomTooltip
|
||||
{
|
||||
public ITooltip GetCustomTooltip() => new DateTooltip();
|
||||
|
@ -1,79 +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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Overlays.Dashboard.Home.News
|
||||
{
|
||||
public abstract class HomeNewsPanelFooter : CompositeDrawable
|
||||
{
|
||||
protected virtual float BarPadding { get; } = 0;
|
||||
|
||||
private readonly APINewsPost post;
|
||||
|
||||
protected HomeNewsPanelFooter(APINewsPost post)
|
||||
{
|
||||
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[]
|
||||
{
|
||||
CreateDate(post.PublishedAt),
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding { Vertical = BarPadding },
|
||||
Child = 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 = CreateContent(post)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract Drawable CreateDate(DateTimeOffset date);
|
||||
|
||||
protected abstract Drawable CreateContent(APINewsPost post);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user