Focus next/previous input element with Tab
This commit is contained in:
@@ -97,6 +97,7 @@ public class App : IApplication
|
||||
if (focused is { })
|
||||
{
|
||||
focused.HandleKeyInput(keyEventArgs);
|
||||
_applicationContext.FocusManager.HandleKeyInput(keyEventArgs);
|
||||
}
|
||||
|
||||
if (focused is null || (!keyEventArgs.Handled && KeysToFurtherProcess.Contains(keyEventArgs.Key)))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using System.Collections.ObjectModel;
|
||||
using FileTime.App.Core.ViewModels;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.ConsoleUI.App;
|
||||
@@ -6,4 +7,6 @@ namespace FileTime.ConsoleUI.App;
|
||||
public partial class ConsoleAppState : AppStateBase, IConsoleAppState
|
||||
{
|
||||
[Notify] private string? _errorText;
|
||||
//TODO: make it thread safe
|
||||
public ObservableCollection<string> PopupTexts { get; } = new();
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public class MainWindow
|
||||
private Grid<IRootViewModel> MainContent() =>
|
||||
new()
|
||||
{
|
||||
RowDefinitionsObject = "Auto * Auto",
|
||||
RowDefinitionsObject = "Auto * Auto Auto",
|
||||
ChildInitializer =
|
||||
{
|
||||
new Grid<IRootViewModel>
|
||||
@@ -194,7 +194,28 @@ public class MainWindow
|
||||
{
|
||||
PossibleCommands()
|
||||
}
|
||||
}
|
||||
},
|
||||
new ItemsControl<IRootViewModel, string>
|
||||
{
|
||||
MaxHeight = 5,
|
||||
Extensions =
|
||||
{
|
||||
new GridPositionExtension(0, 3)
|
||||
},
|
||||
ItemTemplate = () =>
|
||||
{
|
||||
return new TextBlock<string>()
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
dc => dc,
|
||||
t => t.Text));
|
||||
}
|
||||
}
|
||||
.Setup(i => i.Bind(
|
||||
i,
|
||||
root => root.AppState.PopupTexts,
|
||||
c => c.ItemsSource
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -447,6 +468,7 @@ public class MainWindow
|
||||
{
|
||||
var readInputs = new ItemsControl<IRootViewModel, IInputElement>
|
||||
{
|
||||
IsFocusBoundary = true,
|
||||
ItemTemplate = () =>
|
||||
{
|
||||
var root = new Grid<IInputElement>
|
||||
@@ -479,6 +501,10 @@ public class MainWindow
|
||||
v => v ?? string.Empty,
|
||||
fallbackValue: string.Empty
|
||||
))
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
d => ((TextInputElement) d).Label,
|
||||
tb => tb.Name))
|
||||
.WithTextHandler((tb, t) =>
|
||||
{
|
||||
if (tb.DataContext is TextInputElement textInputElement)
|
||||
@@ -504,6 +530,10 @@ public class MainWindow
|
||||
v => v ?? string.Empty,
|
||||
fallbackValue: string.Empty
|
||||
))
|
||||
.Setup(t => t.Bind(
|
||||
t,
|
||||
d => ((PasswordInputElement) d).Label,
|
||||
tb => tb.Name))
|
||||
.WithTextHandler((tb, t) =>
|
||||
{
|
||||
if (tb.DataContext is PasswordInputElement textInputElement)
|
||||
@@ -537,14 +567,14 @@ public class MainWindow
|
||||
{
|
||||
if (_rootViewModel.DialogService.ReadInput.Value is { } readInputsViewModel)
|
||||
readInputsViewModel.Process();
|
||||
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Keys.Escape)
|
||||
{
|
||||
if (_rootViewModel.DialogService.ReadInput.Value is { } readInputsViewModel)
|
||||
readInputsViewModel.Cancel();
|
||||
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
@@ -6,6 +7,13 @@ namespace FileTime.ConsoleUI.App.Services;
|
||||
|
||||
public class CustomLoggerSink : ILogEventSink
|
||||
{
|
||||
private readonly Lazy<IDialogService> _dialogService;
|
||||
|
||||
public CustomLoggerSink(IServiceProvider serviceProvider)
|
||||
{
|
||||
_dialogService = new Lazy<IDialogService>(() => serviceProvider.GetRequiredService<IDialogService>());
|
||||
}
|
||||
|
||||
public void Emit(LogEvent logEvent)
|
||||
{
|
||||
if (logEvent.Level >= LogEventLevel.Error)
|
||||
@@ -14,6 +22,7 @@ public class CustomLoggerSink : ILogEventSink
|
||||
if (logEvent.Exception is not null)
|
||||
message += $" {logEvent.Exception.Message}";
|
||||
Debug.WriteLine(message);
|
||||
_dialogService.Value.ShowToastMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,19 @@ namespace FileTime.ConsoleUI.App.Services;
|
||||
|
||||
public class DialogService : DialogServiceBase, IDialogService
|
||||
{
|
||||
public DialogService(IModalService modalService) : base(modalService)
|
||||
private readonly IConsoleAppState _consoleAppState;
|
||||
|
||||
public DialogService(IModalService modalService, IConsoleAppState consoleAppState) : base(modalService)
|
||||
{
|
||||
_consoleAppState = consoleAppState;
|
||||
}
|
||||
|
||||
|
||||
public override void ShowToastMessage(string text)
|
||||
{
|
||||
// TODO: Implement
|
||||
}
|
||||
=> Task.Run(async () =>
|
||||
{
|
||||
_consoleAppState.PopupTexts.Add(text);
|
||||
await Task.Delay(5000);
|
||||
_consoleAppState.PopupTexts.Remove(text);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user