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: Show a progress ring or bar while loading in the properties window #12544

Merged
merged 2 commits into from
Jun 5, 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
7 changes: 7 additions & 0 deletions src/Files.App/Data/Models/SelectedItemsPropertiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -613,5 +613,12 @@ public bool RunAsAdminEnabled
get => runAsAdminEnabled;
set => SetProperty(ref runAsAdminEnabled, value);
}

private bool isPropertiesLoaded;
public bool IsPropertiesLoaded
{
get => isPropertiesLoaded;
set => SetProperty(ref isPropertiesLoaded, value);
}
}
}
6 changes: 5 additions & 1 deletion src/Files.App/ViewModels/Properties/HashesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void ToggleIsEnabled(string? algorithm)

if (hashInfoItem.HashValue is null && hashInfoItem.IsEnabled)
{
hashInfoItem.HashValue = "Calculating".GetLocalizedResource();
hashInfoItem.IsCalculating = true;

App.Window.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
{
Expand Down Expand Up @@ -111,6 +111,10 @@ private void ToggleIsEnabled(string? algorithm)
{
hashInfoItem.HashValue = "CalculationError".GetLocalizedResource();
}
finally
{
hashInfoItem.IsCalculating = false;
}
});
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/Files.App/Views/Properties/DetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkitconverters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:vm="using:Files.App.ViewModels.Properties"
Loaded="Properties_Loaded"
Tag="Details"
Expand All @@ -16,16 +17,33 @@
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/PropertiesStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
<toolkitconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
</ResourceDictionary>
</Page.Resources>

<ScrollViewer>
<Grid Padding="12">

<!-- Loading -->
<StackPanel
x:Name="LoadingStatePanel"
HorizontalAlignment="Center"
VerticalAlignment="Center"
x:Load="{x:Bind ViewModel.IsPropertiesLoaded, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
Spacing="8">
<ProgressRing HorizontalAlignment="Center" IsIndeterminate="True" />
<TextBlock
x:Name="LoadingTextBlock"
HorizontalAlignment="Center"
Style="{StaticResource BodyStrongTextBlockStyle}"
Text="{helpers:ResourceString Name=Loading}" />
</StackPanel>

<!-- Details Expander List -->
<ListView
x:Name="MainList"
HorizontalAlignment="Stretch"
x:Load="{x:Bind ViewModel.IsPropertiesLoaded, Mode=OneWay}"
ItemsSource="{x:Bind ViewModel.PropertySections, Mode=OneWay}"
SelectionMode="None">

Expand Down
2 changes: 2 additions & 0 deletions src/Files.App/Views/Properties/DetailsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ protected override async void Properties_Loaded(object sender, RoutedEventArgs e
await fileProps.GetSystemFilePropertiesAsync();
stopwatch.Stop();
Debug.WriteLine(string.Format("System file properties were obtained in {0} milliseconds", stopwatch.ElapsedMilliseconds));

ViewModel.IsPropertiesLoaded = true;
}
}

Expand Down
20 changes: 20 additions & 0 deletions src/Files.App/Views/Properties/HashesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,30 @@
Style="{StaticResource BodyTextBlockStyle}"
Text="{x:Bind Algorithm}" />

<!-- Calculating -->
<StackPanel
x:Name="CalculatingPanel"
Grid.Column="2"
x:Load="{x:Bind IsCalculating, Mode=OneWay}"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Style="{StaticResource BodyTextBlockStyle}"
Text="{helpers:ResourceString Name=Calculating}" />

<ProgressBar
Width="100"
Margin="16,0,0,0"
HorizontalAlignment="Left"
IsIndeterminate="True" />
</StackPanel>

<!-- Hash Value -->
<TextBlock
x:Name="HashValueText"
Grid.Column="2"
VerticalAlignment="Center"
x:Load="{x:Bind IsCalculating, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{x:Bind HashValue, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
Expand Down
7 changes: 7 additions & 0 deletions src/Files.Backend/Models/HashInfoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public bool IsSelected
set => SetProperty(ref _IsSelected, value);
}

private bool _IsCalculating;
public bool IsCalculating
{
get => _IsCalculating;
set => SetProperty(ref _IsCalculating, value);
}

private bool _IsCalculated;
public bool IsCalculated
{
Expand Down