Skip to content

Commit 00e6a1d

Browse files
committed
Add transition and use dummy data for auto suggestion
1 parent fac8079 commit 00e6a1d

File tree

8 files changed

+66
-13
lines changed

8 files changed

+66
-13
lines changed

src/Files.App.Controls/Omnibar/Omnibar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected override void OnApplyTemplate()
8383
_modesHostGrid.SizeChanged += _modesHostGrid_SizeChanged;
8484

8585
var parentElement = this.FindAscendant<FrameworkElement>()!;
86-
parentElement.PointerPressed += ParentElement_PointerPressed;
86+
//parentElement.PointerPressed += ParentElement_PointerPressed;
8787
GotFocus += Omnibar_GotFocus;
8888
LostFocus += Omnibar_LostFocus;
8989

src/Files.App.Controls/Omnibar/Omnibar.xaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</ResourceDictionary>
1414
</ResourceDictionary.ThemeDictionaries>-->
1515

16-
<x:Double x:Key="OmnibarDefaultHeight">36</x:Double>
17-
<CornerRadius x:Key="OmnibarDefaultCornerRadius">18</CornerRadius>
16+
<x:Double x:Key="OmnibarDefaultHeight">38</x:Double>
17+
<CornerRadius x:Key="OmnibarDefaultCornerRadius">19</CornerRadius>
1818
<Thickness x:Key="OmnibarFocusedBorderThickness">2</Thickness>
1919
<Thickness x:Key="OmnibarUnfocusedBorderThickness">1</Thickness>
2020
<Thickness x:Key="OmnibarUnfocusedRootPadding">1</Thickness>
@@ -26,11 +26,10 @@
2626

2727
<Style x:Key="DefaultOmnibarStyle" TargetType="local:Omnibar">
2828
<Setter Property="IsTabStop" Value="True" />
29-
<Setter Property="Height" Value="{StaticResource OmnibarDefaultHeight}" />
3029
<Setter Property="UseSystemFocusVisuals" Value="True" />
3130
<Setter Property="HorizontalAlignment" Value="Stretch" />
3231
<Setter Property="Background" Value="{ThemeResource ControlFillColorDefaultBrush}" />
33-
<Setter Property="Padding" Value="{ThemeResource OmnibarUnfocusedRootPadding}" />
32+
<Setter Property="Padding" Value="{StaticResource OmnibarUnfocusedRootPadding}" />
3433
<Setter Property="BorderBrush" Value="{ThemeResource CircleElevationBorderBrush}" />
3534
<Setter Property="BorderThickness" Value="{StaticResource OmnibarUnfocusedBorderThickness}" />
3635
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
@@ -45,11 +44,12 @@
4544
<RowDefinition Height="Auto" />
4645
<RowDefinition Height="Auto" />
4746
</Grid.RowDefinitions>
48-
<!-- input area -->
47+
<!-- Input area -->
4948
<Grid
5049
x:Name="PART_ModesHostGrid"
5150
Grid.Row="0"
52-
Margin="{TemplateBinding Padding}"
51+
Height="{StaticResource OmnibarDefaultHeight}"
52+
Padding="{TemplateBinding Padding}"
5353
Background="{TemplateBinding Background}"
5454
BorderBrush="{TemplateBinding BorderBrush}"
5555
BorderThickness="{TemplateBinding BorderThickness}"
@@ -76,7 +76,8 @@
7676
<ListView
7777
HorizontalAlignment="Stretch"
7878
IsItemClickEnabled="True"
79-
ItemTemplate="{Binding CurrentActiveMode.SuggestionItemTemplate, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
79+
ItemTemplate="{Binding CurrentActiveMode.SuggestionItemTemplate, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
80+
ItemsSource="{Binding CurrentActiveMode.SuggestionItemsSource, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
8081

8182
</Border>
8283
</Popup>
@@ -94,6 +95,17 @@
9495
</VisualState>
9596
</VisualStateGroup>
9697

98+
<VisualStateGroup x:Name="PopupVisibilityStates">
99+
<VisualState x:Name="Closed" />
100+
<VisualState x:Name="Opened">
101+
<VisualState.Setters>
102+
<Setter Target="PART_ModesHostGrid.BorderBrush" Value="{ThemeResource AccentFillColorDefaultBrush}" />
103+
<Setter Target="PART_ModesHostGrid.BorderThickness" Value="{StaticResource OmnibarFocusedBorderThickness}" />
104+
<Setter Target="PART_ModesHostGrid.Margin" Value="-1" />
105+
</VisualState.Setters>
106+
</VisualState>
107+
</VisualStateGroup>
108+
97109
</VisualStateManager.VisualStateGroups>
98110
</Grid>
99111
</ControlTemplate>

