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: Added tooltips to Layout Picker #14852

Merged
merged 16 commits into from
Feb 27, 2024
37 changes: 37 additions & 0 deletions src/Files.App/Converters/EnumValueToEnumNameConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml.Data;

namespace Files.App.Converters
{
internal sealed class EnumValueToEnumNameConverter : IValueConverter
{
public string EnumTypeName { get; set; } = string.Empty;

public object Convert(object value, Type targetType, object parameter, string language)
{
var stringValue = value.ToString() ?? string.Empty;

return EnumTypeName switch
0x5bfa marked this conversation as resolved.
Show resolved Hide resolved
{
"DetailsViewSizeKind"
=> LocalizedEnumDescriptionFactory.Get(Enum.Parse<DetailsViewSizeKind>(stringValue)),
"ListViewSizeKind"
=> LocalizedEnumDescriptionFactory.Get(Enum.Parse<ListViewSizeKind>(stringValue)),
"TilesViewSizeKind"
=> LocalizedEnumDescriptionFactory.Get(Enum.Parse<TilesViewSizeKind>(stringValue)),
"GridViewSizeKind"
=> LocalizedEnumDescriptionFactory.Get(Enum.Parse<GridViewSizeKind>(stringValue)),
"ColumnsViewSizeKind"
=> LocalizedEnumDescriptionFactory.Get(Enum.Parse<ColumnsViewSizeKind>(stringValue)),
_ => string.Empty,
};
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
92 changes: 92 additions & 0 deletions src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Data.Factories
{
internal static class LocalizedEnumDescriptionFactory
{
private static Dictionary<DetailsViewSizeKind, string> DetailsViewSizeKinds { get; } = [];
private static Dictionary<ListViewSizeKind, string> ListViewSizeKinds { get; } = [];
private static Dictionary<TilesViewSizeKind, string> TilesViewSizeKinds { get; } = [];
private static Dictionary<GridViewSizeKind, string> GridViewSizeKinds { get; } = [];
private static Dictionary<ColumnsViewSizeKind, string> ColumnsViewSizeKinds { get; } = [];

public static string Get(DetailsViewSizeKind value)
{
if (DetailsViewSizeKinds.Count == 0)
{
DetailsViewSizeKinds.Add(DetailsViewSizeKind.Compact, "Compact".GetLocalizedResource());
DetailsViewSizeKinds.Add(DetailsViewSizeKind.Small, "Small".GetLocalizedResource());
DetailsViewSizeKinds.Add(DetailsViewSizeKind.Medium, "Medium".GetLocalizedResource());
DetailsViewSizeKinds.Add(DetailsViewSizeKind.Large, "Large".GetLocalizedResource());
DetailsViewSizeKinds.Add(DetailsViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource());
}

var stringValue = DetailsViewSizeKinds.GetValueOrDefault(value)!;
return stringValue;
}

public static string Get(ListViewSizeKind value)
{
if (ListViewSizeKinds.Count == 0)
{
ListViewSizeKinds.Add(ListViewSizeKind.Compact, "Compact".GetLocalizedResource());
ListViewSizeKinds.Add(ListViewSizeKind.Small, "Small".GetLocalizedResource());
ListViewSizeKinds.Add(ListViewSizeKind.Medium, "Medium".GetLocalizedResource());
ListViewSizeKinds.Add(ListViewSizeKind.Large, "Large".GetLocalizedResource());
ListViewSizeKinds.Add(ListViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource());
}

var stringValue = ListViewSizeKinds.GetValueOrDefault(value)!;
return stringValue;
}

public static string Get(TilesViewSizeKind value)
{
if (TilesViewSizeKinds.Count == 0)
{
TilesViewSizeKinds.Add(TilesViewSizeKind.Small, "Small".GetLocalizedResource());
}

var stringValue = TilesViewSizeKinds.GetValueOrDefault(value)!;
return stringValue;
}

public static string Get(GridViewSizeKind value)
{
if (GridViewSizeKinds.Count == 0)
{
GridViewSizeKinds.Add(GridViewSizeKind.Small, "Small".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Medium, "Medium".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Three, "Three".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Four, "Four".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Five, "Five".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Six, "Six".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Seven, "Seven".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Large, "Large".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Nine, "Nine".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Ten, "Ten".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.Eleven, "Eleven".GetLocalizedResource());
GridViewSizeKinds.Add(GridViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource());
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
}

var stringValue = GridViewSizeKinds.GetValueOrDefault(value)!;
return stringValue;
}

public static string Get(ColumnsViewSizeKind value)
{
if (ColumnsViewSizeKinds.Count == 0)
{
ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Compact, "Compact".GetLocalizedResource());
ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Small, "Small".GetLocalizedResource());
ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Medium, "Medium".GetLocalizedResource());
ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.Large, "Large".GetLocalizedResource());
ColumnsViewSizeKinds.Add(ColumnsViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource());
}

var stringValue = ColumnsViewSizeKinds.GetValueOrDefault(value)!;
return stringValue;
}
}
}
52 changes: 52 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3673,4 +3673,56 @@
<data name="TilesViewSizeInfo" xml:space="preserve">
<value>Additional sizes are not yet available for the Tiles View.</value>
</data>
<data name="Compact" xml:space="preserve">
<value>Compact</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Small" xml:space="preserve">
<value>Small</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Medium" xml:space="preserve">
<value>Medium</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Medium+" xml:space="preserve">
<value>Medium +</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Medium++" xml:space="preserve">
<value>Medium ++</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Medium+++" xml:space="preserve">
<value>Medium +++</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Medium++++" xml:space="preserve">
<value>Medium ++++</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Medium+++++" xml:space="preserve">
<value>Medium +++++</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Large" xml:space="preserve">
<value>Large</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Large+" xml:space="preserve">
<value>Large +</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Large++" xml:space="preserve">
<value>Large ++</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="Large+++" xml:space="preserve">
<value>Large +++</value>
<comment>Used to describe layout sizes</comment>
</data>
<data name="ExtraLarge" xml:space="preserve">
<value>Extra large</value>
<comment>Used to describe layout sizes</comment>
</data>
</root>
14 changes: 10 additions & 4 deletions src/Files.App/UserControls/InnerNavigationToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<SolidColorBrush x:Key="CommandBarBorderBrushOpen" Color="Transparent" />

