mirror of
https://github.com/dnwSilver/tld.git
synced 2024-11-25 16:42:07 +00:00
✨ Do page singletones.
This commit is contained in:
parent
d7d2fcd0a6
commit
044618e690
@ -10,6 +10,12 @@ public record DependenciesState(HeaderContainer Header, DashboardContainer Dashb
|
||||
|
||||
public class DependenciesPage : PageBase
|
||||
{
|
||||
private DependenciesPage()
|
||||
{
|
||||
}
|
||||
|
||||
public static DependenciesPage Instance { get; } = new();
|
||||
|
||||
private DependenciesStore _store;
|
||||
|
||||
private DependenciesState _state;
|
||||
@ -48,7 +54,7 @@ public class DependenciesPage : PageBase
|
||||
canvas.Draw(layout);
|
||||
}
|
||||
|
||||
public void LoadDependencies()
|
||||
public override void Load()
|
||||
{
|
||||
Initial();
|
||||
var projects = _state.Dashboard.GetContent();
|
||||
|
@ -6,4 +6,5 @@ interface IPage
|
||||
void Initial();
|
||||
void Render();
|
||||
void Bind();
|
||||
void Load();
|
||||
}
|
@ -12,6 +12,8 @@ public abstract class PageBase : IPage
|
||||
Render();
|
||||
}
|
||||
|
||||
public abstract void Load();
|
||||
|
||||
public abstract void Initial();
|
||||
|
||||
public abstract void Render();
|
||||
|
@ -10,6 +10,12 @@ namespace TUI.Pages;
|
||||
|
||||
public class WelcomePage : PageBase
|
||||
{
|
||||
private WelcomePage()
|
||||
{
|
||||
}
|
||||
|
||||
public static WelcomePage Instance { get; } = new();
|
||||
|
||||
public override void Initial()
|
||||
{
|
||||
}
|
||||
@ -31,6 +37,10 @@ public class WelcomePage : PageBase
|
||||
canvas.Draw(layout);
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Bind()
|
||||
{
|
||||
}
|
||||
|
@ -4,14 +4,12 @@
|
||||
Console.Clear();
|
||||
Console.CursorVisible = false;
|
||||
|
||||
// var settings = Settings.Init();
|
||||
|
||||
var welcomePage = new WelcomePage();
|
||||
var welcomePage = WelcomePage.Instance;
|
||||
welcomePage.Open();
|
||||
Thread.Sleep(500);
|
||||
|
||||
var dependenciesPage = new DependenciesPage();
|
||||
dependenciesPage.Open();
|
||||
IPage currentPage = DependenciesPage.Instance;
|
||||
currentPage.Open();
|
||||
|
||||
|
||||
ConsoleKeyInfo? key = null;
|
||||
@ -19,19 +17,32 @@ ConsoleKeyInfo? key = null;
|
||||
var waitCommand = true;
|
||||
do
|
||||
{
|
||||
if (key?.Key == ConsoleKey.Q)
|
||||
switch (key?.Key)
|
||||
{
|
||||
case ConsoleKey.Q:
|
||||
waitCommand = false;
|
||||
continue;
|
||||
break;
|
||||
case ConsoleKey.R:
|
||||
key = null;
|
||||
currentPage.Load();
|
||||
break;
|
||||
case ConsoleKey.D1:
|
||||
key = null;
|
||||
currentPage = DependenciesPage.Instance;
|
||||
Console.Clear();
|
||||
currentPage.Render();
|
||||
break;
|
||||
case ConsoleKey.D0:
|
||||
key = null;
|
||||
currentPage = WelcomePage.Instance;
|
||||
Console.Clear();
|
||||
currentPage.Render();
|
||||
break;
|
||||
default:
|
||||
key = Console.ReadKey(true);
|
||||
break;
|
||||
}
|
||||
|
||||
if (key?.Key == ConsoleKey.R)
|
||||
{
|
||||
dependenciesPage.LoadDependencies();
|
||||
key = null;
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// if (display.CommandLine.IsFocused)
|
||||
// {
|
||||
// switch (key.Key)
|
||||
@ -67,8 +78,6 @@ do
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
key = Console.ReadKey(true);
|
||||
} while (waitCommand);
|
||||
|
||||
Console.Clear();
|
Loading…
Reference in New Issue
Block a user