Skip to content

Commit a111058

Browse files
committed
Fix Empty folder text display
1 parent a82225e commit a111058

File tree

7 files changed

+36
-43
lines changed

7 files changed

+36
-43
lines changed

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.ObjectModel;
88
using System.Diagnostics;
99
using System.Globalization;
10+
using System.IO;
1011
using System.Linq;
1112
using System.Runtime.InteropServices;
1213
using System.Threading;
@@ -367,17 +368,17 @@ public async void AddItemsToCollectionAsync(string path, Page currentPage)
367368
}
368369
else
369370
{
370-
MessageDialog unsupportedDevice = new MessageDialog("This device may be unsupported. Please file an issue report in Settings - About containing what device we couldn't access. Technical information: " + e, "Unsupported Device");
371+
MessageDialog unsupportedDevice = new MessageDialog("This device may be unsupported. Please file an issue report containing what device we couldn't access. Technical information: " + e, "Unsupported Device");
371372
await unsupportedDevice.ShowAsync();
372373
return;
373374
}
374375
}
375376
catch (COMException e)
376377
{
377378
Frame rootFrame = Window.Current.Content as Frame;
378-
MessageDialog driveGone = new MessageDialog(e.Message, "Drive Unplugged");
379+
MessageDialog driveGone = new MessageDialog(e.Message, "Did you unplug this drive?");
379380
await driveGone.ShowAsync();
380-
rootFrame.Navigate(typeof(ProHome), null, new SuppressNavigationTransitionInfo());
381+
rootFrame.Navigate(typeof(InstanceTabsView), null, new SuppressNavigationTransitionInfo());
381382
return;
382383
}
383384

Files UWP/GenericFileBrowser.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
</MenuFlyout>
177177
</Grid.ContextFlyout>
178178
<ProgressBar Name="progBar" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>
179-
<TextBlock Name="EmptyText" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0"/>
179+
<TextBlock Visibility="{x:Bind TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Name="EmptyText" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0"/>
180180
<controls:DataGrid 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" HorizontalAlignment="Left">
181181
<controls:DataGrid.ColumnHeaderStyle>
182182
<Style TargetType="controlsprimitives:DataGridColumnHeader">

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ public sealed partial class GenericFileBrowser : Page
3333
public ProgressBar progressBar;
3434
public ItemViewModel<GenericFileBrowser> instanceViewModel;
3535
public Interaction<GenericFileBrowser> instanceInteraction;
36-
36+
public EmptyFolderTextState TextState { get; set; } = new EmptyFolderTextState();
3737

3838
public GenericFileBrowser()
3939
{
4040
this.InitializeComponent();
4141
GFBPageName = GenericItemView;
4242
emptyTextGFB = EmptyText;
4343
progressBar = progBar;
44-
EmptyText.Visibility = Visibility.Collapsed;
4544
progressBar.Visibility = Visibility.Collapsed;
4645
data = AllView;
4746
context = RightClickContextMenu;
@@ -61,19 +60,6 @@ public GenericFileBrowser()
6160
CopyItem.Click += instanceInteraction.CopyItem_ClickAsync;
6261
AllView.RightTapped += instanceInteraction.AllView_RightTapped;
6362
AllView.DoubleTapped += instanceInteraction.List_ItemClick;
64-
ItemViewModel<GenericFileBrowser>.GetCurrentSelectedTabInstance<ProHome>().TextState.PropertyChanged += TextState_PropertyChanged;
65-
}
66-
67-
private void TextState_PropertyChanged(object sender, PropertyChangedEventArgs e)
68-
{
69-
if (ItemViewModel<GenericFileBrowser>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible == Visibility.Visible)
70-
{
71-
emptyTextGFB.Visibility = Visibility.Visible;
72-
}
73-
else if (ItemViewModel<GenericFileBrowser>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible == Visibility.Collapsed)
74-
{
75-
emptyTextGFB.Visibility = Visibility.Collapsed;
76-
}
7763
}
7864

