From 1f08ead6da8897d6667835ca8864e081dba8ff2a Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:15:34 -0500 Subject: [PATCH] Cards view --- src/Files.App/Actions/Display/LayoutAction.cs | 19 +- src/Files.App/App.xaml | 3 + .../Converters/EnumToHumanizedConverter.cs | 4 +- .../Data/Commands/Manager/CommandCodes.cs | 2 +- .../Data/Commands/Manager/CommandManager.cs | 4 +- .../Data/Commands/Manager/ICommandManager.cs | 2 +- .../DisplayPage/DisplayPageContext.cs | 8 +- .../Data/Contexts/DisplayPage/LayoutTypes.cs | 2 +- .../Data/Contracts/ILayoutSettingsService.cs | 4 +- src/Files.App/Data/Enums/CardsViewSizeKind.cs | 31 + src/Files.App/Data/Enums/FolderLayoutModes.cs | 4 +- src/Files.App/Data/Enums/TilesViewSizeKind.cs | 16 - .../ContentPageContextFlyoutFactory.cs | 2 +- .../LocalizedEnumDescriptionFactory.cs | 13 +- src/Files.App/Data/Items/ListedItem.cs | 77 ++- .../Layout/LayoutPreferencesManager.cs | 12 +- .../Helpers/Layout/LayoutSizeKindHelper.cs | 93 ++- .../Settings/LayoutSettingsService.cs | 4 +- src/Files.App/Strings/en-US/Resources.resw | 23 +- .../UserControls/InnerNavigationToolbar.xaml | 83 ++- src/Files.App/ViewModels/ShellViewModel.cs | 34 +- .../UserControls/AddressToolbarViewModel.cs | 11 +- src/Files.App/Views/Layouts/BaseLayoutPage.cs | 1 + .../Views/Layouts/ColumnLayoutPage.xaml.cs | 4 +- .../Views/Layouts/GridLayoutPage.xaml | 562 ++++++++++++------ .../Views/Layouts/GridLayoutPage.xaml.cs | 140 +++-- src/Files.App/Views/Settings/LayoutPage.xaml | 2 +- .../Helpers/FileExtensionHelpers.cs | 10 + 28 files changed, 773 insertions(+), 397 deletions(-) create mode 100644 src/Files.App/Data/Enums/CardsViewSizeKind.cs delete mode 100644 src/Files.App/Data/Enums/TilesViewSizeKind.cs diff --git a/src/Files.App/Actions/Display/LayoutAction.cs b/src/Files.App/Actions/Display/LayoutAction.cs index ccb92a3fc822..d24812ba95b7 100644 --- a/src/Files.App/Actions/Display/LayoutAction.cs +++ b/src/Files.App/Actions/Display/LayoutAction.cs @@ -39,16 +39,16 @@ public override HotKey HotKey => new(Keys.Number2, KeyModifiers.CtrlShift); } - internal sealed class LayoutTilesAction : ToggleLayoutAction + internal sealed class LayoutCardsAction : ToggleLayoutAction { protected override LayoutTypes LayoutType - => LayoutTypes.Tiles; + => LayoutTypes.Cards; public override string Label - => "Tiles".GetLocalizedResource(); + => Strings.Cards.GetLocalizedResource(); public override string Description - => "LayoutTilesDescription".GetLocalizedResource(); + => Strings.LayoutCardsDescription.GetLocalizedResource(); public override RichGlyph Glyph => new(themedIconStyle: "App.ThemedIcons.IconLayout.Tiles"); @@ -190,6 +190,7 @@ ContentPageContext.PageType is not ContentPageTypes.Home && ContentPageContext.ShellPage?.InstanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes layoutMode && ((layoutMode is FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize > DetailsViewSizeKind.Compact) || (layoutMode is FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize > ListViewSizeKind.Compact) || + (layoutMode is FolderLayoutModes.CardsView && UserSettingsService.LayoutSettingsService.CardsViewSize > CardsViewSizeKind.Small) || (layoutMode is FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Small) || (layoutMode is FolderLayoutModes.ColumnView && UserSettingsService.LayoutSettingsService.ColumnsViewSize > ColumnsViewSizeKind.Compact)); @@ -217,6 +218,7 @@ private void UserSettingsService_PropertyChanged(object? sender, PropertyChanged case nameof(ILayoutSettingsService.ListViewSize): case nameof(ILayoutSettingsService.GridViewSize): case nameof(ILayoutSettingsService.ColumnsViewSize): + case nameof(ILayoutSettingsService.CardsViewSize): OnPropertyChanged(nameof(IsExecutable)); break; } @@ -234,7 +236,9 @@ public Task ExecuteAsync(object? parameter = null) if (UserSettingsService.LayoutSettingsService.ListViewSize > ListViewSizeKind.Compact) UserSettingsService.LayoutSettingsService.ListViewSize -= 1; break; - case FolderLayoutModes.TilesView: + case FolderLayoutModes.CardsView: + if (UserSettingsService.LayoutSettingsService.CardsViewSize > CardsViewSizeKind.Small) + UserSettingsService.LayoutSettingsService.CardsViewSize -= 1; break; case FolderLayoutModes.GridView: if (UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Small) @@ -274,6 +278,7 @@ ContentPageContext.PageType is not ContentPageTypes.Home && ContentPageContext.ShellPage?.InstanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes layoutMode && ((layoutMode is FolderLayoutModes.DetailsView && UserSettingsService.LayoutSettingsService.DetailsViewSize < DetailsViewSizeKind.ExtraLarge) || (layoutMode is FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize < ListViewSizeKind.ExtraLarge) || + (layoutMode is FolderLayoutModes.CardsView && UserSettingsService.LayoutSettingsService.CardsViewSize < CardsViewSizeKind.ExtraLarge) || (layoutMode is FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.ExtraLarge) || (layoutMode is FolderLayoutModes.ColumnView && UserSettingsService.LayoutSettingsService.ColumnsViewSize < ColumnsViewSizeKind.ExtraLarge)); @@ -318,7 +323,9 @@ public Task ExecuteAsync(object? parameter = null) if (UserSettingsService.LayoutSettingsService.ListViewSize < ListViewSizeKind.ExtraLarge) UserSettingsService.LayoutSettingsService.ListViewSize += 1; break; - case FolderLayoutModes.TilesView: + case FolderLayoutModes.CardsView: + if (UserSettingsService.LayoutSettingsService.CardsViewSize < CardsViewSizeKind.ExtraLarge) + UserSettingsService.LayoutSettingsService.CardsViewSize += 1; break; case FolderLayoutModes.GridView: if (UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.ExtraLarge) diff --git a/src/Files.App/App.xaml b/src/Files.App/App.xaml index 9991fe863f56..d24250ef0de5 100644 --- a/src/Files.App/App.xaml +++ b/src/Files.App/App.xaml @@ -77,6 +77,7 @@ #0070CB + @@ -94,6 +95,7 @@ #50C0FF + @@ -111,6 +113,7 @@ #50C0FF + diff --git a/src/Files.App/Converters/EnumToHumanizedConverter.cs b/src/Files.App/Converters/EnumToHumanizedConverter.cs index c464f7df5877..3cbcd6d26c40 100644 --- a/src/Files.App/Converters/EnumToHumanizedConverter.cs +++ b/src/Files.App/Converters/EnumToHumanizedConverter.cs @@ -19,8 +19,8 @@ public object Convert(object value, Type targetType, object parameter, string la => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), "ListViewSizeKind" => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), - "TilesViewSizeKind" - => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), + "CardsViewSizeKind" + => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), "GridViewSizeKind" => LocalizedEnumDescriptionFactory.Get(Enum.Parse(stringValue)), "ColumnsViewSizeKind" diff --git a/src/Files.App/Data/Commands/Manager/CommandCodes.cs b/src/Files.App/Data/Commands/Manager/CommandCodes.cs index 0ea8a3416d76..19c2158a0a29 100644 --- a/src/Files.App/Data/Commands/Manager/CommandCodes.cs +++ b/src/Files.App/Data/Commands/Manager/CommandCodes.cs @@ -133,7 +133,7 @@ public enum CommandCodes LayoutIncreaseSize, LayoutDetails, LayoutList, - LayoutTiles, + LayoutCards, LayoutGrid, LayoutColumns, LayoutAdaptive, diff --git a/src/Files.App/Data/Commands/Manager/CommandManager.cs b/src/Files.App/Data/Commands/Manager/CommandManager.cs index d1e63fca40f5..ba0b307b0b76 100644 --- a/src/Files.App/Data/Commands/Manager/CommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/CommandManager.cs @@ -132,7 +132,7 @@ public IRichCommand this[HotKey hotKey] public IRichCommand LayoutIncreaseSize => commands[CommandCodes.LayoutIncreaseSize]; public IRichCommand LayoutDetails => commands[CommandCodes.LayoutDetails]; public IRichCommand LayoutList => commands[CommandCodes.LayoutList]; - public IRichCommand LayoutTiles => commands[CommandCodes.LayoutTiles]; + public IRichCommand LayoutCards=> commands[CommandCodes.LayoutCards]; public IRichCommand LayoutGrid => commands[CommandCodes.LayoutGrid]; public IRichCommand LayoutColumns => commands[CommandCodes.LayoutColumns]; public IRichCommand LayoutAdaptive => commands[CommandCodes.LayoutAdaptive]; @@ -336,7 +336,7 @@ public IEnumerator GetEnumerator() => [CommandCodes.LayoutIncreaseSize] = new LayoutIncreaseSizeAction(), [CommandCodes.LayoutDetails] = new LayoutDetailsAction(), [CommandCodes.LayoutList] = new LayoutListAction(), - [CommandCodes.LayoutTiles] = new LayoutTilesAction(), + [CommandCodes.LayoutCards] = new LayoutCardsAction(), [CommandCodes.LayoutGrid] = new LayoutGridAction(), [CommandCodes.LayoutColumns] = new LayoutColumnsAction(), [CommandCodes.LayoutAdaptive] = new LayoutAdaptiveAction(), diff --git a/src/Files.App/Data/Commands/Manager/ICommandManager.cs b/src/Files.App/Data/Commands/Manager/ICommandManager.cs index 385fb56ec31f..61e554270e1b 100644 --- a/src/Files.App/Data/Commands/Manager/ICommandManager.cs +++ b/src/Files.App/Data/Commands/Manager/ICommandManager.cs @@ -121,7 +121,7 @@ public interface ICommandManager : IEnumerable IRichCommand LayoutIncreaseSize { get; } IRichCommand LayoutDetails { get; } IRichCommand LayoutList { get; } - IRichCommand LayoutTiles { get; } + IRichCommand LayoutCards{ get; } IRichCommand LayoutGrid { get; } IRichCommand LayoutColumns { get; } IRichCommand LayoutAdaptive { get; } diff --git a/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs b/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs index 7004f0f0742e..1cb483a2c7ea 100644 --- a/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs +++ b/src/Files.App/Data/Contexts/DisplayPage/DisplayPageContext.cs @@ -29,8 +29,8 @@ public LayoutTypes LayoutType case LayoutTypes.List: viewModel.ToggleLayoutModeList(true); break; - case LayoutTypes.Tiles: - viewModel.ToggleLayoutModeTiles(true); + case LayoutTypes.Cards: + viewModel.ToggleLayoutModeCards(true); break; case LayoutTypes.Grid: viewModel.ToggleLayoutModeGridView(true); @@ -230,11 +230,11 @@ private LayoutTypes GetLayoutType() { FolderLayoutModes.DetailsView => LayoutTypes.Details, FolderLayoutModes.ListView => LayoutTypes.List, - FolderLayoutModes.TilesView => LayoutTypes.Tiles, + FolderLayoutModes.CardsView => LayoutTypes.Cards, FolderLayoutModes.GridView => LayoutTypes.Grid, FolderLayoutModes.ColumnView => LayoutTypes.Columns, _ => throw new InvalidEnumArgumentException(), }; } } -} +} \ No newline at end of file diff --git a/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs b/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs index a91860b117f2..4d6309a34712 100644 --- a/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs +++ b/src/Files.App/Data/Contexts/DisplayPage/LayoutTypes.cs @@ -8,7 +8,7 @@ public enum LayoutTypes : ushort None, Details, List, - Tiles, + Cards, Grid, Columns, Adaptive, diff --git a/src/Files.App/Data/Contracts/ILayoutSettingsService.cs b/src/Files.App/Data/Contracts/ILayoutSettingsService.cs index 549544ff50ac..05b4363f7385 100644 --- a/src/Files.App/Data/Contracts/ILayoutSettingsService.cs +++ b/src/Files.App/Data/Contracts/ILayoutSettingsService.cs @@ -206,9 +206,9 @@ public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyC ListViewSizeKind ListViewSize { get; set; } /// - /// Item size in the Tiles View + /// Item size in the Cards View /// - TilesViewSizeKind TilesViewSize { get; set; } + CardsViewSizeKind CardsViewSize { get; set; } /// /// Item size in the Grid View diff --git a/src/Files.App/Data/Enums/CardsViewSizeKind.cs b/src/Files.App/Data/Enums/CardsViewSizeKind.cs new file mode 100644 index 000000000000..2f266326395e --- /dev/null +++ b/src/Files.App/Data/Enums/CardsViewSizeKind.cs @@ -0,0 +1,31 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +namespace Files.App.Data.Enums +{ + /// + /// Defines constants that specify the size in the Cards View layout. + /// + public enum CardsViewSizeKind + { + /// + /// The size is small. + /// + Small = 1, + + /// + /// The size is medium. + /// + Medium = 2, + + /// + /// The size is large. + /// + Large = 3, + + /// + /// The size is extra large. + /// + ExtraLarge = 4, + } +} diff --git a/src/Files.App/Data/Enums/FolderLayoutModes.cs b/src/Files.App/Data/Enums/FolderLayoutModes.cs index 055965af078f..46d61ab87a75 100644 --- a/src/Files.App/Data/Enums/FolderLayoutModes.cs +++ b/src/Files.App/Data/Enums/FolderLayoutModes.cs @@ -16,9 +16,9 @@ public enum FolderLayoutModes ListView = 1, /// - /// Tiles view + /// Cards view /// - TilesView = 2, + CardsView = 2, /// /// Column view diff --git a/src/Files.App/Data/Enums/TilesViewSizeKind.cs b/src/Files.App/Data/Enums/TilesViewSizeKind.cs deleted file mode 100644 index cb5bc73ea868..000000000000 --- a/src/Files.App/Data/Enums/TilesViewSizeKind.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Files Community -// Licensed under the MIT License. - -namespace Files.App.Data.Enums -{ - /// - /// Defines constants that specify the size in the Tiles View layout. - /// - public enum TilesViewSizeKind - { - /// - /// The size is small. - /// - Small = 1, - } -} diff --git a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs index f97414f2f89d..51138f5dcd46 100644 --- a/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs +++ b/src/Files.App/Data/Factories/ContentPageContextFlyoutFactory.cs @@ -122,7 +122,7 @@ public static List GetBaseItemMenuItems( { IsToggle = true }.Build(), - new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutTiles) + new ContextMenuFlyoutItemViewModelBuilder(Commands.LayoutCards) { IsToggle = true }.Build(), diff --git a/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs b/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs index e20483b9c7de..0b69ce7d41b8 100644 --- a/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs +++ b/src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs @@ -10,7 +10,7 @@ internal static class LocalizedEnumDescriptionFactory { private static Dictionary DetailsViewSizeKinds { get; } = []; private static Dictionary ListViewSizeKinds { get; } = []; - private static Dictionary TilesViewSizeKinds { get; } = []; + private static Dictionary CardsViewSizeKinds { get; } = []; private static Dictionary GridViewSizeKinds { get; } = []; private static Dictionary ColumnsViewSizeKinds { get; } = []; @@ -44,14 +44,17 @@ public static string Get(ListViewSizeKind value) return stringValue; } - public static string Get(TilesViewSizeKind value) + public static string Get(CardsViewSizeKind value) { - if (TilesViewSizeKinds.Count == 0) + if (CardsViewSizeKinds.Count == 0) { - TilesViewSizeKinds.Add(TilesViewSizeKind.Small, "Small".GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.Small, Strings.Small.GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.Medium, Strings.Medium.GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.Large, Strings.Large.GetLocalizedResource()); + CardsViewSizeKinds.Add(CardsViewSizeKind.ExtraLarge, Strings.ExtraLarge.GetLocalizedResource()); } - var stringValue = TilesViewSizeKinds.GetValueOrDefault(value)!; + var stringValue = CardsViewSizeKinds.GetValueOrDefault(value)!; return stringValue; } diff --git a/src/Files.App/Data/Items/ListedItem.cs b/src/Files.App/Data/Items/ListedItem.cs index 488728e692c3..35574cf93adf 100644 --- a/src/Files.App/Data/Items/ListedItem.cs +++ b/src/Files.App/Data/Items/ListedItem.cs @@ -6,7 +6,6 @@ using FluentFTP; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Media.Imaging; -using System.Drawing; using System.IO; using System.Text; using Windows.Storage; @@ -47,8 +46,8 @@ public string ItemTooltipText tooltipBuilder.Append($"{"ToolTipDescriptionDate".GetLocalizedResource()} {ItemDateModified}"); if (!string.IsNullOrWhiteSpace(FileSize)) tooltipBuilder.Append($"{Environment.NewLine}{"SizeLabel".GetLocalizedResource()} {FileSize}"); - if (SyncStatusUI.SyncStatus is not CloudDriveSyncStatus.FileOnline and not CloudDriveSyncStatus.FolderOnline && !string.IsNullOrWhiteSpace(DimensionsDisplay)) - tooltipBuilder.Append($"{Environment.NewLine}{"PropertyDimensionsColon".GetLocalizedResource()} {DimensionsDisplay}"); + if (!string.IsNullOrWhiteSpace(ImageDimensions)) + tooltipBuilder.Append($"{Environment.NewLine}{"PropertyDimensionsColon".GetLocalizedResource()} {ImageDimensions}"); if (SyncStatusUI.LoadSyncStatus) tooltipBuilder.Append($"{Environment.NewLine}{"StatusWithColon".GetLocalizedResource()} {syncStatusUI.SyncStatusString}"); @@ -330,39 +329,35 @@ public ObservableCollection ItemProperties set => SetProperty(ref itemProperties, value); } - public string DimensionsDisplay + private string imageDimensions; + public string ImageDimensions { - get - { - int imageHeight = 0; - int imageWidth = 0; + get => imageDimensions; + set => SetProperty(ref imageDimensions, value); + } - var isImageFile = FileExtensionHelpers.IsImageFile(FileExtension); - if (isImageFile) - { - try - { - // TODO: Consider to use 'System.Kind' instead. - using FileStream fileStream = new(ItemPath, FileMode.Open, FileAccess.Read, FileShare.Read); - using Image image = Image.FromStream(fileStream, false, false); - - if (image is not null) - { - imageHeight = image.Height; - imageWidth = image.Width; - } - } - catch { } - } + private string fileVersion; + public string FileVersion + { + get => fileVersion; + set => SetProperty(ref fileVersion, value); + } + private string mediaDuration; + public string MediaDuration + { + get => mediaDuration; + set => SetProperty(ref mediaDuration, value); + } - return - isImageFile && - imageWidth > 0 && - imageHeight > 0 - ? $"{imageWidth} \u00D7 {imageHeight}" - : string.Empty; - } + /// + /// Contextual property that changes based on the item type. + /// + private string contextualProperty; + public string ContextualProperty + { + get => contextualProperty; + set => SetProperty(ref contextualProperty, value); } /// @@ -771,24 +766,24 @@ public override string Name } public interface IGitItem { - public bool StatusPropertiesInitialized { get ; set; } + public bool StatusPropertiesInitialized { get; set; } public bool CommitPropertiesInitialized { get; set; } - public Style? UnmergedGitStatusIcon{ get; set; } + public Style? UnmergedGitStatusIcon { get; set; } - public string? UnmergedGitStatusName{ get; set; } + public string? UnmergedGitStatusName { get; set; } - public DateTimeOffset? GitLastCommitDate{ get; set; } + public DateTimeOffset? GitLastCommitDate { get; set; } - public string? GitLastCommitDateHumanized{ get; set; } + public string? GitLastCommitDateHumanized { get; set; } - public string? GitLastCommitMessage{ get; set; } + public string? GitLastCommitMessage { get; set; } - public string? GitLastCommitAuthor{ get; set; } + public string? GitLastCommitAuthor { get; set; } - public string? GitLastCommitSha{ get; set; } + public string? GitLastCommitSha { get; set; } - public string? GitLastCommitFullSha{ get; set; } + public string? GitLastCommitFullSha { get; set; } public string ItemPath { diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs index 5f350b9dba5e..c8895e1acb0f 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs @@ -218,7 +218,7 @@ public Type GetLayoutType(string path, bool changeLayoutMode = true) { FolderLayoutModes.DetailsView => typeof(DetailsLayoutPage), FolderLayoutModes.ListView => typeof(GridLayoutPage), - FolderLayoutModes.TilesView => typeof(GridLayoutPage), + FolderLayoutModes.CardsView => typeof(GridLayoutPage), FolderLayoutModes.GridView => typeof(GridLayoutPage), FolderLayoutModes.ColumnView => typeof(ColumnsLayoutPage), _ => typeof(DetailsLayoutPage) @@ -252,14 +252,14 @@ public void ToggleLayoutModeGridView(bool manuallySet) LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.GridView)); } - public void ToggleLayoutModeTiles(bool manuallySet) + public void ToggleLayoutModeCards(bool manuallySet) { IsAdaptiveLayoutEnabled &= !manuallySet; - // Tiles View - LayoutMode = FolderLayoutModes.TilesView; + // Cards View + LayoutMode = FolderLayoutModes.CardsView; - LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.TilesView)); + LayoutModeChangeRequested?.Invoke(this, new LayoutModeEventArgs(FolderLayoutModes.CardsView)); } public void ToggleLayoutModeList(bool manuallySet) @@ -578,4 +578,4 @@ private bool SetProperty(Func prop, Actio return true; } } -} +} \ No newline at end of file diff --git a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs index a69fd2c1b79a..6dec2955adff 100644 --- a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs +++ b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs @@ -7,6 +7,50 @@ public static class LayoutSizeKindHelper { private static ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetRequiredService(); + /// + /// Gets the desired icon size for the requested layout + /// + /// + /// + public static uint GetIconSize(FolderLayoutModes folderLayoutMode) + { + return folderLayoutMode switch + { + // Details + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium => 20, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large => 24, + FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // List + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium => 20, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Large => 24, + FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // Columns + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Compact => Constants.ShellIconSizes.Small, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Small => Constants.ShellIconSizes.Small, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Medium => 20, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Large => 24, + FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, + + // Card + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Small => 64, + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Medium => 64, + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Large => 80, + FolderLayoutModes.CardsView when LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge => 96, + + // Grid + FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small => 96, + FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, + + _ => 256, + }; + } + /// /// Gets the desired height for items in the Details View /// @@ -93,45 +137,6 @@ public static int GetListViewRowHeight(ListViewSizeKind listViewSizeKind) } } - /// - /// Gets the desired icon size for the requested layout - /// - /// - /// - public static uint GetIconSize(FolderLayoutModes folderLayoutMode) - { - return folderLayoutMode switch - { - // Details - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact => Constants.ShellIconSizes.Small, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small => Constants.ShellIconSizes.Small, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium => 20, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large => 24, - FolderLayoutModes.DetailsView when LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, - - // List - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact => Constants.ShellIconSizes.Small, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Small => Constants.ShellIconSizes.Small, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium => 20, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.Large => 24, - FolderLayoutModes.ListView when LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, - - // Columns - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Compact => Constants.ShellIconSizes.Small, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Small => Constants.ShellIconSizes.Small, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Medium => 20, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Large => 24, - FolderLayoutModes.ColumnView when LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.ExtraLarge => Constants.ShellIconSizes.Large, - - // Grid and Tiles - FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small => 96, - FolderLayoutModes.GridView when LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, - FolderLayoutModes.TilesView => 96, - - _ => 256, - }; - } - /// /// Gets the desired height for items in the Columns View /// @@ -155,15 +160,5 @@ public static int GetColumnsViewRowHeight(ColumnsViewSizeKind columnsViewSizeKin return 32; } } - - /// - /// Gets the desired width for items in the Tiles View - /// - /// - /// - public static int GetTilesViewItemWidth(TilesViewSizeKind tilesViewSizeKind) - { - return 260; - } } } \ No newline at end of file diff --git a/src/Files.App/Services/Settings/LayoutSettingsService.cs b/src/Files.App/Services/Settings/LayoutSettingsService.cs index 912607b6e3a3..fb637fe98cf7 100644 --- a/src/Files.App/Services/Settings/LayoutSettingsService.cs +++ b/src/Files.App/Services/Settings/LayoutSettingsService.cs @@ -307,9 +307,9 @@ public ListViewSizeKind ListViewSize set => Set(value); } - public TilesViewSizeKind TilesViewSize + public CardsViewSizeKind CardsViewSize { - get => Get(TilesViewSizeKind.Small); + get => Get(CardsViewSizeKind.Small); set => Set(value); } diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index 47ffdc413c7d..b4f3d9cbbc1d 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -1058,9 +1058,6 @@ Details (Ctrl+Shift+1) - - Tiles (Ctrl+Shift+2) - Date deleted @@ -1658,15 +1655,6 @@ Home - - Ctrl+Shift+1 - - - Ctrl+Shift+2 - - - Ctrl+Shift+6 - The archive extraction completed successfully. @@ -1724,8 +1712,8 @@ Columns - - Tiles + + Cards Open folders in new tab @@ -2585,8 +2573,8 @@ Switch to details view - - Switch to tiles view + + Switch to cards view Switch to list view @@ -3726,9 +3714,6 @@ Questions & discussions - - Additional sizes are not yet available for the Tiles View. - Compact Used to describe layout sizes diff --git a/src/Files.App/UserControls/InnerNavigationToolbar.xaml b/src/Files.App/UserControls/InnerNavigationToolbar.xaml index e8a20252bad2..a740239b5d5f 100644 --- a/src/Files.App/UserControls/InnerNavigationToolbar.xaml +++ b/src/Files.App/UserControls/InnerNavigationToolbar.xaml @@ -28,7 +28,7 @@ - + @@ -733,14 +733,14 @@ - + + ToolTipService.ToolTip="{x:Bind Commands.LayoutCards.LabelWithHotKey, Mode=OneWay}"> @@ -950,21 +950,62 @@ - - + - - + x:Name="CardsView" + Spacing="4" + Visibility="{x:Bind ViewModel.IsCardsLayout, Mode=OneWay}"> + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Files.App/ViewModels/ShellViewModel.cs b/src/Files.App/ViewModels/ShellViewModel.cs index 3200a142cc35..4eddda45ed6f 100644 --- a/src/Files.App/ViewModels/ShellViewModel.cs +++ b/src/Files.App/ViewModels/ShellViewModel.cs @@ -977,7 +977,7 @@ private async Task LoadThumbnailAsync(ListedItem item, CancellationToken cancell var returnIconOnly = UserSettingsService.FoldersSettingsService.ShowThumbnails == false || thumbnailSize < 48; // TODO Remove this property when all the layouts can support different icon sizes - var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView || folderSettings.LayoutMode == FolderLayoutModes.ListView || folderSettings.LayoutMode == FolderLayoutModes.ColumnView; + var useCurrentScale = folderSettings.LayoutMode == FolderLayoutModes.DetailsView || folderSettings.LayoutMode == FolderLayoutModes.ListView || folderSettings.LayoutMode == FolderLayoutModes.ColumnView || folderSettings.LayoutMode == FolderLayoutModes.CardsView; byte[]? result = null; @@ -1141,6 +1141,7 @@ public async Task LoadExtendedItemPropertiesAsync(ListedItem item) var fileFRN = await FileTagsHelper.GetFileFRN(matchingStorageFile); var fileTag = FileTagsHelper.ReadFileTag(item.ItemPath); var itemType = (item.ItemType == "Folder".GetLocalizedResource()) ? item.ItemType : matchingStorageFile.DisplayType; + var extraProperties = await GetExtraProperties(matchingStorageFile); cts.Token.ThrowIfCancellationRequested(); @@ -1152,6 +1153,27 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => item.FileFRN = fileFRN; item.FileTags = fileTag; item.IsElevationRequired = CheckElevationRights(item); + item.ImageDimensions = extraProperties?.Result["System.Image.Dimensions"]?.ToString() ?? string.Empty; + item.FileVersion = extraProperties?.Result["System.FileVersion"]?.ToString() ?? string.Empty; + item.MediaDuration = ulong.TryParse(extraProperties?.Result["System.Media.Duration"]?.ToString(), out ulong duration) + ? TimeSpan.FromTicks((long)duration).ToString(@"hh\:mm\:ss") + : string.Empty; + + switch (true) + { + case var _ when !string.IsNullOrEmpty(item.ImageDimensions): + item.ContextualProperty = $"{Strings.PropertyDimensions.GetLocalizedResource()}: {item.ImageDimensions}"; + break; + case var _ when !string.IsNullOrEmpty(item.MediaDuration): + item.ContextualProperty = $"{Strings.PropertyDuration.GetLocalizedResource()}: {item.MediaDuration}"; + break; + case var _ when !string.IsNullOrEmpty(item.FileVersion): + item.ContextualProperty = $"{Strings.PropertyVersion.GetLocalizedResource()}: {item.FileVersion}"; + break; + default: + item.ContextualProperty = $"{Strings.Modified.GetLocalizedResource()}: {item.ItemDateModified}"; + break; + } }, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low); @@ -1187,6 +1209,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => var fileFRN = await FileTagsHelper.GetFileFRN(matchingStorageFolder); var fileTag = FileTagsHelper.ReadFileTag(item.ItemPath); var itemType = (item.ItemType == "Folder".GetLocalizedResource()) ? item.ItemType : matchingStorageFolder.DisplayType; + cts.Token.ThrowIfCancellationRequested(); await dispatcherQueue.EnqueueOrInvokeAsync(() => @@ -1196,6 +1219,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() => item.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus); item.FileFRN = fileFRN; item.FileTags = fileTag; + item.ContextualProperty = $"{Strings.Modified.GetLocalizedResource()}: {item.ItemDateModified}"; }, Microsoft.UI.Dispatching.DispatcherQueuePriority.Low); @@ -1908,6 +1932,14 @@ public async Task CheckCloudDriveSyncStatusAsync(IStorageI return (CloudDriveSyncStatus)syncStatus; } + private async Task>?> GetExtraProperties(IStorageItem matchingStorageItem) + { + if (matchingStorageItem is BaseStorageFile file && file.Properties != null) + return await FilesystemTasks.Wrap(() => file.Properties.RetrievePropertiesAsync(["System.Image.Dimensions", "System.Media.Duration", "System.FileVersion"]).AsTask()); + + return null; + } + private async Task WatchForStorageFolderChangesAsync(BaseStorageFolder? rootFolder) { if (rootFolder is null) diff --git a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs index 4a770a16bc85..d606a6db2541 100644 --- a/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs +++ b/src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs @@ -251,6 +251,7 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh case nameof(UserSettingsService.LayoutSettingsService.DetailsViewSize): case nameof(UserSettingsService.LayoutSettingsService.ListViewSize): case nameof(UserSettingsService.LayoutSettingsService.ColumnsViewSize): + case nameof(UserSettingsService.LayoutSettingsService.CardsViewSize): case nameof(UserSettingsService.LayoutSettingsService.GridViewSize): OnPropertyChanged(nameof(IsLayoutSizeCompact)); OnPropertyChanged(nameof(IsLayoutSizeSmall)); @@ -992,12 +993,12 @@ private void FolderSettings_PropertyChanged(object? sender, PropertyChangedEvent LayoutThemedIcon = instanceViewModel.FolderSettings.LayoutMode switch { FolderLayoutModes.ListView => Commands.LayoutList.ThemedIconStyle!, - FolderLayoutModes.TilesView => Commands.LayoutTiles.ThemedIconStyle!, + FolderLayoutModes.CardsView => Commands.LayoutCards.ThemedIconStyle!, FolderLayoutModes.ColumnView => Commands.LayoutColumns.ThemedIconStyle!, FolderLayoutModes.GridView => Commands.LayoutGrid.ThemedIconStyle!, _ => Commands.LayoutDetails.ThemedIconStyle! }; - OnPropertyChanged(nameof(IsTilesLayout)); + OnPropertyChanged(nameof(IsCardsLayout)); OnPropertyChanged(nameof(IsListLayout)); OnPropertyChanged(nameof(IsColumnLayout)); OnPropertyChanged(nameof(IsGridLayout)); @@ -1055,7 +1056,7 @@ public List SelectedItems public bool IsInfFile => SelectedItems is not null && SelectedItems.Count == 1 && FileExtensionHelpers.IsInfFile(SelectedItems.First().FileExtension) && !InstanceViewModel.IsPageTypeRecycleBin; public bool IsFont => SelectedItems is not null && SelectedItems.Any() && SelectedItems.All(x => FileExtensionHelpers.IsFontFile(x.FileExtension)) && !InstanceViewModel.IsPageTypeRecycleBin; - public bool IsTilesLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.TilesView; + public bool IsCardsLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.CardsView; public bool IsColumnLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.ColumnView; public bool IsGridLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.GridView; public bool IsDetailsLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.DetailsView; @@ -1070,24 +1071,28 @@ public List SelectedItems (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Small) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Small) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Small) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.Small); public bool IsLayoutSizeMedium => (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Medium) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Medium) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Medium) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Medium) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.Medium); public bool IsLayoutSizeLarge => (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Large) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Large) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Large) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Large) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.Large); public bool IsLayoutSizeExtraLarge => (IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.ExtraLarge) || (IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.ExtraLarge) || (IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.ExtraLarge) || + (IsCardsLayout && UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge) || (IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.ExtraLarge); public string ExtractToText diff --git a/src/Files.App/Views/Layouts/BaseLayoutPage.cs b/src/Files.App/Views/Layouts/BaseLayoutPage.cs index c38181d24653..3b12288fe123 100644 --- a/src/Files.App/Views/Layouts/BaseLayoutPage.cs +++ b/src/Files.App/Views/Layouts/BaseLayoutPage.cs @@ -39,6 +39,7 @@ public abstract class BaseLayoutPage : Page, IBaseLayoutPage, INotifyPropertyCha protected IFileTagsSettingsService FileTagsSettingsService { get; } = Ioc.Default.GetService()!; protected IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetService()!; + protected ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetService()!; protected ICommandManager Commands { get; } = Ioc.Default.GetRequiredService(); public InfoPaneViewModel InfoPaneViewModel { get; } = Ioc.Default.GetRequiredService(); protected readonly IWindowContext WindowContext = Ioc.Default.GetRequiredService(); diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs index 02a11423ccff..88ae5d878993 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs @@ -587,8 +587,8 @@ protected override void BaseFolderSettings_LayoutModeChangeRequested(object? sen case FolderLayoutModes.ListView: parent.FolderSettings.ToggleLayoutModeList(true); break; - case FolderLayoutModes.TilesView: - parent.FolderSettings.ToggleLayoutModeTiles(true); + case FolderLayoutModes.CardsView: + parent.FolderSettings.ToggleLayoutModeCards(true); break; case FolderLayoutModes.GridView: parent.FolderSettings.ToggleLayoutModeGridView(true); diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml b/src/Files.App/Views/Layouts/GridLayoutPage.xaml index 4a394e65df23..e354bf14a603 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml @@ -7,6 +7,7 @@ xmlns:controls="using:Files.App.Controls" xmlns:converters="using:Files.App.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:datamodels="using:Files.App.Data.Models" xmlns:filesystem="using:Files.App.Utils" xmlns:helpers="using:Files.App.Helpers" xmlns:i="using:Microsoft.Xaml.Interactivity" @@ -86,11 +87,6 @@ TrueValue="Visible" /> - - 0 - - - @@ -433,192 +429,246 @@ - - + + - - - - - - - - + - - - - + + - + + + - + + - - - - - - - - - - - - - - - - - - - - + + + - + - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -729,6 +779,65 @@ + + + + + + + + + diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs index ee1435271b64..33fe4438c147 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml.cs @@ -39,50 +39,108 @@ public sealed partial class GridLayoutPage : BaseGroupableLayoutPage protected override SemanticZoom RootZoom => RootGridZoom; + // List View properties + /// /// Row height in the List View layout /// - public int RowHeightListView - { - get => LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize); - } + public int RowHeightListView => + LayoutSizeKindHelper.GetListViewRowHeight(LayoutSettingsService.ListViewSize); /// /// Icon Box size in the List View layout. The value is increased by 4px to account for icon overlays. /// - public int IconBoxSizeListView + public int IconBoxSizeListView => + (int)(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.ListView) + 4); + + + + // Grid View properties + + /// + /// Item width in the Grid View layout + /// + public int ItemWidthGridView => + LayoutSizeKindHelper.GetGridViewItemWidth(LayoutSettingsService.GridViewSize); + + + + // Cards View properties + + /// + /// Gets the details box width for the Cards View layout based on the card size. + /// + public int CardsViewDetailsBoxWidth => LayoutSettingsService.CardsViewSize switch { - get => (int)(LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.ListView) + 4); - } + CardsViewSizeKind.Small => 196, + CardsViewSizeKind.Medium => 240, + CardsViewSizeKind.Large => 280, + CardsViewSizeKind.ExtraLarge => 320, + _ => 300 + }; /// - /// Item width in the Tiles View layout + /// Gets the details box height for the Cards View layout based on the card size. /// - public int ItemWidthTilesView + public int CardsViewDetailsBoxHeight => LayoutSettingsService.CardsViewSize switch { - get => LayoutSizeKindHelper.GetTilesViewItemWidth(UserSettingsService.LayoutSettingsService.TilesViewSize); - } + CardsViewSizeKind.Small => 104, + CardsViewSizeKind.Medium => 144, + CardsViewSizeKind.Large => 144, + CardsViewSizeKind.ExtraLarge => 128, + _ => 128 + }; /// - /// Item width in the Grid View layout + /// Gets the icon box height for the Cards View layout based on the card size. /// - public int ItemWidthGridView + public int CardsViewIconBoxHeight => LayoutSettingsService.CardsViewSize switch { - get => LayoutSizeKindHelper.GetGridViewItemWidth(UserSettingsService.LayoutSettingsService.GridViewSize); - } + CardsViewSizeKind.Small => 104, + CardsViewSizeKind.Medium => 96, + CardsViewSizeKind.Large => 128, + CardsViewSizeKind.ExtraLarge => 160, + _ => 128 + }; - public bool IsPointerOver + /// + /// Gets the icon box width for the Cards View layout based on the card size. + /// + public int CardsViewIconBoxWidth => LayoutSettingsService.CardsViewSize switch { - get => (bool)GetValue(IsPointerOverProperty); - set => SetValue(IsPointerOverProperty, value); - } + CardsViewSizeKind.Small => 104, + CardsViewSizeKind.Medium => 240, + CardsViewSizeKind.Large => 280, + CardsViewSizeKind.ExtraLarge => 320, + _ => 128 + }; + + /// + /// Gets the orientation of cards in the Cards View layout. + /// + public Orientation CardsViewOrientation => UserSettingsService.LayoutSettingsService.CardsViewSize == CardsViewSizeKind.Small + ? Orientation.Horizontal + : Orientation.Vertical; + + /// + /// Gets the maximum lines for item names in the Cards View layout. + /// + public int CardsViewItemNameMaxLines => + LayoutSettingsService.CardsViewSize == CardsViewSizeKind.ExtraLarge ? 1 : 2; + + /// + /// Gets the visibility for the contextual property string in the Cards View layout. + /// + public bool CardsViewShowContextualProperty=> + LayoutSettingsService.CardsViewSize != CardsViewSizeKind.Small; + + /// + /// Gets the icon size for item names in the Cards View layout. + /// + public int CardsViewIconSize => + (int)LayoutSizeKindHelper.GetIconSize(FolderLayoutModes.CardsView); + - public static readonly DependencyProperty IsPointerOverProperty = - DependencyProperty.Register( - nameof(IsPointerOver), - typeof(bool), - typeof(GridLayoutPage), - new PropertyMetadata(false)); // Constructor @@ -181,10 +239,8 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang SetItemContainerStyle(); FolderSettings_IconSizeChanged(); } - if (e.PropertyName == nameof(ILayoutSettingsService.TilesViewSize)) + if (e.PropertyName == nameof(ILayoutSettingsService.CardsViewSize)) { - NotifyPropertyChanged(nameof(ItemWidthTilesView)); - // Update the container style to match the item size SetItemContainerStyle(); FolderSettings_IconSizeChanged(); @@ -205,7 +261,7 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e) { if (FolderSettings.LayoutMode == FolderLayoutModes.ListView - || FolderSettings.LayoutMode == FolderLayoutModes.TilesView + || FolderSettings.LayoutMode == FolderLayoutModes.CardsView || FolderSettings.LayoutMode == FolderLayoutModes.GridView) { // Set ItemTemplate @@ -220,7 +276,7 @@ private void SetItemTemplate() var newFileListStyle = FolderSettings.LayoutMode switch { FolderLayoutModes.ListView => (Style)Resources["VerticalLayoutGridView"], - FolderLayoutModes.TilesView => (Style)Resources["HorizontalLayoutGridView"], + FolderLayoutModes.CardsView => (Style)Resources["HorizontalLayoutGridView"], _ => (Style)Resources["HorizontalLayoutGridView"] }; @@ -239,8 +295,8 @@ private void SetItemTemplate() case FolderLayoutModes.ListView: FileList.ItemTemplate = ListViewBrowserTemplate; break; - case FolderLayoutModes.TilesView: - FileList.ItemTemplate = TilesBrowserTemplate; + case FolderLayoutModes.CardsView: + FileList.ItemTemplate = CardsBrowserTemplate; break; default: FileList.ItemTemplate = GridViewBrowserTemplate; @@ -250,7 +306,15 @@ private void SetItemTemplate() private void SetItemContainerStyle() { - if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact) + if (FolderSettings?.LayoutMode == FolderLayoutModes.CardsView) + { + // Toggle style to force item size to update + FileList.ItemContainerStyle = DefaultItemContainerStyle; + + // Set correct style + FileList.ItemContainerStyle = CardsItemContainerStyle; + } + else if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact) { // Toggle style to force item size to update FileList.ItemContainerStyle = DefaultItemContainerStyle; @@ -303,7 +367,7 @@ override public void StartRenameItem() TextBox? textBox = null; - // Handle layout differences between tiles browser and photo album + // Grid View if (FolderSettings.LayoutMode == FolderLayoutModes.GridView) { if (gridViewItem.FindDescendant("EditPopup") is not Popup popup) @@ -318,6 +382,7 @@ override public void StartRenameItem() popup.IsOpen = true; OldItemName = textBlock.Text; } + // List View else if (FolderSettings.LayoutMode == FolderLayoutModes.ListView) { textBox = gridViewItem.FindDescendant("ListViewTextBoxItemName") as TextBox; @@ -336,6 +401,7 @@ override public void StartRenameItem() return; } } + // Cards View else { textBox = gridViewItem.FindDescendant("TileViewTextBoxItemName") as TextBox; @@ -344,12 +410,10 @@ override public void StartRenameItem() textBox.Text = textBlock.Text; OldItemName = textBlock.Text; - textBlock.Visibility = Visibility.Collapsed; textBox.Visibility = Visibility.Visible; if (textBox.FindParent() is null) { - textBlock.Visibility = Visibility.Visible; textBox.Visibility = Visibility.Collapsed; return; } @@ -398,7 +462,7 @@ protected override void EndRename(TextBox textBox) if (textBlock is not null) textBlock.Opacity = (textBlock.DataContext as ListedItem)!.Opacity; } - else if (FolderSettings.LayoutMode == FolderLayoutModes.TilesView || FolderSettings.LayoutMode == FolderLayoutModes.ListView) + else if (FolderSettings.LayoutMode == FolderLayoutModes.CardsView || FolderSettings.LayoutMode == FolderLayoutModes.ListView) { TextBlock? textBlock = gridViewItem.FindDescendant("ItemName") as TextBlock; @@ -698,7 +762,7 @@ private void SelectionCheckbox_PointerCanceled(object sender, PointerRoutedEvent // To avoid crashes, disable scrolling when drag-and-drop if grouped. (#14484) private bool ShouldDisableScrollingWhenDragAndDrop => - FolderSettings?.LayoutMode is FolderLayoutModes.GridView or FolderLayoutModes.TilesView && + FolderSettings?.LayoutMode is FolderLayoutModes.GridView or FolderLayoutModes.CardsView && (ParentShellPageInstance?.ShellViewModel.FilesAndFolders.IsGrouped ?? false); protected override void FileList_DragItemsStarting(object sender, DragItemsStartingEventArgs e) diff --git a/src/Files.App/Views/Settings/LayoutPage.xaml b/src/Files.App/Views/Settings/LayoutPage.xaml index 92f5a92914bf..cdb803006dda 100644 --- a/src/Files.App/Views/Settings/LayoutPage.xaml +++ b/src/Files.App/Views/Settings/LayoutPage.xaml @@ -64,7 +64,7 @@ - + diff --git a/src/Files.Shared/Helpers/FileExtensionHelpers.cs b/src/Files.Shared/Helpers/FileExtensionHelpers.cs index 232adf1f57e8..63225d85cf16 100644 --- a/src/Files.Shared/Helpers/FileExtensionHelpers.cs +++ b/src/Files.Shared/Helpers/FileExtensionHelpers.cs @@ -256,6 +256,16 @@ public static bool IsScriptFile(string? filePathToCheck) { return HasExtension(filePathToCheck, ".py", ".ahk"); } + + /// + /// Check if the file extension is a system file. + /// + /// + /// true if the filePathToCheck is a system file; otherwise, false. + public static bool IsSystemFile(string? filePathToCheck) + { + return HasExtension(filePathToCheck, ".dll", ".exe", ".sys", ".inf"); + } } }