forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatusBarControl.xaml
359 lines (335 loc) · 13.7 KB
/
StatusBarControl.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. -->
<UserControl
x:Class="Files.App.UserControls.StatusBarControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Files.App.Converters"
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:usercontrols="using:Files.App.UserControls"
d:DesignHeight="32"
d:DesignWidth="400"
mc:Ignorable="d">
<UserControl.Resources>
<converters:NullToTrueConverter x:Key="NullToFalseConverter" Inverse="True" />
<converters:NullToVisibilityCollapsedConverter x:Key="NullToVisibilityCollapsedConverter" />
<Style x:Key="Local.RadioButtonStyle" TargetType="RadioButton">
<Setter Property="Foreground" Value="{ThemeResource TextFillColorSecondaryBrush}" />
<Setter Property="BorderBrush" Value="{ThemeResource RadioButtonBorderBrush}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Grid x:Name="RootGrid" Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="4" />
</Grid.RowDefinitions>
<ContentPresenter
x:Name="ContentPresenter"
Grid.Row="0"
Padding="12,4,12,4"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
Foreground="{TemplateBinding Foreground}"
TextWrapping="Wrap" />
<Border
x:Name="SelectionPill"
Grid.Row="1"
Height="2"
Margin="16,0,16,0"
Background="Transparent"
CornerRadius="2" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorPrimaryBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorPrimaryBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorDisabledBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SelectionPill" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemAccentColor}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextFillColorPrimaryBrush}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked" />
<VisualState x:Name="Indeterminate" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid Padding="8,0" ColumnSpacing="4">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel
Grid.Column="0"
Height="32"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Orientation="Horizontal"
Spacing="8"
Visibility="{x:Bind ShowInfoText, Mode=OneWay}">
<TextBlock
x:Name="DirectoryItemCount"
VerticalAlignment="Center"
x:Load="{x:Bind ShowInfoText, Mode=OneWay}"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind DirectoryPropertiesViewModel.DirectoryItemCount, Mode=OneWay}" />
<!-- Divider -->
<Border
x:Name="SelectedItemsCountDivider"
Width="1"
Height="18"
x:Load="{x:Bind SelectedItemsPropertiesViewModel.IsItemSelected, Mode=OneWay}"
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
<!-- Selected Items Count -->
<TextBlock
x:Name="SelectedItemsCountString"
VerticalAlignment="Center"
x:Load="{x:Bind SelectedItemsPropertiesViewModel.IsItemSelected, Mode=OneWay}"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind SelectedItemsPropertiesViewModel.SelectedItemsCountString, Mode=OneWay}" />
<!-- Divider -->
<Border
x:Name="ItemSizeDivider"
Width="1"
Height="18"
x:Load="{x:Bind SelectedItemsPropertiesViewModel.ItemSizeVisibility, Mode=OneWay}"
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
<!-- Item Size -->
<TextBlock
x:Name="ItemSize"
VerticalAlignment="Center"
x:Load="{x:Bind SelectedItemsPropertiesViewModel.ItemSizeVisibility, Mode=OneWay}"
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{x:Bind SelectedItemsPropertiesViewModel.ItemSize, Mode=OneWay}" />
</StackPanel>
<StackPanel
x:Name="GitActionsPanel"
Grid.Column="1"
VerticalAlignment="Center"
x:Load="{x:Bind DirectoryPropertiesViewModel.GitBranchDisplayName, Mode=OneWay, Converter={StaticResource NullToFalseConverter}, FallbackValue=False}"
Orientation="Horizontal"
Spacing="4">
<!-- Open in IDE Button -->
<Button
x:Name="OpenInIDEButton"
Height="24"
Padding="8,0,8,0"
VerticalAlignment="Center"
x:Load="{x:Bind Commands.OpenInVSCode.IsExecutable, Mode=OneWay}"
Background="Transparent"
BorderBrush="Transparent">
<Button.Content>
<StackPanel Orientation="Horizontal" Spacing="8">
<usercontrols:OpacityIcon
Width="16"
Height="16"
Style="{StaticResource ColorIconOpen}" />
<TextBlock Text="{helpers:ResourceString Name=Open}" />
</StackPanel>
</Button.Content>
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem
x:Name="OpenFolderInVSCodeButton"
Command="{x:Bind Commands.OpenInVSCode}"
KeyboardAcceleratorTextOverride="{x:Bind Commands.OpenInVSCode.HotKeys, Mode=OneWay}"
Text="{x:Bind Commands.OpenInVSCode.Label, Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind Commands.OpenInVSCode.LabelWithHotKey, Mode=OneWay}" />
<MenuFlyoutItem
x:Name="OpenRepoInVSCodeButton"
Command="{x:Bind Commands.OpenRepoInVSCode}"
KeyboardAcceleratorTextOverride="{x:Bind Commands.OpenRepoInVSCode.HotKeys, Mode=OneWay}"
Text="{x:Bind Commands.OpenRepoInVSCode.Label, Mode=OneWay}"
ToolTipService.ToolTip="{x:Bind Commands.OpenRepoInVSCode.LabelWithHotKey, Mode=OneWay}" />
</MenuFlyout>
</Button.Flyout>
</Button>
<!-- Divider -->
<Border
x:Name="VSCodeDivider"
Width="1"
Height="18"
x:Load="{x:Bind Commands.OpenInVSCode.IsExecutable, Mode=OneWay}"
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
<Button
x:Name="GitNetworkActions"
Height="24"
Padding="8,0,8,0"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="Transparent"
ToolTipService.ToolTip="{x:Bind DirectoryPropertiesViewModel.ExtendedStatusInfo, Mode=OneWay}">
<Button.Flyout>
<MenuFlyout>
<!-- Pull Button -->
<MenuFlyoutItem
x:Name="GitPullButton"
Command="{x:Bind Commands.GitPull}"
IsEnabled="{x:Bind Commands.GitPull.IsExecutable, Mode=OneWay}"
Text="{x:Bind Commands.GitPull.Label}"
ToolTipService.ToolTip="{x:Bind Commands.GitPull.LabelWithHotKey, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon FontSize="12" Glyph="{x:Bind Commands.GitPull.Glyph.BaseGlyph}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<!-- Push Button -->
<MenuFlyoutItem
x:Name="GitPushButton"
Command="{x:Bind Commands.GitPush}"
IsEnabled="{x:Bind Commands.GitPush.IsExecutable, Mode=OneWay}"
Text="{x:Bind Commands.GitPush.Label}"
ToolTipService.ToolTip="{x:Bind Commands.GitPush.LabelWithHotKey, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon FontSize="12" Glyph="{x:Bind Commands.GitPush.Glyph.BaseGlyph}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<!-- Sync Button -->
<MenuFlyoutItem
x:Name="GitSyncButton"
Command="{x:Bind Commands.GitSync}"
IsEnabled="{x:Bind Commands.GitSync.IsExecutable, Mode=OneWay}"
Text="{x:Bind Commands.GitSync.Label}"
ToolTipService.ToolTip="{x:Bind Commands.GitSync.LabelWithHotKey, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon FontSize="12" Glyph="{x:Bind Commands.GitSync.Glyph.BaseGlyph}" />
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyout>
</Button.Flyout>
<StackPanel Orientation="Horizontal" Spacing="8">
<usercontrols:OpacityIcon
Width="16"
Height="16"
Style="{StaticResource ColorIconGitGeneral}" />
<!-- Outgoing / Incoming commits -->
<TextBlock Text="{x:Bind DirectoryPropertiesViewModel.StatusInfo, Mode=OneWay}" />
</StackPanel>
</Button>
<!-- Divider -->
<Border
Width="1"
Height="18"
Background="{ThemeResource DividerStrokeColorDefaultBrush}" />
</StackPanel>
<!-- Use visibility because it causes a crash to use a TwoWay x:Bind on an element that is inside an element with x:Load (#12589, #12599) -->
<Button
x:Name="GitBranch"
Grid.Column="2"
Height="24"
Padding="8,0,8,0"
Background="Transparent"
BorderBrush="Transparent"
ToolTipService.ToolTip="{helpers:ResourceString Name=ManageBranches}"
Visibility="{x:Bind DirectoryPropertiesViewModel.GitBranchDisplayName, Mode=OneWay, Converter={StaticResource NullToVisibilityCollapsedConverter}, FallbackValue=Collapsed}">
<Button.Content>
<StackPanel Orientation="Horizontal" Spacing="8">
<usercontrols:OpacityIcon
Width="16"
Height="16"
Style="{StaticResource ColorIconGitBranches}" />
<!-- Branch Name -->
<TextBlock Text="{x:Bind DirectoryPropertiesViewModel.GitBranchDisplayName, Mode=OneWay}" />
</StackPanel>
</Button.Content>
<Button.Flyout>
<Flyout x:Name="BranchesFlyout" Opening="BranchesFlyout_Opening">
<Grid
Width="300"
Height="340"
Margin="-16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- Header -->
<Grid
Grid.Row="0"
Padding="4,8,8,8"
Background="{ThemeResource AcrylicBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="0,0,0,1">
<!-- Locals and Remotes -->
<StackPanel
Grid.Row="1"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<RadioButton
Content="{helpers:ResourceString Name=Locals}"
IsChecked="{x:Bind DirectoryPropertiesViewModel.ShowLocals, Mode=TwoWay}"
Style="{StaticResource Local.RadioButtonStyle}" />
<RadioButton Content="{helpers:ResourceString Name=Remotes}" Style="{StaticResource Local.RadioButtonStyle}" />
</StackPanel>
<!-- New Branch Button -->
<Button
x:Name="NewBranchButton"
Height="24"
Padding="8,0"
HorizontalAlignment="Right"
Command="{x:Bind DirectoryPropertiesViewModel.NewBranchCommand, Mode=OneWay}"
Content="{helpers:ResourceString Name=CreateBranch}"
FontSize="12"
ToolTipService.ToolTip="{helpers:ResourceString Name=CreateBranch}" />
</Grid>
<!-- Branches List -->
<ListView
x:Name="BranchesList"
Grid.Row="1"
Padding="4"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
IsItemClickEnabled="True"
ItemClick="BranchesList_ItemClick"
ItemsSource="{x:Bind DirectoryPropertiesViewModel.BranchesNames, Mode=OneWay}"
SelectedIndex="{x:Bind DirectoryPropertiesViewModel.SelectedBranchIndex, Mode=TwoWay}"
SelectionMode="Single" />
</Grid>
</Flyout>
</Button.Flyout>
</Button>
</Grid>
</UserControl>