7965
private void SelectAllAcceleratorDG_Invoked(Windows.UI.Xaml.Input.KeyboardAccelerator sender, Windows.UI.Xaml.Input.KeyboardAcceleratorInvokedEventArgs args)
@@ -122,6 +108,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
122108
CurrentInstance.RefreshButton.Click += NavigationActions.Refresh_Click;
123109
CurrentInstance.AddItemButton.Click += AddItem_Click;
124110
instanceViewModel.AddItemsToCollectionAsync(instanceViewModel.Universal.path, this);
111+
TextState_PropertyChanged(null, null);
125112
if (parameters.Equals(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))
126113
{
127114
CurrentInstance.PathText.Text = "Desktop";
@@ -290,6 +277,10 @@ private void AllView_DragLeave(object sender, DragEventArgs e)
290277

291278
}
292279

280+
internal void TextState_PropertyChanged(object sender, PropertyChangedEventArgs e)
281+
{
282+
TextState.isVisible = ItemViewModel<GenericFileBrowser>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible;
283+
}
293284
}
294285

295286
public class EmptyFolderTextState : INotifyPropertyChanged

Files UWP/PhotoAlbum.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
</MenuFlyout>
397397
</Grid.ContextFlyout>
398398
<ProgressBar Name="ProgBar" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>
399-
<TextBlock Name="EmptyText" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
399+
<TextBlock Visibility="{x:Bind TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Name="EmptyText" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
400400

401401
<controls:AdaptiveGridView animations:ReorderGridAnimation.Duration="300" ShowsScrollingPlaceholders="True" Margin="24,24,24,0" Grid.Row="3" SelectionMode="Extended" IsRightTapEnabled="True" IsDoubleTapEnabled="True" Name="FileList" Padding="0, 0, 0, 0" >
402402
<controls:AdaptiveGridView.ItemTemplate>

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Files.Navigation;
1515
using System.Diagnostics;
1616
using Windows.UI.Xaml.Media.Animation;
17+
using System.ComponentModel;
1718

1819
namespace Files
1920
{
@@ -33,6 +34,7 @@ public sealed partial class PhotoAlbum : Page
3334
public ProgressBar progressBar;
3435
public ItemViewModel<PhotoAlbum> instanceViewModel;
3536
public Interaction<PhotoAlbum> instanceInteraction;
37+
public EmptyFolderTextState TextState { get; set; } = new EmptyFolderTextState();
3638

3739

3840
public PhotoAlbum()
@@ -47,19 +49,6 @@ public PhotoAlbum()
4749
instanceViewModel = new ItemViewModel<PhotoAlbum>(this, null);
4850
instanceInteraction = new Interaction<PhotoAlbum>(this);
4951
gv.ItemsSource = instanceViewModel.FilesAndFolders;
50-
ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().TextState.PropertyChanged += TextState_PropertyChanged;
51-
}
52-
53-
private void TextState_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
54-
{
55-
if (ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible == Visibility.Visible)
56-
{
57-
EmptyTextPA.Visibility = Visibility.Visible;
58-
}
59-
else if (ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible == Visibility.Collapsed)
60-
{
61-
EmptyTextPA.Visibility = Visibility.Collapsed;
62-
}
6352
}
6453

6554
protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
@@ -72,6 +61,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
7261
instanceViewModel.AlwaysPresentCommands.isEnabled = true;
7362
var parameters = eventArgs.Parameter.ToString();
7463
instanceViewModel.AddItemsToCollectionAsync(parameters, this);
64+
TextState_PropertyChanged(null, null);
7565
FileList.DoubleTapped += instanceInteraction.List_ItemClick;
7666

