-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[net7.0] [iOS] RadioButton a11y (#11969)
* First attempt of radiobutton a11y * Make Switch trait work as expected * Update control gallery sample * Make class internal for potential backport * Update based on feedback * Add comment * Update based on feedback * Refactor based on feedback * Update * Update Co-authored-by: Rachel Kang <rachelkang@microsoft.com>
- Loading branch information
1 parent
1a23c52
commit bf6a0b7
Showing
6 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using CoreGraphics; | ||
using Microsoft.Maui.Graphics; | ||
using ObjCRuntime; | ||
using UIKit; | ||
|
||
namespace Microsoft.Maui.Platform; | ||
|
||
// This class should remain internal until further refactored. | ||
// It is currently being used only for RadioButton accessibility on iOS. | ||
internal class SemanticSwitchContentView : ContentView | ||
{ | ||
UIAccessibilityTrait _accessibilityTraits; | ||
|
||
internal SemanticSwitchContentView(IContentView virtualView) | ||
{ | ||
CrossPlatformMeasure = virtualView.CrossPlatformMeasure; | ||
CrossPlatformArrange = virtualView.CrossPlatformArrange; | ||
IsAccessibilityElement = true; | ||
} | ||
|
||
static UIKit.UIAccessibilityTrait? s_switchAccessibilityTraits; | ||
UIKit.UIAccessibilityTrait SwitchAccessibilityTraits | ||
{ | ||
get | ||
{ | ||
if (s_switchAccessibilityTraits == null || | ||
s_switchAccessibilityTraits == UIKit.UIAccessibilityTrait.None) | ||
{ | ||
s_switchAccessibilityTraits = new UIKit.UISwitch().AccessibilityTraits; | ||
} | ||
|
||
return s_switchAccessibilityTraits ?? UIKit.UIAccessibilityTrait.None; | ||
} | ||
} | ||
|
||
public override UIAccessibilityTrait AccessibilityTraits | ||
{ | ||
get => _accessibilityTraits |= SwitchAccessibilityTraits; | ||
set => _accessibilityTraits = value | SwitchAccessibilityTraits; | ||
} | ||
} |