Skip to content

Commit 206bfc6

Browse files
committed
Update
1 parent 6c37e2e commit 206bfc6

File tree

15 files changed

+409
-93
lines changed

15 files changed

+409
-93
lines changed

src/Files.App.Controls/Breadcrumb/Breadcrumb.xaml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using CommunityToolkit.WinUI;
5+
using Microsoft.UI;
6+
using Microsoft.UI.Xaml;
7+
using Microsoft.UI.Xaml.Controls;
8+
using Microsoft.UI.Xaml.Input;
9+
using Microsoft.UI.Xaml.Markup;
10+
using Microsoft.UI.Xaml.Media;
11+
using Microsoft.UI.Xaml.Shapes;
12+
13+
namespace Files.App.Controls
14+
{
15+
public sealed partial class BreadcrumbBar : Control
16+
{
17+
[GeneratedDependencyProperty]
18+
public partial object? ItemsSource { get; set; }
19+
20+
[GeneratedDependencyProperty]
21+
public partial object? ItemTemplate { get; set; }
22+
23+
partial void OnItemsSourceChanged(object? newValue)
24+
{
25+
}
26+
27+
partial void OnItemTemplateChanged(object? newValue)
28+
{
29+
}
30+
}
31+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using CommunityToolkit.WinUI;
5+
using Microsoft.UI;
6+
using Microsoft.UI.Xaml;
7+
using Microsoft.UI.Xaml.Controls;
8+
using Microsoft.UI.Xaml.Input;
9+
using Microsoft.UI.Xaml.Markup;
10+
using Microsoft.UI.Xaml.Media;
11+
using Microsoft.UI.Xaml.Shapes;
12+
using Windows.Foundation;
13+
14+
namespace Files.App.Controls
15+
{
16+
// Template parts
17+
[TemplatePart(Name = "PART_ItemsRepeater", Type = typeof(ItemsRepeater))]
18+
public sealed partial class BreadcrumbBar : Control
19+
{
20+
// Constants
21+
22+
private const string _itemsRepeaterName = "PART_RootItemsRepeater";
23+
24+
// Fields
25+
26+
private ItemsRepeater _itemsRepeater = null!;
27+
private BreadcrumbBarLayout _itemsRepeaterLayout = null!;
28+
29+
// Events
30+
31+
/// <summary>
32+
/// Occurs when an item is clicked in this <see cref="BreadcrumbBar"/> instance.
33+
/// </summary>
34+
public event TypedEventHandler<BreadcrumbBar, BreadcrumbBarItemClickedEventArgs>? ItemClicked;
35+
36+
// Constructor
37+
38+
public BreadcrumbBar()
39+
{
40+
DefaultStyleKey = typeof(BreadcrumbBar);
41+
42+
_itemsRepeaterLayout = new(this);
43+
}
44+
45+
// Methods
46+
47+
protected override void OnApplyTemplate()
48+
{
49+
_itemsRepeater = GetTemplateChild(_itemsRepeaterName) as ItemsRepeater
50+
?? throw new MissingFieldException($"Could not find {_itemsRepeaterName} in the given {nameof(BreadcrumbBar)}'s style.");
51+
52+
//_itemsRepeater.Layout = _itemsRepeaterLayout;
53+
54+
if (ItemsSource is not null)
55+
_itemsRepeater.ItemsSource = ItemsSource;
56+
57+
if (ItemTemplate is not null)
58+
_itemsRepeater.ItemTemplate = ItemTemplate;
59+
60+
base.OnApplyTemplate();
61+
}
62+
}
63+
}
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
2+
<ResourceDictionary
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Files.App.Controls">
6+
7+
<Style BasedOn="{StaticResource DefaultBreadcrumbBarStyle}" TargetType="local:BreadcrumbBar" />
8+
<Style BasedOn="{StaticResource DefaultBreadcrumbBarItemStyle}" TargetType="local:BreadcrumbBarItem" />
9+
10+
<Style x:Key="DefaultBreadcrumbBarStyle" TargetType="local:BreadcrumbBar">
11+
<Setter Property="AutomationProperties.LandmarkType" Value="Navigation" />
12+
<Setter Property="IsTabStop" Value="False" />
13+
<Setter Property="Template">
14+
<Setter.Value>
15+
<ControlTemplate TargetType="local:BreadcrumbBar">
16+
<ItemsRepeater x:Name="PART_RootItemsRepeater">
17+
<ItemsRepeater.Layout>
18+
<StackLayout Orientation="Horizontal" />
19+
</ItemsRepeater.Layout>
20+
</ItemsRepeater>
21+
</ControlTemplate>
22+
</Setter.Value>
23+
</Setter>
24+
</Style>
25+
26+
<Style x:Key="DefaultBreadcrumbBarItemStyle" TargetType="local:BreadcrumbBarItem">
27+
<Setter Property="Background" Value="{ThemeResource BreadcrumbBarBackgroundBrush}" />
28+
<Setter Property="BorderBrush" Value="{ThemeResource BreadcrumbBarBorderBrush}" />
29+
<Setter Property="FocusVisualMargin" Value="1" />
30+
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
31+
<Setter Property="FontSize" Value="{ThemeResource BreadcrumbBarItemThemeFontSize}" />
32+
<Setter Property="FontWeight" Value="{ThemeResource BreadcrumbBarItemFontWeight}" />
33+
<Setter Property="Foreground" Value="{ThemeResource BreadcrumbBarForegroundBrush}" />
34+
<Setter Property="HorizontalAlignment" Value="Stretch" />
35+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
36+
<Setter Property="IsTabStop" Value="True" />
37+
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
38+
<Setter Property="VerticalAlignment" Value="Center" />
39+
<Setter Property="VerticalContentAlignment" Value="Center" />
40+
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
41+
<Setter Property="Template">
42+
<Setter.Value>
43+
<ControlTemplate TargetType="local:BreadcrumbBarItem">
44+
<Grid x:Name="PART_LayoutRoot" CornerRadius="{TemplateBinding CornerRadius}">
45+
<Grid.ColumnDefinitions>
46+
<ColumnDefinition x:Name="PART_ContentColumn" Width="Auto" />
47+
<ColumnDefinition x:Name="PART_ChevronColumn" Width="Auto" />
48+
</Grid.ColumnDefinitions>
49+
50+
<!-- Clickable Area -->
51+
<Button
52+
x:Name="PART_ItemButton"
53+
AutomationProperties.AccessibilityView="Raw"
54+
Background="{TemplateBinding Background}"
55+
BorderBrush="{TemplateBinding BorderBrush}"
56+
BorderThickness="{TemplateBinding BorderThickness}"
57+
Control.IsTemplateFocusTarget="True"
58+
CornerRadius="{TemplateBinding CornerRadius}"
59+
FocusVisualMargin="-3"
60+
IsTabStop="False">
61+
<Grid AutomationProperties.AccessibilityView="Raw">
62+
<ContentPresenter
63+
x:Name="PART_ItemContentPresenter"
64+
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
65+
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
66+
AutomationProperties.AccessibilityView="Raw"
67+
Content="{TemplateBinding Content}"
68+
ContentTemplate="{TemplateBinding ContentTemplate}"
69+
ContentTransitions="{TemplateBinding ContentTransitions}"
70+
FontFamily="{TemplateBinding FontFamily}"
71+
FontSize="{TemplateBinding FontSize}"
72+
FontWeight="{TemplateBinding FontWeight}" />
73+
<TextBlock
74+
x:Name="PART_EllipsisTextBlock"
75+
Padding="3"
76+
VerticalAlignment="Stretch"
77+
AutomationProperties.AccessibilityView="Raw"
78+
FontFamily="{ThemeResource SymbolThemeFontFamily}"
79+
FontSize="{TemplateBinding FontSize}"
80+
IsTextScaleFactorEnabled="False"
81+
Text="&#xE712;"
82+
Visibility="Collapsed" />
83+
</Grid>
84+
</Button>
85+
86+
<!-- Chevron -->
87+
<TextBlock
88+
x:Name="PART_ChevronTextBlock"
89+
Grid.Column="1"
90+
Padding="{ThemeResource BreadcrumbBarChevronPadding}"
91+
HorizontalAlignment="Center"
92+
VerticalAlignment="Center"
93+
AutomationProperties.AccessibilityView="Raw"
94+
FontFamily="{ThemeResource SymbolThemeFontFamily}"
95+
FontSize="{ThemeResource BreadcrumbBarChevronFontSize}"
96+
Foreground="{ThemeResource BreadcrumbBarNormalForegroundBrush}"
97+
IsTextScaleFactorEnabled="False"
98+
Text="&#xE76C;" />
99+
100+
<VisualStateManager.VisualStateGroups>
101+
<VisualStateGroup x:Name="ItemTypeStates">
102+
<VisualState x:Name="DefaultItemType" />
103+
<VisualState x:Name="LastItemType">
104+
<VisualState.Setters>
105+
<Setter Target="PART_ItemButton.Visibility" Value="Collapsed" />
106+
</VisualState.Setters>
107+
</VisualState>
108+
<!--<VisualState x:Name="CollapsedItemType">
109+
<VisualState.Setters>
110+
</VisualState.Setters>
111+
</VisualState>-->
112+
</VisualStateGroup>
113+
</VisualStateManager.VisualStateGroups>
114+
</Grid>
115+
</ControlTemplate>
116+
</Setter.Value>
117+
</Setter>
118+
</Style>
119+
120+
<Style x:Key="DefaultBreadcrumbEllipsisFlyoutStyle" TargetType="FlyoutPresenter">
121+
<Setter Property="Background" Value="{ThemeResource BreadcrumbBarEllipsisFlyoutPresenterBackground}" />
122+
<Setter Property="BorderBrush" Value="{ThemeResource BreadcrumbBarEllipsisFlyoutPresenterBorderBrush}" />
123+
<Setter Property="BorderThickness" Value="{ThemeResource BreadcrumbBarEllipsisFlyoutPresenterBorderThemeThickness}" />
124+
<Setter Property="Padding" Value="0,2" />
125+
<Setter Property="ScrollViewer.HorizontalScrollMode" Value="Disabled" />
126+
<Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
127+
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
128+
<Setter Property="ScrollViewer.IsHorizontalRailEnabled" Value="False" />
129+
<Setter Property="ScrollViewer.IsVerticalRailEnabled" Value="False" />
130+
<Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
131+
<Setter Property="MaxWidth" Value="{ThemeResource FlyoutThemeMaxWidth}" />
132+
<Setter Property="MinHeight" Value="40" />
133+
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
134+
<Setter Property="Template">
135+
<Setter.Value>
136+
<ControlTemplate TargetType="FlyoutPresenter">
137+
<Grid
138+
Background="{TemplateBinding Background}"
139+
BackgroundSizing="InnerBorderEdge"
140+
CornerRadius="{TemplateBinding CornerRadius}">
141+
<ScrollViewer
142+
x:Name="FlyoutPresenterScrollViewer"
143+
Margin="{TemplateBinding Padding}"
144+
AutomationProperties.AccessibilityView="Raw"
145+
Content="{TemplateBinding Content}"
146+
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
147+
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
148+
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
149+
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
150+
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
151+
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
152+
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}" />
153+
<Border
154+
x:Name="FlyoutPresenterBorder"
155+
BorderBrush="{TemplateBinding BorderBrush}"
156+
BorderThickness="{TemplateBinding BorderThickness}"
157+
CornerRadius="{TemplateBinding CornerRadius}" />
158+
</Grid>
159+
</ControlTemplate>
160+
</Setter.Value>
161+
</Setter>
162+
</Style>
163+
164+
</ResourceDictionary>

