Skip to content

Commit 8ad604f

Browse files
committed
Improved
1 parent 8a35997 commit 8ad604f

File tree

10 files changed

+1447
-1638
lines changed

10 files changed

+1447
-1638
lines changed

tests/Files.App.UITests/Controls/SamplePanel.Properties.cs renamed to src/Files.App.Controls/SamplePanel/SamplePanel.Properties.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ public sealed partial class SamplePanel
1717

1818
[GeneratedDependencyProperty]
1919
public partial UIElement? SideContent { get; set; }
20+
21+
partial void OnSideContentChanged(UIElement? newValue)
22+
{
23+
UpdateVisualStates();
24+
}
2025
}
2126
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
using Microsoft.UI.Xaml;
5+
using Microsoft.UI.Xaml.Controls;
6+
using Microsoft.UI.Xaml.Markup;
7+
8+
namespace Files.App.UITests.Controls
9+
{
10+
// Visual states
11+
[TemplateVisualState(GroupName = "SideContentVisibilityStates", Name = "NothingToShowTextCollapsed")]
12+
[TemplateVisualState(GroupName = "SideContentVisibilityStates", Name = "NothingToShowTextVisible")]
13+
public sealed partial class SamplePanel : Control
14+
{
15+
public SamplePanel()
16+
{
17+
DefaultStyleKey = typeof(SamplePanel);
18+
}
19+
20+
protected override void OnApplyTemplate()
21+
{
22+
UpdateVisualStates();
23+
24+
base.OnApplyTemplate();
25+
}
26+
27+
private void UpdateVisualStates()
28+
{
29+
VisualStateManager.GoToState(this, SideContent is null ? "NothingToShowTextVisible" : "NothingToShowTextCollapsed", true);
30+
}
31+
}
32+
}

tests/Files.App.UITests/Controls/SamplePanel.xaml renamed to src/Files.App.Controls/SamplePanel/SamplePanel.xaml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:local="using:Files.App.UITests.Controls">
66

7-
<x:Double x:Key="SamplePanelSideContentWidth">320</x:Double>
7+
<x:Double x:Key="SamplePanelSideContentWidth">360</x:Double>
88
<Thickness x:Key="SamplePanelPadding">24</Thickness>
99

1010
<Style BasedOn="{StaticResource DefaultSamplePanelStyle}" TargetType="local:SamplePanel" />
@@ -52,16 +52,53 @@
5252
Padding="{TemplateBinding Padding}"
5353
Content="{Binding MainContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
5454

55-
<ContentPresenter
55+
<StackPanel
5656
Grid.Column="1"
5757
Width="{StaticResource SamplePanelSideContentWidth}"
5858
Padding="{TemplateBinding Padding}"
5959
Background="{ThemeResource LayerFillColorDefaultBrush}"
6060
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
6161
BorderThickness="1,0,0,0"
62-
Content="{Binding SideContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
62+
Spacing="12">
63+
64+
<SelectorBar Padding="-12,0">
65+
<SelectorBarItem IsSelected="True" Text="Manipulation">
66+
<SelectorBarItem.Icon>
67+
<FontIcon Glyph="&#xE713;" />
68+
</SelectorBarItem.Icon>
69+
</SelectorBarItem>
70+
<SelectorBarItem IsEnabled="False" Text="Code">
71+
<SelectorBarItem.Icon>
72+
<FontIcon Glyph="&#xE943;" />
73+
</SelectorBarItem.Icon>
74+
</SelectorBarItem>
75+
</SelectorBar>
76+
77+
<ContentPresenter Margin="0,12,0,0" Content="{Binding SideContent, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
78+
79+
<TextBlock
80+
x:Name="PART_NothingToShowTextBlock"
81+
Margin="24"
82+
HorizontalAlignment="Center"
83+
VerticalAlignment="Center"
84+
FontStyle="Italic"
85+
Text="Nothing to show"
86+
Visibility="Collapsed" />
87+
88+
</StackPanel>
6389
</Grid>
6490

91+
<VisualStateManager.VisualStateGroups>
92+
93+
<VisualStateGroup x:Name="SideContentVisibilityStates">
94+
<VisualState x:Name="NothingToShowTextCollapsed" />
95+
<VisualState x:Name="NothingToShowTextVisible">
96+
<VisualState.Setters>
97+
<Setter Target="PART_NothingToShowTextBlock.Visibility" Value="Visible" />
98+
</VisualState.Setters>
99+
</VisualState>
100+
</VisualStateGroup>
101+
</VisualStateManager.VisualStateGroups>
65102
</Grid>
66103
</ControlTemplate>
67104
</Setter.Value>

src/Files.App.Controls/Themes/Generic.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Omnibar/OmnibarMode.xaml" />
6060
<!--#endregion-->
6161

62+
<!--#region SamplePanel-->
63+
<ResourceDictionary Source="ms-appx:///Files.App.Controls/SamplePanel/SamplePanel.xaml" />
64+
<!--#endregion-->
65+
6266
</ResourceDictionary.MergedDictionaries>
6367

6468
</ResourceDictionary>

tests/Files.App.UITests/App.xaml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,10 @@
1313

1414
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Themes/Generic.xaml" />
1515

16-
<ResourceDictionary Source="ms-appx:///Controls/SamplePanel.xaml" />
17-
1816
<ResourceDictionary>
1917

2018
<Thickness x:Key="NavigationViewHeaderMargin">36,40,0,0</Thickness>
2119

22-
<Style x:Key="StackPanelControlTestingStyle" TargetType="StackPanel">
23-
<Setter Property="Padding" Value="16,16,16,24" />
24-
<Setter Property="Background" Value="{ThemeResource LayerFillColorDefaultBrush}" />
25-
<Setter Property="BorderBrush" Value="{ThemeResource DividerStrokeColorDefaultBrush}" />
26-
<Setter Property="BorderThickness" Value="1,0,0,0" />
27-
<Setter Property="CornerRadius" Value="0,8,8,0" />
28-
<Setter Property="Spacing" Value="24" />
29-
</Style>
30-
31-
<Style x:Key="GridExampleControlStyle" TargetType="Grid">
32-
<Setter Property="Background" Value="{ThemeResource ApplicationPageBackgroundThemeBrush}" />
33-
<Setter Property="BorderBrush" Value="{ThemeResource DividerStrokeColorDefaultBrush}" />
34-
<Setter Property="BorderThickness" Value="1" />
35-
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
36-
</Style>
37-
3820
<Style
3921
x:Key="TextExampleCaptionStyle"
4022
BasedOn="{StaticResource CaptionTextBlockStyle}"

tests/Files.App.UITests/Controls/SamplePanel.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/Files.App.UITests/Views/OmnibarPage.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
<controls2:SamplePanel Header="Default usage">
1717
<controls2:SamplePanel.MainContent>
18-
1918
<controls:Omnibar HorizontalAlignment="Stretch" VerticalAlignment="Center">
2019

2120
<controls:OmnibarMode
@@ -108,7 +107,6 @@
108107
</controls:OmnibarMode>
109108

110109
</controls:Omnibar>
111-
112110
</controls2:SamplePanel.MainContent>
113111
</controls2:SamplePanel>
114112

0 commit comments

Comments
 (0)