Move common things to AppCore from GuiApp

This commit is contained in:
2023-08-07 12:06:34 +02:00
parent 3d0eda54fb
commit 936c3896b9
48 changed files with 427 additions and 187 deletions

View File

@@ -2,11 +2,16 @@
using Avalonia.Controls;
using Avalonia.Input;
using FileTime.App.CommandPalette.ViewModels;
using FileTime.App.Core.Services;
using FileTime.GuiApp.App.Extensions;
using Microsoft.Extensions.DependencyInjection;
namespace FileTime.GuiApp.App.Views;
public partial class CommandPalette : UserControl
{
private readonly Lazy<IAppKeyService<Key>> _appKeyService = new(() => DI.ServiceProvider.GetRequiredService<IAppKeyService<Key>>());
public CommandPalette()
{
InitializeComponent();
@@ -34,14 +39,18 @@ public partial class CommandPalette : UserControl
}
else
{
viewModel.HandleKeyDown(e);
if (e.ToGeneralKeyEventArgs(_appKeyService.Value) is not { } eventArgs) return;
viewModel.HandleKeyDown(eventArgs);
}
}
private void Search_OnKeyUp(object? sender, KeyEventArgs e)
{
if (e.Handled) return;
if (DataContext is not ICommandPaletteViewModel viewModel) return;
viewModel.HandleKeyUp(e);
if (e.Handled
|| DataContext is not ICommandPaletteViewModel viewModel) return;
if (e.ToGeneralKeyEventArgs(_appKeyService.Value) is not { } eventArgs) return;
viewModel.HandleKeyUp(eventArgs);
}
}

View File

@@ -1,12 +1,17 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using FileTime.App.Core.Services;
using FileTime.App.FrequencyNavigation.ViewModels;
using FileTime.GuiApp.App.Extensions;
using Microsoft.Extensions.DependencyInjection;
namespace FileTime.GuiApp.App.Views;
public partial class FrequencyNavigation : UserControl
{
private readonly Lazy<IAppKeyService<Key>> _appKeyService = new(() => DI.ServiceProvider.GetRequiredService<IAppKeyService<Key>>());
public FrequencyNavigation()
{
InitializeComponent();
@@ -34,14 +39,18 @@ public partial class FrequencyNavigation : UserControl
}
else
{
viewModel.HandleKeyDown(e);
if (e.ToGeneralKeyEventArgs(_appKeyService.Value) is not { } eventArgs) return;
viewModel.HandleKeyDown(eventArgs);
}
}
private void Search_OnKeyUp(object? sender, KeyEventArgs e)
{
if (e.Handled) return;
if (DataContext is not IFrequencyNavigationViewModel viewModel) return;
viewModel.HandleKeyUp(e);
if (e.Handled
|| DataContext is not IFrequencyNavigationViewModel viewModel) return;
if (e.ToGeneralKeyEventArgs(_appKeyService.Value) is not { } eventArgs) return;
viewModel.HandleKeyUp(eventArgs);
}
}

View File

@@ -23,6 +23,7 @@
xmlns:appCoreModels="using:FileTime.App.Core.Models"
xmlns:appInteractions="using:FileTime.App.Core.Interactions"
xmlns:config="using:FileTime.GuiApp.App.Configuration"
xmlns:configuration="clr-namespace:FileTime.App.Core.Configuration;assembly=FileTime.App.Core.Abstraction"
xmlns:corevm="using:FileTime.App.Core.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
@@ -764,7 +765,7 @@
<ItemsRepeater Grid.Row="1" ItemsSource="{Binding AppState.PossibleCommands}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="config:CommandBindingConfiguration">
<DataTemplate x:DataType="configuration:CommandBindingConfiguration">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />