Skip to content

Feature: Switched to StackPanel in the Details Layout template #10936

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

Merged
merged 3 commits into from
Jan 8, 2023
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
46 changes: 13 additions & 33 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -532,26 +532,14 @@
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate x:DataType="local2:ListedItem">
<Grid
<StackPanel
HorizontalAlignment="Stretch"
AutomationProperties.Name="{x:Bind Name, Mode=OneWay}"
IsRightTapEnabled="True"
Loaded="Grid_Loaded"
Loaded="StackPanel_Loaded"
Orientation="Horizontal"
ToolTipService.ToolTip="{x:Bind ItemTooltipText, Mode=OneWay}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ColumnsViewModel.IconColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.NameColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.TagColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.OriginalPathColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.DateDeletedColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.DateModifiedColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.DateCreatedColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.ItemTypeColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.SizeColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
<ColumnDefinition Width="{Binding ColumnsViewModel.StatusColumn.LengthIncludingGridSplitter, ElementName=PageRoot, Mode=OneWay}" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="24"
Height="Auto"
HorizontalAlignment="Center"
Expand Down Expand Up @@ -619,8 +607,7 @@
</Grid>

<Grid
Grid.Column="1"
MinWidth="{Binding ColumnsViewModel.NameColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Width="{Binding ColumnsViewModel.NameColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Expand Down Expand Up @@ -649,7 +636,6 @@

<Grid
x:Name="ItemTagGrid"
Grid.Column="2"
Width="{Binding ColumnsViewModel.TagColumn.Length.Value, ElementName=PageRoot, Mode=OneWay}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Expand All @@ -666,6 +652,7 @@
ToolTipService.ToolTip="{x:Bind FileTagsUI[0].TagName, Mode=OneWay}"
Visibility="{x:Bind FileTagsUI, Converter={StaticResource EmptyObjectToObjectConverter}, Mode=OneWay}">
<TextBlock
x:Name="ItemTag"
FontSize="12"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind FileTagsUI[0].TagName, Mode=OneWay}"
Expand All @@ -675,8 +662,7 @@
</Grid>

<TextBlock
x:Name="ItemOriginalPathGrid"
Grid.Column="3"
x:Name="ItemOriginalPath"
Width="{Binding ColumnsViewModel.OriginalPathColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -686,8 +672,7 @@
Text="{x:Bind AsRecycleBinItem.ItemOriginalPath, Mode=OneWay}" />

<TextBlock
x:Name="ItemDateDeletedGrid"
Grid.Column="4"
x:Name="ItemDateDeleted"
Width="{Binding ColumnsViewModel.DateDeletedColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -697,8 +682,7 @@
Text="{x:Bind AsRecycleBinItem.ItemDateDeleted, Mode=OneWay}" />

<TextBlock
x:Name="ItemDateModifiedGrid"
Grid.Column="5"
x:Name="ItemDateModified"
Width="{Binding ColumnsViewModel.DateModifiedColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -708,8 +692,7 @@
Visibility="{Binding ColumnsViewModel.DateModifiedColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />

<TextBlock
x:Name="ItemDateCreatedGrid"
Grid.Column="6"
x:Name="ItemDateCreated"
Width="{Binding ColumnsViewModel.DateCreatedColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -719,8 +702,7 @@
Visibility="{Binding ColumnsViewModel.DateCreatedColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />

<TextBlock
x:Name="ItemTypeGrid"
Grid.Column="7"
x:Name="ItemType"
Width="{Binding ColumnsViewModel.ItemTypeColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -730,8 +712,7 @@
Visibility="{Binding ColumnsViewModel.ItemTypeColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />

<TextBlock
x:Name="ItemSizeGrid"
Grid.Column="8"
x:Name="ItemSize"
Width="{Binding ColumnsViewModel.SizeColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Padding="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -741,8 +722,7 @@
Visibility="{Binding ColumnsViewModel.SizeColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />

<FontIcon
x:Name="ItemStatusGrid"
Grid.Column="9"
x:Name="ItemStatus"
Width="{Binding ColumnsViewModel.StatusColumn.LengthIncludingGridSplitter.Value, ElementName=PageRoot, Mode=OneWay}"
Margin="12,0,0,0"
HorizontalAlignment="Stretch"
Expand All @@ -751,7 +731,7 @@
FontSize="12"
Glyph="{x:Bind SyncStatusUI.Glyph, Mode=OneWay}"
Visibility="{Binding ColumnsViewModel.StatusColumn.Visibility, ElementName=PageRoot, Mode=OneWay}" />
</Grid>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
<i:Interaction.Behaviors>
Expand Down
28 changes: 19 additions & 9 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,11 @@ public override void Dispose()

#endregion IDisposable

private void Grid_Loaded(object sender, RoutedEventArgs e)
private void StackPanel_Loaded(object sender, RoutedEventArgs e)
{
// This is the best way I could find to set the context flyout, as doing it in the styles isn't possible
// because you can't use bindings in the setters
DependencyObject item = VisualTreeHelper.GetParent(sender as Grid);
DependencyObject item = VisualTreeHelper.GetParent(sender as StackPanel);
while (item is not ListViewItem)
item = VisualTreeHelper.GetParent(item);
if (item is ListViewItem itemContainer)
Expand Down Expand Up @@ -740,14 +740,24 @@ private double MeasureTextColumnEstimate(int columnIndex, int measureItemsCount,
{
var tbs = DependencyObjectHelpers.FindChildren<TextBlock>(FileList.ItemsPanelRoot).Where(tb =>
{
// isolated <TextBlock Grid.Column=...>
if (tb.ReadLocalValue(Grid.ColumnProperty) != DependencyProperty.UnsetValue)
return Grid.GetColumn(tb) == columnIndex;
// <TextBlock> nested in <Grid Grid.Column=...>
else if (tb.Parent is Grid parentGrid)
return Grid.GetColumn(parentGrid) == columnIndex;
int columnIndexFromName = tb.Name switch
{
"ItemName" => 1,
"ItemTag" => 2,
"ItemOriginalPath" => 3,
"ItemDateDeleted" => 4,
"ItemDateModified" => 5,
"ItemDateCreated" => 6,
"ItemType" => 7,
"ItemSize" => 8,
"ItemStatus" => 9,
_ => -1,
};

if (columnIndexFromName == -1)
return false;

return false;
return columnIndexFromName == columnIndex;
});

// heuristic: usually, text with more letters are wider than shorter text with wider letters
Expand Down