-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Feature: Added support for reordering items in the sidebar #11456
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
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
99394f5
Add move items to sidebar
hecksmosis e737769
Merge branch 'main' into add_move_in_sidebar
hecksmosis 96fb86b
Merge branch 'main' into add_move_in_sidebar
yaira2 ddb2cdc
Merge branch 'main' into add_move_in_sidebar
yaira2 af99ff3
Requested changes
hecksmosis b495bae
Merge branch 'main' into add_move_in_sidebar
hecksmosis e1d3e08
Merge branch 'main' into add_move_in_sidebar
yaira2 22cf956
Merge branch 'main' into add_move_in_sidebar
hecksmosis e8df7cb
[WIP]
hecksmosis bb90ab5
[WIP]
hecksmosis 19a45e3
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 20af668
Merge branch 'main' of https://github.com/files-community/Files into …
hecksmosis b16528f
Merge branch 'main' into add_move_in_sidebar
hecksmosis e6715ec
Add dialog for reordering sidebar items
hecksmosis eb77d08
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 3ee0216
Merge branch 'main' into add_move_in_sidebar
hecksmosis b3091ea
Merge branch 'main' into add_move_in_sidebar
hecksmosis 7c028b9
Add drag and drop (fixed)
hecksmosis 2c64099
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 13f1fb9
Requested changes
hecksmosis 07e25d6
Requested changes
hecksmosis c10e35b
Merge branch 'main' into add_move_in_sidebar
hecksmosis 6880215
Requested changes
hecksmosis 37cf1fe
Merge branch 'main' into add_move_in_sidebar
hecksmosis 6af86a7
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 250eedf
Merge branch 'main' into add_move_in_sidebar
hecksmosis 84bcbe6
Merge branch 'main' into add_move_in_sidebar
hecksmosis 1a4959a
Fix + remove arrow in functions
hecksmosis d615ba1
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 50671c2
Merge branch 'main' into add_move_in_sidebar
hecksmosis 7753707
Fix
hecksmosis 68ca1db
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis b68e83c
Merge branch 'main' into add_move_in_sidebar
hecksmosis 55c36ee
Merge branch 'main' into add_move_in_sidebar
hecksmosis d7178ae
Test: Add ListView instead of NavigationView
hecksmosis e1e719a
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 5f5cf80
Merge branch 'main' into add_move_in_sidebar
hecksmosis 12dcf1b
Merge branch 'main' into add_move_in_sidebar
hecksmosis 055dcc2
Merge branch 'main' into add_move_in_sidebar
hecksmosis 32d6376
Merge branch 'main' into add_move_in_sidebar
hecksmosis 4809596
Merge branch 'main' into add_move_in_sidebar
yaira2 66abd83
Requested changes
hecksmosis a83ac77
Merge branch 'main' into add_move_in_sidebar
hecksmosis b2dd299
Change ListViewItem to Grid
hecksmosis 15c0873
Merge branch 'add_move_in_sidebar' of https://github.com/hecksmosis/F…
hecksmosis 1aa7f4a
Merge branch 'main' into add_move_in_sidebar
hecksmosis bf8c1c2
Merge branch 'main' into add_move_in_sidebar
hecksmosis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<ContentDialog | ||
x:Class="Files.App.Dialogs.ReorderSidebarItemsDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:helpers="using:Files.App.Helpers" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:navigationcontrolitems="using:Files.App.DataModels.NavigationControlItems" | ||
Title="{helpers:ResourceString Name=ReorderSidebarItemsDialogText}" | ||
DefaultButton="Primary" | ||
IsPrimaryButtonEnabled="True" | ||
PrimaryButtonCommand="{x:Bind ViewModel.PrimaryButtonCommand}" | ||
PrimaryButtonText="{helpers:ResourceString Name=Save}" | ||
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}" | ||
SecondaryButtonText="{helpers:ResourceString Name=Cancel}" | ||
Style="{StaticResource DefaultContentDialogStyle}" | ||
mc:Ignorable="d"> | ||
|
||
<Grid | ||
x:Name="DestinationPathGrid" | ||
ColumnSpacing="8" | ||
RowSpacing="8"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<ListView | ||
x:Name="SidebarNavView" | ||
Grid.Row="1" | ||
ItemsSource="{x:Bind ViewModel.SidebarFavoriteItems, Mode=OneWay}"> | ||
<ListView.ItemTemplate> | ||
<DataTemplate x:DataType="navigationcontrolitems:LocationItem"> | ||
<Grid | ||
AllowDrop="True" | ||
AutomationProperties.AutomationId="{x:Bind Text}" | ||
DataContext="{x:Bind}" | ||
DragOver="ListViewItem_DragOver" | ||
DragStarting="ListViewItem_DragStarting" | ||
Drop="ListViewItem_Drop" | ||
Tag="{x:Bind Path}" | ||
ToolTipService.ToolTip="{x:Bind ToolTipText, Mode=OneWay}"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="Auto" /> | ||
</Grid.ColumnDefinitions> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<TextBlock Grid.RowSpan="2" Text="{x:Bind Text}" /> | ||
<FontIcon | ||
Grid.Row="1" | ||
HorizontalAlignment="Right" | ||
DataContext="{x:Bind}" | ||
Glyph="" | ||
PointerPressed="MoveItem" | ||
Visibility="{x:Bind IsPinned}" /> | ||
</Grid> | ||
</DataTemplate> | ||
</ListView.ItemTemplate> | ||
</ListView> | ||
</Grid> | ||
</ContentDialog> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using CommunityToolkit.WinUI.UI; | ||
using Files.App.DataModels.NavigationControlItems; | ||
using Files.App.Extensions; | ||
using Files.App.Filesystem; | ||
using Files.App.ServicesImplementation; | ||
using Files.App.ViewModels.Dialogs; | ||
using Files.Backend.ViewModels.Dialogs; | ||
using Files.Shared.Enums; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Input; | ||
using System; | ||
using System.Diagnostics; | ||
using System.Threading.Tasks; | ||
using Windows.ApplicationModel.DataTransfer; | ||
|
||
namespace Files.App.Dialogs | ||
{ | ||
public sealed partial class ReorderSidebarItemsDialog : ContentDialog, IDialog<ReorderSidebarItemsDialogViewModel> | ||
{ | ||
public ReorderSidebarItemsDialogViewModel ViewModel | ||
{ | ||
get => (ReorderSidebarItemsDialogViewModel)DataContext; | ||
set => DataContext = value; | ||
} | ||
|
||
public ReorderSidebarItemsDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private async void MoveItem(object sender, PointerRoutedEventArgs e) | ||
{ | ||
var properties = e.GetCurrentPoint(null).Properties; | ||
var icon = sender as FontIcon; | ||
if (!properties.IsLeftButtonPressed) | ||
return; | ||
|
||
var navItem = icon?.FindAscendant<Grid>(); | ||
if (navItem is not null) | ||
await navItem.StartDragAsync(e.GetCurrentPoint(navItem)); | ||
} | ||
|
||
private void ListViewItem_DragStarting(object sender, DragStartingEventArgs e) | ||
{ | ||
if (sender is not Grid nav || nav.DataContext is not LocationItem) | ||
return; | ||
|
||
// Adding the original Location item dragged to the DragEvents data view | ||
e.Data.Properties.Add("sourceLocationItem", nav); | ||
e.AllowedOperations = DataPackageOperation.Move; | ||
} | ||
|
||
|
||
private void ListViewItem_DragOver(object sender, DragEventArgs e) | ||
{ | ||
if ((sender as Grid)?.DataContext is not LocationItem locationItem) | ||
return; | ||
var deferral = e.GetDeferral(); | ||
|
||
if ((e.DataView.Properties["sourceLocationItem"] as Grid)?.DataContext is LocationItem sourceLocationItem) | ||
{ | ||
DragOver_SetCaptions(sourceLocationItem, locationItem, e); | ||
} | ||
|
||
deferral.Complete(); | ||
} | ||
|
||
private void DragOver_SetCaptions(LocationItem senderLocationItem, LocationItem sourceLocationItem, DragEventArgs e) | ||
{ | ||
// If the location item is the same as the original dragged item | ||
if (sourceLocationItem.CompareTo(senderLocationItem) == 0) | ||
{ | ||
e.AcceptedOperation = DataPackageOperation.None; | ||
e.DragUIOverride.IsCaptionVisible = false; | ||
} | ||
else | ||
{ | ||
e.DragUIOverride.IsCaptionVisible = true; | ||
e.DragUIOverride.Caption = "MoveItemsDialogPrimaryButtonText".GetLocalizedResource(); | ||
e.AcceptedOperation = DataPackageOperation.Move; | ||
} | ||
} | ||
|
||
private void ListViewItem_Drop(object sender, DragEventArgs e) | ||
{ | ||
if (sender is not Grid navView || navView.DataContext is not LocationItem locationItem) | ||
return; | ||
|
||
if ((e.DataView.Properties["sourceLocationItem"] as Grid)?.DataContext is LocationItem sourceLocationItem) | ||
ViewModel.SidebarFavoriteItems.Move(ViewModel.SidebarFavoriteItems.IndexOf(sourceLocationItem), ViewModel.SidebarFavoriteItems.IndexOf(locationItem)); | ||
} | ||
|
||
public new async Task<DialogResult> ShowAsync() => (DialogResult)await base.ShowAsync(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,4 +129,4 @@ | |
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | ||
</Page> | ||
</ItemGroup> | ||
</Project> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.