RapidTravel impr, GoBack/Forward, header navigation

This commit is contained in:
2023-08-03 20:00:55 +02:00
parent 754496625e
commit d6c4f16fc2
22 changed files with 1034 additions and 81 deletions

View File

@@ -1,13 +1,13 @@
<UserControl
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
x:Class="FileTime.GuiApp.App.Views.PathPresenter"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:coremodels="using:FileTime.Core.Models"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ItemsControl ItemsSource="{Binding Converter={StaticResource SplitStringConverter}, ConverterParameter={x:Static coremodels:Constants.SeparatorChar}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
@@ -17,10 +17,13 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" />
<TextBlock
Margin="5,0,5,0"
Classes="PathPresenterItem"
PointerPressed="InputElement_OnPointerPressed"
Text="{Binding}" />
<TextBlock
Foreground="{DynamicResource LightForegroundBrush}"
Margin="5,0,5,0"
Text="/" />
</StackPanel>
</DataTemplate>

View File

@@ -1,11 +1,53 @@
using Avalonia.Controls;
using Avalonia.Input;
using FileTime.App.Core.Services;
using FileTime.App.Core.UserCommand;
using FileTime.Core.Enums;
using FileTime.Core.Models;
using FileTime.Core.Timeline;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace FileTime.GuiApp.App.Views;
public partial class PathPresenter : UserControl
{
private readonly Lazy<ILogger<PathPresenter>> _logger;
public PathPresenter()
{
InitializeComponent();
_logger = new Lazy<ILogger<PathPresenter>>(
() => DI.ServiceProvider.GetRequiredService<ILogger<PathPresenter>>()
);
}
private async void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
try
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
&& DataContext is string fullPath
&& sender is TextBlock textBlock)
{
var pathPart = textBlock.Text;
var path = fullPath[..(fullPath.IndexOf(pathPart) + pathPart.Length)];
var timelessContentProvider = DI.ServiceProvider.GetRequiredService<ITimelessContentProvider>();
var userCommandHandlerService = DI.ServiceProvider.GetRequiredService<IUserCommandHandlerService>();
await userCommandHandlerService.HandleCommandAsync(
new OpenContainerCommand(
new AbsolutePath(
timelessContentProvider,
PointInTime.Present,
new FullName(path),
AbsolutePathType.Container)
)
);
}
}
catch (Exception exception)
{
_logger.Value.LogError(exception, "Failed to open container");
}
}
}