Skip to content

Commit

Permalink
Feature: Added an option to disable auto scroll when navigating up (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Jan 10, 2024
1 parent 9f26eb2 commit a6c0b25
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/Files.App/Services/Settings/FoldersSettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ public bool OpenFoldersInNewTab
set => Set(value);
}

public bool ScrollToParentFolderWhenNavigatingUp
{
get => Get(true);
set => Set(value);
}

public bool CalculateFolderSizes
{
get => Get(false);
Expand Down Expand Up @@ -421,6 +427,7 @@ protected override void RaiseOnSettingChangedEvent(object sender, SettingChanged
case nameof(OpenItemsWithOneClick):
case nameof(ColumnLayoutOpenFoldersWithOneClick):
case nameof(OpenFoldersInNewTab):
case nameof(ScrollToParentFolderWhenNavigatingUp):
case nameof(CalculateFolderSizes):
case nameof(ShowFileExtensions):
case nameof(ShowThumbnails):
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@
<data name="GroupByDateCreatedYearDescription" xml:space="preserve">
<value>Group items by year of date created</value>
</data>
<data name="GroupByDateDeletedDayDescription" xml:space="preserve">
<data name="GroupByDateDeletedDayDescription" xml:space="preserve">
<value>Group items by day of date deleted</value>
</data>
<data name="GroupByDateDeletedMonthDescription" xml:space="preserve">
Expand Down Expand Up @@ -3695,4 +3695,7 @@
<data name="FaildToShareItems" xml:space="preserve">
<value>Failed to share items</value>
</data>
<data name="ScrollToParentFolderWhenNavigatingUp" xml:space="preserve">
<value>Scroll to parent folder when navigating up</value>
</data>
</root>
14 changes: 14 additions & 0 deletions src/Files.App/ViewModels/Settings/FoldersViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,20 @@ public bool CalculateFolderSizes
}
}

public bool ScrollToParentFolderWhenNavigatingUp
{
get => UserSettingsService.FoldersSettingsService.ScrollToParentFolderWhenNavigatingUp;
set
{
if (value != UserSettingsService.FoldersSettingsService.ScrollToParentFolderWhenNavigatingUp)
{
UserSettingsService.FoldersSettingsService.ScrollToParentFolderWhenNavigatingUp = value;

OnPropertyChanged();
}
}
}

private int selectedDefaultSortingIndex;
public int SelectedDefaultSortingIndex
{
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App/Views/Settings/FoldersPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,18 @@
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Scroll to parent folder when navigating up -->
<local:SettingsBlockControl Title="{helpers:ResourceString Name=ScrollToParentFolderWhenNavigatingUp}" HorizontalAlignment="Stretch">
<local:SettingsBlockControl.Icon>
<FontIcon Glyph="&#xECE7;" />
</local:SettingsBlockControl.Icon>

<ToggleSwitch
AutomationProperties.Name="{helpers:ResourceString Name=ScrollToParentFolderWhenNavigatingUp}"
IsOn="{x:Bind ViewModel.ScrollToParentFolderWhenNavigatingUp, Mode=TwoWay}"
Style="{StaticResource RightAlignedToggleSwitchStyle}" />
</local:SettingsBlockControl>

<!-- Calculate folder sizes -->
<local:SettingsBlockControl
Title="{helpers:ResourceString Name=CalculateFolderSizes}"
Expand Down
7 changes: 5 additions & 2 deletions src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,11 @@ protected void FilesystemViewModel_ItemLoadStatusChanged(object sender, ItemLoad

if (itemToSelect is not null && ContentPage is not null)
{
ContentPage.ItemManipulationModel.SetSelectedItem(itemToSelect);
ContentPage.ItemManipulationModel.ScrollIntoView(itemToSelect);
if (userSettingsService.FoldersSettingsService.ScrollToParentFolderWhenNavigatingUp)
{
ContentPage.ItemManipulationModel.SetSelectedItem(itemToSelect);
ContentPage.ItemManipulationModel.ScrollIntoView(itemToSelect);
}
}
}
break;
Expand Down
8 changes: 5 additions & 3 deletions src/Files.Core/Services/Settings/IFoldersSettingsService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Files.Core.Data.Enums;
using System.ComponentModel;

namespace Files.Core.Services.Settings
{
public interface IFoldersSettingsService : IBaseSettingsService, INotifyPropertyChanged
Expand Down Expand Up @@ -203,6 +200,11 @@ public interface IFoldersSettingsService : IBaseSettingsService, INotifyProperty
/// </summary>
bool CalculateFolderSizes { get; set; }

/// <summary>
/// Gets or sets a value indicating whether or not to scroll to the parent folder when navigating up.
/// </summary>
bool ScrollToParentFolderWhenNavigatingUp { get; set; }

/// <summary>
/// Gets or sets a value indicating the default sorting option.
/// </summary>
Expand Down

0 comments on commit a6c0b25

Please sign in to comment.