7767
if (parameters.Equals(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)))
@@ -218,5 +208,10 @@ private async void PropertiesItemGrid_Click(object sender, RoutedEventArgs e)
218208
ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().accessiblePropertiesFrame.Navigate(typeof(Properties), ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().PathText.Text, new SuppressNavigationTransitionInfo());
219209
await ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().propertiesBox.ShowAsync();
220210
}
211+
212+
internal void TextState_PropertyChanged(object sender, PropertyChangedEventArgs e)
213+
{
214+
TextState.isVisible = ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().TextState.isVisible;
215+
}
221216
}
222217
}

Files UWP/ProHome.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@
742742
</ScrollViewer>
743743
</SplitView.Pane>
744744

745-
<Frame Navigated="ItemDisplayFrame_Navigated" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Name="ItemDisplayFrame"/>
745+
<Frame Navigating="ItemDisplayFrame_Navigating" Navigated="ItemDisplayFrame_Navigated" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Name="ItemDisplayFrame"/>
746746

747747
</SplitView>
748748
<ContentDialog Windows10version1809:CornerRadius="5" Grid.RowSpan="4" DefaultButton="Primary" PrimaryButtonClick="PermissionDialog_PrimaryButtonClick" PrimaryButtonText="Grant Permission" Name="PermissionDialog" Title="Welcome to Files UWP">
@@ -753,7 +753,7 @@
753753
<TextBlock TextWrapping="WrapWholeWords" Text="To get started, we need you to grant us permission to show you your files. This will open a Settings page where you can grant us permission. Files will close in the process, so don't be afraid to come back! "/>
754754
</Grid>
755755
</ContentDialog>
756-
<ContentDialog Windows10version1809:CornerRadius="5" Grid.RowSpan="4" Loaded="AddDialog_Loaded" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" BorderThickness="0" Name="AddDialog" PrimaryButtonText="Cancel">
756+
<ContentDialog Windows10version1809:CornerRadius="5" Grid.RowSpan="4" Background="{StaticResource ApplicationPageBackgroundThemeBrush}" BorderThickness="0" Name="AddDialog" PrimaryButtonText="Cancel">
757757
<Windows10version1903:ContentDialog.Shadow>
758758
<Windows10version1903:ThemeShadow/>
759759
</Windows10version1903:ContentDialog.Shadow>

Files UWP/ProHome.xaml.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public ProHome()
9191
ForwardButton.Click += NavigationActions.Forward_Click;
9292
ribbonShadow.Receivers.Add(RibbonShadowSurface);
9393
Ribbon.Translation += new System.Numerics.Vector3(0, 0, 4);
94+
9495
}
9596

9697
public async void PopulateNavViewWithExternalDrives()
@@ -738,13 +739,6 @@ private void ClearAllButton_Click(object sender, RoutedEventArgs e)
738739

739740
}
740741

741-
AddItem addItemPageInstance;
742-
private void AddDialog_Loaded(object sender, RoutedEventArgs e)
743-
{
744-
addItemPageInstance = null;
745-
746-
}
747-
748742
private void NameDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
749743
{
750744
inputForRename = null;
@@ -785,10 +779,22 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
785779
this.Loaded -= Page_Loaded;
786780
}
787781

788-
private void ItemDisplayFrame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
782+
private void ItemDisplayFrame_Navigating(object sender, Windows.UI.Xaml.Navigation.NavigatingCancelEventArgs e)
789783
{
790784

791785
}
786+
787+
private void ItemDisplayFrame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
788+
{
789+
if (accessibleContentFrame.SourcePageType == typeof(GenericFileBrowser))
790+
{
791+
TextState.PropertyChanged += (accessibleContentFrame.Content as GenericFileBrowser).TextState_PropertyChanged;
792+
}
793+
else if (accessibleContentFrame.SourcePageType == typeof(PhotoAlbum))
794+
{
795+
TextState.PropertyChanged += (accessibleContentFrame.Content as PhotoAlbum).TextState_PropertyChanged;
796+
}
797+
}
792798
}
793799
public class NavigationActions
794800
{

0 commit comments

Comments
 (0)