Skip to content

Commit

Permalink
Add support for the UIAccessibilityTraitsTabBar
Browse files Browse the repository at this point in the history
Summary:
Changelog:
Add the capability to set tabbar accessibilityRole which maps to the iOS's UIAccessibilityTraitsTabBar

Reviewed By: yungsters

Differential Revision: D30490752

fbshipit-source-id: f7561a8932306e133d2f65a5ab40ba0be3899ec3
  • Loading branch information
jimmy623 authored and facebook-github-bot committed Aug 24, 2021
1 parent ff4b336 commit 11f8d9c
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/Components/View/ViewAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type AccessibilityRole =
| 'spinbutton'
| 'switch'
| 'tab'
| 'tabbar'
| 'tablist'
| 'timer'
| 'list'
Expand Down
3 changes: 3 additions & 0 deletions React/Fabric/RCTConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ inline UIAccessibilityTraits RCTUIAccessibilityTraitsFromAccessibilityTraits(
if ((accessibilityTraits & AccessibilityTraits::Switch) != AccessibilityTraits::None) {
result |= AccessibilityTraitSwitch;
}
if ((accessibilityTraits & AccessibilityTraits::TabBar) != AccessibilityTraits::None) {
result |= UIAccessibilityTraitTabBar;
}
return result;
};

Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ @implementation RCTConvert (UIAccessibilityTraits)
@"spinbutton" : @(UIAccessibilityTraitNone),
@"switch" : @(SwitchAccessibilityTrait),
@"tab" : @(UIAccessibilityTraitNone),
@"tabbar" : @(UIAccessibilityTraitTabBar),
@"tablist" : @(UIAccessibilityTraitNone),
@"timer" : @(UIAccessibilityTraitNone),
@"toolbar" : @(UIAccessibilityTraitNone),
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/react/renderer/attributedstring/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ inline std::string toString(const AccessibilityRole &accessibilityRole) {
return "switch";
case AccessibilityRole::Tab:
return "tab";
case AccessibilityRole::TabBar:
return "tabbar";
case AccessibilityRole::Tablist:
return "tablist";
case AccessibilityRole::Timer:
Expand Down Expand Up @@ -687,6 +689,8 @@ inline void fromRawValue(
result = AccessibilityRole::Switch;
} else if (string == "tab") {
result = AccessibilityRole::Tab;
} else if (string == "tabbar") {
result = AccessibilityRole::TabBar;
} else if (string == "tablist") {
result = AccessibilityRole::Tablist;
} else if (string == "timer") {
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/react/renderer/attributedstring/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ enum class AccessibilityRole {
Spinbutton,
Switch,
Tab,
TabBar,
Tablist,
Timer,
Toolbar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum class AccessibilityTraits : uint32_t {
CausesPageTurn = (1 << 14),
Header = (1 << 15),
Switch = (1 << 16),
TabBar = (1 << 17),
};

constexpr enum AccessibilityTraits operator|(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ inline void fromString(const std::string &string, AccessibilityTraits &result) {
result = AccessibilityTraits::Switch;
return;
}
if (string == "tabbar") {
result = AccessibilityTraits::TabBar;
return;
}
result = AccessibilityTraits::None;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
case AccessibilityRole::Tab:
attributes[RCTTextAttributesAccessibilityRoleAttributeName] = @("tab");
break;
case AccessibilityRole::TabBar:
attributes[RCTTextAttributesAccessibilityRoleAttributeName] = @("tabbar");
break;
case AccessibilityRole::Tablist:
attributes[RCTTextAttributesAccessibilityRoleAttributeName] = @("tablist");
break;
Expand Down

0 comments on commit 11f8d9c

Please sign in to comment.