Skip to content

Commit 6bf58ed

Browse files
committed
Display Indeterminate Progress Bar on Item Load/Refresh
1 parent bef2df5 commit 6bf58ed

File tree

8 files changed

+64
-308
lines changed

8 files changed

+64
-308
lines changed

Files UWP/App.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public App()
6868
public static Interacts.Layout.LayoutItemsState LayoutItems { get; set; } = new Interacts.Layout.LayoutItemsState();
6969
public static Interacts.AlwaysPresentCommandsState AlwaysPresentCommands { get; set; } = new Interacts.AlwaysPresentCommandsState();
7070
public static DisplayedPathText PathText { get; set; } = new DisplayedPathText();
71+
public static Filesystem.LoadingVisibility Loading { get; set; } = new Filesystem.LoadingVisibility();
7172

7273
/// <summary>
7374
/// Invoked when the application is launched normally by the end user. Other entry points
@@ -76,6 +77,8 @@ public App()
7677
/// <param name="e">Details about the launch request and process.</param>
7778
protected override void OnLaunched(LaunchActivatedEventArgs e)
7879
{
80+
bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch");
81+
7982
Frame rootFrame = Window.Current.Content as Frame;
8083

8184
// Do not repeat app initialization when the Window already has content,
@@ -98,6 +101,11 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
98101

99102
if (e.PrelaunchActivated == false)
100103
{
104+
if (canEnablePrelaunch)
105+
{
106+
TryEnablePrelaunch();
107+
}
108+
101109
if (rootFrame.Content == null)
102110
{
103111

@@ -114,6 +122,10 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
114122
}
115123
}
116124

125+
private void TryEnablePrelaunch()
126+
{
127+
Windows.ApplicationModel.Core.CoreApplication.EnablePrelaunch(true);
128+
}
117129
/// <summary>
118130
/// Invoked when Navigation to a certain page fails
119131
/// </summary>

Files UWP/FilesUWP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<Compile Include="PhotoAlbum.xaml.cs">
131131
<DependentUpon>PhotoAlbum.xaml</DependentUpon>
132132
</Compile>
133-
<Compile Include="ProgressBoxSystem.cs" />
133+
<Compile Include="LoadingIndicator.cs" />
134134
<Compile Include="ProHome.xaml.cs">
135135
<DependentUpon>ProHome.xaml</DependentUpon>
136136
</Compile>

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class ItemViewModel
3333
public EmptyFolderTextState TextState { get; set; } = new EmptyFolderTextState();
3434
public BackState BS { get; set; } = new BackState();
3535
public ForwardState FS { get; set; } = new ForwardState();
36-
public ProgressUIVisibility PVIS { get; set; } = new ProgressUIVisibility();
3736

3837
private ObservableCollection<ListedItem> _filesAndFolders;
3938
private ObservableCollection<ListedItem> _classicFileList;
@@ -116,7 +115,7 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
116115
Stopwatch stopwatch = new Stopwatch();
117116
stopwatch.Start();
118117

119-
PVIS.isVisible = Visibility.Visible;
118+
App.Loading.isVisible = Visibility.Visible;
120119

121120
switch (Universal.path)
122121
{
@@ -260,10 +259,10 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
260259

261260
if (!_pageName.Contains("Classic"))
262261
{
263-
PVIS.isVisible = Visibility.Collapsed;
262+
App.Loading.isVisible = Visibility.Collapsed;
264263
}
265264

266-
PVIS.isVisible = Visibility.Collapsed;
265+
App.Loading.isVisible = Visibility.Collapsed;
267266
}
268267

269268
public static async void FillTreeNode(object item, TreeView EntireControl)
@@ -439,6 +438,11 @@ private async void FileContentsChanged(IStorageQueryResultBase sender, object ar
439438
Debug.WriteLine("Filesystem change event fired. Refreshing...");
440439
}
441440

441+
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
442+
() =>
443+
{
444+
App.Loading.isVisible = Visibility.Visible;
445+
});
442446
_filesRefreshing = true;
443447

