Skip to content

Commit 1781b7f

Browse files
yaira2hishitetsu
andauthored
Feature: Improved UX for the "Create new item" dialog (#16317)
Co-authored-by: hishitetsu <[email protected]>
1 parent e7f8c33 commit 1781b7f

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static DynamicDialog GetFor_ShortcutNotFound(string targetPath)
5858
return dialog;
5959
}
6060

61-
public static DynamicDialog GetFor_RenameDialog()
61+
public static DynamicDialog GetFor_CreateItemDialog(string itemType)
6262
{
6363
DynamicDialog? dialog = null;
6464
TextBox inputText = new()
@@ -70,7 +70,7 @@ public static DynamicDialog GetFor_RenameDialog()
7070
{
7171
Title = "InvalidFilename/Text".GetLocalizedResource(),
7272
PreferredPlacement = TeachingTipPlacementMode.Bottom,
73-
DataContext = new RenameDialogViewModel(),
73+
DataContext = new CreateItemDialogViewModel(),
7474
};
7575

7676
warning.SetBinding(TeachingTip.TargetProperty, new Binding()
@@ -88,7 +88,7 @@ public static DynamicDialog GetFor_RenameDialog()
8888
inputText.TextChanged += (textBox, args) =>
8989
{
9090
var isInputValid = FilesystemHelpers.IsValidForFilename(inputText.Text);
91-
((RenameDialogViewModel)warning.DataContext).IsNameInvalid = !string.IsNullOrEmpty(inputText.Text) && !isInputValid;
91+
((CreateItemDialogViewModel)warning.DataContext).IsNameInvalid = !string.IsNullOrEmpty(inputText.Text) && !isInputValid;
9292
dialog!.ViewModel.DynamicButtonsEnabled = isInputValid
9393
? DynamicDialogButtons.Primary | DynamicDialogButtons.Cancel
9494
: DynamicDialogButtons.Cancel;
@@ -104,7 +104,7 @@ public static DynamicDialog GetFor_RenameDialog()
104104

105105
dialog = new DynamicDialog(new DynamicDialogViewModel()
106106
{
107-
TitleText = "EnterAnItemName".GetLocalizedResource(),
107+
TitleText = string.Format("CreateNewItemTitle".GetLocalizedResource(), itemType),
108108
SubtitleText = null,
109109
DisplayControl = new Grid()
110110
{
@@ -118,7 +118,7 @@ public static DynamicDialog GetFor_RenameDialog()
118118
{
119119
vm.HideDialog(); // Rename successful
120120
},
121-
PrimaryButtonText = "RenameDialog/PrimaryButtonText".GetLocalizedResource(),
121+
PrimaryButtonText = "Create".GetLocalizedResource(),
122122
CloseButtonText = "Cancel".GetLocalizedResource(),
123123
DynamicButtonsEnabled = DynamicDialogButtons.Cancel,
124124
DynamicButtons = DynamicDialogButtons.Primary | DynamicDialogButtons.Cancel

src/Files.App/Helpers/UI/UIFilesystemHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static async Task CreateFileFromDialogResultTypeAsync(AddItemDialogItemTy
8787
string? userInput = null;
8888
if (itemType != AddItemDialogItemType.File || itemInfo?.Command is null)
8989
{
90-
DynamicDialog dialog = DynamicDialogFactory.GetFor_RenameDialog();
90+
DynamicDialog dialog = DynamicDialogFactory.GetFor_CreateItemDialog(itemType.ToString().GetLocalizedResource());
9191
await dialog.TryShowAsync(); // Show rename dialog
9292

9393
if (dialog.DynamicResult != DynamicDialogResult.Primary)

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@
291291
<data name="EnterAnItemName" xml:space="preserve">
292292
<value>Enter an item name</value>
293293
</data>
294-
<data name="RenameDialog.PrimaryButtonText" xml:space="preserve">
295-
<value>Set name</value>
294+
<data name="CreateNewItemTitle" xml:space="preserve">
295+
<value>Create new {0}</value>
296296
</data>
297297
<data name="LightTheme" xml:space="preserve">
298298
<value>Light</value>

src/Files.App/ViewModels/Dialogs/RenameDialogViewModel.cs renamed to src/Files.App/ViewModels/Dialogs/CreateItemDialogViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Files.App.ViewModels.Dialogs
55
{
6-
class RenameDialogViewModel : ObservableObject
6+
class CreateItemDialogViewModel : ObservableObject
77
{
88
private bool isNameInvalid;
99
public bool IsNameInvalid

0 commit comments

Comments
 (0)