Skip to content

Commit 05a2a67

Browse files
authored
Feature: Show a progress ring or bar while loading in the properties window (#12544)
1 parent 9a43c74 commit 05a2a67

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

src/Files.App/Data/Models/SelectedItemsPropertiesViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,5 +613,12 @@ public bool RunAsAdminEnabled
613613
get => runAsAdminEnabled;
614614
set => SetProperty(ref runAsAdminEnabled, value);
615615
}
616+
617+
private bool isPropertiesLoaded;
618+
public bool IsPropertiesLoaded
619+
{
620+
get => isPropertiesLoaded;
621+
set => SetProperty(ref isPropertiesLoaded, value);
622+
}
616623
}
617624
}

src/Files.App/ViewModels/Properties/HashesViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void ToggleIsEnabled(string? algorithm)
8181

8282
if (hashInfoItem.HashValue is null && hashInfoItem.IsEnabled)
8383
{
84-
hashInfoItem.HashValue = "Calculating".GetLocalizedResource();
84+
hashInfoItem.IsCalculating = true;
8585

8686
App.Window.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
8787
{
@@ -111,6 +111,10 @@ private void ToggleIsEnabled(string? algorithm)
111111
{
112112
hashInfoItem.HashValue = "CalculationError".GetLocalizedResource();
113113
}
114+
finally
115+
{
116+
hashInfoItem.IsCalculating = false;
117+
}
114118
});
115119
}
116120
}

src/Files.App/Views/Properties/DetailsPage.xaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:helpers="using:Files.App.Helpers"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:toolkitconverters="using:CommunityToolkit.WinUI.UI.Converters"
910
xmlns:vm="using:Files.App.ViewModels.Properties"
1011
Loaded="Properties_Loaded"
1112
Tag="Details"
@@ -16,16 +17,33 @@
1617
<ResourceDictionary.MergedDictionaries>
1718
<ResourceDictionary Source="ms-appx:///ResourceDictionaries/PropertiesStyles.xaml" />
1819
</ResourceDictionary.MergedDictionaries>
20+
<toolkitconverters:BoolNegationConverter x:Key="BoolNegationConverter" />
1921
</ResourceDictionary>
2022
</Page.Resources>
2123

2224
<ScrollViewer>
2325
<Grid Padding="12">
2426

27+
<!-- Loading -->
28+
<StackPanel
29+
x:Name="LoadingStatePanel"
30+
HorizontalAlignment="Center"
31+
VerticalAlignment="Center"
32+
x:Load="{x:Bind ViewModel.IsPropertiesLoaded, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
33+
Spacing="8">
34+
<ProgressRing HorizontalAlignment="Center" IsIndeterminate="True" />
35+
<TextBlock
36+
x:Name="LoadingTextBlock"
37+
HorizontalAlignment="Center"
38+
Style="{StaticResource BodyStrongTextBlockStyle}"
39+
Text="{helpers:ResourceString Name=Loading}" />
40+
</StackPanel>
41+
2542
<!-- Details Expander List -->
2643
<ListView
2744
x:Name="MainList"
2845
HorizontalAlignment="Stretch"
46+
x:Load="{x:Bind ViewModel.IsPropertiesLoaded, Mode=OneWay}"
2947
ItemsSource="{x:Bind ViewModel.PropertySections, Mode=OneWay}"
3048
SelectionMode="None">
3149

src/Files.App/Views/Properties/DetailsPage.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ protected override async void Properties_Loaded(object sender, RoutedEventArgs e
2424
await fileProps.GetSystemFilePropertiesAsync();
2525
stopwatch.Stop();
2626
Debug.WriteLine(string.Format("System file properties were obtained in {0} milliseconds", stopwatch.ElapsedMilliseconds));
27+
28+
ViewModel.IsPropertiesLoaded = true;
2729
}
2830
}
2931

src/Files.App/Views/Properties/HashesPage.xaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,30 @@
145145
Style="{StaticResource BodyTextBlockStyle}"
146146
Text="{x:Bind Algorithm}" />
147147

148+
<!-- Calculating -->
149+
<StackPanel
150+
x:Name="CalculatingPanel"
151+
Grid.Column="2"
152+
x:Load="{x:Bind IsCalculating, Mode=OneWay}"
153+
Orientation="Horizontal">
154+
<TextBlock
155+
VerticalAlignment="Center"
156+
Style="{StaticResource BodyTextBlockStyle}"
157+
Text="{helpers:ResourceString Name=Calculating}" />
158+
159+
<ProgressBar
160+
Width="100"
161+
Margin="16,0,0,0"
162+
HorizontalAlignment="Left"
163+
IsIndeterminate="True" />
164+
</StackPanel>
165+
148166
<!-- Hash Value -->
149167
<TextBlock
168+
x:Name="HashValueText"
150169
Grid.Column="2"
151170
VerticalAlignment="Center"
171+
x:Load="{x:Bind IsCalculating, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
152172
Style="{StaticResource BodyTextBlockStyle}"
153173
Text="{x:Bind HashValue, Mode=OneWay}"
154174
TextTrimming="CharacterEllipsis"

src/Files.Backend/Models/HashInfoItem.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public bool IsSelected
2828
set => SetProperty(ref _IsSelected, value);
2929
}
3030

31+
private bool _IsCalculating;
32+
public bool IsCalculating
33+
{
34+
get => _IsCalculating;
35+
set => SetProperty(ref _IsCalculating, value);
36+
}
37+
3138
private bool _IsCalculated;
3239
public bool IsCalculated
3340
{

0 commit comments

Comments
 (0)