react-native-navigation 7.39.2 → 7.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Mock/Components/TopBar.tsx +6 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java +1 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt +4 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleSubTitleLayout.kt +10 -0
- package/lib/dist/Mock/Components/TopBar.js +6 -3
- package/lib/ios/RNNTitleViewHelper.h +2 -0
- package/lib/ios/RNNTitleViewHelper.m +13 -1
- package/lib/ios/TopBarTitlePresenter.m +1 -0
- package/package.json +1 -1
|
@@ -26,13 +26,16 @@ export const TopBar = class extends Component<TopBarProps> {
|
|
|
26
26
|
|
|
27
27
|
render() {
|
|
28
28
|
const topBarOptions = this.props.topBarOptions;
|
|
29
|
+
const topbarTestId = topBarOptions?.testID;
|
|
30
|
+
const titleTestId = topbarTestId ? { testID: `${topbarTestId}.title` } : {};
|
|
31
|
+
const subtitleTestId = topbarTestId ? { testID: `${topbarTestId}.subtitle` } : {};
|
|
29
32
|
if (topBarOptions?.visible === false) return null;
|
|
30
33
|
else {
|
|
31
34
|
const component = topBarOptions?.title?.component;
|
|
32
35
|
return (
|
|
33
|
-
<View testID={
|
|
34
|
-
<Text>{topBarOptions?.title?.text}</Text>
|
|
35
|
-
<Text>{topBarOptions?.subtitle?.text}</Text>
|
|
36
|
+
<View testID={topbarTestId}>
|
|
37
|
+
<Text {...titleTestId}>{topBarOptions?.title?.text}</Text>
|
|
38
|
+
<Text {...subtitleTestId}>{topBarOptions?.subtitle?.text}</Text>
|
|
36
39
|
{this.renderButtons(topBarOptions?.leftButtons)}
|
|
37
40
|
{this.renderButtons(topBarOptions?.rightButtons)}
|
|
38
41
|
{component &&
|
package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java
CHANGED
|
@@ -181,6 +181,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
|
|
|
181
181
|
|
|
182
182
|
public void setTestId(String testId) {
|
|
183
183
|
setTag(testId);
|
|
184
|
+
titleAndButtonsContainer.setTestId(testId);
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
public void setTitleTextColor(@ColorInt int color) {
|
|
@@ -99,6 +99,10 @@ class TitleAndButtonsContainer(context: Context) : ViewGroup(context) {
|
|
|
99
99
|
clearComponent()
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
fun setTestId(testId: String) {
|
|
103
|
+
titleSubTitleBar.setTestId(testId)
|
|
104
|
+
}
|
|
105
|
+
|
|
102
106
|
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
|
103
107
|
val titleComponent = getTitleComponent()
|
|
104
108
|
val isCenter = titleComponentAlignment == Alignment.Center
|
|
@@ -75,6 +75,16 @@ class TitleSubTitleLayout(context: Context) : LinearLayout(context) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
fun setTestId(testId: String) {
|
|
79
|
+
if (testId.isEmpty()) {
|
|
80
|
+
this.titleTextView.tag = null
|
|
81
|
+
this.subTitleTextView.tag = null
|
|
82
|
+
} else {
|
|
83
|
+
this.titleTextView.tag = "$testId.title"
|
|
84
|
+
this.subTitleTextView.tag = "$testId.subtitle"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
78
88
|
fun getTitle() = (this.titleTextView.text ?: "").toString()
|
|
79
89
|
|
|
80
90
|
fun clear() {
|
|
@@ -15,13 +15,16 @@ const TopBar = class extends react_1.Component {
|
|
|
15
15
|
}
|
|
16
16
|
render() {
|
|
17
17
|
const topBarOptions = this.props.topBarOptions;
|
|
18
|
+
const topbarTestId = topBarOptions?.testID;
|
|
19
|
+
const titleTestId = topbarTestId ? { testID: `${topbarTestId}.title` } : {};
|
|
20
|
+
const subtitleTestId = topbarTestId ? { testID: `${topbarTestId}.subtitle` } : {};
|
|
18
21
|
if (topBarOptions?.visible === false)
|
|
19
22
|
return null;
|
|
20
23
|
else {
|
|
21
24
|
const component = topBarOptions?.title?.component;
|
|
22
|
-
return (react_1.default.createElement(react_native_1.View, { testID:
|
|
23
|
-
react_1.default.createElement(react_native_1.Text,
|
|
24
|
-
react_1.default.createElement(react_native_1.Text,
|
|
25
|
+
return (react_1.default.createElement(react_native_1.View, { testID: topbarTestId },
|
|
26
|
+
react_1.default.createElement(react_native_1.Text, { ...titleTestId }, topBarOptions?.title?.text),
|
|
27
|
+
react_1.default.createElement(react_native_1.Text, { ...subtitleTestId }, topBarOptions?.subtitle?.text),
|
|
25
28
|
this.renderButtons(topBarOptions?.leftButtons),
|
|
26
29
|
this.renderButtons(topBarOptions?.rightButtons),
|
|
27
30
|
component &&
|
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
|
|
19
19
|
@property(nonatomic, strong) RNNTitleOptions *titleOptions;
|
|
20
20
|
@property(nonatomic, strong) RNNSubtitleOptions *subtitleOptions;
|
|
21
|
+
@property(nonatomic, strong) Text *parentTestID;
|
|
21
22
|
|
|
22
23
|
- (instancetype)initWithTitleViewOptions:(RNNOptions *)titleOptions
|
|
23
24
|
subTitleOptions:(RNNOptions *)subtitleOptions
|
|
25
|
+
parentTestID:(Text *)parentTestID
|
|
24
26
|
viewController:(UIViewController *)viewController;
|
|
25
27
|
|
|
26
28
|
- (void)setup;
|
|
@@ -38,12 +38,14 @@
|
|
|
38
38
|
|
|
39
39
|
- (instancetype)initWithTitleViewOptions:(RNNTitleOptions *)titleOptions
|
|
40
40
|
subTitleOptions:(RNNSubtitleOptions *)subtitleOptions
|
|
41
|
+
parentTestID:(Text *)parentTestID
|
|
41
42
|
viewController:(UIViewController *)viewController {
|
|
42
43
|
self = [super init];
|
|
43
44
|
if (self) {
|
|
44
45
|
self.viewController = viewController;
|
|
45
46
|
self.titleOptions = titleOptions;
|
|
46
47
|
self.subtitleOptions = subtitleOptions;
|
|
48
|
+
self.parentTestID = parentTestID;
|
|
47
49
|
}
|
|
48
50
|
return self;
|
|
49
51
|
}
|
|
@@ -81,7 +83,7 @@
|
|
|
81
83
|
if (self.title) {
|
|
82
84
|
self.titleView.titleLabel = [self setupTitle];
|
|
83
85
|
}
|
|
84
|
-
|
|
86
|
+
|
|
85
87
|
[self centerTitleView:navigationBarBounds
|
|
86
88
|
titleLabel:self.titleView.titleLabel
|
|
87
89
|
subtitleLabel:self.titleView.subtitleLabel];
|
|
@@ -135,6 +137,11 @@
|
|
|
135
137
|
subtitleLabel.textColor = color;
|
|
136
138
|
}
|
|
137
139
|
|
|
140
|
+
if (_parentTestID && _parentTestID.hasValue && ((NSString *)_parentTestID.get).length > 0) {
|
|
141
|
+
subtitleLabel.accessibilityIdentifier =
|
|
142
|
+
[NSString stringWithFormat:@"%@.subtitle", _parentTestID.get];
|
|
143
|
+
}
|
|
144
|
+
|
|
138
145
|
[self.titleView addSubview:subtitleLabel];
|
|
139
146
|
|
|
140
147
|
return subtitleLabel;
|
|
@@ -174,6 +181,11 @@
|
|
|
174
181
|
titleLabel.textColor = color;
|
|
175
182
|
}
|
|
176
183
|
|
|
184
|
+
if (_parentTestID && _parentTestID.hasValue && ((NSString *)_parentTestID.get).length > 0) {
|
|
185
|
+
titleLabel.accessibilityIdentifier =
|
|
186
|
+
[NSString stringWithFormat:@"%@.title", _parentTestID.get];
|
|
187
|
+
}
|
|
188
|
+
|
|
177
189
|
[self.titleView addSubview:titleLabel];
|
|
178
190
|
|
|
179
191
|
return titleLabel;
|