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: Increased the text box height when renaming items in the tiles layout #13114

Merged
merged 14 commits into from
Sep 21, 2023
6 changes: 6 additions & 0 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@
<DataTemplate x:Name="TilesBrowserTemplate" x:DataType="filesystem:ListedItem">
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
<UserControl>
<Grid
x:Name="MainGrid"
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
MaxHeight="68"
Padding="0"
HorizontalAlignment="Left"
Expand Down Expand Up @@ -402,12 +403,16 @@
<TextBox
x:Name="TileViewTextBoxItemName"
Grid.Row="0"
MaxHeight="60"
HorizontalAlignment="Left"
BeforeTextChanging="ItemNameTextBox_BeforeTextChanging"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Text="{x:Bind Name, Mode=OneWay}"
TextWrapping="Wrap"
Visibility="Collapsed" />

<TextBlock
x:Name="ItemFileFormat"
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
Grid.Row="1"
HorizontalAlignment="Left"
FontSize="12px"
Expand All @@ -417,6 +422,7 @@
TextWrapping="NoWrap" />

<TextBlock
x:Name="ItemSize"
Grid.Row="2"
HorizontalAlignment="Left"
FontSize="12px"
Expand Down
42 changes: 35 additions & 7 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Vanara.Extensions.Reflection;
using Windows.Storage;
using Windows.System;
using Windows.UI.Core;
Expand Down Expand Up @@ -183,25 +184,41 @@ override public void StartRenameItem()
{
Popup popup = gridViewItem.FindDescendant("EditPopup") as Popup;
TextBlock textBlock = gridViewItem.FindDescendant("ItemName") as TextBlock;
Grid gridMain = gridViewItem.FindDescendant("GridViewBrowserListedItem") as Grid;

textBox = popup.Child as TextBox;
textBox.Text = textBlock.Text;
textBlock.Opacity = 0;
popup.IsOpen = true;
OldItemName = textBlock.Text;
gridMain.RowDefinitions[0].Height = new GridLength(0);
}
else
{
TextBlock textBlock = gridViewItem.FindDescendant("ItemName") as TextBlock;
TextBlock textBlockName = gridViewItem.FindDescendant("ItemName") as TextBlock;
yaira2 marked this conversation as resolved.
Show resolved Hide resolved
TextBlock textBlockFormat = gridViewItem.FindDescendant("ItemFileFormat") as TextBlock;
TextBlock textBlockSize = gridViewItem.FindDescendant("ItemSize") as TextBlock;
textBox = gridViewItem.FindDescendant("TileViewTextBoxItemName") as TextBox;
textBox.Text = textBlock.Text;
OldItemName = textBlock.Text;
textBlock.Visibility = Visibility.Collapsed;
Grid gridMain = gridViewItem.FindDescendant("MainGrid") as Grid;

textBox.Text = textBlockName.Text;
OldItemName = textBlockName.Text;

textBlockName.Visibility = Visibility.Collapsed;
textBlockFormat.Visibility = Visibility.Collapsed;
textBlockSize.Visibility = Visibility.Collapsed;
textBox.Visibility = Visibility.Visible;
gridMain.ColumnDefinitions[0].Width = new GridLength(0);
gridMain.ColumnDefinitions[1].Width = new GridLength(0);

if (textBox.FindParent<Grid>() is null)
{
textBlock.Visibility = Visibility.Visible;
textBlockName.Visibility = Visibility.Visible;
textBlockFormat.Visibility = Visibility.Visible;
textBlockSize.Visibility = Visibility.Visible;
textBox.Visibility = Visibility.Collapsed;
gridMain.ColumnDefinitions[0].Width = GridLength.Auto;
gridMain.ColumnDefinitions[1].Width = new GridLength(64);
return;
}
}
Expand Down Expand Up @@ -242,14 +259,25 @@ protected override void EndRename(TextBox textBox)
{
Popup? popup = gridViewItem.FindDescendant("EditPopup") as Popup;
TextBlock? textBlock = gridViewItem.FindDescendant("ItemName") as TextBlock;
Grid? gridMain = gridViewItem.FindDescendant("GridViewBrowserListedItem") as Grid;

popup!.IsOpen = false;
textBlock!.Opacity = (textBlock.DataContext as ListedItem)!.Opacity;
gridMain.RowDefinitions[0].Height = GridLength.Auto;
}
else if (FolderSettings.LayoutMode == FolderLayoutModes.TilesView)
{
TextBlock? textBlock = gridViewItem.FindDescendant("ItemName") as TextBlock;
TextBlock? textBlockName = gridViewItem.FindDescendant("ItemName") as TextBlock;
TextBlock? textBlockFormat = gridViewItem.FindDescendant("ItemFileFormat") as TextBlock;
TextBlock? textBlockSize = gridViewItem.FindDescendant("ItemSize") as TextBlock;
Grid? gridMain = gridViewItem.FindDescendant("MainGrid") as Grid;

textBox.Visibility = Visibility.Collapsed;
textBlock!.Visibility = Visibility.Visible;
textBlockName!.Visibility = Visibility.Visible;
textBlockFormat!.Visibility = Visibility.Visible;
textBlockSize!.Visibility = Visibility.Visible;
gridMain.ColumnDefinitions[0].Width = GridLength.Auto;
gridMain.ColumnDefinitions[1].Width = new GridLength(64);
}

textBox!.LostFocus -= RenameTextBox_LostFocus;
Expand Down