Add breadcrumbs

This commit is contained in:
Kolosov Alexandr 2024-04-01 19:16:15 +05:00
parent f80a78f8cb
commit 00e5eadab1
4 changed files with 53 additions and 7 deletions

View File

@ -0,0 +1,20 @@
using TUI.Engine.Attributes;
using TUI.Engine.Components;
using TUI.Engine.Theme;
namespace TUI.Controls.Components;
public class BreadCrumbsComponent : ComponentBase
{
private readonly List<string> _crumbs = new() { " " };
public BreadCrumbsComponent(params string[] crumbs)
{
_crumbs.AddRange(crumbs);
}
protected override Sketch DrawComponent(Size minSize)
{
return new Sketch(string.Join("  ".Hint(), _crumbs).Hint());
}
}

View File

@ -0,0 +1,28 @@
using TUI.Controls.Statics;
using TUI.Engine.Attributes.Alignments;
using TUI.Engine.Components;
using TUI.Engine.Containers;
using TUI.Engine.Nodes;
using TUI.Engine.Theme;
namespace TUI.Controls.Containers;
public class FooterContainer : ContainerBase
{
private readonly INode _breadcrumbs;
public FooterContainer(IComponent breadcrumbs)
{
breadcrumbs.SetAlignment(Horizontal.Left);
breadcrumbs.SetPaddingLeft(Level.Normal);
_breadcrumbs = breadcrumbs;
}
public override Nodes GetNodes()
{
var copyright = new CopyrightComponent();
copyright.SetAlignment(Horizontal.Right);
copyright.SetPaddingRight(Level.Normal);
return new Nodes { _breadcrumbs, copyright };
}
}

View File

@ -3,7 +3,6 @@ using TUI.Engine.Attributes.Orientations;
using TUI.Engine.Components;
using TUI.Engine.Containers;
using TUI.Engine.Nodes;
using TUI.Engine.Theme;
namespace TUI.Controls.Layouts;
@ -13,7 +12,7 @@ public class DashboardLayout : ContainerBase, IContainer
private readonly INode _footer;
private readonly INode _dashboard;
public DashboardLayout(INode header, INode dashboard, IComponent footer)
public DashboardLayout(INode header, INode dashboard, INode footer)
{
SetOrientationVertical();
SetAdaptive(Orientation.Horizontal);
@ -21,9 +20,6 @@ public class DashboardLayout : ContainerBase, IContainer
header.SetFixed(Orientation.Vertical, 6);
footer.SetFixed(Orientation.Vertical, 1);
footer.SetPaddingRight(Level.Normal);
footer.SetAlignment(Horizontal.Right);
footer.SetAlignment(Vertical.Bottom);
_header = header;
_footer = footer;

View File

@ -4,6 +4,7 @@ using TUI.Controls.Containers;
using TUI.Controls.Layouts;
using TUI.Controls.Statics;
using TUI.Domain;
using TUI.Engine;
using TUI.Engine.Rendering.Canvas;
using TUI.Providers.Dependencies;
using TUI.Store;
@ -40,7 +41,6 @@ public class DependenciesPage : PageBase
ICanvas canvas = new ConsoleCanvas();
var header = new HeaderContainer();
var copyright = new CopyrightComponent();
var dashboard = new DashboardContainer();
var dependenciesHeader = new DependenciesContainer();
dependenciesHeader.AddTitleStub();
@ -59,7 +59,9 @@ public class DependenciesPage : PageBase
dashboard.AddChildren(projectDependencies);
}
var layout = new DashboardLayout(header, dashboard, copyright);
var breadCrumbs = new BreadCrumbsComponent(" dependencies", "JavaScript");
var footer = new FooterContainer(breadCrumbs);
var layout = new DashboardLayout(header, dashboard, footer);
canvas.Draw(layout);
// CommandLine = new CommandLine();