You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/09/14 11:28:57 UTC
[2/8] incubator-weex git commit: * [ios] support multi roles
* [ios] support multi roles
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/70d421b9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/70d421b9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/70d421b9
Branch: refs/heads/0.16-dev
Commit: 70d421b95526fa6835dc0040860d0c815d11135c
Parents: 16fb0d9
Author: acton393 <zh...@gmail.com>
Authored: Tue Sep 12 23:49:19 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue Sep 12 23:49:19 2017 +0800
----------------------------------------------------------------------
.../Sources/Component/WXComponent_internal.h | 2 +-
ios/sdk/WeexSDK/Sources/Model/WXComponent.m | 25 +++++++++++++-------
2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/70d421b9/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
index 685ec07..df61f6f 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
+++ b/ios/sdk/WeexSDK/Sources/Component/WXComponent_internal.h
@@ -64,7 +64,7 @@
/**
* accessibility support
*/
- UIAccessibilityTraits _role; //accessibility
+ NSString * _role; //accessibility
NSString * _ariaLabel; //accessibilityLabel
NSString * _ariaHidden; // accessibilityElementsHidden
NSString * _accessible; // accessible
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/70d421b9/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
index 18e7d7c..254a128 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.m
@@ -108,13 +108,13 @@
}
}
- if (attributes[@"role"]){
- _role = [WXConvert WXUIAccessibilityTraits:attributes[@"role"]];
- }
if (attributes[@"ariaHidden"]) {
_ariaHidden = [WXConvert NSString:attributes[@"ariaHidden"]];
}
+ if (attributes[@"role"]) {
+ _role = attributes[@"role"];
+ }
if (attributes[@"ariaLabel"]) {
_ariaLabel = [WXConvert NSString:attributes[@"ariaLabel"]];
}
@@ -140,6 +140,16 @@
return self;
}
+- (UIAccessibilityTraits)_parseAccessibilityTraitsWithTraits:(UIAccessibilityTraits)trait role:(NSString*)roleStr
+{
+ UIAccessibilityTraits newTrait = trait;
+ for (NSString * role in [roleStr componentsSeparatedByString:@" "]) {
+ newTrait |= [WXConvert WXUIAccessibilityTraits: role];
+ }
+
+ return newTrait;
+}
+
- (void)dealloc
{
free_css_node(_cssNode);
@@ -259,7 +269,7 @@
_layer.wx_component = self;
if (_role) {
- _view.accessibilityTraits |= _role;
+ [_view setAccessibilityTraits:[self _parseAccessibilityTraitsWithTraits:self.view.accessibilityTraits role:_role]];
}
if (_testId) {
@@ -610,10 +620,9 @@
- (void)_configWXComponentA11yWithAttributes:(NSDictionary *)attributes
{
WX_CHECK_COMPONENT_TYPE(self.componentType)
-
- if (attributes[@"role"]) {
- _role = [WXConvert WXUIAccessibilityTraits:attributes[@"role"]];
- self.view.accessibilityTraits = _role;
+ if (attributes[@"role"]){
+ _role = attributes[@"role"];
+ [self.view setAccessibilityTraits:[self _parseAccessibilityTraitsWithTraits:self.view.accessibilityTraits role:_role]];
}
if (attributes[@"ariaHidden"]) {
_ariaHidden = [WXConvert NSString:attributes[@"ariaHidden"]];