using System;
using System.Collections.Generic;
namespace LibationUiBase.StatusIcons;
/// What the Liberate column's icon depicts.
public enum LiberateIconKind
{
/// A stoplight, optionally with a PDF glyph beside it.
Book,
/// A series row which can be expanded.
SeriesCollapsed,
/// A series row which can be collapsed.
SeriesExpanded,
/// A book whose download errored.
Error
}
/// Which of the stoplight's three lamps is lit.
public enum StoplightLamp { Red, Yellow, Green }
/// The PDF glyph drawn beside the stoplight, if any.
public enum PdfOverlay { None, Downloaded, NotDownloaded }
///
/// Identifies one Liberate column icon. There is a small, finite number of these, so
/// caches a rendering of each one.
///
///
/// marks an Audible Plus title, as opposed to a purchased one.
///
/// Use the factory methods rather than the constructor: they leave the members which don't apply to
/// a given at their default, so that (for example) every series row
/// shares one cache entry instead of one per lamp/PDF/Plus combination.
///
///
public readonly record struct LiberateIconDescriptor(LiberateIconKind Kind, StoplightLamp Lamp, PdfOverlay Pdf, bool IsPlus, bool IsDark)
{
public static LiberateIconDescriptor ForBook(StoplightLamp lamp, PdfOverlay pdf, bool isPlus, bool isDark)
=> new(LiberateIconKind.Book, lamp, pdf, isPlus, isDark);
public static LiberateIconDescriptor ForSeries(bool expanded, bool isDark)
=> new(expanded ? LiberateIconKind.SeriesExpanded : LiberateIconKind.SeriesCollapsed, default, default, default, isDark);
public static LiberateIconDescriptor ForError(bool isDark)
=> new(LiberateIconKind.Error, default, default, default, isDark);
/// Every icon the Liberate column can display.
public static IEnumerable All()
{
foreach (var isDark in new[] { false, true })
{
foreach (var lamp in Enum.GetValues())
foreach (var pdf in Enum.GetValues())
foreach (var isPlus in new[] { false, true })
yield return ForBook(lamp, pdf, isPlus, isDark);
yield return ForSeries(expanded: false, isDark);
yield return ForSeries(expanded: true, isDark);
yield return ForError(isDark);
}
}
}