Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Added an option to disable auto scroll when navigating up #14412

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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