Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Update layout size selection state #14845

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Files.App/Actions/Display/LayoutAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public HotKey MediaHotKey
ContentPageContext.PageType is not ContentPageTypes.Home &&
((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.Grid && UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Small) ||
(DisplayPageContext.LayoutType == LayoutTypes.Columns && UserSettingsService.LayoutSettingsService.ColumnsViewSize > ColumnsViewSizeKind.Compact));

public LayoutDecreaseSizeAction()
Expand Down Expand Up @@ -248,7 +248,7 @@ public Task ExecuteAsync()
case LayoutTypes.Tiles:
break;
case LayoutTypes.Grid:
if (UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Compact)
if (UserSettingsService.LayoutSettingsService.GridViewSize > GridViewSizeKind.Small)
UserSettingsService.LayoutSettingsService.GridViewSize -= 1;
break;
case LayoutTypes.Columns:
Expand Down Expand Up @@ -283,7 +283,7 @@ public HotKey MediaHotKey
ContentPageContext.PageType is not ContentPageTypes.Home &&
((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.Grid && UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.ExtraLarge) ||
(DisplayPageContext.LayoutType == LayoutTypes.Columns && UserSettingsService.LayoutSettingsService.ColumnsViewSize < ColumnsViewSizeKind.ExtraLarge));

public LayoutIncreaseSizeAction()
Expand Down Expand Up @@ -341,7 +341,7 @@ public Task ExecuteAsync()
case LayoutTypes.Tiles:
break;
case LayoutTypes.Grid:
if (UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.Eleven)
if (UserSettingsService.LayoutSettingsService.GridViewSize < GridViewSizeKind.ExtraLarge)
UserSettingsService.LayoutSettingsService.GridViewSize += 1;
break;
case LayoutTypes.Columns:
Expand Down
24 changes: 12 additions & 12 deletions src/Files.App/Helpers/Layout/LayoutSizeKindHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@ public static int GetGridViewItemWidth(GridViewSizeKind gridViewSizeKind)
{
switch (gridViewSizeKind)
{
case GridViewSizeKind.Compact:
return 80;
case GridViewSizeKind.Small:
return 100;
return 80;
case GridViewSizeKind.Medium:
return 100;
case GridViewSizeKind.Three:
return 120;
case GridViewSizeKind.Large:
case GridViewSizeKind.Four:
return 140;
case GridViewSizeKind.ExtraLarge:
return 160;
case GridViewSizeKind.Five:
return 180;
return 160;
case GridViewSizeKind.Six:
return 200;
return 180;
case GridViewSizeKind.Seven:
return 200;
case GridViewSizeKind.Large:
return 220;
case GridViewSizeKind.Eight:
return 240;
case GridViewSizeKind.Nine:
return 260;
return 240;
case GridViewSizeKind.Ten:
return 280;
return 260;
case GridViewSizeKind.Eleven:
return 280;
case GridViewSizeKind.ExtraLarge:
return 300;
default:
return 100;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Services/Settings/LayoutSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public TilesViewSizeKind TilesViewSize

public GridViewSizeKind GridViewSize
{
get => Get(GridViewSizeKind.ExtraLarge);
get => Get(GridViewSizeKind.Large);
set => Set(value);
}

Expand Down
43 changes: 31 additions & 12 deletions src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,12 @@
x:Name="DetailsViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="4"
Minimum="0"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
TickFrequency="1"
TickPlacement="BottomRight"
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.DetailsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />

<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand All @@ -803,30 +803,35 @@
Grid.Column="0"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeCompact, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesCompact}" />

<local:OpacityIcon
Grid.Column="2"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeSmall, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesSmall}" />

<local:OpacityIcon
Grid.Column="4"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeMedium, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesMedium}" />

<local:OpacityIcon
Grid.Column="6"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesLarge}" />

<local:OpacityIcon
Grid.Column="8"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeExtraLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesExtraLarge}" />
</Grid>
</StackPanel>
Expand All @@ -840,12 +845,12 @@
x:Name="ListViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="4"
Minimum="0"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
TickFrequency="1"
TickPlacement="BottomRight"
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.ListViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />

<!-- List -->
<Grid HorizontalAlignment="Stretch">
Expand All @@ -865,30 +870,35 @@
Grid.Column="0"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeCompact, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesCompact}" />

<local:OpacityIcon
Grid.Column="2"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeSmall, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesSmall}" />

<local:OpacityIcon
Grid.Column="4"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeMedium, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesMedium}" />

<local:OpacityIcon
Grid.Column="6"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesLarge}" />

<local:OpacityIcon
Grid.Column="8"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeExtraLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesExtraLarge}" />
</Grid>
</StackPanel>
Expand Down Expand Up @@ -918,12 +928,12 @@
x:Name="GridViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="11"
Minimum="0"
Maximum="12"
Minimum="1"
SnapsTo="Ticks"
TickFrequency="1"
TickPlacement="BottomRight"
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.GridViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5,6-6,7-7,8-8,9-9,10-10,11-11,12-12'}" />

<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -956,24 +966,28 @@
Grid.Column="0"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeSmall, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesSmall}" />

<local:OpacityIcon
Grid.Column="2"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeMedium, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesMedium}" />

