Skip to content

Commit

Permalink
feat: Implement FlipViewAutomationPeer
Browse files Browse the repository at this point in the history
  • Loading branch information
morning4coffe-dev authored and MartinZikmund committed Jun 17, 2024
1 parent 3c49843 commit f536856
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/Uno.UI/UI/Xaml/Automation/Peers/FlipViewAutomationPeer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference FlipViewAutomationPeer_Partial.cpp, tag winui3/release/1.5-stable

using System.Collections.Generic;

namespace Microsoft.UI.Xaml.Automation.Peers;

/// <summary>
/// Exposes FlipView types to Microsoft UI Automation.
/// </summary>
public partial class FlipViewAutomationPeer : SelectorAutomationPeer
{
public FlipViewAutomationPeer(Controls.FlipView owner) : base(owner)
{

}

protected override IList<AutomationPeer> GetChildrenCore()
{
var children = base.GetChildrenCore();

if ((Owner as Controls.FlipView).SelectedItem is { } selectedItem)
{
var itemPeer = CreateItemAutomationPeer(selectedItem);

if (itemPeer is { })
{
var itemPeerAsAP = itemPeer as AutomationPeer;
children.Add(itemPeerAsAP);

if (children is { })
{
(var previousButton, var nextButton) = (Owner as Controls.FlipView).GetPreviousAndNextButtons();

if (nextButton is { })
{
var nextButtonAP = nextButton.GetOrCreateAutomationPeer();

if (nextButtonAP is { })
{
children.Insert(0, nextButtonAP);
}
}
if (previousButton is { })
{
var previousButtonAP = previousButton.GetOrCreateAutomationPeer();

if (previousButtonAP is { })
{
children.Insert(0, previousButtonAP);
}
}
}
}
}

return children;
}

protected override string GetClassNameCore() => nameof(Controls.FlipView);

protected override AutomationControlType GetAutomationControlTypeCore()
=> AutomationControlType.List;//UNO TODO: AutomationControlType.FlipView;

}
6 changes: 6 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/FlipView/FlipView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@ public bool UseTouchAnimationsForAllNavigation
DependencyProperty.Register("UseTouchAnimationsForAllNavigation", typeof(bool), typeof(FlipView), new FrameworkPropertyMetadata(true));

partial void InitializePartial();

internal (ButtonBase previousButton, ButtonBase nextButton) GetPreviousAndNextButtons()
{
// UNO TODO: Implement GetPreviousAndNextButtons on FlipView
return (null, null);
}
}
}

0 comments on commit f536856

Please sign in to comment.