2015-03-06 00:36:41 +00:00
|
|
|
/**
|
2015-03-23 20:35:08 +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-06 00:36:41 +00:00
|
|
|
*
|
|
|
|
* @providesModule TabBarIOS
|
2015-03-25 19:55:10 +00:00
|
|
|
* @flow
|
2015-03-06 00:36:41 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2018-03-03 23:04:46 +00:00
|
|
|
const ColorPropType = require('ColorPropType');
|
|
|
|
const React = require('React');
|
2017-04-12 23:09:48 +00:00
|
|
|
const PropTypes = require('prop-types');
|
2018-03-03 23:04:46 +00:00
|
|
|
const StyleSheet = require('StyleSheet');
|
|
|
|
const TabBarItemIOS = require('TabBarItemIOS');
|
2017-03-24 07:22:57 +00:00
|
|
|
const ViewPropTypes = require('ViewPropTypes');
|
2015-03-06 00:36:41 +00:00
|
|
|
|
2018-03-03 23:04:46 +00:00
|
|
|
const requireNativeComponent = require('requireNativeComponent');
|
2015-03-06 00:36:41 +00:00
|
|
|
|
2017-11-02 02:14:03 +00:00
|
|
|
import type {StyleObj} from 'StyleSheetTypes';
|
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
|
|
|
|
class TabBarIOS extends React.Component<ViewProps & {
|
|
|
|
style?: StyleObj,
|
|
|
|
unselectedTintColor?: string,
|
|
|
|
tintColor?: string,
|
|
|
|
unselectedItemTintColor?: string,
|
|
|
|
barTintColor?: string,
|
2017-08-25 07:03:17 +00:00
|
|
|
barStyle?: 'default' | 'black',
|
2017-08-18 01:36:54 +00:00
|
|
|
translucent?: boolean,
|
|
|
|
itemPositioning?: 'fill' | 'center' | 'auto',
|
2017-11-02 02:14:03 +00:00
|
|
|
children: React.Node,
|
2017-08-18 01:36:54 +00:00
|
|
|
}> {
|
2016-07-26 08:00:02 +00:00
|
|
|
static Item = TabBarItemIOS;
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-03-24 07:22:57 +00:00
|
|
|
...ViewPropTypes,
|
|
|
|
style: ViewPropTypes.style,
|
2016-05-03 12:39:21 +00:00
|
|
|
/**
|
|
|
|
* Color of text on unselected tabs
|
|
|
|
*/
|
|
|
|
unselectedTintColor: ColorPropType,
|
2015-05-26 23:40:56 +00:00
|
|
|
/**
|
|
|
|
* Color of the currently selected tab icon
|
|
|
|
*/
|
2015-12-23 03:29:01 +00:00
|
|
|
tintColor: ColorPropType,
|
2016-11-29 20:14:41 +00:00
|
|
|
/**
|
|
|
|
* Color of unselected tab icons. Available since iOS 10.
|
|
|
|
*/
|
|
|
|
unselectedItemTintColor: ColorPropType,
|
2015-05-26 23:40:56 +00:00
|
|
|
/**
|
|
|
|
* Background color of the tab bar
|
|
|
|
*/
|
2015-12-23 03:29:01 +00:00
|
|
|
barTintColor: ColorPropType,
|
2017-08-25 07:03:17 +00:00
|
|
|
/**
|
|
|
|
* The style of the tab bar. Supported values are 'default', 'black'.
|
|
|
|
* Use 'black' instead of setting `barTintColor` to black. This produces
|
|
|
|
* a tab bar with the native iOS style with higher translucency.
|
|
|
|
*/
|
|
|
|
barStyle: PropTypes.oneOf(['default', 'black']),
|
2015-07-14 15:05:08 +00:00
|
|
|
/**
|
|
|
|
* A Boolean value that indicates whether the tab bar is translucent
|
|
|
|
*/
|
2017-04-12 23:09:48 +00:00
|
|
|
translucent: PropTypes.bool,
|
2016-05-21 00:17:29 +00:00
|
|
|
/**
|
|
|
|
* Specifies tab bar item positioning. Available values are:
|
|
|
|
* - fill - distributes items across the entire width of the tab bar
|
|
|
|
* - center - centers item in the available tab bar space
|
|
|
|
* - auto (default) - distributes items dynamically according to the
|
|
|
|
* user interface idiom. In a horizontally compact environment (e.g. iPhone 5)
|
|
|
|
* this value defaults to `fill`, in a horizontally regular one (e.g. iPad)
|
|
|
|
* it defaults to center.
|
|
|
|
*/
|
2017-04-12 23:09:48 +00:00
|
|
|
itemPositioning: PropTypes.oneOf(['fill', 'center', 'auto']),
|
2016-07-26 08:00:02 +00:00
|
|
|
};
|
2015-04-02 20:35:03 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-03-06 00:36:41 +00:00
|
|
|
return (
|
2015-05-26 23:40:56 +00:00
|
|
|
<RCTTabBar
|
|
|
|
style={[styles.tabGroup, this.props.style]}
|
2016-05-03 12:39:21 +00:00
|
|
|
unselectedTintColor={this.props.unselectedTintColor}
|
2016-11-29 20:14:41 +00:00
|
|
|
unselectedItemTintColor={this.props.unselectedItemTintColor}
|
2015-05-26 23:40:56 +00:00
|
|
|
tintColor={this.props.tintColor}
|
2015-07-14 15:05:08 +00:00
|
|
|
barTintColor={this.props.barTintColor}
|
2017-08-25 07:03:17 +00:00
|
|
|
barStyle={this.props.barStyle}
|
2016-05-21 00:17:29 +00:00
|
|
|
itemPositioning={this.props.itemPositioning}
|
2015-07-14 15:05:08 +00:00
|
|
|
translucent={this.props.translucent !== false}>
|
2017-11-02 02:14:03 +00:00
|
|
|
{this.props.children}
|
2015-03-17 10:08:46 +00:00
|
|
|
</RCTTabBar>
|
2015-03-06 00:36:41 +00:00
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-03-06 00:36:41 +00:00
|
|
|
|
2018-03-03 23:04:46 +00:00
|
|
|
const styles = StyleSheet.create({
|
2015-03-06 00:36:41 +00:00
|
|
|
tabGroup: {
|
|
|
|
flex: 1,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-03 23:04:46 +00:00
|
|
|
const RCTTabBar = requireNativeComponent('RCTTabBar', TabBarIOS);
|
2015-03-06 00:36:41 +00:00
|
|
|
|
|
|
|
module.exports = TabBarIOS;
|