Skip to content

Commit c39360f

Browse files
0x5bfayaira2
andauthored
Feature: Moved sidebar toggle button to the address toolbar (#15876)
Co-authored-by: Yair <[email protected]>
1 parent a476294 commit c39360f

File tree

9 files changed

+87
-70
lines changed

9 files changed

+87
-70
lines changed

src/Files.App.Controls/ThemedIcon/ThemedIcon.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
x:Name="PART_OutlinePath"
6363
Width="{TemplateBinding IconSize}"
6464
Height="{TemplateBinding IconSize}"
65-
Fill="{ThemeResource ThemedIconBaseBrush}"/>
65+
Fill="{ThemeResource ThemedIconBaseBrush}" />
6666
</Viewbox>
6767

6868
<!-- Layered (Rendered From Top to Bottom in The Visual Tree Order) -->

src/Files.App/UserControls/AddressToolbar.xaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<ResourceDictionary>
3636
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
3737
<SolidColorBrush x:Key="ButtonBackgroundDisabled" Color="Transparent" />
38+
<SolidColorBrush x:Key="AppBarButtonBackgroundPointerOver" Color="{ThemeResource ButtonBackgroundPointerOver}" />
3839

3940
<Style
4041
x:Key="AddressToolbarButtonStyle"
@@ -239,6 +240,28 @@
239240
Grid.Row="1"
240241
Orientation="Horizontal"
241242
Spacing="4">
243+
244+
<ToggleButton
245+
x:Name="SidebarPaneToggleButton"
246+
Width="36"
247+
Height="32"
248+
Padding="0"
249+
x:Load="{x:Bind IsSidebarPaneOpenToggleButtonVisible, Mode=OneWay}"
250+
AutomationProperties.Name="ToggleSidebarPane"
251+
Background="Transparent"
252+
BorderBrush="Transparent"
253+
IsChecked="{x:Bind MainPageViewModel.IsSidebarPaneOpen, Mode=TwoWay}"
254+
ToolTipService.ToolTip="{helpers:ResourceString Name=ToggleSidebar}">
255+
<AnimatedIcon Width="16">
256+
<AnimatedIcon.Source>
257+
<animatedvisuals:AnimatedGlobalNavigationButtonVisualSource />
258+
</AnimatedIcon.Source>
259+
<AnimatedIcon.FallbackIconSource>
260+
<SymbolIconSource Symbol="GlobalNavigationButton" />
261+
</AnimatedIcon.FallbackIconSource>
262+
</AnimatedIcon>
263+
</ToggleButton>
264+
242265
<Button
243266
x:Name="Back"
244267
x:FieldModifier="public"

src/Files.App/UserControls/AddressToolbar.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ namespace Files.App.UserControls
1515
public sealed partial class AddressToolbar : UserControl
1616
{
1717
private readonly IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
18+
private readonly MainPageViewModel MainPageViewModel = Ioc.Default.GetRequiredService<MainPageViewModel>();
1819
public ICommandManager Commands { get; } = Ioc.Default.GetRequiredService<ICommandManager>();
1920

21+
public static readonly DependencyProperty IsSidebarPaneOpenToggleButtonVisibleProperty =
22+
DependencyProperty.Register(nameof(IsSidebarPaneOpenToggleButtonVisible), typeof(bool), typeof(AddressToolbar), new(false));
23+
public bool IsSidebarPaneOpenToggleButtonVisible
24+
{
25+
get => (bool)GetValue(IsSidebarPaneOpenToggleButtonVisibleProperty);
26+
set => SetValue(IsSidebarPaneOpenToggleButtonVisibleProperty, value);
27+
}
28+
2029
// Using a DependencyProperty as the backing store for ShowOngoingTasks. This enables animation, styling, binding, etc...
2130
public static readonly DependencyProperty ShowOngoingTasksProperty =
2231
DependencyProperty.Register(nameof(ShowOngoingTasks), typeof(bool), typeof(AddressToolbar), new(null));

src/Files.App/UserControls/InnerNavigationToolbar.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,21 +540,21 @@
540540
Command="{x:Bind Commands.SelectAll}"
541541
KeyboardAcceleratorTextOverride="{x:Bind Commands.SelectAll.HotKeyText, Mode=OneWay}"
542542
Text="{x:Bind Commands.SelectAll.Label}"
543-
ThemedIconStyle ="{x:Bind Commands.SelectAll.ThemedIconStyle}" />
543+
ThemedIconStyle="{x:Bind Commands.SelectAll.ThemedIconStyle}" />
544544
<local:MenuFlyoutItemWithThemedIcon
545545
x:Name="InvertSelectionMFI"
546546
AccessKey="I"
547547
Command="{x:Bind Commands.InvertSelection}"
548548
KeyboardAcceleratorTextOverride="{x:Bind Commands.InvertSelection.HotKeyText, Mode=OneWay}"
549549
Text="{x:Bind Commands.InvertSelection.Label}"
550-
ThemedIconStyle ="{x:Bind Commands.InvertSelection.ThemedIconStyle}" />
550+
ThemedIconStyle="{x:Bind Commands.InvertSelection.ThemedIconStyle}" />
551551
<local:MenuFlyoutItemWithThemedIcon
552552
x:Name="ClearSelectionMFI"
553553
AccessKey="C"
554554
Command="{x:Bind Commands.ClearSelection}"
555555
KeyboardAcceleratorTextOverride="{x:Bind Commands.ClearSelection.HotKeyText, Mode=OneWay}"
556556
Text="{x:Bind Commands.ClearSelection.Label}"
557-
ThemedIconStyle ="{x:Bind Commands.ClearSelection.ThemedIconStyle}" />
557+
ThemedIconStyle="{x:Bind Commands.ClearSelection.ThemedIconStyle}" />
558558
</MenuFlyout>
559559
</AppBarButton.Flyout>
560560

src/Files.App/UserControls/StatusBar.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
Command="{x:Bind Commands.GitPull}"
229229
IsEnabled="{x:Bind Commands.GitPull.IsExecutable, Mode=OneWay}"
230230
Text="{x:Bind Commands.GitPull.Label}"
231-
ThemedIconStyle ="{StaticResource App.ThemedIcons.Git.Pull}"
231+
ThemedIconStyle="{StaticResource App.ThemedIcons.Git.Pull}"
232232
ToolTipService.ToolTip="{x:Bind Commands.GitPull.LabelWithHotKey, Mode=OneWay}" />
233233

234234
<!-- Push Button -->
@@ -237,7 +237,7 @@
237237
Command="{x:Bind Commands.GitPush}"
238238
IsEnabled="{x:Bind Commands.GitPush.IsExecutable, Mode=OneWay}"
239239
Text="{x:Bind Commands.GitPush.Label}"
240-
ThemedIconStyle ="{StaticResource App.ThemedIcons.Git.Push}"
240+
ThemedIconStyle="{StaticResource App.ThemedIcons.Git.Push}"
241241
ToolTipService.ToolTip="{x:Bind Commands.GitPush.LabelWithHotKey, Mode=OneWay}" />
242242

243243
<!-- Sync Button -->
@@ -246,7 +246,7 @@
246246
Command="{x:Bind Commands.GitSync}"
247247
IsEnabled="{x:Bind Commands.GitSync.IsExecutable, Mode=OneWay}"
248248
Text="{x:Bind Commands.GitSync.Label}"
249-
ThemedIconStyle ="{StaticResource App.ThemedIcons.Git.Sync}"
249+
ThemedIconStyle="{StaticResource App.ThemedIcons.Git.Sync}"
250250
ToolTipService.ToolTip="{x:Bind Commands.GitSync.LabelWithHotKey, Mode=OneWay}" />
251251
</MenuFlyout>
252252
</Button.Flyout>

src/Files.App/UserControls/TabBar/TabBar.xaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,23 @@
122122
Command="{x:Bind Commands.NewWindow}"
123123
KeyboardAcceleratorTextOverride="{x:Bind Commands.NewWindow.HotKeyText, Mode=OneWay}"
124124
Text="{x:Bind Commands.NewWindow.Label}"
125-
ThemedIconStyle ="{x:Bind Commands.NewWindow.ThemedIconStyle}" />
125+
ThemedIconStyle="{x:Bind Commands.NewWindow.ThemedIconStyle}" />
126126

127127
<!-- Enter Compact Overlay -->
128128
<uc:MenuFlyoutItemWithThemedIcon
129129
x:Name="EnterCompactOverlayTabActionButton"
130130
x:Load="{x:Bind Commands.EnterCompactOverlay.IsExecutable, Mode=OneWay}"
131131
Command="{x:Bind Commands.EnterCompactOverlay}"
132132
Text="{x:Bind Commands.EnterCompactOverlay.Label}"
133-
ThemedIconStyle ="{x:Bind Commands.EnterCompactOverlay.ThemedIconStyle}" />
133+
ThemedIconStyle="{x:Bind Commands.EnterCompactOverlay.ThemedIconStyle}" />
134134

135135
<!-- Exit Compact Overlay -->
136136
<uc:MenuFlyoutItemWithThemedIcon
137137
x:Name="ExitCompactOverlayTabActionButton"
138138
x:Load="{x:Bind Commands.ExitCompactOverlay.IsExecutable, Mode=OneWay}"
139139
Command="{x:Bind Commands.ExitCompactOverlay}"
140140
Text="{x:Bind Commands.ExitCompactOverlay.Label}"
141-
ThemedIconStyle ="{x:Bind Commands.ExitCompactOverlay.ThemedIconStyle}" />
141+
ThemedIconStyle="{x:Bind Commands.ExitCompactOverlay.ThemedIconStyle}" />
142142

143143
<!-- Add Pane -->
144144
<MenuFlyoutSubItem
@@ -152,15 +152,15 @@
152152
Command="{x:Bind Commands.AddHorizontalPane, Mode=OneWay}"
153153
KeyboardAcceleratorTextOverride="{x:Bind Commands.AddHorizontalPane.HotKeyText, Mode=OneWay}"
154154
Text="{x:Bind Commands.AddHorizontalPane.Label}"
155-
ThemedIconStyle ="{x:Bind Commands.AddHorizontalPane.ThemedIconStyle}" />
155+
ThemedIconStyle="{x:Bind Commands.AddHorizontalPane.ThemedIconStyle}" />
156156

157157
<!-- Vertical -->
158158
<uc:MenuFlyoutItemWithThemedIcon
159159
x:Name="AddVerticalPaneTabActionButton"
160160
Command="{x:Bind Commands.AddVerticalPane, Mode=OneWay}"
161161
KeyboardAcceleratorTextOverride="{x:Bind Commands.AddVerticalPane.HotKeyText, Mode=OneWay}"
162162
Text="{x:Bind Commands.AddVerticalPane.Label}"
163-
ThemedIconStyle ="{x:Bind Commands.AddVerticalPane.ThemedIconStyle}" />
163+
ThemedIconStyle="{x:Bind Commands.AddVerticalPane.ThemedIconStyle}" />
164164
</MenuFlyoutSubItem.Items>
165165
</MenuFlyoutSubItem>
166166

@@ -177,7 +177,7 @@
177177
IsChecked="{x:Bind Commands.ArrangePanesHorizontally.IsOn, Mode=OneWay}"
178178
KeyboardAcceleratorTextOverride="{x:Bind Commands.ArrangePanesHorizontally.HotKeyText, Mode=OneWay}"
179179
Text="{x:Bind Commands.ArrangePanesHorizontally.Label}"
180-
ThemedIconStyle ="{x:Bind Commands.ArrangePanesHorizontally.ThemedIconStyle}" />
180+
ThemedIconStyle="{x:Bind Commands.ArrangePanesHorizontally.ThemedIconStyle}" />
181181

182182
<!-- Vertical -->
183183
<uc:ToggleMenuFlyoutItemWithThemedIcon
@@ -186,7 +186,7 @@
186186
IsChecked="{x:Bind Commands.ArrangePanesVertically.IsOn, Mode=OneWay}"
187187
KeyboardAcceleratorTextOverride="{x:Bind Commands.ArrangePanesVertically.HotKeyText, Mode=OneWay}"
188188
Text="{x:Bind Commands.ArrangePanesVertically.Label}"
189-
ThemedIconStyle ="{x:Bind Commands.ArrangePanesVertically.ThemedIconStyle}" />
189+
ThemedIconStyle="{x:Bind Commands.ArrangePanesVertically.ThemedIconStyle}" />
190190
</MenuFlyoutSubItem.Items>
191191
</MenuFlyoutSubItem>
192192

@@ -197,7 +197,7 @@
197197
Command="{x:Bind Commands.CloseActivePane}"
198198
KeyboardAcceleratorTextOverride="{x:Bind Commands.CloseActivePane.HotKeyText, Mode=OneWay}"
199199
Text="{x:Bind Commands.CloseActivePane.Label}"
200-
ThemedIconStyle ="{x:Bind Commands.CloseActivePane.ThemedIconStyle}" />
200+
ThemedIconStyle="{x:Bind Commands.CloseActivePane.ThemedIconStyle}" />
201201

202202
</MenuFlyout>
203203
</Button.Flyout>

src/Files.App/ViewModels/MainPageViewModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ public sealed class MainPageViewModel : ObservableObject
3333

3434
public ITabBar? MultitaskingControl { get; set; }
3535

36+
private bool _IsSidebarPaneOpen;
37+
public bool IsSidebarPaneOpen
38+
{
39+
get => _IsSidebarPaneOpen;
40+
set => SetProperty(ref _IsSidebarPaneOpen, value);
41+
}
42+
43+
private bool _IsSidebarPaneOpenToggleButtonVisible;
44+
public bool IsSidebarPaneOpenToggleButtonVisible
45+
{
46+
get => _IsSidebarPaneOpenToggleButtonVisible;
47+
set => SetProperty(ref _IsSidebarPaneOpenToggleButtonVisible, value);
48+
}
49+
3650
private TabBarItem? selectedTabItem;
3751
public TabBarItem? SelectedTabItem
3852
{

src/Files.App/Views/MainPage.xaml

Lines changed: 25 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -119,67 +119,50 @@
119119

120120
<Grid>
121121
<Grid.RowDefinitions>
122+
<RowDefinition Height="Auto" />
122123
<RowDefinition Height="Auto" />
123124
<RowDefinition Height="*" />
124125
</Grid.RowDefinitions>
125126

126127
<!-- Background Image -->
127128
<Image
128-
Grid.RowSpan="2"
129+
Grid.RowSpan="3"
129130
HorizontalAlignment="{x:Bind ViewModel.AppThemeBackgroundImageHorizontalAlignment, Mode=OneWay}"
130131
VerticalAlignment="{x:Bind ViewModel.AppThemeBackgroundImageVerticalAlignment, Mode=OneWay}"
131132
Opacity="{x:Bind ViewModel.AppThemeBackgroundImageOpacity, Mode=OneWay}"
132133
Source="{x:Bind ViewModel.AppThemeBackgroundImageSource, Mode=OneWay}"
133134
Stretch="{x:Bind ViewModel.AppThemeBackgroundImageFit, Mode=OneWay}" />
134135

135-
<!-- Header Area -->
136-
<Grid>
137-
<Grid.RowDefinitions>
138-
<RowDefinition Height="Auto" />
139-
<RowDefinition Height="Auto" />
140-
</Grid.RowDefinitions>
141-
142-
<!-- Tab Control -->
143-
<tabbar:TabBar
144-
x:Name="TabControl"
145-
HorizontalContentAlignment="Stretch"
146-
x:Load="False"
147-
Loaded="HorizontalMultitaskingControl_Loaded"
148-
TabIndex="0" />
149-
150-
<!-- Address Bar -->
151-
<uc:AddressToolbar
152-
x:Name="NavToolbar"
153-
Grid.Row="1"
154-
HorizontalAlignment="Stretch"
155-
HorizontalContentAlignment="Stretch"
156-
x:Load="False"
157-
Loaded="NavToolbar_Loaded"
158-
OngoingTasksViewModel="{x:Bind OngoingTasksViewModel}"
159-
ShowOngoingTasks="True"
160-
ShowSearchBox="True"
161-
ShowSettingsButton="{x:Bind WindowContext.IsCompactOverlay, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
162-
TabIndex="1" />
136+
<!-- Tab Bar -->
137+
<tabbar:TabBar
138+
x:Name="TabControl"
139+
HorizontalContentAlignment="Stretch"
140+
x:Load="False"
141+
Loaded="HorizontalMultitaskingControl_Loaded"
142+
TabIndex="0" />
163143

164-
<Button
165-
x:Name="TogglePaneButton"
166-
Margin="2,2,0,0"
167-
HorizontalAlignment="Left"
168-
VerticalAlignment="Top"
169-
Background="Transparent"
170-
BorderThickness="0"
171-
Click="TogglePaneButton_Click"
172-
Style="{StaticResource PaneToggleButtonStyle}"
173-
Visibility="Collapsed" />
174-
</Grid>
144+
<!-- Address Bar -->
145+
<uc:AddressToolbar
146+
x:Name="NavToolbar"
147+
Grid.Row="1"
148+
HorizontalAlignment="Stretch"
149+
HorizontalContentAlignment="Stretch"
150+
x:Load="False"
151+
Loaded="NavToolbar_Loaded"
152+
OngoingTasksViewModel="{x:Bind OngoingTasksViewModel}"
153+
ShowOngoingTasks="True"
154+
ShowSearchBox="True"
155+
ShowSettingsButton="{x:Bind WindowContext.IsCompactOverlay, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
156+
TabIndex="1" />
175157

176158
<!-- Content Area -->
177159
<sidebar:SidebarView
178160
x:Name="SidebarControl"
179-
Grid.Row="1"
161+
Grid.Row="2"
180162
HorizontalAlignment="Stretch"
181163
HorizontalContentAlignment="Stretch"
182164
DisplayMode="{x:Bind SidebarAdaptiveViewModel.SidebarDisplayMode, Mode=TwoWay}"
165+
IsPaneOpen="{x:Bind ViewModel.IsSidebarPaneOpen, Mode=TwoWay}"
183166
Loaded="SidebarControl_Loaded"
184167
MenuItemsSource="{x:Bind SidebarAdaptiveViewModel.SidebarItems, Mode=OneWay}"
185168
OpenPaneLength="{x:Bind UserSettingsService.AppearanceSettingsService.SidebarWidth, Mode=TwoWay}"
@@ -289,9 +272,8 @@
289272
<AdaptiveTrigger MinWindowWidth="0" />
290273
</VisualState.StateTriggers>
291274
<VisualState.Setters>
292-
<Setter Target="TabControl.Margin" Value="48,0,0,0" />
293275
<Setter Target="SidebarControl.DisplayMode" Value="Minimal" />
294-
<Setter Target="TogglePaneButton.Visibility" Value="Visible" />
276+
<Setter Target="NavToolbar.IsSidebarPaneOpenToggleButtonVisible" Value="True" />
295277
</VisualState.Setters>
296278
</VisualState>
297279
<VisualState x:Name="MinimalSidebarState">

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public sealed partial class MainPage : Page
3131
public MainPageViewModel ViewModel { get; }
3232
public StatusCenterViewModel OngoingTasksViewModel { get; }
3333

34-
public static AppModel AppModel
35-
=> App.AppModel;
36-
3734
private bool keyReleased = true;
3835

3936
private DispatcherQueueTimer _updateDateDisplayTimer;
@@ -108,7 +105,7 @@ private async Task AppRunningAsAdminPromptAsync()
108105
UserSettingsService.ApplicationSettingsService.ShowRunningAsAdminPrompt = false;
109106
}
110107

111-
// WINUI3
108+
// WINUI3
112109
private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
113110
{
114111
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8))
@@ -489,13 +486,5 @@ private void PaneSplitter_ManipulationStarted(object sender, ManipulationStarted
489486
this.ChangeCursor(InputSystemCursor.Create(PaneSplitter.GripperCursor == GridSplitter.GripperCursorType.SizeWestEast ?
490487
InputSystemCursorShape.SizeWestEast : InputSystemCursorShape.SizeNorthSouth));
491488
}
492-
493-
private void TogglePaneButton_Click(object sender, RoutedEventArgs e)
494-
{
495-
if (SidebarControl.DisplayMode == SidebarDisplayMode.Minimal)
496-
{
497-
SidebarControl.IsPaneOpen = !SidebarControl.IsPaneOpen;
498-
}
499-
}
500489
}
501490
}

0 commit comments

Comments
 (0)