diff --git a/src/Files.App/Actions/Display/LayoutAction.cs b/src/Files.App/Actions/Display/LayoutAction.cs index 09f03ab73cce..85164ef35bf0 100644 --- a/src/Files.App/Actions/Display/LayoutAction.cs +++ b/src/Files.App/Actions/Display/LayoutAction.cs @@ -188,10 +188,10 @@ public HotKey MediaHotKey public bool IsExecutable => ContentPageContext.PageType is not ContentPageTypes.Home && - ((DisplayPageContext.LayoutType == LayoutTypes.Details && UserSettingsService.LayoutSettingsService.ItemSizeDetailsView > Constants.IconHeights.DetailsView.Minimum) || - (DisplayPageContext.LayoutType == LayoutTypes.List && UserSettingsService.LayoutSettingsService.ItemSizeListView > Constants.IconHeights.ListView.Minimum) || - (DisplayPageContext.LayoutType == LayoutTypes.Grid && UserSettingsService.LayoutSettingsService.ItemSizeGridView > Constants.IconHeights.GridView.Minimum) || - (DisplayPageContext.LayoutType == LayoutTypes.Columns && UserSettingsService.LayoutSettingsService.ItemSizeColumnsView > Constants.IconHeights.ColumnsView.Minimum)); + ((DisplayPageContext.LayoutType == LayoutTypes.Details && UserSettingsService.LayoutSettingsService.DetailsViewSize > DetailsViewSizeKind.Compact) || + (DisplayPageContext.LayoutType == LayoutTypes.List && UserSettingsService.LayoutSettingsService.ListViewSize > ListViewSizeKind.Compact) || + (DisplayPageContext.LayoutType == LayoutTypes.Grid && UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Compact) || + (DisplayPageContext.LayoutType == LayoutTypes.Columns && UserSettingsService.LayoutSettingsService.ColumnsViewSize > ColumnsViewSizeKind.Compact)); public LayoutDecreaseSizeAction() { @@ -224,10 +224,10 @@ private void UserSettingsService_PropertyChanged(object? sender, PropertyChanged { switch (e.PropertyName) { - case nameof(ILayoutSettingsService.ItemSizeDetailsView): - case nameof(ILayoutSettingsService.ItemSizeListView): - case nameof(ILayoutSettingsService.ItemSizeGridView): - case nameof(ILayoutSettingsService.ItemSizeColumnsView): + case nameof(ILayoutSettingsService.DetailsViewSize): + case nameof(ILayoutSettingsService.ListViewSize): + case nameof(ILayoutSettingsService.GridViewSize): + case nameof(ILayoutSettingsService.ColumnsViewSize): OnPropertyChanged(nameof(IsExecutable)); break; } @@ -238,22 +238,22 @@ public Task ExecuteAsync() switch (DisplayPageContext.LayoutType) { case LayoutTypes.Details: - if (UserSettingsService.LayoutSettingsService.ItemSizeDetailsView > Constants.IconHeights.DetailsView.Minimum) - UserSettingsService.LayoutSettingsService.ItemSizeDetailsView -= Constants.IconHeights.DetailsView.Increment; + if (UserSettingsService.LayoutSettingsService.DetailsViewSize > DetailsViewSizeKind.Compact) + UserSettingsService.LayoutSettingsService.DetailsViewSize -= 1; break; case LayoutTypes.List: - if (UserSettingsService.LayoutSettingsService.ItemSizeListView > Constants.IconHeights.ListView.Minimum) - UserSettingsService.LayoutSettingsService.ItemSizeListView -= Constants.IconHeights.ListView.Increment; + if (UserSettingsService.LayoutSettingsService.ListViewSize > ListViewSizeKind.Compact) + UserSettingsService.LayoutSettingsService.ListViewSize -= 1; break; case LayoutTypes.Tiles: break; case LayoutTypes.Grid: - if (UserSettingsService.LayoutSettingsService.ItemSizeGridView > Constants.IconHeights.GridView.Minimum) - UserSettingsService.LayoutSettingsService.ItemSizeGridView -= Constants.IconHeights.GridView.Increment; + if (UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Compact) + UserSettingsService.LayoutSettingsService.GridViewSize -= 1; break; case LayoutTypes.Columns: - if (UserSettingsService.LayoutSettingsService.ItemSizeColumnsView > Constants.IconHeights.ColumnsView.Minimum) - UserSettingsService.LayoutSettingsService.ItemSizeColumnsView -= Constants.IconHeights.ColumnsView.Increment; + if (UserSettingsService.LayoutSettingsService.ColumnsViewSize > ColumnsViewSizeKind.Compact) + UserSettingsService.LayoutSettingsService.ColumnsViewSize -= 1; break; } @@ -281,10 +281,10 @@ public HotKey MediaHotKey public bool IsExecutable => ContentPageContext.PageType is not ContentPageTypes.Home && - ((DisplayPageContext.LayoutType == LayoutTypes.Details && UserSettingsService.LayoutSettingsService.ItemSizeDetailsView < Constants.IconHeights.DetailsView.Maximum) || - (DisplayPageContext.LayoutType == LayoutTypes.List && UserSettingsService.LayoutSettingsService.ItemSizeListView < Constants.IconHeights.ListView.Maximum) || - (DisplayPageContext.LayoutType == LayoutTypes.Grid && UserSettingsService.LayoutSettingsService.ItemSizeGridView < Constants.IconHeights.GridView.Maximum) || - (DisplayPageContext.LayoutType == LayoutTypes.Columns && UserSettingsService.LayoutSettingsService.ItemSizeColumnsView < Constants.IconHeights.ColumnsView.Maximum)); + ((DisplayPageContext.LayoutType == LayoutTypes.Details && UserSettingsService.LayoutSettingsService.DetailsViewSize < DetailsViewSizeKind.ExtraLarge) || + (DisplayPageContext.LayoutType == LayoutTypes.List && UserSettingsService.LayoutSettingsService.ListViewSize < ListViewSizeKind.ExtraLarge) || + (DisplayPageContext.LayoutType == LayoutTypes.Grid && UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.Eleven) || + (DisplayPageContext.LayoutType == LayoutTypes.Columns && UserSettingsService.LayoutSettingsService.ColumnsViewSize < ColumnsViewSizeKind.ExtraLarge)); public LayoutIncreaseSizeAction() { @@ -317,10 +317,10 @@ private void UserSettingsService_PropertyChanged(object? sender, PropertyChanged { switch (e.PropertyName) { - case nameof(ILayoutSettingsService.ItemSizeDetailsView): - case nameof(ILayoutSettingsService.ItemSizeListView): - case nameof(ILayoutSettingsService.ItemSizeGridView): - case nameof(ILayoutSettingsService.ItemSizeColumnsView): + case nameof(ILayoutSettingsService.DetailsViewSize): + case nameof(ILayoutSettingsService.ListViewSize): + case nameof(ILayoutSettingsService.GridViewSize): + case nameof(ILayoutSettingsService.ColumnsViewSize): OnPropertyChanged(nameof(IsExecutable)); break; } @@ -331,22 +331,22 @@ public Task ExecuteAsync() switch (DisplayPageContext.LayoutType) { case LayoutTypes.Details: - if (UserSettingsService.LayoutSettingsService.ItemSizeDetailsView < Constants.IconHeights.DetailsView.Maximum) - UserSettingsService.LayoutSettingsService.ItemSizeDetailsView += Constants.IconHeights.DetailsView.Increment; + if (UserSettingsService.LayoutSettingsService.DetailsViewSize < DetailsViewSizeKind.ExtraLarge) + UserSettingsService.LayoutSettingsService.DetailsViewSize += 1; break; case LayoutTypes.List: - if (UserSettingsService.LayoutSettingsService.ItemSizeListView < Constants.IconHeights.ListView.Maximum) - UserSettingsService.LayoutSettingsService.ItemSizeListView += Constants.IconHeights.ListView.Increment; + if (UserSettingsService.LayoutSettingsService.ListViewSize < ListViewSizeKind.ExtraLarge) + UserSettingsService.LayoutSettingsService.ListViewSize += 1; break; case LayoutTypes.Tiles: break; case LayoutTypes.Grid: - if (UserSettingsService.LayoutSettingsService.ItemSizeGridView < Constants.IconHeights.GridView.Maximum) - UserSettingsService.LayoutSettingsService.ItemSizeGridView += Constants.IconHeights.GridView.Increment; + if (UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.Eleven) + UserSettingsService.LayoutSettingsService.GridViewSize += 1; break; case LayoutTypes.Columns: - if (UserSettingsService.LayoutSettingsService.ItemSizeColumnsView < Constants.IconHeights.ColumnsView.Maximum) - UserSettingsService.LayoutSettingsService.ItemSizeColumnsView += Constants.IconHeights.ColumnsView.Increment; + if (UserSettingsService.LayoutSettingsService.ColumnsViewSize < ColumnsViewSizeKind.ExtraLarge) + UserSettingsService.LayoutSettingsService.ColumnsViewSize += 1; break; } diff --git a/src/Files.App/Constants.cs b/src/Files.App/Constants.cs index af61e52381cb..65eb1e53bc87 100644 --- a/src/Files.App/Constants.cs +++ b/src/Files.App/Constants.cs @@ -118,70 +118,6 @@ public static class Appearance public const string StandardFont = "Segoe UI Variable"; } - // Default icon heights used in the differents layouts - public static class IconHeights - { - public static class GridView - { - public const int Increment = 20; - - public const int Minimum = 80; - - public const int Small = 100; - - public const int Medium = 160; - - public const int Large = 220; - - public const int Maximum = 300; - } - - public static class TilesView - { - public const int Regular = 100; - } - - public static class ListView - { - public const int Increment = 4; - - public const int Minimum = 24; - - public const int Small = 28; - - public const int Regular = 32; - - public const int Maximum = 36; - } - - public static class DetailsView - { - public const int Increment = 4; - - public const int Minimum = 28; - - public const int Small = 32; - - public const int Regular = 36; - - public const int Maximum = 40; - } - - public static class ColumnsView - { - public const int Increment = 4; - - public const int Minimum = 28; - - public const int Small = 32; - - public const int Regular = 36; - - public const int Maximum = 40; - } - } - - // Default icon sizes that are available for files and folders public static class ShellIconSizes { diff --git a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs index 1f469a250ea3..09eec45a8dd2 100644 --- a/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs +++ b/src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs @@ -235,11 +235,10 @@ public uint GetRoundedIconSize() => Constants.ShellIconSizes.Large, FolderLayoutModes.ColumnView => Constants.ShellIconSizes.Large, - _ when LayoutMode == FolderLayoutModes.TilesView && UserSettingsService.LayoutSettingsService.ItemSizeTilesView <= 96 || - LayoutMode == FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.ItemSizeGridView <= 96 + _ when LayoutMode == FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize <= GridViewSizeKind.Small || + LayoutMode == FolderLayoutModes.TilesView => 96, - _ when LayoutMode == FolderLayoutModes.TilesView && UserSettingsService.LayoutSettingsService.ItemSizeTilesView <= 128 || - LayoutMode == FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.ItemSizeGridView <= 128 + _ when LayoutMode == FolderLayoutModes.GridView && UserSettingsService.LayoutSettingsService.GridViewSize <= GridViewSizeKind.Large => 128, _ => 256, }; diff --git a/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs new file mode 100644 index 000000000000..557ad9749fe2 --- /dev/null +++ b/src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs @@ -0,0 +1,130 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.App.Helpers +{ + public static class LayoutSizeKindHelper + { + private static ILayoutSettingsService LayoutSettingsService { get; } = Ioc.Default.GetRequiredService(); + + /// + /// Gets the desired height for items in the Details View + /// + /// + /// + public static int GetDetailsViewRowHeight(DetailsViewSizeKind detailsViewSizeKind) + { + switch (detailsViewSizeKind) + { + case DetailsViewSizeKind.Compact: + return 28; + case DetailsViewSizeKind.Small: + return 36; + case DetailsViewSizeKind.Medium: + return 40; + case DetailsViewSizeKind.Large: + return 44; + case DetailsViewSizeKind.ExtraLarge: + return 48; + default: + return 36; + } + } + + /// + /// Gets the desired width for items in the Grid View + /// + /// + /// + public static int GetGridViewItemWidth(GridViewSizeKind gridViewSizeKind) + { + switch (gridViewSizeKind) + { + case GridViewSizeKind.Compact: + return 80; + case GridViewSizeKind.Small: + return 100; + case GridViewSizeKind.Medium: + return 120; + case GridViewSizeKind.Large: + return 140; + case GridViewSizeKind.ExtraLarge: + return 160; + case GridViewSizeKind.Five: + return 180; + case GridViewSizeKind.Six: + return 200; + case GridViewSizeKind.Seven: + return 220; + case GridViewSizeKind.Eight: + return 240; + case GridViewSizeKind.Nine: + return 260; + case GridViewSizeKind.Ten: + return 280; + case GridViewSizeKind.Eleven: + return 300; + default: + return 100; + } + } + + /// + /// Gets the desired height for items in the List View + /// + /// + /// + public static int GetListViewRowHeight(ListViewSizeKind listViewSizeKind) + { + switch (listViewSizeKind) + { + case ListViewSizeKind.Compact: + return 24; + case ListViewSizeKind.Small: + return 32; + case ListViewSizeKind.Medium: + return 36; + case ListViewSizeKind.Large: + return 40; + case ListViewSizeKind.ExtraLarge: + return 44; + default: + return 32; + } + } + + /// + /// Gets the desired height for items in the Columns View + /// + /// + /// + public static int GetColumnsViewRowHeight(ColumnsViewSizeKind columnsViewSizeKind) + { + switch (columnsViewSizeKind) + { + case ColumnsViewSizeKind.Compact: + return 28; + case ColumnsViewSizeKind.Small: + return 36; + case ColumnsViewSizeKind.Medium: + return 40; + case ColumnsViewSizeKind.Large: + return 44; + case ColumnsViewSizeKind.ExtraLarge: + return 48; + default: + return 36; + } + } + + /// + /// 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 397d51b60c0d..61892b9cf7e7 100644 --- a/src/Files.App/Services/Settings/LayoutSettingsService.cs +++ b/src/Files.App/Services/Settings/LayoutSettingsService.cs @@ -11,34 +11,34 @@ public LayoutSettingsService(ISettingsSharingContext settingsSharingContext) RegisterSettingsContext(settingsSharingContext); } - public int ItemSizeDetailsView + public DetailsViewSizeKind DetailsViewSize { - get => (int)Get((long)Constants.IconHeights.DetailsView.Regular); - set => Set((long)value); + get => Get(DetailsViewSizeKind.Small); + set => Set(value); } - public int ItemSizeListView + public ListViewSizeKind ListViewSize { - get => (int)Get((long)Constants.IconHeights.ListView.Regular); - set => Set((long)value); + get => Get(ListViewSizeKind.Small); + set => Set(value); } - public int ItemSizeTilesView + public TilesViewSizeKind TilesViewSize { - get => (int)Get((long)Constants.IconHeights.TilesView.Regular); - set => Set((long)value); + get => Get(TilesViewSizeKind.Small); + set => Set(value); } - public int ItemSizeGridView + public GridViewSizeKind GridViewSize { - get => (int)Get((long)Constants.IconHeights.GridView.Medium); - set => Set((long)value); + get => Get(GridViewSizeKind.ExtraLarge); + set => Set(value); } - public int ItemSizeColumnsView + public ColumnsViewSizeKind ColumnsViewSize { - get => (int)Get((long)Constants.IconHeights.ColumnsView.Regular); - set => Set((long)value); + get => Get(ColumnsViewSizeKind.Small); + set => Set(value); } } } diff --git a/src/Files.App/UserControls/InnerNavigationToolbar.xaml b/src/Files.App/UserControls/InnerNavigationToolbar.xaml index a3770e2e39ca..23159176dc23 100644 --- a/src/Files.App/UserControls/InnerNavigationToolbar.xaml +++ b/src/Files.App/UserControls/InnerNavigationToolbar.xaml @@ -4,6 +4,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:contract8Present="http://schemas.microsoft.com/winfx/2006/xaml/presentation?IsApiContractPresent(Windows.Foundation.UniversalApiContract,8)" + xmlns:converters="using:Files.App.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:helpers="using:Files.App.Helpers" xmlns:local="using:Files.App.UserControls" @@ -24,6 +25,7 @@ + + Value="{x:Bind UserSettingsService.LayoutSettingsService.DetailsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='0-0,1-1,2-2,3-3,4-4'}" /> + Value="{x:Bind UserSettingsService.LayoutSettingsService.ListViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='0-0,1-1,2-2,3-3,4-4'}" /> + Value="{x:Bind UserSettingsService.LayoutSettingsService.GridViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='0-0,1-1,2-2,3-3,4-4,5-5,6-6,7-7,8-8,9-9,10-10,11-11'}" /> + Value="{x:Bind UserSettingsService.LayoutSettingsService.ColumnsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='0-0,1-1,2-2,3-3,4-4'}" /> diff --git a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml index 95cf10e6f813..bc9ea625b2e3 100644 --- a/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/ColumnLayoutPage.xaml @@ -125,25 +125,12 @@ - - - - @@ -231,7 +206,7 @@ - /// Item size for the Columns View + /// Row height in the Columns View /// - public int ItemSize + public int RowHeight { - get => UserSettingsService.LayoutSettingsService.ItemSizeColumnsView; + get => LayoutSizeKindHelper.GetColumnsViewRowHeight(UserSettingsService.LayoutSettingsService.ColumnsViewSize); set { - if (value != UserSettingsService.LayoutSettingsService.ItemSizeColumnsView) + if (value != LayoutSizeKindHelper.GetColumnsViewRowHeight(UserSettingsService.LayoutSettingsService.ColumnsViewSize)) { - NotifyPropertyChanged(nameof(ItemSize)); + NotifyPropertyChanged(nameof(RowHeight)); } } } @@ -176,9 +176,9 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang { // TODO keep scroll position when changing styles (see details view) - if (e.PropertyName == nameof(ILayoutSettingsService.ItemSizeColumnsView)) + if (e.PropertyName == nameof(ILayoutSettingsService.ColumnsViewSize)) { - ItemSize = UserSettingsService.LayoutSettingsService.ItemSizeColumnsView; + RowHeight = LayoutSizeKindHelper.GetColumnsViewRowHeight(UserSettingsService.LayoutSettingsService.ColumnsViewSize); SetItemContainerStyle(); } } @@ -235,16 +235,27 @@ public override void ResetItemOpacity() protected override bool CanGetItemFromElement(object element) => element is ListViewItem; + /// + /// Sets the item size and spacing + /// private void SetItemContainerStyle() { - if (ItemSize <= Constants.IconHeights.ColumnsView.Minimum) - FileList.ItemContainerStyle = MinimumItemContainerStyle; - else if (ItemSize <= Constants.IconHeights.ColumnsView.Small) - FileList.ItemContainerStyle = SmallItemContainerStyle; - else if (ItemSize <= Constants.IconHeights.ColumnsView.Regular) + if (UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Compact) + { + // Toggle style to force item size to update FileList.ItemContainerStyle = RegularItemContainerStyle; + + // Set correct style + FileList.ItemContainerStyle = CompactItemContainerStyle; + } else - FileList.ItemContainerStyle = MaximumItemContainerStyle; + { + // Toggle style to force item size to update + FileList.ItemContainerStyle = CompactItemContainerStyle; + + // Set correct style + FileList.ItemContainerStyle = RegularItemContainerStyle; + } } public override void Dispose() diff --git a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml index 68813afc2678..00ce0da28316 100644 --- a/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/DetailsLayoutPage.xaml @@ -900,7 +900,7 @@ - /// Item size for the Details View + /// Row height for items in the Details View /// - public int ItemSize + public int RowHeight { - get => UserSettingsService.LayoutSettingsService.ItemSizeDetailsView; + get => LayoutSizeKindHelper.GetDetailsViewRowHeight((DetailsViewSizeKind)UserSettingsService.LayoutSettingsService.DetailsViewSize); set { - if (value != UserSettingsService.LayoutSettingsService.ItemSizeDetailsView) - NotifyPropertyChanged(nameof(ItemSize)); + if (value != LayoutSizeKindHelper.GetDetailsViewRowHeight((DetailsViewSizeKind)UserSettingsService.LayoutSettingsService.DetailsViewSize)) + NotifyPropertyChanged(nameof(RowHeight)); } } @@ -84,7 +84,7 @@ public DetailsLayoutPage() : base() protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? sender, ListedItem e) { FileList.ScrollIntoView(e); - ContentScroller?.ChangeView(null, FileList.Items.IndexOf(e) * ItemSize, null, true); // Scroll to index * item height + ContentScroller?.ChangeView(null, FileList.Items.IndexOf(e) * RowHeight, null, true); // Scroll to index * item height } protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? sender, EventArgs e) @@ -92,7 +92,7 @@ protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? if (SelectedItems?.Any() ?? false) { FileList.ScrollIntoView(SelectedItems.Last()); - ContentScroller?.ChangeView(null, FileList.Items.IndexOf(SelectedItems.Last()) * ItemSize, null, false); + ContentScroller?.ChangeView(null, FileList.Items.IndexOf(SelectedItems.Last()) * RowHeight, null, false); (FileList.ContainerFromItem(SelectedItems.Last()) as ListViewItem)?.Focus(FocusState.Keyboard); } } @@ -195,12 +195,12 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (e.PropertyName == nameof(ILayoutSettingsService.ItemSizeDetailsView)) + if (e.PropertyName == nameof(ILayoutSettingsService.DetailsViewSize)) { // Get current scroll position var previousOffset = ContentScroller?.VerticalOffset; - ItemSize = UserSettingsService.LayoutSettingsService.ItemSizeDetailsView; + RowHeight = LayoutSizeKindHelper.GetDetailsViewRowHeight(UserSettingsService.LayoutSettingsService.DetailsViewSize); // Update the container style to match the item size SetItemContainerStyle(); @@ -215,7 +215,7 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang /// private void SetItemContainerStyle() { - if (ItemSize <= Constants.IconHeights.DetailsView.Small) + if (UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact) { // Toggle style to force item size to update FileList.ItemContainerStyle = RegularItemContainerStyle; diff --git a/src/Files.App/Views/Layouts/GridLayoutPage.xaml b/src/Files.App/Views/Layouts/GridLayoutPage.xaml index a1c71c614bd3..26368d9428a6 100644 --- a/src/Files.App/Views/Layouts/GridLayoutPage.xaml +++ b/src/Files.App/Views/Layouts/GridLayoutPage.xaml @@ -95,7 +95,7 @@ @@ -134,8 +133,8 @@ @@ -289,8 +288,8 @@ - /// Width of the GridItem in the selected layout. + /// Row height in the List View layout /// - public int GridViewItemWidth => - FolderSettings.LayoutMode == FolderLayoutModes.ListView || - FolderSettings.LayoutMode == FolderLayoutModes.TilesView - ? 260 - : UserSettingsService.LayoutSettingsService.ItemSizeGridView; - - - /// - /// Item size for the List View - /// - public int ItemSizeListView + public int RowHeightListView { - get => UserSettingsService.LayoutSettingsService.ItemSizeListView; + get => LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize); set { - if (value != UserSettingsService.LayoutSettingsService.ItemSizeListView) - { - NotifyPropertyChanged(nameof(ItemSizeListView)); - NotifyPropertyChanged(nameof(GridViewItemWidth)); - } + if (value != LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize)) + NotifyPropertyChanged(nameof(RowHeightListView)); } } /// - /// Item size for the Tiles View + /// Item width in the Tiles View layout /// - public int ItemSizeTilesView + public int ItemWidthTilesView { - get => UserSettingsService.LayoutSettingsService.ItemSizeTilesView; + get => LayoutSizeKindHelper.GetTilesViewItemWidth(UserSettingsService.LayoutSettingsService.TilesViewSize); set { - if (value != UserSettingsService.LayoutSettingsService.ItemSizeTilesView) - { - NotifyPropertyChanged(nameof(ItemSizeTilesView)); - NotifyPropertyChanged(nameof(GridViewItemWidth)); - } + if (value != LayoutSizeKindHelper.GetTilesViewItemWidth(UserSettingsService.LayoutSettingsService.TilesViewSize)) + NotifyPropertyChanged(nameof(ItemWidthTilesView)); } } /// - /// Item size for the Grid View + /// Item width in the Grid View layout /// - public int ItemSizeGridView + public int ItemWidthGridView { - get => UserSettingsService.LayoutSettingsService.ItemSizeGridView; + get => LayoutSizeKindHelper.GetGridViewItemWidth(UserSettingsService.LayoutSettingsService.GridViewSize); set { - if (value != UserSettingsService.LayoutSettingsService.ItemSizeGridView) - { - NotifyPropertyChanged(nameof(ItemSizeGridView)); - NotifyPropertyChanged(nameof(GridViewItemWidth)); - } + if (value != LayoutSizeKindHelper.GetGridViewItemWidth(UserSettingsService.LayoutSettingsService.GridViewSize)) + NotifyPropertyChanged(nameof(ItemWidthGridView)); } } @@ -183,21 +164,21 @@ private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChang { // TODO keep scroll position when changing styles (see details view) - if (e.PropertyName == nameof(ILayoutSettingsService.ItemSizeListView)) + if (e.PropertyName == nameof(ILayoutSettingsService.ListViewSize)) { - ItemSizeListView = UserSettingsService.LayoutSettingsService.ItemSizeListView; + RowHeightListView = LayoutSizeKindHelper.GetListViewRowHeight(UserSettingsService.LayoutSettingsService.ListViewSize); SetItemContainerStyle(); FolderSettings_IconHeightChanged(); } - if (e.PropertyName == nameof(ILayoutSettingsService.ItemSizeTilesView)) + if (e.PropertyName == nameof(ILayoutSettingsService.TilesViewSize)) { - ItemSizeTilesView = UserSettingsService.LayoutSettingsService.ItemSizeTilesView; + ItemWidthTilesView = LayoutSizeKindHelper.GetTilesViewItemWidth(UserSettingsService.LayoutSettingsService.TilesViewSize); SetItemContainerStyle(); FolderSettings_IconHeightChanged(); } - if (e.PropertyName == nameof(ILayoutSettingsService.ItemSizeGridView)) + if (e.PropertyName == nameof(ILayoutSettingsService.GridViewSize)) { - ItemSizeGridView = UserSettingsService.LayoutSettingsService.ItemSizeGridView; + ItemWidthGridView = LayoutSizeKindHelper.GetGridViewItemWidth(UserSettingsService.LayoutSettingsService.GridViewSize); SetItemContainerStyle(); FolderSettings_IconHeightChanged(); } @@ -257,7 +238,7 @@ private void SetItemTemplate() private void SetItemContainerStyle() { - if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && ItemSizeListView < Constants.IconHeights.ListView.Small) + if (FolderSettings?.LayoutMode == FolderLayoutModes.ListView && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact) { // Toggle style to force item size to update FileList.ItemContainerStyle = DefaultItemContainerStyle; diff --git a/src/Files.Core/Data/Enums/ColumnsViewSizeKind.cs b/src/Files.Core/Data/Enums/ColumnsViewSizeKind.cs new file mode 100644 index 000000000000..4e773822271b --- /dev/null +++ b/src/Files.Core/Data/Enums/ColumnsViewSizeKind.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Data.Enums +{ + public enum ColumnsViewSizeKind + { + Compact = 0, + Small = 1, + Medium = 2, + Large = 3, + ExtraLarge = 4, + } +} diff --git a/src/Files.Core/Data/Enums/DetailsViewSizeKind.cs b/src/Files.Core/Data/Enums/DetailsViewSizeKind.cs new file mode 100644 index 000000000000..6a11a492d757 --- /dev/null +++ b/src/Files.Core/Data/Enums/DetailsViewSizeKind.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Data.Enums +{ + public enum DetailsViewSizeKind + { + Compact = 0, + Small = 1, + Medium = 2, + Large = 3, + ExtraLarge = 4, + } +} diff --git a/src/Files.Core/Data/Enums/GridViewSizeKind.cs b/src/Files.Core/Data/Enums/GridViewSizeKind.cs new file mode 100644 index 000000000000..7e1cf480bc02 --- /dev/null +++ b/src/Files.Core/Data/Enums/GridViewSizeKind.cs @@ -0,0 +1,21 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Data.Enums +{ + public enum GridViewSizeKind + { + Compact = 0, + Small = 1, + Medium = 2, + Large = 3, + ExtraLarge = 4, + Five = 5, + Six = 6, + Seven = 7, + Eight = 8, + Nine = 9, + Ten = 10, + Eleven = 11, + } +} diff --git a/src/Files.Core/Data/Enums/ListViewSizeKind.cs b/src/Files.Core/Data/Enums/ListViewSizeKind.cs new file mode 100644 index 000000000000..08375c218f09 --- /dev/null +++ b/src/Files.Core/Data/Enums/ListViewSizeKind.cs @@ -0,0 +1,14 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Data.Enums +{ + public enum ListViewSizeKind + { + Compact = 0, + Small = 1, + Medium = 2, + Large = 3, + ExtraLarge = 4, + } +} diff --git a/src/Files.Core/Data/Enums/TilesViewSizeKind.cs b/src/Files.Core/Data/Enums/TilesViewSizeKind.cs new file mode 100644 index 000000000000..e7a45d4c1f12 --- /dev/null +++ b/src/Files.Core/Data/Enums/TilesViewSizeKind.cs @@ -0,0 +1,10 @@ +// Copyright (c) 2023 Files Community +// Licensed under the MIT License. See the LICENSE. + +namespace Files.Core.Data.Enums +{ + public enum TilesViewSizeKind + { + Small = 1, + } +} diff --git a/src/Files.Core/Services/Settings/ILayoutSettingsService.cs b/src/Files.Core/Services/Settings/ILayoutSettingsService.cs index 75577f2af671..0ab94a05cffc 100644 --- a/src/Files.Core/Services/Settings/ILayoutSettingsService.cs +++ b/src/Files.Core/Services/Settings/ILayoutSettingsService.cs @@ -1,6 +1,8 @@ // Copyright (c) 2023 Files Community // Licensed under the MIT License. See the LICENSE. +using Files.Core.Data.Enums; + namespace Files.Core.Services.Settings { public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyChanged @@ -8,26 +10,26 @@ public interface ILayoutSettingsService : IBaseSettingsService, INotifyPropertyC /// /// Item size in the Details View /// - int ItemSizeDetailsView { get; set; } + DetailsViewSizeKind DetailsViewSize { get; set; } /// /// Item size in the List View /// - int ItemSizeListView { get; set; } + ListViewSizeKind ListViewSize { get; set; } /// /// Item size in the Tiles View /// - int ItemSizeTilesView { get; set; } + TilesViewSizeKind TilesViewSize { get; set; } /// /// Item size in the Grid View /// - int ItemSizeGridView { get; set; } + GridViewSizeKind GridViewSize { get; set; } /// /// Item size in the Columns View /// - int ItemSizeColumnsView { get; set; } + ColumnsViewSizeKind ColumnsViewSize { get; set; } } }