-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
yaira2
merged 16 commits into
files-community:main
from
0x5bfa:5bfa/Add-LayoutFlyoutSliderTooltip
Feb 27, 2024
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8820632
Initial commit
0x5bfa 1f21af3
Added comments & description
0x5bfa b16f9d4
Reflect
0x5bfa bc9d120
Commentted out
0x5bfa 51eb33a
Added strings
yaira2 46f44c1
Update Resources.resw
yaira2 f7d5cfc
Revert
0x5bfa 7129759
Merge branch '5bfa/Add-LayoutFlyoutSliderTooltip' of https://github.c…
0x5bfa b675aa0
Added template for the factory
0x5bfa 7af12ff
Removed unneeded property set
0x5bfa 87192ed
Add space
yaira2 3794f50
Populate
0x5bfa 36e368f
Merge branch '5bfa/Add-LayoutFlyoutSliderTooltip' of https://github.c…
0x5bfa fa3b31d
Update
0x5bfa 754afd0
Rename
0x5bfa 0520b9b
Fix comments
yaira2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 EnumToHumanizedConverter : 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 | ||
{ | ||
"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(); | ||
} | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
src/Files.App/Data/Factories/LocalizedEnumDescriptionFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
namespace Files.App.Data.Factories | ||
{ | ||
/// <summary> | ||
/// Generates localization description for an enum value. | ||
/// </summary> | ||
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, "Medium+".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Four, "Medium++".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Five, "Medium+++".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Six, "Medium++++".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Seven, "Medium+++++".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Large, "Large".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Nine, "Large+".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Ten, "Large++".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.Eleven, "Large+++".GetLocalizedResource()); | ||
GridViewSizeKinds.Add(GridViewSizeKind.ExtraLarge, "ExtraLarge".GetLocalizedResource()); | ||
} | ||
|
||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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