From 00e5eadab101ba96b4cc82bc9fb7b971e6784aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BE=D1=81=D0=BE=D0=B2?= Date: Mon, 1 Apr 2024 19:16:15 +0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20breadcrumbs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/BreadCrumbsComponent.cs | 20 +++++++++++++ .../Controls/Containers/FooterContainer.cs | 28 +++++++++++++++++++ src/TUI/Controls/Layouts/DashboardLayout.cs | 6 +--- src/TUI/Pages/DependenciesPage.cs | 6 ++-- 4 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 src/TUI/Controls/Components/BreadCrumbsComponent.cs create mode 100644 src/TUI/Controls/Containers/FooterContainer.cs diff --git a/src/TUI/Controls/Components/BreadCrumbsComponent.cs b/src/TUI/Controls/Components/BreadCrumbsComponent.cs new file mode 100644 index 0000000..0d230a5 --- /dev/null +++ b/src/TUI/Controls/Components/BreadCrumbsComponent.cs @@ -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 _crumbs = new() { " " }; + + public BreadCrumbsComponent(params string[] crumbs) + { + _crumbs.AddRange(crumbs); + } + + protected override Sketch DrawComponent(Size minSize) + { + return new Sketch(string.Join("  ".Hint(), _crumbs).Hint()); + } +} \ No newline at end of file diff --git a/src/TUI/Controls/Containers/FooterContainer.cs b/src/TUI/Controls/Containers/FooterContainer.cs new file mode 100644 index 0000000..90c98d5 --- /dev/null +++ b/src/TUI/Controls/Containers/FooterContainer.cs @@ -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 }; + } +} \ No newline at end of file diff --git a/src/TUI/Controls/Layouts/DashboardLayout.cs b/src/TUI/Controls/Layouts/DashboardLayout.cs index 9efb3a7..f8e75e6 100644 --- a/src/TUI/Controls/Layouts/DashboardLayout.cs +++ b/src/TUI/Controls/Layouts/DashboardLayout.cs @@ -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; diff --git a/src/TUI/Pages/DependenciesPage.cs b/src/TUI/Pages/DependenciesPage.cs index aa2ecd1..985f2b9 100644 --- a/src/TUI/Pages/DependenciesPage.cs +++ b/src/TUI/Pages/DependenciesPage.cs @@ -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();