Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions src/Files.App.Controls/BladeView/BladeItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public partial class BladeItem : ContentControl
{
private const double MINIMUM_WIDTH = 150;
private const double DEFAULT_WIDTH = 300; // Default width for the blade item
private const double DEFAULT_WIDTH = 200; // Default width for the blade item

private Button _closeButton;
private Border _bladeResizer;
Expand All @@ -27,7 +27,7 @@
/// <summary>
/// Initializes a new instance of the <see cref="BladeItem"/> class.
/// </summary>
public BladeItem()

Check warning on line 30 in src/Files.App.Controls/BladeView/BladeItem.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

Non-nullable field '_closeButton' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 30 in src/Files.App.Controls/BladeView/BladeItem.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

Non-nullable field '_bladeResizer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 30 in src/Files.App.Controls/BladeView/BladeItem.cs

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

Non-nullable field '_closeButton' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
DefaultStyleKey = typeof(BladeItem);
}
Expand Down Expand Up @@ -113,6 +113,12 @@
}

private void BladeResizer_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
SetWidth();
e.Handled = true;
}

public void SetWidth()
{
var optimalWidth = CalculateOptimalWidth();
if (optimalWidth > 0)
Expand All @@ -124,8 +130,6 @@
// Fallback to default width if calculation fails
Width = DEFAULT_WIDTH;
}

e.Handled = true;
}

private double CalculateOptimalWidth()
Expand Down Expand Up @@ -201,7 +205,7 @@
catch (Exception)
{
// Fallback calculation
return 200; // Default reasonable width
return DEFAULT_WIDTH; // Default reasonable width
}
}

Expand Down
11 changes: 2 additions & 9 deletions src/Files.App.Controls/BladeView/BladeView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@
<Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="True" />
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="True" />
<Setter Property="ScrollViewer.BringIntoViewOnFocusChange" Value="False" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="ItemContainerTransitions">
<Setter.Value>
<TransitionCollection>
<AddDeleteThemeTransition />
<ContentThemeTransition />
<ReorderThemeTransition />
<EntranceThemeTransition IsStaggeringEnabled="False" />
</TransitionCollection>
<TransitionCollection />
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
Expand Down Expand Up @@ -96,12 +91,10 @@
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0" />
<Setter Property="MinWidth" Value="{ThemeResource GridViewItemMinWidth}" />
<Setter Property="MinHeight" Value="{ThemeResource GridViewItemMinHeight}" />
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Width" Value="320" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:BladeItem">
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App/Views/Layouts/ColumnLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,20 @@ public ColumnLayoutPage() : base()

// Methods

private void OnItemLoadStatusChanged(object sender, ItemLoadStatusChangedEventArgs args)
{
if (args is ItemLoadStatusChangedEventArgs statusArgs && statusArgs.Status is ItemLoadStatusChangedEventArgs.ItemLoadStatus.Complete)
{
var currentBladeIndex = (ParentShellPageInstance is ColumnShellPage associatedColumnShellPage) ? associatedColumnShellPage.ColumnParams.Column : 0;
this.FindAscendant<ColumnsLayoutPage>()?.SetWidth(currentBladeIndex);
}
}


private void FileList_Loaded(object sender, RoutedEventArgs e)
{
ContentScroller = FileList.FindDescendant<ScrollViewer>(x => x.Name == "ScrollViewer");
ParentShellPageInstance.ShellViewModel.ItemLoadStatusChanged += OnItemLoadStatusChanged;
}

private void ColumnViewBase_GotFocus(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -186,6 +197,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
{
base.OnNavigatingFrom(e);
UserSettingsService.LayoutSettingsService.PropertyChanged -= LayoutSettingsService_PropertyChanged;
ParentShellPageInstance.ShellViewModel.ItemLoadStatusChanged -= OnItemLoadStatusChanged;
}

private void LayoutSettingsService_PropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Setter Property="CloseButtonVisibility" Value="Collapsed" />
<Setter Property="BorderThickness" Value="0,0,1,0" />
<Setter Property="BorderBrush" Value="{ThemeResource DividerStrokeColorDefaultBrush}" />
<Setter Property="Width" Value="300" />
<Setter Property="Width" Value="200" />
</Style>
</local:BaseLayoutPage.Resources>

Expand Down
6 changes: 6 additions & 0 deletions src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e)
}
}

public void SetWidth(int index)
{
var blade = ColumnHost.ActiveBlades[index];
blade?.SetWidth();
}

private void ContentChanged(IShellPage p)
{
(ParentShellPageInstance as ModernShellPage)?.RaiseContentChanged(p, p.TabBarItemParameter);
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Views/Shells/ColumnShellPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
x:Name="RootPage"
KeyboardAcceleratorPlacementMode="Hidden"
Loaded="Page_Loaded"
Unloaded="Page_Unloaded"
mc:Ignorable="d">

<local:BaseShellPage.Resources>
Expand Down
10 changes: 10 additions & 0 deletions src/Files.App/Views/Shells/ColumnShellPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ protected override void Page_Loaded(object sender, RoutedEventArgs e)
NotifyPropertyChanged(nameof(ShellViewModel));
}

private void Page_Unloaded(object sender, RoutedEventArgs e)
{
ShellViewModel.WorkingDirectoryModified -= ViewModel_WorkingDirectoryModified;
ShellViewModel.ItemLoadStatusChanged -= FilesystemViewModel_ItemLoadStatusChanged;
ShellViewModel.DirectoryInfoUpdated -= FilesystemViewModel_DirectoryInfoUpdated;
ShellViewModel.PageTypeUpdated -= FilesystemViewModel_PageTypeUpdated;
ShellViewModel.OnSelectionRequestedEvent -= FilesystemViewModel_OnSelectionRequestedEvent;
ShellViewModel.GitDirectoryUpdated -= FilesystemViewModel_GitDirectoryUpdated;
}

protected override async void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryModifiedEventArgs e)
{
string value = e.Path;
Expand Down
Loading