<local:OpacityIcon
Grid.Column="14"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesLarge}" />

<local:OpacityIcon
Grid.Column="22"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeExtraLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesExtraLarge}" />
</Grid>
</StackPanel>
Expand All @@ -987,12 +1001,12 @@
x:Name="ColumnViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="4"
Minimum="0"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.ColumnsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='0-0,1-1,2-2,3-3,4-4'}" />
Value="{x:Bind UserSettingsService.LayoutSettingsService.ColumnsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />

<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
Expand All @@ -1011,30 +1025,35 @@
Grid.Column="0"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeCompact, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesCompact}" />

<local:OpacityIcon
Grid.Column="2"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeSmall, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesSmall}" />

<local:OpacityIcon
Grid.Column="4"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeMedium, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesMedium}" />

<local:OpacityIcon
Grid.Column="6"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesLarge}" />

<local:OpacityIcon
Grid.Column="8"
Width="28"
Height="28"
IsSelected="{x:Bind ViewModel.IsLayoutSizeExtraLarge, Mode=OneWay}"
Style="{StaticResource ColorIconLayoutSizesExtraLarge}" />
</Grid>
</StackPanel>
Expand Down
44 changes: 44 additions & 0 deletions src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,16 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh
RefreshWidgetsRequested?.Invoke(this, EventArgs.Empty);
OnPropertyChanged(e.SettingName);
break;
case nameof(UserSettingsService.LayoutSettingsService.DetailsViewSize):
case nameof(UserSettingsService.LayoutSettingsService.ListViewSize):
case nameof(UserSettingsService.LayoutSettingsService.ColumnsViewSize):
case nameof(UserSettingsService.LayoutSettingsService.GridViewSize):
OnPropertyChanged(nameof(IsLayoutSizeCompact));
OnPropertyChanged(nameof(IsLayoutSizeSmall));
OnPropertyChanged(nameof(IsLayoutSizeMedium));
OnPropertyChanged(nameof(IsLayoutSizeLarge));
OnPropertyChanged(nameof(IsLayoutSizeExtraLarge));
break;
}
}

Expand Down Expand Up @@ -963,6 +973,11 @@ private void FolderSettings_PropertyChanged(object? sender, PropertyChangedEvent
OnPropertyChanged(nameof(IsColumnLayout));
OnPropertyChanged(nameof(IsGridLayout));
OnPropertyChanged(nameof(IsDetailsLayout));
OnPropertyChanged(nameof(IsLayoutSizeCompact));
OnPropertyChanged(nameof(IsLayoutSizeSmall));
OnPropertyChanged(nameof(IsLayoutSizeMedium));
OnPropertyChanged(nameof(IsLayoutSizeLarge));
OnPropertyChanged(nameof(IsLayoutSizeExtraLarge));
break;
}
}
Expand Down Expand Up @@ -1017,6 +1032,35 @@ public List<ListedItem> SelectedItems
public bool IsDetailsLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.DetailsView;
public bool IsListLayout => instanceViewModel.FolderSettings.LayoutMode is FolderLayoutModes.ListView;

public bool IsLayoutSizeCompact =>
(IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Compact) ||
(IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Compact) ||
(IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.Compact);

public bool IsLayoutSizeSmall =>
(IsDetailsLayout && UserSettingsService.LayoutSettingsService.DetailsViewSize == DetailsViewSizeKind.Small) ||
(IsListLayout && UserSettingsService.LayoutSettingsService.ListViewSize == ListViewSizeKind.Small) ||
(IsColumnLayout && UserSettingsService.LayoutSettingsService.ColumnsViewSize == ColumnsViewSizeKind.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) ||
(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) ||
(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) ||
(IsGridLayout && UserSettingsService.LayoutSettingsService.GridViewSize == GridViewSizeKind.ExtraLarge);

public string ExtractToText
=> IsSelectionArchivesOnly ? SelectedItems.Count > 1 ? string.Format("ExtractToChildFolder".GetLocalizedResource(), $"*{Path.DirectorySeparatorChar}") : string.Format("ExtractToChildFolder".GetLocalizedResource() + "\\", Path.GetFileNameWithoutExtension(selectedItems.First().Name)) : "ExtractToChildFolder".GetLocalizedResource();

Expand Down
10 changes: 5 additions & 5 deletions src/Files.Core/Data/Enums/ColumnsViewSizeKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Files.Core.Data.Enums
{
public enum ColumnsViewSizeKind
{
Compact = 0,
Small = 1,
Medium = 2,
Large = 3,
ExtraLarge = 4,
Compact = 1,
Copy link
Member

@0x5bfa 0x5bfa Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the first value has been changed?
Is that just your preference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either

Small = 2,
Medium = 3,
Large = 4,
ExtraLarge = 5,
}
}
10 changes: 5 additions & 5 deletions src/Files.Core/Data/Enums/DetailsViewSizeKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace Files.Core.Data.Enums
{
public enum DetailsViewSizeKind
{
Compact = 0,
Small = 1,
Medium = 2,
Large = 3,
ExtraLarge = 4,
Compact = 1,
Small = 2,
Medium = 3,
Large = 4,
ExtraLarge = 5,
}
}
Loading
Loading