-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build the framework for RCTParagraphComponentAccessibilityProvider
Summary: Changelog: [iOS][Added] - This is the first step to build RCTParagraphComponentAccessibilityProvider. The main idea of RCTParagraphComponentAccessibilityProvider is to provide an array of accessible elements for the AttributedString in PCTParagraphComponentView. Reviewed By: sammy-SC Differential Revision: D22214855 fbshipit-source-id: 69d47555e86452620f89a4b2e21ed6065c8e669c
- Loading branch information
1 parent
e881b24
commit ffa0725
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.h
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,23 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import <react/attributedstring/AttributedString.h> | ||
|
||
#import "RCTParagraphComponentView.h" | ||
|
||
@interface RCTParagraphComponentAccessibilityProvider : NSObject | ||
|
||
- (instancetype)initWithString:(facebook::react::AttributedString)attributedString view:(UIView *)view; | ||
|
||
/** | ||
@abstract Array of accessibleElements for use in UIAccessibilityContainer implementation. | ||
*/ | ||
- (NSArray<UIAccessibilityElement *> *)accessibilityElements; | ||
|
||
@end |
46 changes: 46 additions & 0 deletions
46
React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm
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,46 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "RCTParagraphComponentAccessibilityProvider.h" | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <react/components/text/ParagraphProps.h> | ||
#import <react/textlayoutmanager/RCTTextLayoutManager.h> | ||
#import <react/textlayoutmanager/TextLayoutManager.h> | ||
|
||
#import "RCTConversions.h" | ||
#import "RCTFabricComponentsPlugins.h" | ||
|
||
using namespace facebook::react; | ||
|
||
@implementation RCTParagraphComponentAccessibilityProvider { | ||
NSMutableArray<UIAccessibilityElement *> *_accessibilityElements; | ||
AttributedString _attributedString; | ||
__weak UIView *_view; | ||
} | ||
|
||
- (instancetype)initWithString:(AttributedString)attributedString view:(UIView *)view | ||
{ | ||
if (self = [super init]) { | ||
_attributedString = attributedString; | ||
_view = view; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSArray<UIAccessibilityElement *> *)accessibilityElements | ||
{ | ||
// verify if accessibleElements are exist | ||
// build an array of the accessibleElements | ||
// add first element has the text for the whole textview in order to read out the whole text | ||
// add additional elements for those parts of text with embedded link so VoiceOver could specially recognize links | ||
// add accessible element for truncation attributed string for automation purposes only | ||
_accessibilityElements = [NSMutableArray new]; | ||
return _accessibilityElements; | ||
} | ||
|
||
@end |