diff --git a/src/Files.App.Controls/Omnibar/Omnibar.Properties.cs b/src/Files.App.Controls/Omnibar/Omnibar.Properties.cs new file mode 100644 index 000000000000..063c45909bd1 --- /dev/null +++ b/src/Files.App.Controls/Omnibar/Omnibar.Properties.cs @@ -0,0 +1,23 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using CommunityToolkit.WinUI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Markup; +using Microsoft.UI.Xaml.Shapes; +using System.Linq; +using System.Collections.Generic; + +namespace Files.App.Controls +{ + public partial class Omnibar + { + [GeneratedDependencyProperty] + public partial IList? Modes { get; set; } + + [GeneratedDependencyProperty] + public partial OmnibarMode? CurrentSelectedMode { get; set; } + } +} diff --git a/src/Files.App.Controls/Omnibar/Omnibar.cs b/src/Files.App.Controls/Omnibar/Omnibar.cs new file mode 100644 index 000000000000..caaae18cf855 --- /dev/null +++ b/src/Files.App.Controls/Omnibar/Omnibar.cs @@ -0,0 +1,180 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using CommunityToolkit.WinUI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Markup; +using Microsoft.UI.Xaml.Shapes; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI; +using Windows.ApplicationModel.Contacts; + +namespace Files.App.Controls +{ + // Content + [ContentProperty(Name = nameof(Modes))] + // Template parts + [TemplatePart(Name = "PART_ModesHostGrid", Type = typeof(Grid))] + // Visual states + [TemplateVisualState(Name = "Focused", GroupName = "FocusStates")] + [TemplateVisualState(Name = "Normal", GroupName = "FocusStates")] + public partial class Omnibar : Control + { + private const string ModesHostGrid = "PART_ModesHostGrid"; + private const string AutoSuggestPopup = "PART_AutoSuggestPopup"; + private const string AutoSuggestBoxBorder = "PART_AutoSuggestBoxBorder"; + + private Grid? _modesHostGrid; + private Popup? _autoSuggestPopup; + private Border? _autoSuggestBoxBorder; + private bool _isFocused; + private bool _stillHasFocus; + + public Omnibar() + { + DefaultStyleKey = typeof(Omnibar); + + Modes ??= []; + } + + protected override void OnApplyTemplate() + { + _modesHostGrid = GetTemplateChild(ModesHostGrid) as Grid + ?? throw new MissingFieldException($"Could not find {ModesHostGrid} in the given {nameof(Omnibar)}'s style."); + _autoSuggestPopup = GetTemplateChild(AutoSuggestPopup) as Popup + ?? throw new MissingFieldException($"Could not find {AutoSuggestPopup} in the given {nameof(Omnibar)}'s style."); + _autoSuggestBoxBorder = GetTemplateChild(AutoSuggestBoxBorder) as Border + ?? throw new MissingFieldException($"Could not find {AutoSuggestBoxBorder} in the given {nameof(Omnibar)}'s style."); + + if (Modes is null) + return; + + // Add shadow to the popup and set the proper width + _autoSuggestBoxBorder!.Translation = new(0, 0, 32); + _autoSuggestBoxBorder!.Width = _modesHostGrid!.ActualWidth; + + // Populate the modes + foreach (var mode in Modes) + { + // Insert a divider + if (_modesHostGrid.Children.Count is not 0) + { + var divider = new Rectangle() + { + Fill = (SolidColorBrush)Application.Current.Resources["DividerStrokeColorDefaultBrush"], + Height = 20, + Margin = new(2,0,2,0), + Width = 1, + }; + + _modesHostGrid.ColumnDefinitions.Add(new() { Width = GridLength.Auto }); + Grid.SetColumn(divider, _modesHostGrid.Children.Count); + _modesHostGrid.Children.Add(divider); + } + + // Insert the mode + _modesHostGrid.ColumnDefinitions.Add(new() { Width = GridLength.Auto }); + Grid.SetColumn(mode, _modesHostGrid.Children.Count); + _modesHostGrid.Children.Add(mode); + mode.Host = this; + } + + _modesHostGrid.SizeChanged += ModesHostGrid_SizeChanged; + + GotFocus += Omnibar_GotFocus; + LostFocus += Omnibar_LostFocus; + LosingFocus += Omnibar_LosingFocus; + + UpdateVisualStates(); + + base.OnApplyTemplate(); + } + + // Methods + + internal void ChangeMode(OmnibarMode modeToExpand) + { + if (_modesHostGrid is null || Modes is null) + throw new NullReferenceException(); + + // Reset + foreach (var column in _modesHostGrid.ColumnDefinitions) + column.Width = GridLength.Auto; + foreach (var mode in Modes) + VisualStateManager.GoToState(mode, "Unfocused", true); + + // Expand the given mode + VisualStateManager.GoToState(modeToExpand, "Focused", true); + _modesHostGrid.ColumnDefinitions[_modesHostGrid.Children.IndexOf(modeToExpand)].Width = new(1, GridUnitType.Star); + + CurrentSelectedMode = modeToExpand; + + UpdateVisualStates(); + } + + private void UpdateVisualStates() + { + VisualStateManager.GoToState(this, _isFocused ? "Focused" : "Normal", true); + + if (CurrentSelectedMode is not null && _autoSuggestPopup is not null) + { + // Close anyway + if (_autoSuggestPopup.IsOpen && CurrentSelectedMode.SuggestionItemsSource is null) + VisualStateManager.GoToState(this, "PopupClosed", true); + + // Decide open or close + if (_isFocused != _autoSuggestPopup.IsOpen) + VisualStateManager.GoToState(this, _isFocused && CurrentSelectedMode.SuggestionItemsSource is not null ? "PopupOpened" : "PopupClosed", true); + } + + if (CurrentSelectedMode is not null) + VisualStateManager.GoToState( + CurrentSelectedMode, + _isFocused + ? "Focused" + : CurrentSelectedMode.ContentOnInactive is null + ? "CurrentUnfocusedWithoutInactiveMode" + : "CurrentUnfocusedWithInactiveMode", + true); + } + + // Events + + private void ModesHostGrid_SizeChanged(object sender, SizeChangedEventArgs e) + { + _autoSuggestBoxBorder!.Width = _modesHostGrid!.ActualWidth; + } + + private void Omnibar_GotFocus(object sender, RoutedEventArgs e) + { + _isFocused = true; + UpdateVisualStates(); + } + + private void Omnibar_LosingFocus(UIElement sender, LosingFocusEventArgs args) + { + // Ignore when user clicks on the TextBox or the button area of an OmnibarMode, Omnibar still has focus anyway + if (args.NewFocusedElement?.GetType() is not { } focusedType || + focusedType == typeof(TextBox) || + focusedType == typeof(OmnibarMode) || + focusedType == typeof(Omnibar)) + { + _stillHasFocus = true; + } + } + + private void Omnibar_LostFocus(object sender, RoutedEventArgs e) + { + if (_stillHasFocus) + { + _stillHasFocus = false; + return; + } + + _isFocused = false; + UpdateVisualStates(); + } + } +} diff --git a/src/Files.App.Controls/Omnibar/Omnibar.xaml b/src/Files.App.Controls/Omnibar/Omnibar.xaml new file mode 100644 index 000000000000..e89841dfac45 --- /dev/null +++ b/src/Files.App.Controls/Omnibar/Omnibar.xaml @@ -0,0 +1,114 @@ + + + + + + 38 + 19 + 2 + 1 + 1 + + + + diff --git a/src/Files.App.Controls/Omnibar/OmnibarMode.Properties.cs b/src/Files.App.Controls/Omnibar/OmnibarMode.Properties.cs new file mode 100644 index 000000000000..aff5a6397038 --- /dev/null +++ b/src/Files.App.Controls/Omnibar/OmnibarMode.Properties.cs @@ -0,0 +1,47 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using CommunityToolkit.WinUI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Markup; +using Microsoft.UI.Xaml.Shapes; +using System.Linq; +using System.Collections.Generic; + +namespace Files.App.Controls +{ + public partial class OmnibarMode + { + [GeneratedDependencyProperty] + public partial string? Text { get; set; } + + [GeneratedDependencyProperty] + public partial string? TextPlaceholder { get; set; } + + [GeneratedDependencyProperty] + public partial string? ModeName { get; set; } + + [GeneratedDependencyProperty] + public partial FrameworkElement? ContentOnInactive { get; set; } + + [GeneratedDependencyProperty] + public partial FrameworkElement? IconOnActive { get; set; } + + [GeneratedDependencyProperty] + public partial FrameworkElement? IconOnInactive { get; set; } + + [GeneratedDependencyProperty] + public partial object? SuggestionItemsSource { get; set; } + + [GeneratedDependencyProperty] + public partial DataTemplate? SuggestionItemTemplate { get; set; } + + [GeneratedDependencyProperty] + public partial bool IsDefault { get; set; } + + [GeneratedDependencyProperty] + internal partial Omnibar? Host { get; set; } + } +} diff --git a/src/Files.App.Controls/Omnibar/OmnibarMode.cs b/src/Files.App.Controls/Omnibar/OmnibarMode.cs new file mode 100644 index 000000000000..2c4c1da64288 --- /dev/null +++ b/src/Files.App.Controls/Omnibar/OmnibarMode.cs @@ -0,0 +1,116 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Markup; +using Microsoft.UI.Xaml.Shapes; + +namespace Files.App.Controls +{ + // Template parts + [TemplatePart(Name = "PART_ModeClickBorder", Type = typeof(Border))] + [TemplatePart(Name = "PART_ModeIconPresenter", Type = typeof(ContentPresenter))] + [TemplatePart(Name = "PART_InputTextBox", Type = typeof(TextBox))] + // Visual states + [TemplateVisualState(GroupName = "CommonStates", Name = "PointerNormal")] + [TemplateVisualState(GroupName = "CommonStates", Name = "PointerOver")] + [TemplateVisualState(GroupName = "CommonStates", Name = "PointerPressed")] + [TemplateVisualState(GroupName = "CommonStates", Name = "Focused")] + [TemplateVisualState(GroupName = "InputVisibilityStates", Name = "Collapsed")] + [TemplateVisualState(GroupName = "InputVisibilityStates", Name = "Visible")] + [TemplateVisualState(GroupName = "IconStates", Name = "InactiveIcon")] + [TemplateVisualState(GroupName = "IconStates", Name = "ActiveIcon")] + public partial class OmnibarMode : Control + { + private const string ModeClickBorder = "PART_ModeClickBorder"; + private const string InputTextBox = "PART_InputTextBox"; + + private Border? _modeClickArea; + private TextBox? _inputTextBox; + + private bool _isHoveredOver; + private bool _isPressed; + + public OmnibarMode() + { + DefaultStyleKey = typeof(OmnibarMode); + } + + protected override void OnApplyTemplate() + { + _modeClickArea = GetTemplateChild(ModeClickBorder) as Border + ?? throw new MissingFieldException($"Could not find {ModeClickBorder} in the given {nameof(OmnibarMode)}'s style."); + _inputTextBox = GetTemplateChild(InputTextBox) as TextBox + ?? throw new MissingFieldException($"Could not find {InputTextBox} in the given {nameof(OmnibarMode)}'s style."); + + if (IsDefault) + Host!.ChangeMode(this); + + UpdateVisualStates(); + + _modeClickArea.PointerEntered += OmnibarMode_PointerEntered; + _modeClickArea.PointerPressed += OmnibarMode_PointerPressed; + _modeClickArea.PointerReleased += OmnibarMode_PointerReleased; + _modeClickArea.PointerExited += OmnibarMode_PointerExited; + + base.OnApplyTemplate(); + } + + private void UpdateVisualStates() + { + VisualStateManager.GoToState( + this, + _isPressed ? "PointerPressed" : _isHoveredOver ? "PointerOver" : "PointerNormal", + true); + } + + public override string ToString() + { + return ModeName ?? ""; + } + + // Events + + private void OmnibarMode_PointerEntered(object sender, PointerRoutedEventArgs e) + { + if (Host!.CurrentSelectedMode == this) + return; + + _isHoveredOver = true; + _isPressed = false; + UpdateVisualStates(); + } + + private void OmnibarMode_PointerPressed(object sender, PointerRoutedEventArgs e) + { + if (Host!.CurrentSelectedMode == this) + return; + + _isHoveredOver = false; + _isPressed = true; + UpdateVisualStates(); + } + + private void OmnibarMode_PointerReleased(object sender, PointerRoutedEventArgs e) + { + if (Host!.CurrentSelectedMode == this) + return; + + _isHoveredOver = true; + _isPressed = false; + UpdateVisualStates(); + Host.ChangeMode(this); + _inputTextBox?.Focus(FocusState.Pointer); + _inputTextBox?.Select(_inputTextBox.Text.Length, 0); + } + + private void OmnibarMode_PointerExited(object sender, PointerRoutedEventArgs e) + { + _isHoveredOver = _isPressed = false; + UpdateVisualStates(); + } + } +} diff --git a/src/Files.App.Controls/Omnibar/OmnibarMode.xaml b/src/Files.App.Controls/Omnibar/OmnibarMode.xaml new file mode 100644 index 000000000000..97509be1f842 --- /dev/null +++ b/src/Files.App.Controls/Omnibar/OmnibarMode.xaml @@ -0,0 +1,134 @@ + + + + 32 + 46 + 16 + + + + diff --git a/src/Files.App.Controls/SamplePanel/SamplePanel.Properties.cs b/src/Files.App.Controls/SamplePanel/SamplePanel.Properties.cs new file mode 100644 index 000000000000..99ff6328a8c0 --- /dev/null +++ b/src/Files.App.Controls/SamplePanel/SamplePanel.Properties.cs @@ -0,0 +1,26 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using CommunityToolkit.WinUI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace Files.App.Controls +{ + public sealed partial class SamplePanel + { + [GeneratedDependencyProperty] + public partial string? Header { get; set; } + + [GeneratedDependencyProperty] + public partial UIElement? MainContent { get; set; } + + [GeneratedDependencyProperty] + public partial UIElement? SideContent { get; set; } + + partial void OnSideContentChanged(UIElement? newValue) + { + UpdateVisualStates(); + } + } +} diff --git a/src/Files.App.Controls/SamplePanel/SamplePanel.cs b/src/Files.App.Controls/SamplePanel/SamplePanel.cs new file mode 100644 index 000000000000..9b727cb2a0bf --- /dev/null +++ b/src/Files.App.Controls/SamplePanel/SamplePanel.cs @@ -0,0 +1,32 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Markup; + +namespace Files.App.Controls +{ + // Visual states + [TemplateVisualState(GroupName = "SideContentVisibilityStates", Name = "NothingToShowTextCollapsed")] + [TemplateVisualState(GroupName = "SideContentVisibilityStates", Name = "NothingToShowTextVisible")] + public sealed partial class SamplePanel : Control + { + public SamplePanel() + { + DefaultStyleKey = typeof(SamplePanel); + } + + protected override void OnApplyTemplate() + { + UpdateVisualStates(); + + base.OnApplyTemplate(); + } + + private void UpdateVisualStates() + { + VisualStateManager.GoToState(this, SideContent is null ? "NothingToShowTextVisible" : "NothingToShowTextCollapsed", true); + } + } +} diff --git a/src/Files.App.Controls/SamplePanel/SamplePanel.xaml b/src/Files.App.Controls/SamplePanel/SamplePanel.xaml new file mode 100644 index 000000000000..32b39686bda2 --- /dev/null +++ b/src/Files.App.Controls/SamplePanel/SamplePanel.xaml @@ -0,0 +1,108 @@ + + + + 360 + 24 + + + + diff --git a/src/Files.App.Controls/ThemedIcon/Styles/Icons.Common.xaml b/src/Files.App.Controls/ThemedIcon/Styles/Icons.Common.xaml index 079afe9f9535..3bfd3c2a8247 100644 --- a/src/Files.App.Controls/ThemedIcon/Styles/Icons.Common.xaml +++ b/src/Files.App.Controls/ThemedIcon/Styles/Icons.Common.xaml @@ -1264,4 +1264,118 @@ + + + + + + + + + + + + diff --git a/src/Files.App.Controls/ThemedIcon/ThemedIcon.Properties.cs b/src/Files.App.Controls/ThemedIcon/ThemedIcon.Properties.cs index 177cf7d6390e..f72caa7a414e 100644 --- a/src/Files.App.Controls/ThemedIcon/ThemedIcon.Properties.cs +++ b/src/Files.App.Controls/ThemedIcon/ThemedIcon.Properties.cs @@ -71,6 +71,7 @@ partial void OnIconColorTypeChanged(ThemedIconColorType newValue) partial void OnIconSizeChanged(double newValue) { UpdateVisualStates(); + OnIconSizeChanged(); } partial void OnIsToggledChanged(bool newValue) diff --git a/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs b/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs index c48c9b11d143..a42168104c90 100644 --- a/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs +++ b/src/Files.App.Controls/ThemedIcon/ThemedIcon.cs @@ -43,6 +43,7 @@ protected override void OnApplyTemplate() OnIconTypeChanged(); OnIconColorTypeChanged(); + OnIconSizeChanged(); } private void GetTemplateParts() @@ -249,5 +250,10 @@ private void OnIconColorChanged() if (GetTemplateChild(FilledIconPath) is Path fillPath) fillPath.Fill = (Brush)this.GetValue(ColorProperty); } + + private void OnIconSizeChanged() + { + Height = Width = IconSize; + } } } diff --git a/src/Files.App.Controls/Themes/Generic.xaml b/src/Files.App.Controls/Themes/Generic.xaml index d669987b00ec..895bc9763802 100644 --- a/src/Files.App.Controls/Themes/Generic.xaml +++ b/src/Files.App.Controls/Themes/Generic.xaml @@ -54,7 +54,18 @@ - + + + + + + + + + + + + diff --git a/tests/Files.App.UITests/App.xaml b/tests/Files.App.UITests/App.xaml index 8016c2f8af50..cb0022c590f9 100644 --- a/tests/Files.App.UITests/App.xaml +++ b/tests/Files.App.UITests/App.xaml @@ -4,12 +4,35 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Files.App.UITests"> + + + + + + 36,40,0,36 + + + + + @@ -33,4 +56,5 @@ + diff --git a/tests/Files.App.UITests/Data/DummyIcon1.png b/tests/Files.App.UITests/Data/DummyIcon1.png new file mode 100644 index 000000000000..b6121308740e Binary files /dev/null and b/tests/Files.App.UITests/Data/DummyIcon1.png differ diff --git a/tests/Files.App.UITests/Data/DummyItem1.cs b/tests/Files.App.UITests/Data/DummyItem1.cs new file mode 100644 index 000000000000..b7cbcc219245 --- /dev/null +++ b/tests/Files.App.UITests/Data/DummyItem1.cs @@ -0,0 +1,7 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +namespace Files.App.UITests.Data +{ + internal record DummyItem1(string Title, string Description, string HotKeys); +} diff --git a/tests/Files.App.UITests/Files.App.UITests.csproj b/tests/Files.App.UITests/Files.App.UITests.csproj index 59bc9248f903..659bc29acd1b 100644 --- a/tests/Files.App.UITests/Files.App.UITests.csproj +++ b/tests/Files.App.UITests/Files.App.UITests.csproj @@ -16,17 +16,15 @@ - + + + - - - - @@ -37,18 +35,5 @@ true - - - - - - MSBuild:Compile - - - - - MSBuild:Compile - - diff --git a/tests/Files.App.UITests/MainWindow.xaml b/tests/Files.App.UITests/MainWindow.xaml index e93f472c2de9..fc82d9ed9f3c 100644 --- a/tests/Files.App.UITests/MainWindow.xaml +++ b/tests/Files.App.UITests/MainWindow.xaml @@ -26,9 +26,11 @@ Grid.Row="0" HorizontalAlignment="Stretch"> - - + + + + + + + + + - + + - + - - - - - - - - - - - - - diff --git a/tests/Files.App.UITests/MainWindow.xaml.cs b/tests/Files.App.UITests/MainWindow.xaml.cs index 33aa1ea5a43a..29e688b50e13 100644 --- a/tests/Files.App.UITests/MainWindow.xaml.cs +++ b/tests/Files.App.UITests/MainWindow.xaml.cs @@ -4,6 +4,8 @@ using Files.App.UITests.Views; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using System; namespace Files.App.UITests { @@ -17,8 +19,22 @@ private MainWindow() InitializeComponent(); ExtendsContentIntoTitleBar = true; - MainFrame.Navigate(typeof(MainPage)); + + // Set the toggle state for theme change button + if (Content is FrameworkElement element) + { + if (element.ActualTheme is ElementTheme.Light) + { + AppThemeChangeToggleButton.IsChecked = true; + AppThemeGlyph.Glyph = "\uE706"; // Sun + } + else + { + AppThemeChangeToggleButton.IsChecked = false; + AppThemeGlyph.Glyph = "\uE708"; // Moon + } + } } private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) @@ -26,40 +42,35 @@ private void NavigationView_SelectionChanged(NavigationView sender, NavigationVi if (args.SelectedItem is not NavigationViewItem item || item.Tag is not string tag) return; - switch (tag) - { - case "ThemedIconPage": - MainFrame.Navigate(typeof(ThemedIconPage)); - break; - case "ToolbarPage": - MainFrame.Navigate(typeof(ToolbarPage)); - break; - case "StorageControlsPage": - MainFrame.Navigate(typeof(StorageControlsPage)); - break; - case "SidebarViewPage": - MainFrame.Navigate(typeof(SidebarViewPage)); - break; - } + MainFrame.Navigate( + tag switch + { + nameof(ThemedIconPage) => typeof(ThemedIconPage), + nameof(ToolbarPage) => typeof(ToolbarPage), + nameof(StorageControlsPage) => typeof(StorageControlsPage), + nameof(SidebarViewPage) => typeof(SidebarViewPage), + nameof(OmnibarPage) => typeof(OmnibarPage), + _ => throw new InvalidOperationException("There's no applicable page associated with the given key."), + }); + + MainNavigationView.Header = item.Content.ToString(); } - private void ThemeModeSelectorCombBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void AppThemeChangeToggleButton_Click(object sender, RoutedEventArgs e) { - if (sender is not ComboBox comboBox || + if (sender is not ToggleButton toggleButton || Content is not FrameworkElement element) return; - switch (comboBox.SelectedIndex) + if (toggleButton.IsChecked is true) + { + element.RequestedTheme = ElementTheme.Light; + AppThemeGlyph.Glyph = "\uE706"; // Sun + } + else { - case 0: - element.RequestedTheme = ElementTheme.Default; - break; - case 1: - element.RequestedTheme = ElementTheme.Light; - break; - case 2: - element.RequestedTheme = ElementTheme.Dark; - break; + element.RequestedTheme = ElementTheme.Dark; + AppThemeGlyph.Glyph = "\uE708"; // Moon } } } diff --git a/tests/Files.App.UITests/Views/MainPage.xaml b/tests/Files.App.UITests/Views/MainPage.xaml index e0a87f5c5b5f..44b76623d425 100644 --- a/tests/Files.App.UITests/Views/MainPage.xaml +++ b/tests/Files.App.UITests/Views/MainPage.xaml @@ -9,44 +9,13 @@ mc:Ignorable="d"> - - - - - - - - - - - - - - + Text="All Samples here to test UI accessibility. Select a page from the sidebar to test it." /> diff --git a/tests/Files.App.UITests/Views/OmnibarPage.xaml b/tests/Files.App.UITests/Views/OmnibarPage.xaml new file mode 100644 index 000000000000..43ddf95bbc20 --- /dev/null +++ b/tests/Files.App.UITests/Views/OmnibarPage.xaml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Files.App.UITests/Views/OmnibarPage.xaml.cs b/tests/Files.App.UITests/Views/OmnibarPage.xaml.cs new file mode 100644 index 000000000000..a1d577b09b69 --- /dev/null +++ b/tests/Files.App.UITests/Views/OmnibarPage.xaml.cs @@ -0,0 +1,33 @@ +// Copyright (c) Files Community +// Licensed under the MIT License. + +using Files.App.UITests.Data; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System.Collections.ObjectModel; + +namespace Files.App.UITests.Views +{ + public sealed partial class OmnibarPage : Page + { + private readonly ObservableCollection DummyItems1; + + public OmnibarPage() + { + InitializeComponent(); + + DummyItems1 = + [ + new("Open online help page in browser", "Open online help page in browser", "Control + H"), + new("Toggle full screen", "Toggle full screen", "Control + H"), + new("Enter compact overlay", "Enter compact overlay", "Control + H"), + new("Toggle compact overlay", "Toggle compact overlay", "Control + H"), + new("Go to search box", "Go to search box", "Control + H"), + new("Focus path bar", "Focus path bar", "Control + H"), + new("Redo the last file operation", "Redo the last file operation", "Control + H"), + new("Undo the last file operation", "Undo the last file operation", "Control + H"), + new("Toggle whether to show hidden items", "Toggle whether to show hidden items", "Control + H"), + ]; + } + } +} diff --git a/tests/Files.App.UITests/Views/StorageControlsPage.xaml b/tests/Files.App.UITests/Views/StorageControlsPage.xaml index 0ee12b86a51b..31e876302e87 100644 --- a/tests/Files.App.UITests/Views/StorageControlsPage.xaml +++ b/tests/Files.App.UITests/Views/StorageControlsPage.xaml @@ -9,180 +9,50 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + HorizontalAlignment="Stretch" + ColumnSpacing="24"> + + + + + + + + + + + + + + + + + + - + - - + - + + + + + + - + - - - - - - - - - - - - - - - + - + + + + + + + - - + + - - - - + Width="{x:Bind testWidth.Value, Mode=TwoWay}" + Height="{x:Bind testHeight.Value, Mode=TwoWay}" + Background="#FF005500" + BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}" + BorderThickness="1" + FlowDirection="RightToLeft" + Foreground="Cyan" + IsEnabled="{x:Bind testIsEnabled.IsOn, Mode=TwoWay}" + MaxAngle="{x:Bind testMAngle.Value, Mode=TwoWay}" + MinAngle="{x:Bind testSAngle.Value, Mode=TwoWay}" + StartAngle="{x:Bind testSAngle.Value, Mode=TwoWay}" + TrackRingThickness="{x:Bind testTrackThickness.Value, Mode=TwoWay}" + ValueRingThickness="{x:Bind testValueThickness.Value, Mode=TwoWay}" + Value="{x:Bind testValue.Value, Mode=TwoWay}" /> - - + - + + - - - - - + + + + - + - - + - - - - - - + Header="Width:" + SpinButtonPlacementMode="Inline" + Value="100" /> - + - + - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + + + + + + + + + + - - - + - - - + - + - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + - + + + + + + + - - - + + + Width="Auto" + HorizontalAlignment="Stretch" + Background="#FF005500" + BarShape="Flat" + BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}" + BorderThickness="1" + FlowDirection="RightToLeft" + Foreground="Cyan" + IsEnabled="{x:Bind barTestIsEnabled.IsOn, Mode=TwoWay}" + TrackBarHeight="{x:Bind barTestTrackThickness.Value, Mode=TwoWay}" + ValueBarHeight="{x:Bind barTestValueThickness.Value, Mode=TwoWay}" + Value="{x:Bind barTestValue.Value, Mode=TwoWay}" /> + + - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Files.App.UITests/Views/ThemedIconPage.xaml b/tests/Files.App.UITests/Views/ThemedIconPage.xaml index 104846f718ab..3db6a6e804b3 100644 --- a/tests/Files.App.UITests/Views/ThemedIconPage.xaml +++ b/tests/Files.App.UITests/Views/ThemedIconPage.xaml @@ -14,1106 +14,844 @@ - - - - - - - + TargetType="controls:ThemedIcon" /> - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + - + - - + - + - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Text="Accent" /> - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + - + + + - - + + + - + - + Style="{StaticResource IconTest}" + ToggleBehavior="On" /> - + Style="{StaticResource IconTest}" + ToggleBehavior="On" /> + Style="{StaticResource IconTest}" + ToggleBehavior="On" /> + + + - + - + IsEnabled="False" + Style="{StaticResource IconTest}" + ToggleBehavior="On" /> - + Style="{StaticResource IconTest}" + ToggleBehavior="On" /> + IsEnabled="False" + Style="{StaticResource IconTest}" + ToggleBehavior="On" /> + - - + + - + - - - - - - - - - + + + + - - - - - - - - + - - - - - - - - - - - - - + - - + + + - - + + + + - + - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + + AutomationProperties.Name="TestToggleButton1" + IsChecked="{x:Bind TestToggleSwitch.IsOn, Mode=OneWay}"> - - - - - - + + + AutomationProperties.Name="TestToggleButton2" + IsChecked="{x:Bind TestToggleSwitch.IsOn, Mode=OneWay}"> + ToggleBehavior="Auto" /> + + + ToggleBehavior="Auto" /> + + - + ToggleBehavior="Auto" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AutomationProperties.Name="TestToggle1-Off" + IsChecked="{x:Bind OffTestToggleSwitch.IsOn, Mode=OneWay}"> + ToggleBehavior="Off" /> + + + ToggleBehavior="Off" /> + + - - - - + + - - + AutomationProperties.Name="TestToggle4-Off" + IsChecked="{x:Bind OffTestToggleSwitch.IsOn, Mode=OneWay}" + IsEnabled="False"> - - - - - - - - - - - + Style="{StaticResource IconTest}" + ToggleBehavior="Off" /> + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + ToggleBehavior="Off" /> + + + + + - - + ToggleBehavior="Off" /> + + + + + - - + ToggleBehavior="Off" /> + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ToggleBehavior="Off" /> + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Orientation="Horizontal" + Spacing="16"> + + - - + + + + + - - + + + + + - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + - + - - - - - - - - - - - - - - - - - - + Width="{x:Bind TestSize.Value, Mode=TwoWay}" + Height="{x:Bind TestSize.Value, Mode=TwoWay}" + IconType="Layered" + Style="{StaticResource IconTest}" /> - - - - - - - - - - - - - - - - - - + Width="{x:Bind TestSize.Value, Mode=TwoWay}" + Height="{x:Bind TestSize.Value, Mode=TwoWay}" + IsFilled="True" + Style="{StaticResource IconTest}" /> + + + + + - + + + + + + + + + + + - - - + - + + + + diff --git a/tests/Files.App.UITests/Views/ToolbarPage.xaml b/tests/Files.App.UITests/Views/ToolbarPage.xaml index 2ba237d005e6..b3662ffb1a60 100644 --- a/tests/Files.App.UITests/Views/ToolbarPage.xaml +++ b/tests/Files.App.UITests/Views/ToolbarPage.xaml @@ -8,345 +8,209 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="using:Files.App.UITests.Views" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" mc:Ignorable="d"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + ItemType="ToggleButton" + Label="Xaml Label 4" + OverflowBehavior="Never" + ThemedIcon="{StaticResource App.ThemedIcons.PanelRight}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Files.App.UITests/Views/ToolbarPage.xaml.cs b/tests/Files.App.UITests/Views/ToolbarPage.xaml.cs index f2f8dbd73885..ae8e5bdd48fa 100644 --- a/tests/Files.App.UITests/Views/ToolbarPage.xaml.cs +++ b/tests/Files.App.UITests/Views/ToolbarPage.xaml.cs @@ -3,30 +3,14 @@ using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Controls.Primitives; -using Microsoft.UI.Xaml.Data; -using Microsoft.UI.Xaml.Input; -using Microsoft.UI.Xaml.Media; -using Microsoft.UI.Xaml.Navigation; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.Foundation; -using Windows.Foundation.Collections; - namespace Files.App.UITests.Views { - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// public sealed partial class ToolbarPage : Page { public ToolbarPage() { - this.InitializeComponent(); + InitializeComponent(); } } } diff --git a/tests/Files.App.UITests/app.manifest b/tests/Files.App.UITests/app.manifest index db9db83bafd6..19988fdbd77d 100644 --- a/tests/Files.App.UITests/app.manifest +++ b/tests/Files.App.UITests/app.manifest @@ -5,14 +5,9 @@ - true/PM PerMonitorV2, PerMonitor - \ No newline at end of file +