<converters:GenericEnumConverter x:Key="GenericEnumConverter" />
<converters:EnumValueToEnumNameConverter x:Key="EnumDetailsViewSizeKindToEnumNameConverter" EnumTypeName="DetailsViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumListViewSizeKindToEnumNameConverter" EnumTypeName="ListViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumTilesViewSizeKindToEnumNameConverter" EnumTypeName="TilesViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumGridViewSizeKindToEnumNameConverter" EnumTypeName="GridViewSizeKind" />
<converters:EnumValueToEnumNameConverter x:Key="EnumColumnsViewSizeKindToEnumNameConverter" EnumTypeName="ColumnsViewSizeKind" />
<wctconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
<wctconverters:BoolToVisibilityConverter
x:Key="NegatedBoolToVisibilityConverter"
Expand Down Expand Up @@ -770,6 +775,7 @@
<!-- Sizes -->
<TextBlock FontWeight="Medium" Text="{helpers:ResourceString Name=Size}" />
<Grid>

<!-- Details -->
<StackPanel
x:Name="DetailsView"
Expand All @@ -778,10 +784,10 @@
<Slider
x:Name="DetailsViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumDetailsViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.DetailsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />
Expand Down Expand Up @@ -844,10 +850,10 @@
<Slider
x:Name="ListViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumListViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.ListViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />
Expand Down Expand Up @@ -927,10 +933,10 @@
<Slider
x:Name="GridViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="12"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumGridViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
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'}" />
Expand Down Expand Up @@ -1000,10 +1006,10 @@
<Slider
x:Name="ColumnViewSlider"
Padding="4,0,4,0"
IsThumbToolTipEnabled="False"
Maximum="5"
Minimum="1"
SnapsTo="Ticks"
ThumbToolTipValueConverter="{StaticResource EnumColumnsViewSizeKindToEnumNameConverter}"
TickFrequency="1"
TickPlacement="BottomRight"
Value="{x:Bind UserSettingsService.LayoutSettingsService.ColumnsViewSize, Mode=TwoWay, Converter={StaticResource GenericEnumConverter}, ConverterParameter='1-1,2-2,3-3,4-4,5-5'}" />
Expand Down
22 changes: 22 additions & 0 deletions src/Files.Core/Data/Enums/ColumnsViewSizeKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@

