summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2017-01-31 19:49:15 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-10-23 04:34:24 (GMT)
commita787e5f5b177727384bb45d772547735c1269adf (patch)
tree2fa704a0c67355f770c1f5c165759f1c14628463 /Xamarin.Forms.Platform.iOS
parentefd669c4c3e334caa63776ca7bcb2717c5534efa (diff)
downloadxamarin-forms-a787e5f5b177727384bb45d772547735c1269adf.zip
xamarin-forms-a787e5f5b177727384bb45d772547735c1269adf.tar.gz
xamarin-forms-a787e5f5b177727384bb45d772547735c1269adf.tar.bz2
[All] Basic Accessibility Support (#713)
* [Core] Add accessibility properties * [Controls] Add accessibility gallery * [iOS] Implement accessibility properties * [Android] Implement accessibilty properties * [Win] Implement accessibility properties * [Win] Select ListView item on selected for a11y * Update docs * TODO: macOS accessibility * [iOS] Fix failing UI Tests
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs15
-rw-r--r--Xamarin.Forms.Platform.iOS/ViewRenderer.cs43
2 files changed, 58 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
index ed9291b..c3002b0 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ButtonRenderer.cs
@@ -119,6 +119,21 @@ namespace Xamarin.Forms.Platform.iOS
}
}
+ protected override void SetAccessibilityLabel()
+ {
+ // If we have not specified an AccessibilityLabel and the AccessibiltyLabel is current bound to the Title,
+ // exit this method so we don't set the AccessibilityLabel value and break the binding.
+ // This may pose a problem for users who want to explicitly set the AccessibilityLabel to null, but this
+ // will prevent us from inadvertently breaking UI Tests that are using Query.Marked to get the dynamic Title
+ // of the Button.
+
+ var elemValue = (string)Element?.GetValue(Accessibility.NameProperty);
+ if (string.IsNullOrWhiteSpace(elemValue) && Control?.AccessibilityLabel == Control?.Title(UIControlState.Normal))
+ return;
+
+ base.SetAccessibilityLabel();
+ }
+
void OnButtonTouchUpInside(object sender, EventArgs eventArgs)
{
((IButtonController)Element)?.SendReleased();
diff --git a/Xamarin.Forms.Platform.iOS/ViewRenderer.cs b/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
index 13b11e6..8044963 100644
--- a/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/ViewRenderer.cs
@@ -151,6 +151,49 @@ namespace Xamarin.Forms.Platform.MacOS
Control.AccessibilityLabel = (string)Element.GetValue(AutomationProperties.NameProperty) ?? _defaultAccessibilityLabel;
}
+#if __MOBILE__
+ protected override void SetAccessibilityHint()
+ {
+ if (Control == null)
+ {
+ base.SetAccessibilityHint();
+ return;
+ }
+
+ if (Element == null)
+ return;
+
+ if (_defaultAccessibilityHint == null)
+ _defaultAccessibilityHint = Control.AccessibilityHint;
+
+ Control.AccessibilityHint = (string)Element.GetValue(Accessibility.HintProperty) ?? _defaultAccessibilityHint;
+
+ }
+
+ protected override void SetAccessibilityLabel()
+ {
+ if (Control == null)
+ {
+ base.SetAccessibilityLabel();
+ return;
+ }
+
+ if (Element == null)
+ return;
+
+ if (_defaultAccessibilityLabel == null)
+ _defaultAccessibilityLabel = Control.AccessibilityLabel;
+
+ Control.AccessibilityLabel = (string)Element.GetValue(Accessibility.NameProperty) ?? _defaultAccessibilityLabel;
+ }
+
+ protected override void SetIsAccessibilityElement()
+ {
+ if (Control == null)
+ {
+ base.SetIsAccessibilityElement();
+ return;
+ }
protected override void SetIsAccessibilityElement()
{