Skip to content

Commit a191d0d

Browse files
committed
Try to impl for iOS
1 parent 7ab7647 commit a191d0d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/ios/RNNTitleViewHelper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
@property(nonatomic, strong) RNNTitleOptions *titleOptions;
2020
@property(nonatomic, strong) RNNSubtitleOptions *subtitleOptions;
21+
@property(nonatomic, strong) Text *parentTestID;
2122

2223
- (instancetype)initWithTitleViewOptions:(RNNOptions *)titleOptions
2324
subTitleOptions:(RNNOptions *)subtitleOptions
25+
parentTestID:(Text *)parentTestID
2426
viewController:(UIViewController *)viewController;
2527

2628
- (void)setup;

lib/ios/RNNTitleViewHelper.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@ @implementation RNNTitleViewHelper
3838

3939
- (instancetype)initWithTitleViewOptions:(RNNTitleOptions *)titleOptions
4040
subTitleOptions:(RNNSubtitleOptions *)subtitleOptions
41+
parentTestID:(Text *)parentTestID
4142
viewController:(UIViewController *)viewController {
4243
self = [super init];
4344
if (self) {
4445
self.viewController = viewController;
4546
self.titleOptions = titleOptions;
4647
self.subtitleOptions = subtitleOptions;
48+
self.parentTestID = parentTestID;
4749
}
4850
return self;
4951
}
@@ -81,7 +83,7 @@ - (void)setup {
8183
if (self.title) {
8284
self.titleView.titleLabel = [self setupTitle];
8385
}
84-
86+
8587
[self centerTitleView:navigationBarBounds
8688
titleLabel:self.titleView.titleLabel
8789
subtitleLabel:self.titleView.subtitleLabel];
@@ -134,6 +136,10 @@ - (UILabel *)setupSubtitle {
134136
UIColor *color = _subtitleOptions.color.get;
135137
subtitleLabel.textColor = color;
136138
}
139+
140+
if (_parentTestID && _parentTestID.hasValue && ((NSString *) _parentTestID.get).length > 0) {
141+
subtitleLabel.accessibilityLabel = [NSString stringWithFormat:@"%@.subtitle", _parentTestID.get];
142+
}
137143

138144
[self.titleView addSubview:subtitleLabel];
139145

@@ -174,6 +180,10 @@ - (UILabel *)setupTitle {
174180
titleLabel.textColor = color;
175181
}
176182

183+
if (_parentTestID && _parentTestID.hasValue && ((NSString *) _parentTestID.get).length > 0) {
184+
titleLabel.accessibilityLabel = [NSString stringWithFormat:@"%@.title", _parentTestID.get];
185+
}
186+
177187
[self.titleView addSubview:titleLabel];
178188

179189
return titleLabel;

lib/ios/TopBarTitlePresenter.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ - (void)setTitleViewWithSubtitle:(RNNTopBarOptions *)options {
4747
_titleViewHelper =
4848
[[RNNTitleViewHelper alloc] initWithTitleViewOptions:options.title
4949
subTitleOptions:options.subtitle
50+
parentTestID:options.testID
5051
viewController:self.boundViewController];
5152

5253
if (options.title.text.hasValue) {

0 commit comments

Comments
 (0)