Console Styling

This commit is contained in:
2023-08-21 12:27:02 +02:00
parent 793f653db0
commit fff07e5da7
26 changed files with 572 additions and 160 deletions

View File

@@ -0,0 +1,9 @@
using FileTime.ConsoleUI.App.Configuration.Theme;
namespace FileTime.ConsoleUI.App.Configuration;
public class StyleConfigurationRoot
{
public string? Theme { get; set; }
public Dictionary<string, ThemeConfiguration> Themes { get; set; } = new();
}

View File

@@ -0,0 +1,6 @@
namespace FileTime.ConsoleUI.App.Configuration.Theme;
public class ConsoleThemeConfiguration
{
public ControlThemesConfiguration ControlThemes { get; set; } = new();
}

View File

@@ -0,0 +1,6 @@
namespace FileTime.ConsoleUI.App.Configuration.Theme;
public class ControlThemesConfiguration
{
public ProgressBarThemeConfiguration? ProgressBar { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace FileTime.ConsoleUI.App.Configuration.Theme;
public class ListViewItemThemeConfiguration
{
public string? SelectedForegroundColor { get; set; }
public string? SelectedBackgroundColor { get; set; }
}

View File

@@ -0,0 +1,24 @@
using TerminalUI.Models;
namespace FileTime.ConsoleUI.App.Configuration.Theme;
public class ProgressBarThemeConfiguration
{
public string? ForegroundColor { get; set; }
public string? BackgroundColor { get; set; }
public string? UnfilledForeground { get; set; }
public string? UnfilledBackground { get; set; }
public SelectiveChar? FilledCharacter { get; set; }
public SelectiveChar? UnfilledCharacter { get; set; }
public SelectiveChar? Fraction1Per8Character { get; set; }
public SelectiveChar? Fraction2Per8Character { get; set; }
public SelectiveChar? Fraction3Per8Character { get; set; }
public SelectiveChar? Fraction4Per8Character { get; set; }
public SelectiveChar? Fraction5Per8Character { get; set; }
public SelectiveChar? Fraction6Per8Character { get; set; }
public SelectiveChar? Fraction7Per8Character { get; set; }
public SelectiveChar? FractionFull { get; set; }
public SelectiveChar? LeftCap { get; set; }
public SelectiveChar? RightCap { get; set; }
}

View File

@@ -0,0 +1,20 @@
namespace FileTime.ConsoleUI.App.Configuration.Theme;
public class ThemeConfiguration
{
public string? DefaultForegroundColor { get; set; }
public string? DefaultForegroundAccentColor { get; set; }
public string? DefaultBackgroundColor { get; set; }
public string? ElementColor { get; set; }
public string? ContainerColor { get; set; }
public string? MarkedItemForegroundColor { get; set; }
public string? MarkedItemBackgroundColor { get; set; }
public string? MarkedSelectedItemForegroundColor { get; set; }
public string? MarkedSelectedItemBackgroundColor { get; set; }
public string? SelectedItemColor { get; set; }
public string? SelectedTabBackgroundColor { get; set; }
public string? WarningForegroundColor { get; set; }
public string? ErrorForegroundColor { get; set; }
public ConsoleThemeConfiguration? ConsoleTheme { get; set; }
public ListViewItemThemeConfiguration? ListViewItemTheme { get; set; }
}

View File

@@ -1,7 +0,0 @@
namespace FileTime.ConsoleUI.App;
public interface IColorSampleProvider
{
public Type? ForegroundColors { get; }
public Type? BackgroundColors { get; }
}

View File

@@ -0,0 +1,96 @@
using TerminalUI.Color;
namespace FileTime.ConsoleUI.App.Styling;
using IConsoleTheme = TerminalUI.Styling.ITheme;
using ConsoleTheme = TerminalUI.Styling.Theme;
public record Theme(
IColor? DefaultForegroundColor,
IColor? DefaultForegroundAccentColor,
IColor? DefaultBackgroundColor,
IColor? ElementColor,
IColor? ContainerColor,
IColor? MarkedItemForegroundColor,
IColor? MarkedItemBackgroundColor,
IColor? MarkedSelectedItemForegroundColor,
IColor? MarkedSelectedItemBackgroundColor,
IColor? SelectedItemColor,
IColor? SelectedTabBackgroundColor,
IColor? WarningForegroundColor,
IColor? ErrorForegroundColor,
ListViewItemTheme ListViewItemTheme,
IConsoleTheme? ConsoleTheme) : ITheme;
/*public static class DefaultThemes
{
public static Theme Color256Theme => new(
DefaultForegroundColor: null,
DefaultForegroundAccentColor: Color256Colors.Foregrounds.Red,
DefaultBackgroundColor: null,
ElementColor: Color256Colors.Foregrounds.Gray,
ContainerColor: Color256Colors.Foregrounds.Blue,
MarkedItemForegroundColor: Color256Colors.Foregrounds.Yellow,
MarkedItemBackgroundColor: null,
MarkedSelectedItemForegroundColor: Color256Colors.Foregrounds.Black,
MarkedSelectedItemBackgroundColor: Color256Colors.Foregrounds.Yellow,
SelectedItemColor: Color256Colors.Foregrounds.Black,
SelectedTabBackgroundColor: Color256Colors.Backgrounds.Green,
WarningForegroundColor: Color256Colors.Foregrounds.Yellow,
ErrorForegroundColor: Color256Colors.Foregrounds.Red,
ListViewItemTheme: new(
SelectedBackgroundColor: Color256Colors.Backgrounds.Gray,
SelectedForegroundColor: Color256Colors.Foregrounds.Black
),
ConsoleTheme: new ConsoleTheme
{
ControlThemes = new ControlThemes
{
ProgressBar = new ProgressBarTheme
{
ForegroundColor = Color256Colors.Foregrounds.Blue,
BackgroundColor = Color256Colors.Backgrounds.Gray,
UnfilledForeground = Color256Colors.Foregrounds.Gray,
UnfilledBackground = Color256Colors.Backgrounds.Gray,
}
}
},
ForegroundColors: typeof(Color256Colors.Foregrounds),
BackgroundColors: typeof(Color256Colors.Backgrounds)
);
public static Theme ConsoleColorTheme => new(
DefaultForegroundColor: null,
DefaultForegroundAccentColor: ConsoleColors.Foregrounds.Red,
DefaultBackgroundColor: null,
ElementColor: ConsoleColors.Foregrounds.Gray,
ContainerColor: ConsoleColors.Foregrounds.Blue,
MarkedItemForegroundColor: ConsoleColors.Foregrounds.Yellow,
MarkedItemBackgroundColor: null,
MarkedSelectedItemForegroundColor: ConsoleColors.Foregrounds.Black,
MarkedSelectedItemBackgroundColor: ConsoleColors.Foregrounds.Yellow,
SelectedItemColor: ConsoleColors.Foregrounds.Black,
SelectedTabBackgroundColor: ConsoleColors.Backgrounds.Green,
WarningForegroundColor: ConsoleColors.Foregrounds.Yellow,
ErrorForegroundColor: ConsoleColors.Foregrounds.Red,
ListViewItemTheme: new(
SelectedBackgroundColor: ConsoleColors.Backgrounds.Gray,
SelectedForegroundColor: ConsoleColors.Foregrounds.Black
),
ConsoleTheme: new ConsoleTheme
{
ControlThemes = new ControlThemes
{
ProgressBar = new ProgressBarTheme
{
ForegroundColor = ConsoleColors.Foregrounds.Blue,
BackgroundColor = ConsoleColors.Backgrounds.Gray,
UnfilledForeground = ConsoleColors.Foregrounds.Gray,
UnfilledBackground = ConsoleColors.Backgrounds.Gray
}
}
},
ForegroundColors: typeof(ConsoleColors.Foregrounds),
BackgroundColors: typeof(ConsoleColors.Backgrounds)
);
}*/

View File

@@ -0,0 +1,6 @@
namespace FileTime.ConsoleUI.App.Styling;
public interface IThemeProvider
{
ITheme CurrentTheme { get; }
}