RootDrive navigation

This commit is contained in:
2022-05-15 21:55:06 +02:00
parent f99f90783f
commit b260b4d58a
4 changed files with 22 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ public class OpenContainerCommand : IUserCommand
{ {
public IAbsolutePath Path { get; } public IAbsolutePath Path { get; }
private OpenContainerCommand(IAbsolutePath path) public OpenContainerCommand(IAbsolutePath path)
{ {
Path = path; Path = path;
} }

View File

@@ -47,12 +47,21 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
new TypeUserCommandHandler<GoUpCommand>(GoUp), new TypeUserCommandHandler<GoUpCommand>(GoUp),
new TypeUserCommandHandler<MoveCursorDownCommand>(MoveCursorDown), new TypeUserCommandHandler<MoveCursorDownCommand>(MoveCursorDown),
new TypeUserCommandHandler<MoveCursorUpCommand>(MoveCursorUp), new TypeUserCommandHandler<MoveCursorUpCommand>(MoveCursorUp),
new TypeUserCommandHandler<OpenSelectedCommand>(OpenContainer), new TypeUserCommandHandler<OpenContainerCommand>(OpenContainer),
new TypeUserCommandHandler<OpenSelectedCommand>(OpenSelected),
new TypeUserCommandHandler<SwitchToTabCommand>(SwitchToTab), new TypeUserCommandHandler<SwitchToTabCommand>(SwitchToTab),
}); });
} }
private Task OpenContainer() private async Task OpenContainer(OpenContainerCommand command)
{
var resolvedPath = await command.Path.ResolveAsync();
if (resolvedPath is not IContainer resolvedContainer) return;
_selectedTab?.Tab?.SetCurrentLocation(resolvedContainer);
}
private Task OpenSelected()
{ {
if (_currentSelectedItem is not IContainerViewModel containerViewModel || containerViewModel.Container is null) return Task.CompletedTask; if (_currentSelectedItem is not IContainerViewModel containerViewModel || containerViewModel.Container is null) return Task.CompletedTask;

View File

@@ -67,8 +67,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable
CurrentLocation = tab.CurrentLocation.AsObservable(); CurrentLocation = tab.CurrentLocation.AsObservable();
CurrentItems = tab.CurrentItems CurrentItems = tab.CurrentItems
.Select(items => items?.Transform(i => MapItemToViewModel(i, ItemViewModelType.Main))) .Select(items => items?.Transform(i => MapItemToViewModel(i, ItemViewModelType.Main)))
.ObserveOn(_rxSchedulerService.GetWorkerScheduler()) /*.ObserveOn(_rxSchedulerService.GetWorkerScheduler())
.SubscribeOn(_rxSchedulerService.GetUIScheduler()) .SubscribeOn(_rxSchedulerService.GetUIScheduler())*/
.Publish(null) .Publish(null)
.RefCount(); .RefCount();
@@ -119,8 +119,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable
.Where(c => c is null or not IContainerViewModel) .Where(c => c is null or not IContainerViewModel)
.Select(_ => (IObservable<IChangeSet<IItemViewModel>>?) null) .Select(_ => (IObservable<IChangeSet<IItemViewModel>>?) null)
) )
.ObserveOn(_rxSchedulerService.GetWorkerScheduler()) /*.ObserveOn(_rxSchedulerService.GetWorkerScheduler())
.SubscribeOn(_rxSchedulerService.GetUIScheduler()) .SubscribeOn(_rxSchedulerService.GetUIScheduler())*/
.Publish(null) .Publish(null)
.RefCount(); .RefCount();
} }
@@ -147,8 +147,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable
.Where(p => p is null) .Where(p => p is null)
.Select(_ => (IObservable<IChangeSet<IItemViewModel>>?) null) .Select(_ => (IObservable<IChangeSet<IItemViewModel>>?) null)
) )
.ObserveOn(_rxSchedulerService.GetWorkerScheduler()) /*.ObserveOn(_rxSchedulerService.GetWorkerScheduler())
.SubscribeOn(_rxSchedulerService.GetUIScheduler()) .SubscribeOn(_rxSchedulerService.GetUIScheduler())*/
.Publish(null) .Publish(null)
.RefCount(); .RefCount();
} }

View File

@@ -1,6 +1,7 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using FileTime.App.Core.UserCommand;
using FileTime.Core.Models; using FileTime.Core.Models;
using FileTime.GuiApp.Models; using FileTime.GuiApp.Models;
using FileTime.GuiApp.ViewModels; using FileTime.GuiApp.ViewModels;
@@ -101,7 +102,7 @@ public partial class MainWindow : Window
var resolvedItem = await path.ResolveAsync(); var resolvedItem = await path.ResolveAsync();
if (resolvedItem is not IContainer resolvedContainer) return; if (resolvedItem is not IContainer resolvedContainer) return;
//ViewModel.CommandHandlerService.HandleCommandAsync() await ViewModel.UserCommandHandlerService.HandleCommandAsync(new OpenContainerCommand(new AbsolutePath(resolvedContainer)));
e.Handled = true; e.Handled = true;
} }
} }