diff --git a/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanContainer.cs b/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanContainer.cs index e6bc336..5c9f68c 100644 --- a/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanContainer.cs +++ b/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanContainer.cs @@ -23,10 +23,11 @@ public record SizeScanContainer : ISizeScanContainer public required NativePath? NativePath { get; init; } public required AbsolutePath? Parent { get; init; } public required IContentProvider Provider { get; init; } + public required DateTime? CreatedAt { get; init; } = DateTime.Now; + public required DateTime? ModifiedAt { get; init;} = DateTime.Now; + public required SupportsDelete CanDelete { get; init; } public bool IsHidden => false; public bool IsExists => true; - public DateTime? CreatedAt { get; } = DateTime.Now; - public SupportsDelete CanDelete => SupportsDelete.True; public bool CanRename => false; public string? Attributes => null; public AbsolutePathType Type => AbsolutePathType.Container; diff --git a/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanElement.cs b/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanElement.cs index da09993..7175f8f 100644 --- a/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanElement.cs +++ b/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanElement.cs @@ -13,12 +13,13 @@ public record SizeScanElement : ISizeScanElement public required string DisplayName { get; init; } public required FullName FullName { get; init; } public required NativePath NativePath { get; init; } - public AbsolutePath? Parent { get; init; } + public required AbsolutePath? Parent { get; init; } + public required DateTime? CreatedAt { get; init; } + public required DateTime? ModifiedAt { get; init;} public required IDeclarativeProperty Size { get; init; } public bool IsHidden => false; public bool IsExists => true; - public DateTime? CreatedAt { get; } = DateTime.Now; public SupportsDelete CanDelete => SupportsDelete.False; public bool CanRename => false; public string? Attributes => ""; diff --git a/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanTask.cs b/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanTask.cs index 6339ed7..5252089 100644 --- a/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanTask.cs +++ b/src/AppCommon/FileTime.App.ContainerSizeScanner/SizeScanTask.cs @@ -1,4 +1,5 @@ using DeclarativeProperty; +using FileTime.Core.Enums; using FileTime.Core.Models; using FileTime.Core.Models.Extensions; using FileTime.Core.Timeline; @@ -48,7 +49,10 @@ public class SizeScanTask : ISizeScanTask RealContainer = scanSizeOf, Provider = _containerSizeScanProvider, Status = _containerStatusDebounced, - SizeScanTask = this + SizeScanTask = this, + CreatedAt = scanSizeOf.CreatedAt, + ModifiedAt = scanSizeOf.ModifiedAt, + CanDelete = SupportsDelete.True }; } @@ -114,7 +118,9 @@ public class SizeScanTask : ISizeScanTask NativePath = new NativePath(childName), Parent = new AbsolutePath(_timelessContentProvider, sizeScanContainer), Provider = _containerSizeScanProvider, - Size = sizeProperty + Size = sizeProperty, + CreatedAt = element.CreatedAt, + ModifiedAt = element.ModifiedAt, }; await sizeScanContainer.AddSizeChildAsync(childElement); @@ -137,7 +143,10 @@ public class SizeScanTask : ISizeScanTask RealContainer = childContainer, Provider = _containerSizeScanProvider, Status = _containerStatusDebounced, - SizeScanTask = this + SizeScanTask = this, + CreatedAt = childContainer.CreatedAt, + ModifiedAt = childContainer.ModifiedAt, + CanDelete = SupportsDelete.False }; await sizeScanContainer.AddSizeChildAsync(childSearchContainer); diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/Models/ItemOrdering.cs b/src/AppCommon/FileTime.App.Core.Abstraction/Models/ItemOrdering.cs index e2ee76f..2b63cbc 100644 --- a/src/AppCommon/FileTime.App.Core.Abstraction/Models/ItemOrdering.cs +++ b/src/AppCommon/FileTime.App.Core.Abstraction/Models/ItemOrdering.cs @@ -4,6 +4,8 @@ public enum ItemOrdering { Name, NameDesc, + CreationDate, + CreationDateDesc, LastModifyDate, LastModifyDateDesc, } \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/SortItemsCommand.cs b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/SortItemsCommand.cs index 0401972..b827d2f 100644 --- a/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/SortItemsCommand.cs +++ b/src/AppCommon/FileTime.App.Core.Abstraction/UserCommand/SortItemsCommand.cs @@ -6,8 +6,10 @@ public sealed class SortItemsCommand : IIdentifiableUserCommand { public const string OrderByNameCommandName = "order_by_name"; public const string OrderByNameDescCommandName = "order_by_name_desc"; - public const string OrderByDateCommandName = "order_by_date"; - public const string OrderByDateDescCommandName = "order_by_date_desc"; + public const string OrderByCreatedAtCommandName = "order_by_created_at"; + public const string OrderByCreatedAtDescCommandName = "order_by_created_at_desc"; + public const string OrderByModifiedAtCommandName = "order_by_modified_at"; + public const string OrderByModifiedAtDescCommandName = "order_by_modified_at_desc"; public static readonly SortItemsCommand OrderByNameCommand = new(OrderByNameCommandName, ItemOrdering.Name, "Order by name"); @@ -15,11 +17,17 @@ public sealed class SortItemsCommand : IIdentifiableUserCommand public static readonly SortItemsCommand OrderByNameDescCommand = new(OrderByNameDescCommandName, ItemOrdering.NameDesc, "Order by name (descending)"); - public static readonly SortItemsCommand OrderByDateCommand = - new(OrderByDateCommandName, ItemOrdering.LastModifyDate, "Order by date"); + public static readonly SortItemsCommand OrderByCreatedAtCommand = + new(OrderByCreatedAtCommandName, ItemOrdering.CreationDate, "Order by created"); - public static readonly SortItemsCommand OrderByDateDescCommand = - new(OrderByDateDescCommandName, ItemOrdering.LastModifyDateDesc, "Order by date (descending)"); + public static readonly SortItemsCommand OrderByCreatedAtDescCommand = + new(OrderByCreatedAtDescCommandName, ItemOrdering.CreationDateDesc, "Order by created (descending)"); + + public static readonly SortItemsCommand OrderByLastModifiedCommand = + new(OrderByModifiedAtCommandName, ItemOrdering.LastModifyDate, "Order by last modified"); + + public static readonly SortItemsCommand OrderByLastModifiedDescCommand = + new(OrderByModifiedAtDescCommandName, ItemOrdering.LastModifyDateDesc, "Order by last modified (descending)"); private SortItemsCommand(string userCommandId, ItemOrdering ordering, string title) { diff --git a/src/AppCommon/FileTime.App.Core.Abstraction/ViewModels/IItemViewModel.cs b/src/AppCommon/FileTime.App.Core.Abstraction/ViewModels/IItemViewModel.cs index 65fdd65..9856dd6 100644 --- a/src/AppCommon/FileTime.App.Core.Abstraction/ViewModels/IItemViewModel.cs +++ b/src/AppCommon/FileTime.App.Core.Abstraction/ViewModels/IItemViewModel.cs @@ -15,6 +15,7 @@ public interface IItemViewModel : IInitable IsAlternative { get; } IDeclarativeProperty ViewMode { get; set; } DateTime? CreatedAt { get; set; } + DateTime? ModifiedAt { get; set; } string? Attributes { get; set; } bool EqualsTo(IItemViewModel? itemViewModel); } \ No newline at end of file diff --git a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs index 5e264ef..bddf33e 100644 --- a/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs +++ b/src/AppCommon/FileTime.App.Core/StartupServices/DefaultIdentifiableCommandHandlerRegister.cs @@ -52,8 +52,10 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler AddUserCommand(StartCommandSchedulerCommand.Instance); AddUserCommand(SortItemsCommand.OrderByNameCommand); AddUserCommand(SortItemsCommand.OrderByNameDescCommand); - AddUserCommand(SortItemsCommand.OrderByDateCommand); - AddUserCommand(SortItemsCommand.OrderByDateDescCommand); + AddUserCommand(SortItemsCommand.OrderByCreatedAtCommand); + AddUserCommand(SortItemsCommand.OrderByCreatedAtDescCommand); + AddUserCommand(SortItemsCommand.OrderByLastModifiedCommand); + AddUserCommand(SortItemsCommand.OrderByLastModifiedDescCommand); AddUserCommand(IdentifiableSearchCommand.SearchByNameContains); AddUserCommand(IdentifiableSearchCommand.SearchByRegex); AddUserCommand(SwitchToTabCommand.SwitchToLastTab); diff --git a/src/AppCommon/FileTime.App.Core/ViewModels/ItemViewModel.cs b/src/AppCommon/FileTime.App.Core/ViewModels/ItemViewModel.cs index 1e095f4..2706412 100644 --- a/src/AppCommon/FileTime.App.Core/ViewModels/ItemViewModel.cs +++ b/src/AppCommon/FileTime.App.Core/ViewModels/ItemViewModel.cs @@ -31,6 +31,7 @@ public abstract partial class ItemViewModel : IItemViewModel [Property] private IDeclarativeProperty _viewMode; [Property] private DateTime? _createdAt; + [Property] private DateTime? _modifiedAt; [Property] private string? _attributes; @@ -88,6 +89,7 @@ public abstract partial class ItemViewModel : IItemViewModel .Debounce(TimeSpan.FromMilliseconds(100)); Attributes = item.Attributes; CreatedAt = item.CreatedAt; + ModifiedAt = item.ModifiedAt; } private Task GenerateViewMode(bool isMarked, bool isSelected, bool isAlternative) diff --git a/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs b/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs index 5bdc45f..8eb5fbc 100644 --- a/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs +++ b/src/AppCommon/FileTime.App.Core/ViewModels/TabViewModel.cs @@ -93,18 +93,24 @@ public partial class TabViewModel : ITabViewModel { ItemOrdering.Name => items - .Ordering(i => i.BaseItem.Type) + .Ordering(i => i.BaseItem!.Type) .ThenOrdering(i => i.DisplayNameText), ItemOrdering.NameDesc => items - .Ordering(i => i.BaseItem.Type) + .Ordering(i => i.BaseItem!.Type) .ThenOrdering(i => i.DisplayNameText, ListSortDirection.Descending), - ItemOrdering.LastModifyDate => + ItemOrdering.CreationDate => items .Ordering(i => i.CreatedAt), - ItemOrdering.LastModifyDateDesc => + 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() }; diff --git a/src/AppCommon/FileTime.App.Search/SearchTask.cs b/src/AppCommon/FileTime.App.Search/SearchTask.cs index f46aa0e..ad879c7 100644 --- a/src/AppCommon/FileTime.App.Search/SearchTask.cs +++ b/src/AppCommon/FileTime.App.Search/SearchTask.cs @@ -51,6 +51,7 @@ public class SearchTask : ISearchTask false, true, null, + null, SupportsDelete.False, false, null, diff --git a/src/Core/FileTime.Core.Abstraction/Models/IItem.cs b/src/Core/FileTime.Core.Abstraction/Models/IItem.cs index e9b5dd5..67e5f77 100644 --- a/src/Core/FileTime.Core.Abstraction/Models/IItem.cs +++ b/src/Core/FileTime.Core.Abstraction/Models/IItem.cs @@ -15,6 +15,7 @@ public interface IItem bool IsHidden { get; } bool IsExists { get; } DateTime? CreatedAt { get; } + DateTime? ModifiedAt { get; } SupportsDelete CanDelete { get; } bool CanRename { get; } IContentProvider Provider { get; } diff --git a/src/Core/FileTime.Core.ContentAccess/ContentProviderBase.cs b/src/Core/FileTime.Core.ContentAccess/ContentProviderBase.cs index 85bb57c..9f35d1a 100644 --- a/src/Core/FileTime.Core.ContentAccess/ContentProviderBase.cs +++ b/src/Core/FileTime.Core.ContentAccess/ContentProviderBase.cs @@ -34,6 +34,7 @@ public abstract class ContentProviderBase : IContentProvider public AbsolutePath? Parent { get; } public DateTime? CreatedAt => null; + public DateTime? ModifiedAt => null; public string? Attributes => null; diff --git a/src/Core/FileTime.Core.ContentAccess/RootContentProvider.cs b/src/Core/FileTime.Core.ContentAccess/RootContentProvider.cs index da43b24..589bf6e 100644 --- a/src/Core/FileTime.Core.ContentAccess/RootContentProvider.cs +++ b/src/Core/FileTime.Core.ContentAccess/RootContentProvider.cs @@ -18,6 +18,7 @@ public class RootContentProvider : IRootContentProvider public bool IsHidden => false; public bool IsExists => true; public DateTime? CreatedAt => null; + public DateTime? ModifiedAt => null; public SupportsDelete CanDelete => SupportsDelete.False; public bool CanRename => false; public IContentProvider Provider => this; diff --git a/src/Core/FileTime.Core.Models/Container.cs b/src/Core/FileTime.Core.Models/Container.cs index ba64e3d..39a5534 100644 --- a/src/Core/FileTime.Core.Models/Container.cs +++ b/src/Core/FileTime.Core.Models/Container.cs @@ -16,6 +16,7 @@ public record Container( bool IsHidden, bool IsExists, DateTime? CreatedAt, + DateTime? ModifiedAt, SupportsDelete CanDelete, bool CanRename, string? Attributes, diff --git a/src/Core/FileTime.Core.Models/Element.cs b/src/Core/FileTime.Core.Models/Element.cs index f25a8a9..af1dca0 100644 --- a/src/Core/FileTime.Core.Models/Element.cs +++ b/src/Core/FileTime.Core.Models/Element.cs @@ -14,6 +14,7 @@ public record Element( bool IsHidden, bool IsExists, DateTime? CreatedAt, + DateTime? ModifiedAt, SupportsDelete CanDelete, bool CanRename, string? Attributes, diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp.DesignPreview/Services/ItemPreview.cs b/src/GuiApp/Avalonia/FileTime.GuiApp.DesignPreview/Services/ItemPreview.cs index ad9123b..f0b9d73 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp.DesignPreview/Services/ItemPreview.cs +++ b/src/GuiApp/Avalonia/FileTime.GuiApp.DesignPreview/Services/ItemPreview.cs @@ -27,6 +27,7 @@ public class ItemPreview false, true, DateTime.Now, + DateTime.Now, SupportsDelete.True, true, "attr", @@ -54,6 +55,7 @@ public class ItemPreview false, true, DateTime.Now, + DateTime.Now, SupportsDelete.True, true, "attr", diff --git a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/ItemView.axaml b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/ItemView.axaml index 41c252b..6cfa13a 100644 --- a/src/GuiApp/Avalonia/FileTime.GuiApp/Views/ItemView.axaml +++ b/src/GuiApp/Avalonia/FileTime.GuiApp/Views/ItemView.axaml @@ -11,7 +11,6 @@ x:Name="ItemRoot" xmlns="https://github.com/avaloniaui" xmlns:appcore="using:FileTime.App.Core.ViewModels" - xmlns:appcoreenums="using:FileTime.App.Core.Models.Enums" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:guiappvm="using:FileTime.GuiApp.ViewModels" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" @@ -88,12 +87,12 @@