Order in Tab instead TabViewModel, Utf8 char handling
This commit is contained in:
11
src/Core/FileTime.Core.Abstraction/Models/ItemOrdering.cs
Normal file
11
src/Core/FileTime.Core.Abstraction/Models/ItemOrdering.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace FileTime.App.Core.Models;
|
||||
|
||||
public enum ItemOrdering
|
||||
{
|
||||
Name,
|
||||
NameDesc,
|
||||
CreationDate,
|
||||
CreationDateDesc,
|
||||
LastModifyDate,
|
||||
LastModifyDateDesc,
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using DeclarativeProperty;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.Core.Models;
|
||||
using InitableService;
|
||||
|
||||
@@ -7,10 +8,11 @@ namespace FileTime.Core.Services;
|
||||
|
||||
public interface ITab : IAsyncInitable<IContainer>, IDisposable
|
||||
{
|
||||
public IDeclarativeProperty<IContainer?> CurrentLocation { get; }
|
||||
public IDeclarativeProperty<ObservableCollection<IItem>?> CurrentItems { get; }
|
||||
public IDeclarativeProperty<AbsolutePath?> CurrentSelectedItem { get; }
|
||||
IDeclarativeProperty<IContainer?> CurrentLocation { get; }
|
||||
IDeclarativeProperty<ObservableCollection<IItem>?> CurrentItems { get; }
|
||||
IDeclarativeProperty<AbsolutePath?> CurrentSelectedItem { get; }
|
||||
FullName? LastDeepestSelectedPath { get; }
|
||||
DeclarativeProperty<ItemOrdering?> Ordering { get; }
|
||||
|
||||
Task SetCurrentLocation(IContainer newLocation);
|
||||
void AddItemFilter(ItemFilter filter);
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using ByteSizeLib;
|
||||
using DeclarativeProperty;
|
||||
using FileTime.Core.Enums;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Timeline;
|
||||
using Humanizer.Bytes;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FileTime.Core.Command.Copy;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteSize" Version="2.1.1" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\AppCommon\FileTime.App.Core.Abstraction\FileTime.App.Core.Abstraction.csproj" />
|
||||
<ProjectReference Include="..\..\Library\CircularBuffer\CircularBuffer.csproj" />
|
||||
<ProjectReference Include="..\..\Library\Defer\Defer.csproj" />
|
||||
<ProjectReference Include="..\..\Tools\FileTime.Tools\FileTime.Tools.csproj" />
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using CircularBuffer;
|
||||
using DeclarativeProperty;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.Core.Helper;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Timeline;
|
||||
using ObservableComputations;
|
||||
using IContainer = FileTime.Core.Models.IContainer;
|
||||
|
||||
namespace FileTime.Core.Services;
|
||||
|
||||
@@ -14,9 +16,9 @@ public class Tab : ITab
|
||||
{
|
||||
private readonly ITimelessContentProvider _timelessContentProvider;
|
||||
private readonly ITabEvents _tabEvents;
|
||||
private readonly DeclarativeProperty<IContainer?> _currentLocation = new(null);
|
||||
private readonly DeclarativeProperty<IContainer?> _currentLocationForced = new(null);
|
||||
private readonly DeclarativeProperty<AbsolutePath?> _currentRequestItem = new(null);
|
||||
private readonly DeclarativeProperty<IContainer?> _currentLocation = new();
|
||||
private readonly DeclarativeProperty<IContainer?> _currentLocationForced = new();
|
||||
private readonly DeclarativeProperty<AbsolutePath?> _currentRequestItem = new();
|
||||
private readonly ObservableCollection<ItemFilter> _itemFilters = new();
|
||||
private readonly CircularBuffer<FullName> _history = new(20);
|
||||
private readonly CircularBuffer<FullName> _future = new(20);
|
||||
@@ -28,11 +30,11 @@ public class Tab : ITab
|
||||
public IDeclarativeProperty<ObservableCollection<IItem>?> CurrentItems { get; }
|
||||
public IDeclarativeProperty<AbsolutePath?> CurrentSelectedItem { get; }
|
||||
public FullName? LastDeepestSelectedPath { get; private set; }
|
||||
public DeclarativeProperty<ItemOrdering?> Ordering { get; } = new(ItemOrdering.Name);
|
||||
|
||||
public Tab(
|
||||
ITimelessContentProvider timelessContentProvider,
|
||||
ITabEvents tabEvents,
|
||||
IRefreshSmoothnessCalculator refreshSmoothnessCalculator)
|
||||
ITabEvents tabEvents)
|
||||
{
|
||||
_timelessContentProvider = timelessContentProvider;
|
||||
_tabEvents = tabEvents;
|
||||
@@ -47,7 +49,7 @@ public class Tab : ITab
|
||||
_currentLocationForced
|
||||
);
|
||||
|
||||
CurrentLocation.Subscribe((c, _) =>
|
||||
CurrentLocation.Subscribe((_, _) =>
|
||||
{
|
||||
if (_currentSelectedItemCached is not null)
|
||||
{
|
||||
@@ -78,6 +80,39 @@ public class Tab : ITab
|
||||
|
||||
return Task.FromResult(items);
|
||||
}
|
||||
).CombineLatest(
|
||||
Ordering,
|
||||
(items, ordering) =>
|
||||
{
|
||||
if (items is null) return Task.FromResult<ObservableCollection<IItem>?>(null);
|
||||
|
||||
ObservableCollection<IItem>? orderedItems = ordering switch
|
||||
{
|
||||
ItemOrdering.Name =>
|
||||
items
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => i.DisplayName),
|
||||
ItemOrdering.NameDesc =>
|
||||
items
|
||||
.Ordering(i => i.Type)
|
||||
.ThenOrdering(i => i.DisplayName, ListSortDirection.Descending),
|
||||
ItemOrdering.CreationDate =>
|
||||
items
|
||||
.Ordering(i => i.CreatedAt),
|
||||
ItemOrdering.CreationDateDesc =>
|
||||
items
|
||||
.Ordering(i => i.CreatedAt, ListSortDirection.Descending),
|
||||
ItemOrdering.LastModifyDate =>
|
||||
items
|
||||
.Ordering(i => i.ModifiedAt),
|
||||
ItemOrdering.LastModifyDateDesc =>
|
||||
items
|
||||
.Ordering(i => i.ModifiedAt, ListSortDirection.Descending),
|
||||
_ => throw new NotImplementedException()
|
||||
};
|
||||
|
||||
return Task.FromResult(orderedItems);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -92,12 +127,6 @@ public class Tab : ITab
|
||||
return Task.FromResult(GetSelectedItemByItems(items));
|
||||
}).DistinctUntilChanged();
|
||||
|
||||
CurrentSelectedItem.Subscribe((v) =>
|
||||
{
|
||||
refreshSmoothnessCalculator.RegisterChange();
|
||||
refreshSmoothnessCalculator.RecalculateSmoothness();
|
||||
});
|
||||
|
||||
CurrentSelectedItem.Subscribe(async (s, _) =>
|
||||
{
|
||||
_currentSelectedItemCached = s;
|
||||
|
||||
Reference in New Issue
Block a user