namespace Files.Core.Data.Enums
{
/// <summary>
/// Defines constant that specifies the icon/height size in Columns layout.
/// </summary>
public enum ColumnsViewSizeKind
{
/// <summary>
/// The icon/heigh is compact.
/// </summary>
Compact = 1,

/// <summary>
/// The icon/heigh is small.
/// </summary>
Small = 2,

/// <summary>
/// The icon/heigh is medium.
/// </summary>
Medium = 3,

/// <summary>
/// The icon/heigh is large.
/// </summary>
Large = 4,

/// <summary>
/// The icon/heigh is extra large.
/// </summary>
ExtraLarge = 5,
}
}
22 changes: 22 additions & 0 deletions src/Files.Core/Data/Enums/DetailsViewSizeKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@

namespace Files.Core.Data.Enums
{
/// <summary>
/// Defines constant that specifies the icon/height size in Details layout.
/// </summary>
public enum DetailsViewSizeKind
{
/// <summary>
/// The icon/heigh is compact.
/// </summary>
Compact = 1,

/// <summary>
/// The icon/heigh is small.
/// </summary>
Small = 2,

/// <summary>
/// The icon/heigh is medium.
/// </summary>
Medium = 3,

/// <summary>
/// The icon/heigh is large.
/// </summary>
Large = 4,

/// <summary>
/// The icon/heigh is extra large.
/// </summary>
ExtraLarge = 5,
}
}
50 changes: 50 additions & 0 deletions src/Files.Core/Data/Enums/GridViewSizeKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,69 @@

namespace Files.Core.Data.Enums
{
/// <summary>
/// Defines constant that specifies the icon/height size in Grid layout.
Copy link
Member

Choose a reason for hiding this comment

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

This isn't specific to the icon height

Copy link
Member

Choose a reason for hiding this comment

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

I updated the comments accordingly

/// </summary>
public enum GridViewSizeKind
{
/// <summary>
/// The icon/heigh is small.
/// </summary>
Small = 1,

/// <summary>
/// The icon/heigh is medium.
/// </summary>
Medium = 2,

/// <summary>
/// The icon/heigh is medium+.
/// </summary>
Three = 3,

/// <summary>
/// The icon/heigh is medium++.
/// </summary>
Four = 4,

/// <summary>
/// The icon/heigh is medium+++.
/// </summary>
Five = 5,

/// <summary>
/// The icon/heigh is medium++++.
/// </summary>
Six = 6,

/// <summary>
/// The icon/heigh is medium+++++.
/// </summary>
Seven = 7,

/// <summary>
/// The icon/heigh is large.
/// </summary>
Large = 8,

/// <summary>
/// The icon/heigh is large+.
/// </summary>
Nine = 9,

/// <summary>
/// The icon/heigh is large++.
/// </summary>
Ten = 10,

/// <summary>
/// The icon/heigh is large+++.
/// </summary>
Eleven = 11,

/// <summary>
/// The icon/heigh is extra large.
/// </summary>
ExtraLarge = 12,
}
}
Loading
Loading