mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-13 19:37:44 +01:00
Add Reduced Motion for Notifications (#1732)
When Reduced Motion configuration is on, the expiry progressbar is removed, and instead a pie on top right is shown, and relative time update interval increases to 15 seconds. Progress wave animation also is suppressed.
This commit is contained in:
parent
fb60ac5b4b
commit
95defa200f
6 changed files with 185 additions and 49 deletions
|
|
@ -44,8 +44,9 @@ public static class DateTimeSpanExtensions
|
|||
|
||||
/// <summary>Formats an instance of <see cref="DateTime"/> as a localized relative time.</summary>
|
||||
/// <param name="when">When.</param>
|
||||
/// <param name="floorBy">The alignment unit of time span.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
public static string LocRelativePastLong(this DateTime when)
|
||||
public static string LocRelativePastLong(this DateTime when, TimeSpan floorBy)
|
||||
{
|
||||
var loc = Loc.Localize(
|
||||
"DateTimeSpanExtensions.RelativeFormatStringsLong",
|
||||
|
|
@ -55,13 +56,17 @@ public static class DateTimeSpanExtensions
|
|||
if (relativeFormatStringLong?.FormatStringLoc != loc)
|
||||
relativeFormatStringLong ??= new(loc);
|
||||
|
||||
return relativeFormatStringLong.Format(DateTime.Now - when);
|
||||
return
|
||||
floorBy == default
|
||||
? relativeFormatStringLong.Format(DateTime.Now - when)
|
||||
: relativeFormatStringLong.Format(Math.Floor((DateTime.Now - when) / floorBy) * floorBy);
|
||||
}
|
||||
|
||||
/// <summary>Formats an instance of <see cref="DateTime"/> as a localized relative time.</summary>
|
||||
/// <param name="when">When.</param>
|
||||
/// <param name="floorBy">The alignment unit of time span.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
public static string LocRelativePastShort(this DateTime when)
|
||||
public static string LocRelativePastShort(this DateTime when, TimeSpan floorBy)
|
||||
{
|
||||
var loc = Loc.Localize(
|
||||
"DateTimeSpanExtensions.RelativeFormatStringsShort",
|
||||
|
|
@ -71,9 +76,22 @@ public static class DateTimeSpanExtensions
|
|||
if (relativeFormatStringShort?.FormatStringLoc != loc)
|
||||
relativeFormatStringShort = new(loc);
|
||||
|
||||
return relativeFormatStringShort.Format(DateTime.Now - when);
|
||||
return
|
||||
floorBy == default
|
||||
? relativeFormatStringShort.Format(DateTime.Now - when)
|
||||
: relativeFormatStringShort.Format(Math.Floor((DateTime.Now - when) / floorBy) * floorBy);
|
||||
}
|
||||
|
||||
/// <summary>Formats an instance of <see cref="DateTime"/> as a localized relative time.</summary>
|
||||
/// <param name="when">When.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
public static string LocRelativePastLong(this DateTime when) => when.LocRelativePastLong(TimeSpan.FromSeconds(1));
|
||||
|
||||
/// <summary>Formats an instance of <see cref="DateTime"/> as a localized relative time.</summary>
|
||||
/// <param name="when">When.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
public static string LocRelativePastShort(this DateTime when) => when.LocRelativePastShort(TimeSpan.FromSeconds(1));
|
||||
|
||||
private sealed class ParsedRelativeFormatStrings
|
||||
{
|
||||
private readonly List<(float MinSeconds, string FormatString)> formatStrings = new();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue