EventLoop V1
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.ConsoleUI.App.KeyInputHandling;
|
||||
using TerminalUI;
|
||||
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
|
||||
@@ -9,6 +10,7 @@ public class App : IApplication
|
||||
private readonly IConsoleAppState _consoleAppState;
|
||||
//private readonly IAppKeyService<Key> _appKeyService;
|
||||
private readonly MainWindow _mainWindow;
|
||||
private readonly IApplicationContext _applicationContext;
|
||||
private readonly IKeyInputHandlerService _keyInputHandlerService;
|
||||
|
||||
public App(
|
||||
@@ -16,20 +18,23 @@ public class App : IApplication
|
||||
IKeyInputHandlerService keyInputHandlerService,
|
||||
IConsoleAppState consoleAppState,
|
||||
//IAppKeyService<Key> appKeyService,
|
||||
MainWindow mainWindow)
|
||||
MainWindow mainWindow,
|
||||
IApplicationContext applicationContext)
|
||||
{
|
||||
_lifecycleService = lifecycleService;
|
||||
_keyInputHandlerService = keyInputHandlerService;
|
||||
_consoleAppState = consoleAppState;
|
||||
//_appKeyService = appKeyService;
|
||||
_mainWindow = mainWindow;
|
||||
_applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
Console.WriteLine("Loading...");
|
||||
Task.Run(async () => await _lifecycleService.InitStartupHandlersAsync()).Wait();
|
||||
|
||||
_mainWindow.Initialize();
|
||||
|
||||
_applicationContext.EventLoop.Run();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq.Expressions;
|
||||
using DeclarativeProperty;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using FileTime.ConsoleUI.App.Extensions;
|
||||
using TerminalUI;
|
||||
using TerminalUI.Controls;
|
||||
using TerminalUI.Extensions;
|
||||
@@ -11,23 +10,39 @@ namespace FileTime.ConsoleUI.App;
|
||||
public class MainWindow
|
||||
{
|
||||
private readonly IConsoleAppState _consoleAppState;
|
||||
private readonly IApplicationContext _applicationContext;
|
||||
private const int ParentColumnWidth = 20;
|
||||
|
||||
public MainWindow(IConsoleAppState consoleAppState)
|
||||
public MainWindow(IConsoleAppState consoleAppState, IApplicationContext applicationContext)
|
||||
{
|
||||
_consoleAppState = consoleAppState;
|
||||
_applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
ListView<IAppState, IItemViewModel> selectedItemsView = new();
|
||||
ListView<IAppState, IItemViewModel> selectedItemsView = new()
|
||||
{
|
||||
ApplicationContext = _applicationContext
|
||||
};
|
||||
selectedItemsView.DataContext = _consoleAppState;
|
||||
selectedItemsView.ItemTemplate = item =>
|
||||
{
|
||||
var textBlock = item.CreateChild<TextBlock<IItemViewModel>>();
|
||||
textBlock.Bind(
|
||||
textBlock,
|
||||
dc => dc == null ? string.Empty : dc.DisplayNameText,
|
||||
tb => tb.Text
|
||||
);
|
||||
|
||||
return textBlock;
|
||||
};
|
||||
|
||||
selectedItemsView.Bind(
|
||||
selectedItemsView,
|
||||
appState => appState.SelectedTab.Map(t => t == null ? null : t.CurrentItems).Switch(),
|
||||
v => v.ItemsSource);
|
||||
|
||||
selectedItemsView.Render();
|
||||
selectedItemsView.RequestRerender();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using FileTime.ConsoleUI.App.Services;
|
||||
using FileTime.Core.Interactions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using TerminalUI;
|
||||
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
|
||||
@@ -20,6 +21,7 @@ public static class Startup
|
||||
services.TryAddSingleton<IKeyInputHandlerService, KeyInputHandlerService>();
|
||||
services.AddSingleton<CustomLoggerSink>();
|
||||
|
||||
services.TryAddSingleton<IApplicationContext, ApplicationContext>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user