teamlead-dashboard/src/TUI/UserInterface/Header.cs

79 lines
2.9 KiB
C#
Raw Normal View History

2023-08-03 19:21:06 +00:00
using TUI.Controls;
namespace TUI.UserInterface;
public class Header : IControl
{
public const int LogoWidth = 16;
public const int Height = 6;
2023-08-10 13:55:22 +00:00
public const int MaxHeaderBlocksWidth = 16;
private readonly Dictionary<string, string> _hints = new()
{
{ "󰎔", "too new".Info() },
{ "", "so good" },
{ "", "be nice".Primary() },
{ "󰬟", "too old".Warning() }
};
2023-08-29 04:40:28 +00:00
private readonly Dictionary<string, string> _hotKeys = new()
{
{ "", "select prev" },
{ "", "select next" },
{ "󰬌", "toggle head" },
{ "󰬘", "quit" }
};
2023-08-10 13:55:22 +00:00
private readonly Dictionary<string, string> _tags = new()
{
{ Icons.Auth, "Auth" },
{ Icons.NetworkPublic, "WWW" },
{ Icons.SEO, "SEO" },
2023-08-29 04:40:28 +00:00
{ Icons.GitLab, "VCS" }
2023-08-10 13:55:22 +00:00
};
2023-08-03 19:21:06 +00:00
public void Render(Position position)
{
Console.SetCursorPosition(position.Left, position.Top);
2023-08-29 04:40:28 +00:00
for (var i = 1; i <= Height; i++) Console.WriteLine(new string(' ', Console.WindowWidth - LogoWidth));
2023-08-03 19:21:06 +00:00
2023-08-10 13:55:22 +00:00
RenderBlock(0, _hints);
RenderBlock(1, _tags);
RenderBlock(2, Icons.Applications);
RenderBlock(3, _hotKeys);
2023-08-03 19:21:06 +00:00
RenderLogo();
}
2023-08-10 13:55:22 +00:00
private static void RenderBlock(int blockNumber, Dictionary<string, string> items)
2023-08-06 20:12:22 +00:00
{
2023-08-10 13:55:22 +00:00
var leftPadding = Theme.Padding + blockNumber * MaxHeaderBlocksWidth;
2023-08-06 20:12:22 +00:00
2023-08-10 13:55:22 +00:00
var hotKeyNumber = 0;
foreach (var item in items)
{
Console.SetCursorPosition(leftPadding, Theme.Padding + hotKeyNumber++);
Console.Write((item.Key + " " + item.Value).Hint());
}
2023-08-06 20:12:22 +00:00
}
2023-08-10 13:55:22 +00:00
private static void RenderLogo()
2023-08-03 19:21:06 +00:00
{
Console.SetCursorPosition(Console.WindowWidth - LogoWidth - Theme.Padding, 0);
Console.WriteLine(" ╭━━━━┳╮".Primary() + "".Hint() + "╭━━━╮ ".Primary());
Console.SetCursorPosition(Console.WindowWidth - LogoWidth - Theme.Padding, 1);
Console.WriteLine(" ┃╭╮╭╮┃┃".Primary() + "".Hint() + "╰╮╭╮┃ ".Primary());
Console.SetCursorPosition(Console.WindowWidth - LogoWidth - Theme.Padding, 2);
Console.WriteLine(" ╰╯┃┃╰┫┃".Primary() + "".Hint() + "┃┃┃┃ ".Primary());
Console.SetCursorPosition(Console.WindowWidth - LogoWidth - Theme.Padding, 3);
2023-08-10 13:55:22 +00:00
Console.WriteLine(" ".Hint() + "┃┃".Primary() + "".Hint() + "┃┃".Primary() + "".Hint() +
"╭╮┃┃┃┃ ".Primary());
2023-08-03 19:21:06 +00:00
Console.SetCursorPosition(Console.WindowWidth - LogoWidth - Theme.Padding, 4);
Console.WriteLine(" ".Hint() + "┃┃".Primary() + "".Hint() + "┃╰━╯┣╯╰╯┃ ".Primary());
Console.SetCursorPosition(Console.WindowWidth - LogoWidth - Theme.Padding, 5);
Console.WriteLine("".Hint() + "╰╯".Primary() + "".Hint() + "╰━━━┻━━━╯ ".Primary());
}
}