src/Files.App.Controls/Breadcrumb/Breadcrumb.cs renamed to src/Files.App.Controls/BreadcrumbBar/BreadcrumbBarItem.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22
// Licensed under the MIT License.
33

44
using CommunityToolkit.WinUI;
5+
using Microsoft.UI;
56
using Microsoft.UI.Xaml;
67
using Microsoft.UI.Xaml.Controls;
7-
using Microsoft.UI.Xaml.Media;
8+
using Microsoft.UI.Xaml.Input;
89
using Microsoft.UI.Xaml.Markup;
10+
using Microsoft.UI.Xaml.Media;
911
using Microsoft.UI.Xaml.Shapes;
10-
using Microsoft.UI.Xaml.Input;
11-
using Microsoft.UI;
1212

1313
namespace Files.App.Controls
1414
{
15-
public sealed partial class Breadcrumb : Control
15+
public sealed partial class BreadcrumbBarItem : ContentControl
1616
{
17-
public Breadcrumb()
17+
public BreadcrumbBarItem()
18+
{
19+
DefaultStyleKey = typeof(BreadcrumbBarItem);
20+
}
21+
22+
protected override void OnApplyTemplate()
1823
{
19-
DefaultStyleKey = typeof(Breadcrumb);
24+
base.OnApplyTemplate();
2025
}
2126
}
2227
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.UI.Xaml.Automation.Peers;
5+
using Microsoft.UI.Xaml.Automation.Provider;
6+
7+
namespace Files.App.Controls
8+
{
9+
public partial class BreadcrumbBarItemAutomationPeer : FrameworkElementAutomationPeer, IInvokeProvider
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the BreadcrumbBarItemAutomationPeer class.
13+
/// </summary>
14+
/// <param name="owner"></param>
15+
public BreadcrumbBarItemAutomationPeer(BreadcrumbBarItem owner) : base(owner)
16+
{
17+
}
18+
19+
// IAutomationPeerOverrides
20+
protected override string GetLocalizedControlTypeCore()
21+
{
22+
return "breadcrumb bar item";
23+
}
24+
25+
protected override object GetPatternCore(PatternInterface patternInterface)
26+
{
27+
if (patternInterface is PatternInterface.Invoke)
28+
return this;
29+
30+
return base.GetPatternCore(patternInterface);
31+
}
32+
33+
protected override string GetClassNameCore()
34+
{
35+
return nameof(BreadcrumbBarItem);
36+
}
37+
38+
protected override AutomationControlType GetAutomationControlTypeCore()
39+
{
40+
return AutomationControlType.Button;
41+
}
42+
43+
/// <summary>
44+
/// Sends a request to invoke the item associated with the automation peer.
45+
/// </summary>
46+
public void Invoke()
47+
{
48+
if (Owner is not BreadcrumbBarItem item)
49+
return;
50+
51+
//item.OnClickEvent(null, null);
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)