444448
//query options have to be reapplied otherwise old results are returned
@@ -489,6 +493,13 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
489493
RemoveFileOrFolder(toRemove);
490494
});
491495
}
496+
497+
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
498+
() =>
499+
{
500+
App.Loading.isVisible = Visibility.Collapsed;
501+
});
502+
492503
_filesRefreshing = false;
493504
Debug.WriteLine("Filesystem refresh complete");
494505
}

Files UWP/GenericFileBrowser.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
</MenuFlyout.Items>
176176
</MenuFlyout>
177177
</Grid.ContextFlyout>
178+
<ProgressBar Visibility="{x:Bind local:App.Loading.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>
178179
<TextBlock Name="EmptyText" Visibility="{x:Bind local:App.ViewModel.TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0"/>
179180
<controls:DataGrid DataContext="{x:Bind local:App.ViewModel.FilesAndFolders}" RowDetailsVisibilityMode="Collapsed" AllowDrop="True" Drop="AllView_DropAsync" DragLeave="AllView_DragLeave" DragStarting="AllView_DragStarting" SelectionChanged="AllView_SelectionChanged" Margin="24,24,0,0" Grid.Row="3" CellEditEnded="AllView_CellEditEnded" FocusVisualPrimaryThickness="0" SelectionMode="Extended" IsDoubleTapEnabled="True" x:FieldModifier="public" x:Name="AllView" AutoGenerateColumns="False" CanDrag="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" ItemsSource="{x:Bind local:App.ViewModel.FilesAndFolders}" HorizontalAlignment="Left">
180181
<controls:DataGrid.ColumnHeaderStyle>

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public GenericFileBrowser()
3636
this.InitializeComponent();
3737
GFBPageName = GenericItemView;
3838
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
39-
App.ViewModel.PVIS.isVisible = Visibility.Collapsed;
39+
App.Loading.isVisible = Visibility.Collapsed;
4040
data = AllView;
4141
context = RightClickContextMenu;
4242
HeaderContextMenu = HeaderRightClickMenu;
@@ -189,7 +189,7 @@ private async void AllView_DropAsync(object sender, DragEventArgs e)
189189

190190
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
191191
{
192-
App.ViewModel.PVIS.isVisible = Visibility.Collapsed;
192+
App.Loading.isVisible = Visibility.Collapsed;
193193
}
194194

195195
private async void AllView_CellEditEnded(object sender, DataGridCellEditEndedEventArgs e)

Files UWP/LoadingIndicator.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.ComponentModel;
2+
using Windows.UI.Xaml;
3+
4+
namespace Files.Filesystem
5+
{
6+
public class LoadingVisibility : INotifyPropertyChanged
7+
{
8+
public Visibility _isVisible;
9+
public Visibility isVisible
10+
{
11+
get
12+
{
13+
return _isVisible;
14+
}
15+
16+
set
17+
{
18+
if (value != _isVisible)
19+
{
20+
_isVisible = value;
21+
NotifyPropertyChanged("isVisible");
22+
}
23+
}
24+
}
25+
public event PropertyChangedEventHandler PropertyChanged;
26+
27+
private void NotifyPropertyChanged(string info)
28+
{
29+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(info));
30+
}
31+
}
32+
}

Files UWP/PhotoAlbum.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@
395395
</MenuFlyout.Items>
396396
</MenuFlyout>
397397
</Grid.ContextFlyout>
398+
<ProgressBar Visibility="{x:Bind local:App.Loading.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>
398399
<TextBlock Name="EmptyText" Visibility="{x:Bind local:App.ViewModel.TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
399400

400401
<controls:AdaptiveGridView animations:ReorderGridAnimation.Duration="300" ShowsScrollingPlaceholders="True" Margin="24,24,24,0" Grid.Row="3" SelectionMode="Extended" IsDoubleTapEnabled="True" IsRightTapEnabled="True" ItemsSource="{x:Bind local:App.ViewModel.FilesAndFolders}" Name="FileList" Padding="0, 0, 0, 0" >

0 commit comments

Comments
 (0)