src/Files.App.Controls/Omnibar/OmnibarMode.Properties.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public partial class OmnibarMode
3232
[GeneratedDependencyProperty]
3333
public partial FrameworkElement? IconOnInactive { get; set; }
3434

35+
[GeneratedDependencyProperty]
36+
public partial object? SuggestionItemsSource { get; set; }
37+
3538
[GeneratedDependencyProperty]
3639
public partial DataTemplate? SuggestionItemTemplate { get; set; }
3740

src/Files.App.Controls/Omnibar/OmnibarMode.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,40 @@ private void UpdateVisualStates()
7171

7272
private void OmnibarMode_PointerEntered(object sender, PointerRoutedEventArgs e)
7373
{
74+
if (Host!.CurrentActiveMode == this)
75+
return;
76+
7477
_isHoveredOver = true;
7578
_isPressed = false;
7679
UpdateVisualStates();
7780
}
7881

7982
private void OmnibarMode_PointerPressed(object sender, PointerRoutedEventArgs e)
8083
{
84+
if (Host!.CurrentActiveMode == this)
85+
return;
86+
8187
_isHoveredOver = false;
8288
_isPressed = true;
8389
UpdateVisualStates();
8490
}
8591

8692
private void OmnibarMode_PointerReleased(object sender, PointerRoutedEventArgs e)
8793
{
94+
if (Host!.CurrentActiveMode == this)
95+
return;
96+
8897
_isHoveredOver = true;
8998
_isPressed = false;
9099
UpdateVisualStates();
91-
92-
if (Host!.CurrentActiveMode == this)
93-
Host.ChangeExpandedMode(this);
100+
Host.ChangeExpandedMode(this);
94101
}
95102

96103
private void OmnibarMode_PointerExited(object sender, PointerRoutedEventArgs e)
97104
{
105+
//if (Host!.CurrentActiveMode == this)
106+
// return;
107+
98108
_isHoveredOver = _isPressed = false;
99109
UpdateVisualStates();
100110
}

src/Files.App.Controls/Omnibar/OmnibarMode.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
<Setter Property="CornerRadius" Value="{StaticResource OmnibarDefaultCornerRadius}" />
2020
<Setter Property="VerticalAlignment" Value="Stretch" />
2121
<Setter Property="IsFocusEngagementEnabled" Value="True" />
22+
<Setter Property="Transitions">
23+
<Setter.Value>
24+
<TransitionCollection>
25+
<RepositionThemeTransition />
26+
</TransitionCollection>
27+
</Setter.Value>
28+
</Setter>
2229
<Setter Property="Template">
2330
<Setter.Value>
2431
<ControlTemplate TargetType="local:OmnibarMode">
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) Files Community
2+
// Licensed under the MIT License.
3+
4+
namespace Files.App.UITests.Data
5+
{
6+
internal record DummyItem1(string Title, string Description, string HotKeys);
7+
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
66
xmlns:controls="using:Files.App.Controls"
77
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:data="using:Files.App.UITests.Data"
89
xmlns:local="using:Files.App.UITests.Views"
910
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1011
mc:Ignorable="d">
@@ -68,6 +69,7 @@
6869
<controls:OmnibarMode
6970
HideContentOnInactive="True"
7071
IsDefault="True"
72+
SuggestionItemsSource="{x:Bind DummyItems1, Mode=OneWay}"
7173
Text="Path..."
7274
TextPlaceholder="Enter text..."
7375
ToolTip="Path">
@@ -78,8 +80,8 @@
7880
<controls:ThemedIcon Style="{StaticResource App.ThemedIcons.Omnibar.Path}" />
7981
</controls:OmnibarMode.IconOnInactive>
8082
<controls:OmnibarMode.SuggestionItemTemplate>
81-
<DataTemplate>
82-
<TextBlock Text="Text here..." />
83+
<DataTemplate x:DataType="data:DummyItem1">
84+
<TextBlock Text="{x:Bind Title}" />
8385
</DataTemplate>
8486
</controls:OmnibarMode.SuggestionItemTemplate>
8587
</controls:OmnibarMode>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using Files.App.UITests.Data;
45
using Microsoft.UI.Xaml;
56
using Microsoft.UI.Xaml.Controls;
7+
using System.Collections.ObjectModel;
68

79
namespace Files.App.UITests.Views
810
{
911
public sealed partial class OmnibarPage : Page
1012
{
13+
private ObservableCollection<DummyItem1> DummyItems1 = [];
14+
1115
public OmnibarPage()
1216
{
1317
InitializeComponent();
18+
19+
DummyItems1 =
20+
[
21+
new("Title", "Description", "HotKeys"),
22+
new("Title", "Description", "HotKeys"),
23+
new("Title", "Description", "HotKeys"),
24+
new("Title", "Description", "HotKeys"),
25+
];
1426
}
1527
}
1628
}

0 commit comments

Comments
 (0)