2015-03-23 20:28:42 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-03-23 20:28:42 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-03-23 20:28:42 +00:00
|
|
|
*/
|
2015-03-06 00:36:41 +00:00
|
|
|
|
|
|
|
#import "RCTTabBarItemManager.h"
|
|
|
|
|
|
|
|
#import "RCTConvert.h"
|
|
|
|
#import "RCTTabBarItem.h"
|
|
|
|
|
|
|
|
@implementation RCTTabBarItemManager
|
|
|
|
|
2015-04-08 12:42:43 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-03-06 00:36:41 +00:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
2015-08-17 14:35:34 +00:00
|
|
|
return [RCTTabBarItem new];
|
2015-03-06 00:36:41 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 11:29:08 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(badge, id /* NSString or NSNumber */)
|
2016-05-03 12:39:21 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(renderAsOriginal, BOOL)
|
Added mechanism for directly mapping JS event handlers to blocks
Summary:
Currently, the system for mapping JS event handlers to blocks is quite clean on the JS side, but is clunky on the native side. The event property is passed as a boolean, which can then be checked by the native side, and if true, the native side is supposed to send an event via the event dispatcher.
This diff adds the facility to declare the property as a block instead. This means that the event side can simply call the block, and it will automatically send the event. Because the blocks for bubbling and direct events are named differently, we can also use this to generate the event registration data and get rid of the arrays of event names.
The name of the event is inferred from the property name, which means that the property for an event called "load" must be called `onLoad` or the mapping won't work. This can be optionally remapped to a different property name on the view itself if necessary, e.g.
RCT_REMAP_VIEW_PROPERTY(onLoad, loadEventBlock, RCTDirectEventBlock)
If you don't want to use this mechanism then for now it is still possible to declare the property as a BOOL instead and use the old mechanism (this approach is now deprecated however, and may eventually be removed altogether).
2015-09-02 12:58:10 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(selected, BOOL)
|
2015-12-08 11:29:08 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(icon, UIImage)
|
2016-05-24 08:52:01 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(selectedIcon, UIImage)
|
2015-12-08 11:29:08 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(systemIcon, UITabBarSystemItem)
|
Added mechanism for directly mapping JS event handlers to blocks
Summary:
Currently, the system for mapping JS event handlers to blocks is quite clean on the JS side, but is clunky on the native side. The event property is passed as a boolean, which can then be checked by the native side, and if true, the native side is supposed to send an event via the event dispatcher.
This diff adds the facility to declare the property as a block instead. This means that the event side can simply call the block, and it will automatically send the event. Because the blocks for bubbling and direct events are named differently, we can also use this to generate the event registration data and get rid of the arrays of event names.
The name of the event is inferred from the property name, which means that the property for an event called "load" must be called `onLoad` or the mapping won't work. This can be optionally remapped to a different property name on the view itself if necessary, e.g.
RCT_REMAP_VIEW_PROPERTY(onLoad, loadEventBlock, RCTDirectEventBlock)
If you don't want to use this mechanism then for now it is still possible to declare the property as a BOOL instead and use the old mechanism (this approach is now deprecated however, and may eventually be removed altogether).
2015-09-02 12:58:10 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
|
2016-11-29 19:37:47 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor)
|
2016-12-19 14:26:07 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(isTVSelectable, BOOL)
|
2017-12-04 19:14:17 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(testID, NSString)
|
2015-03-26 04:29:28 +00:00
|
|
|
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
|
2015-03-06 00:36:41 +00:00
|
|
|
{
|
|
|
|
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;
|
2015-08-24 10:14:33 +00:00
|
|
|
view.barItem.imageInsets = view.barItem.title.length ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0};
|
2015-03-06 00:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|