Make testID work for iOS tabs

Reviewed By: shergin

Differential Revision: D6455054

fbshipit-source-id: 3c667b585e9332a1dbfff1fd3325f2c95985a5be
This commit is contained in:
Alex Kotliarskyi 2017-12-04 11:14:17 -08:00 committed by Facebook Github Bot
parent ca106043fc
commit e19d9dec9b
3 changed files with 7 additions and 0 deletions

View File

@ -28,6 +28,7 @@
@property (nonatomic, assign, getter=isSelected) BOOL selected;
@property (nonatomic, readonly) UITabBarItem *barItem;
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
@property (nonatomic, strong) NSString *testID;
#if TARGET_OS_TV
@property (nonatomic, assign) BOOL wasSelectedInJS;

View File

@ -58,6 +58,11 @@ RCT_ENUM_CONVERTER(UITabBarSystemItem, (@{
return _barItem;
}
- (void)setTestID:(NSString *)testID
{
self.barItem.accessibilityIdentifier = testID;
}
- (void)setBadge:(id)badge
{
_badge = [badge copy];

View File

@ -30,6 +30,7 @@ RCT_EXPORT_VIEW_PROPERTY(systemIcon, UITabBarSystemItem)
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor)
RCT_EXPORT_VIEW_PROPERTY(isTVSelectable, BOOL)
RCT_EXPORT_VIEW_PROPERTY(testID, NSString)
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
{
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;