Skip to content

Commit ffa0725

Browse files
ZHUANGPPfacebook-github-bot
authored andcommitted
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
1 parent e881b24 commit ffa0725

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#import <UIKit/UIKit.h>
9+
10+
#import <react/attributedstring/AttributedString.h>
11+
12+
#import "RCTParagraphComponentView.h"
13+
14+
@interface RCTParagraphComponentAccessibilityProvider : NSObject
15+
16+
- (instancetype)initWithString:(facebook::react::AttributedString)attributedString view:(UIView *)view;
17+
18+
/**
19+
@abstract Array of accessibleElements for use in UIAccessibilityContainer implementation.
20+
*/
21+
- (NSArray<UIAccessibilityElement *> *)accessibilityElements;
22+
23+
@end
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#import "RCTParagraphComponentAccessibilityProvider.h"
9+
10+
#import <Foundation/Foundation.h>
11+
#import <react/components/text/ParagraphProps.h>
12+
#import <react/textlayoutmanager/RCTTextLayoutManager.h>
13+
#import <react/textlayoutmanager/TextLayoutManager.h>
14+
15+
#import "RCTConversions.h"
16+
#import "RCTFabricComponentsPlugins.h"
17+
18+
using namespace facebook::react;
19+
20+
@implementation RCTParagraphComponentAccessibilityProvider {
21+
NSMutableArray<UIAccessibilityElement *> *_accessibilityElements;
22+
AttributedString _attributedString;
23+
__weak UIView *_view;
24+
}
25+
26+
- (instancetype)initWithString:(AttributedString)attributedString view:(UIView *)view
27+
{
28+
if (self = [super init]) {
29+
_attributedString = attributedString;
30+
_view = view;
31+
}
32+
return self;
33+
}
34+
35+
- (NSArray<UIAccessibilityElement *> *)accessibilityElements
36+
{
37+
// verify if accessibleElements are exist
38+
// build an array of the accessibleElements
39+
// add first element has the text for the whole textview in order to read out the whole text
40+
// add additional elements for those parts of text with embedded link so VoiceOver could specially recognize links
41+
// add accessible element for truncation attributed string for automation purposes only
42+
_accessibilityElements = [NSMutableArray new];
43+
return _accessibilityElements;
44+
}
45+
46+
@end

0 commit comments

Comments
 (0)