2015-03-23 22:07:33 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
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 22:07:33 +00:00
|
|
|
*/
|
2015-03-06 17:54:10 +00:00
|
|
|
|
|
|
|
#import "RCTTabBarManager.h"
|
|
|
|
|
|
|
|
#import "RCTBridge.h"
|
|
|
|
#import "RCTTabBar.h"
|
2017-12-18 19:43:35 +00:00
|
|
|
#import "RCTUIManager.h"
|
|
|
|
#import "RCTUIManagerObserverCoordinator.h"
|
2015-03-06 17:54:10 +00:00
|
|
|
|
2016-05-21 00:17:29 +00:00
|
|
|
@implementation RCTConvert (UITabBar)
|
|
|
|
|
|
|
|
RCT_ENUM_CONVERTER(UITabBarItemPositioning, (@{
|
|
|
|
@"fill" : @(UITabBarItemPositioningFill),
|
|
|
|
@"auto" : @(UITabBarItemPositioningAutomatic),
|
|
|
|
@"center" : @(UITabBarItemPositioningCentered)
|
|
|
|
}), UITabBarItemPositioningAutomatic, integerValue)
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2017-12-18 19:43:35 +00:00
|
|
|
@interface RCTTabBarManager () <RCTUIManagerObserver>
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-03-06 17:54:10 +00:00
|
|
|
@implementation RCTTabBarManager
|
2017-12-18 19:43:35 +00:00
|
|
|
{
|
|
|
|
// The main thread only.
|
|
|
|
NSHashTable<RCTTabBar *> *_viewRegistry;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBridge:(RCTBridge *)bridge
|
|
|
|
{
|
|
|
|
[super setBridge:bridge];
|
|
|
|
|
|
|
|
[self.bridge.uiManager.observerCoordinator addObserver:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invalidate
|
|
|
|
{
|
|
|
|
[self.bridge.uiManager.observerCoordinator removeObserver:self];
|
|
|
|
}
|
2015-03-06 17:54:10 +00:00
|
|
|
|
2015-04-09 15:46:53 +00:00
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
2015-03-06 17:54:10 +00:00
|
|
|
- (UIView *)view
|
|
|
|
{
|
2017-12-18 19:43:35 +00:00
|
|
|
if (!_viewRegistry) {
|
|
|
|
_viewRegistry = [NSHashTable hashTableWithOptions:NSPointerFunctionsWeakMemory];
|
|
|
|
}
|
|
|
|
|
|
|
|
RCTTabBar *view = [RCTTabBar new];
|
|
|
|
[_viewRegistry addObject:view];
|
|
|
|
return view;
|
2015-03-06 17:54:10 +00:00
|
|
|
}
|
|
|
|
|
2016-05-03 12:39:21 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(unselectedTintColor, UIColor)
|
2015-05-26 23:40:56 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(barTintColor, UIColor)
|
2015-07-14 15:05:08 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(translucent, BOOL)
|
2017-08-25 07:03:17 +00:00
|
|
|
#if !TARGET_OS_TV
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(barStyle, UIBarStyle)
|
|
|
|
#endif
|
2016-05-21 00:17:29 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(itemPositioning, UITabBarItemPositioning)
|
2016-11-29 20:14:41 +00:00
|
|
|
RCT_EXPORT_VIEW_PROPERTY(unselectedItemTintColor, UIColor)
|
2015-05-26 23:40:56 +00:00
|
|
|
|
2017-12-18 19:43:35 +00:00
|
|
|
#pragma mark - RCTUIManagerObserver
|
|
|
|
|
|
|
|
- (void)uiManagerDidPerformMounting:(__unused RCTUIManager *)manager
|
|
|
|
{
|
|
|
|
RCTExecuteOnMainQueue(^{
|
|
|
|
for (RCTTabBar *view in self->_viewRegistry) {
|
|
|
|
[view uiManagerDidPerformMounting];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:10 +00:00
|
|
|
@end
|