Skip to content

Commit 8e24854

Browse files
authored
Switch to WinUI ProgressBar (#918)
1 parent 8cb2e53 commit 8e24854

File tree

7 files changed

+22
-54
lines changed

7 files changed

+22
-54
lines changed

Files/Files.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@
220220
<Compile Include="UserControls\LayoutModes\GridViewBrowser.xaml.cs">
221221
<DependentUpon>GridViewBrowser.xaml</DependentUpon>
222222
</Compile>
223-
<Compile Include="Interacts\LoadingIndicator.cs" />
224223
<Compile Include="Views\Pages\ModernShellPage.xaml.cs">
225224
<DependentUpon>ModernShellPage.xaml</DependentUpon>
226225
</Compile>

Files/Interacts/Interaction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ public async void ExtractItems_Click(object sender, RoutedEventArgs e)
10241024
int totalCount = zipArchive.Entries.Count;
10251025
int index = 0;
10261026

1027-
(App.CurrentInstance.ContentPage as BaseLayout).AssociatedViewModel.LoadIndicator.IsVisible = Visibility.Visible;
1027+
App.InteractionViewModel.IsContentLoadingIndicatorVisible = true;
10281028

10291029
foreach (ZipArchiveEntry archiveEntry in zipArchive.Entries)
10301030
{
@@ -1042,7 +1042,7 @@ public async void ExtractItems_Click(object sender, RoutedEventArgs e)
10421042
index++;
10431043
if (index == totalCount)
10441044
{
1045-
(App.CurrentInstance.ContentPage as BaseLayout).AssociatedViewModel.LoadIndicator.IsVisible = Visibility.Collapsed;
1045+
App.InteractionViewModel.IsContentLoadingIndicatorVisible = false;
10461046
}
10471047
}
10481048
await CloneDirectoryAsync(destFolder_InBuffer.Path, destinationPath, destFolder_InBuffer.Name, true)

Files/Interacts/LoadingIndicator.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

Files/UserControls/LayoutModes/GenericFileBrowser.xaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,12 @@
357357
Invoked="{x:Bind local:App.CurrentInstance.ContentPage.GridViewSizeIncrease}"
358358
Modifiers="Control" />
359359
</Grid.KeyboardAccelerators>
360-
<ProgressBar
360+
<muxc:ProgressBar
361361
x:Name="progBar"
362-
Height="10"
363-
VerticalAlignment="Top"
362+
x:Load="{x:Bind local:App.InteractionViewModel.IsContentLoadingIndicatorVisible, Mode=OneWay}"
364363
Background="Transparent"
365-
IsIndeterminate="True"
366-
Visibility="{x:Bind AssociatedViewModel.LoadIndicator.IsVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
364+
VerticalAlignment="Top"
365+
IsIndeterminate="True"/>
367366
<TextBlock
368367
x:Name="EmptyText"
369368
x:Uid="EmptyFolder"

Files/UserControls/LayoutModes/GridViewBrowser.xaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,12 @@
543543
Invoked="{x:Bind local:App.CurrentInstance.ContentPage.GridViewSizeDecrease}"
544544
Modifiers="Control" />
545545
</Grid.KeyboardAccelerators>
546-
<ProgressBar
547-
Name="ProgBar"
548-
Height="10"
549-
VerticalAlignment="Top"
546+
<muxc:ProgressBar
547+
x:Name="progBar"
548+
x:Load="{x:Bind local:App.InteractionViewModel.IsContentLoadingIndicatorVisible, Mode=OneWay}"
550549
Background="Transparent"
551-
IsIndeterminate="True"
552-
Visibility="{x:Bind AssociatedViewModel.LoadIndicator.IsVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
550+
VerticalAlignment="Top"
551+
IsIndeterminate="True"/>
553552
<TextBlock
554553
x:Name="EmptyText"
555554
x:Uid="EmptyFolder"

Files/View Models/InteractionViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ namespace Files.Controls
77
{
88
public class InteractionViewModel : ViewModelBase
99
{
10+
private bool _IsContentLoadingIndicatorVisible = false;
11+
public bool IsContentLoadingIndicatorVisible
12+
{
13+
get => _IsContentLoadingIndicatorVisible;
14+
set => Set(ref _IsContentLoadingIndicatorVisible, value);
15+
}
16+
1017
private Thickness _TabsLeftMargin = new Thickness(200, 0, 0, 0);
1118

1219
public Thickness TabsLeftMargin

Files/View Models/ItemViewModel.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ namespace Files.Filesystem
3737
public class ItemViewModel : INotifyPropertyChanged, IDisposable
3838
{
3939
public EmptyFolderTextState EmptyTextState { get; set; } = new EmptyFolderTextState();
40-
public LoadingIndicator LoadIndicator { get; set; } = new LoadingIndicator();
4140
public ReadOnlyObservableCollection<ListedItem> FilesAndFolders { get; }
4241
public ListedItem CurrentFolder { get => _rootFolderItem; }
4342
public CollectionViewSource viewSource;
@@ -699,7 +698,7 @@ public async Task RapidAddItemsToCollectionAsync(string path)
699698
_filesAndFolders.Clear();
700699
Stopwatch stopwatch = new Stopwatch();
701700
stopwatch.Start();
702-
LoadIndicator.IsVisible = Visibility.Visible;
701+
App.InteractionViewModel.IsContentLoadingIndicatorVisible = true;
703702

704703
switch (WorkingDirectory)
705704
{
@@ -769,7 +768,7 @@ public async Task RapidAddItemsToCollectionAsync(string path)
769768
stopwatch.Stop();
770769
Debug.WriteLine("Loading of items in " + WorkingDirectory + " completed in " + stopwatch.ElapsedMilliseconds + " milliseconds.\n");
771770
App.CurrentInstance.NavigationToolbar.CanRefresh = true;
772-
LoadIndicator.IsVisible = Visibility.Collapsed;
771+
App.InteractionViewModel.IsContentLoadingIndicatorVisible = false;
773772
IsLoadingItems = false;
774773
}
775774
finally
@@ -1281,7 +1280,7 @@ public async void FileContentsChanged(IStorageQueryResultBase sender, object arg
12811280
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
12821281
() =>
12831282
{
1284-
LoadIndicator.IsVisible = Visibility.Visible;
1283+
App.InteractionViewModel.IsContentLoadingIndicatorVisible = true;
12851284
});
12861285
_filesRefreshing = true;
12871286

@@ -1350,7 +1349,7 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
13501349
async () =>
13511350
{
13521351
await RefreshItems();
1353-
LoadIndicator.IsVisible = Visibility.Collapsed;
1352+
App.InteractionViewModel.IsContentLoadingIndicatorVisible = false;
13541353
});
13551354

13561355
_filesRefreshing = false;

0 commit comments

Comments
 (0)