Skip to content

Commit

Permalink
Feature: Added "Properties" button to the Details Pane (#12913)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrariofilippo authored Jul 10, 2023
1 parent e1f43cc commit a5d3844
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/Files.App/UserControls/Pane/PreviewPane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:properties="using:Files.App.ViewModels.Properties"
xmlns:triggers="using:CommunityToolkit.WinUI.UI.Triggers"
xmlns:usercontrols="using:Files.App.UserControls"
x:Name="Root"
MinWidth="90"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -267,6 +268,22 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<!-- Open Properties Button -->
<Button
x:Name="DetailsOpenProperties"
Margin="8,0,8,8"
HorizontalAlignment="Left"
Command="{x:Bind Commands.OpenProperties}"
IsEnabled="{x:Bind Commands.OpenProperties.IsExecutable, Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind Commands.OpenProperties.LabelWithHotKey, Mode=OneWay}">
<Button.Content>
<StackPanel Orientation="Horizontal" Spacing="8">
<usercontrols:OpacityIcon Style="{x:Bind Commands.OpenProperties.OpacityStyle}" />
<TextBlock Text="{helpers:ResourceString Name=Properties}" />
</StackPanel>
</Button.Content>
</Button>
</StackPanel>
</ScrollViewer>

Expand Down
8 changes: 3 additions & 5 deletions src/Files.App/UserControls/Pane/PreviewPane.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Extensions;
using Files.App.ViewModels;
using Files.Core.Services.Settings;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
Expand All @@ -25,6 +20,8 @@ public sealed partial class PreviewPane : UserControl

private readonly IPreviewPaneSettingsService PaneSettingsService;

private readonly ICommandManager Commands;

private readonly PreviewPaneViewModel ViewModel;

private ObservableContext Context { get; } = new();
Expand All @@ -33,6 +30,7 @@ public PreviewPane()
{
InitializeComponent();
PaneSettingsService = Ioc.Default.GetRequiredService<IPreviewPaneSettingsService>();
Commands = Ioc.Default.GetRequiredService<ICommandManager>();
ViewModel = Ioc.Default.GetRequiredService<PreviewPaneViewModel>();
}

Expand Down
3 changes: 2 additions & 1 deletion src/Files.App/ViewModels/Previews/FolderPreviewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ private async Task LoadPreviewAndDetailsAsync()
}

var tags = Item.FileTagsUI is not null ? string.Join(',', Item.FileTagsUI.Select(x => x.Name)) : null;
Item.FileDetails.Add(GetFileProperty("FileTags", tags));
if (tags is not null)
Item.FileDetails.Add(GetFileProperty("FileTags", tags));
}

private static FileProperty GetFileProperty(string nameResource, object value)
Expand Down

0 comments on commit a5d3844

Please sign in to comment.