mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-11 17:19:35 +08:00
Remove TabbarIOS from OSS
Reviewed By: fkgozali Differential Revision: D13858496 fbshipit-source-id: ba9dd9912f4abcbeb3326f412ec91be9bee9cfd3
This commit is contained in:
committed by
Facebook Github Bot
parent
8a50bc3ab3
commit
02697291ff
@@ -1,104 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @noflow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
import type {SyntheticEvent} from 'CoreEventTypes';
|
||||
import type {NativeComponent} from 'ReactNative';
|
||||
import type {ImageSource} from 'ImageSource';
|
||||
|
||||
type TabBarItemEvent = SyntheticEvent<null>;
|
||||
|
||||
type NativeProps = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
|
||||
/**
|
||||
* Little red bubble that sits at the top right of the icon.
|
||||
*/
|
||||
badge?: ?(string | number),
|
||||
|
||||
/**
|
||||
* Background color for the badge. Available since iOS 10.
|
||||
*/
|
||||
badgeColor?: ColorValue,
|
||||
|
||||
/**
|
||||
* Items comes with a few predefined system icons. Note that if you are
|
||||
* using them, the title and selectedIcon will be overridden with the
|
||||
* system ones.
|
||||
*/
|
||||
systemIcon?: ?(
|
||||
| 'bookmarks'
|
||||
| 'contacts'
|
||||
| 'downloads'
|
||||
| 'favorites'
|
||||
| 'featured'
|
||||
| 'history'
|
||||
| 'more'
|
||||
| 'most-recent'
|
||||
| 'most-viewed'
|
||||
| 'recents'
|
||||
| 'search'
|
||||
| 'top-rated'
|
||||
),
|
||||
|
||||
/**
|
||||
* A custom icon for the tab. It is ignored when a system icon is defined.
|
||||
*/
|
||||
icon?: ?ImageSource,
|
||||
|
||||
/**
|
||||
* A custom icon when the tab is selected. It is ignored when a system
|
||||
* icon is defined. If left empty, the icon will be tinted in blue.
|
||||
*/
|
||||
selectedIcon?: ?ImageSource,
|
||||
|
||||
/**
|
||||
* Callback when this tab is being selected, you should change the state of your
|
||||
* component to set selected={true}.
|
||||
*/
|
||||
onPress?: ?(event: TabBarItemEvent) => mixed,
|
||||
|
||||
/**
|
||||
* If set to true it renders the image as original,
|
||||
* it defaults to being displayed as a template
|
||||
*/
|
||||
renderAsOriginal?: ?boolean,
|
||||
|
||||
/**
|
||||
* It specifies whether the children are visible or not. If you see a
|
||||
* blank content, you probably forgot to add a selected one.
|
||||
*/
|
||||
selected?: ?boolean,
|
||||
|
||||
/**
|
||||
* Text that appears under the icon. It is ignored when a system icon
|
||||
* is defined.
|
||||
*/
|
||||
title?: ?string,
|
||||
|
||||
/**
|
||||
* *(Apple TV only)* When set to true, this view will be focusable
|
||||
* and navigable using the Apple TV remote.
|
||||
*
|
||||
* @platform ios
|
||||
*/
|
||||
isTVSelectable?: ?boolean,
|
||||
|}>;
|
||||
|
||||
type RCTTabBarItemNativeType = Class<NativeComponent<NativeProps>>;
|
||||
|
||||
module.exports = ((requireNativeComponent(
|
||||
'RCTTabBarItem',
|
||||
): any): RCTTabBarItemNativeType);
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const requireNativeComponent = require('requireNativeComponent');
|
||||
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
|
||||
import type {NativeComponent} from 'ReactNative';
|
||||
|
||||
type NativeProps = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
unselectedTintColor?: ColorValue,
|
||||
tintColor?: ColorValue,
|
||||
unselectedItemTintColor?: ColorValue,
|
||||
barTintColor?: ColorValue,
|
||||
barStyle?: ?('default' | 'black'),
|
||||
translucent?: ?boolean,
|
||||
itemPositioning?: ?('fill' | 'center' | 'auto'),
|
||||
|}>;
|
||||
|
||||
type RCTTabBarNativeType = Class<NativeComponent<NativeProps>>;
|
||||
|
||||
module.exports = ((requireNativeComponent(
|
||||
'RCTTabBar',
|
||||
): any): RCTTabBarNativeType);
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const TabBarItemIOS = require('TabBarItemIOS');
|
||||
const View = require('View');
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class DummyTabBarIOS extends React.Component<$FlowFixMeProps> {
|
||||
static Item = TabBarItemIOS;
|
||||
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={[this.props.style, styles.tabGroup]}>
|
||||
{this.props.children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabGroup: {
|
||||
flex: 1,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = DummyTabBarIOS;
|
||||
@@ -1,108 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('React');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const TabBarItemIOS = require('TabBarItemIOS');
|
||||
|
||||
const RCTTabBar = require('RCTTabBarNativeComponent');
|
||||
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
|
||||
/**
|
||||
* Color of text on unselected tabs
|
||||
*/
|
||||
unselectedTintColor?: ColorValue,
|
||||
|
||||
/**
|
||||
* Color of the currently selected tab icon
|
||||
*/
|
||||
tintColor?: ColorValue,
|
||||
|
||||
/**
|
||||
* Color of unselected tab icons. Available since iOS 10.
|
||||
*/
|
||||
unselectedItemTintColor?: ColorValue,
|
||||
|
||||
/**
|
||||
* Background color of the tab bar
|
||||
*/
|
||||
barTintColor?: ColorValue,
|
||||
|
||||
/**
|
||||
* 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?: ?('default' | 'black'),
|
||||
|
||||
/**
|
||||
* A Boolean value that indicates whether the tab bar is translucent
|
||||
*/
|
||||
translucent?: ?boolean,
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
itemPositioning?: ?('fill' | 'center' | 'auto'),
|
||||
|}>;
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class TabBarIOS extends React.Component<Props> {
|
||||
static Item = TabBarItemIOS;
|
||||
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<RCTTabBar
|
||||
style={[styles.tabGroup, this.props.style]}
|
||||
unselectedTintColor={this.props.unselectedTintColor}
|
||||
unselectedItemTintColor={this.props.unselectedItemTintColor}
|
||||
tintColor={this.props.tintColor}
|
||||
barTintColor={this.props.barTintColor}
|
||||
barStyle={this.props.barStyle}
|
||||
itemPositioning={this.props.itemPositioning}
|
||||
translucent={this.props.translucent !== false}>
|
||||
{this.props.children}
|
||||
</RCTTabBar>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabGroup: {
|
||||
flex: 1,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = TabBarIOS;
|
||||
@@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('React');
|
||||
const View = require('View');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class DummyTab extends React.Component {
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
if (!this.props.selected) {
|
||||
return <View />;
|
||||
}
|
||||
return (
|
||||
<View style={[this.props.style, styles.tab]}>{this.props.children}</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tab: {
|
||||
// TODO(5405356): Implement overflow: visible so position: absolute isn't useless
|
||||
// position: 'absolute',
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
borderColor: 'red',
|
||||
borderWidth: 1,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = DummyTab;
|
||||
@@ -1,169 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @noflow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('React');
|
||||
const StaticContainer = require('StaticContainer.react');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const View = require('View');
|
||||
const RCTTabBarItemNativeComponent = require('RCTTabBarItemNativeComponent');
|
||||
|
||||
import type {ViewProps} from 'ViewPropTypes';
|
||||
import type {ColorValue} from 'StyleSheetTypes';
|
||||
import type {SyntheticEvent} from 'CoreEventTypes';
|
||||
import type {ImageSource} from 'ImageSource';
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
|
||||
/**
|
||||
* Little red bubble that sits at the top right of the icon.
|
||||
*/
|
||||
badge?: ?(string | number),
|
||||
|
||||
/**
|
||||
* Background color for the badge. Available since iOS 10.
|
||||
*/
|
||||
badgeColor?: ColorValue,
|
||||
|
||||
/**
|
||||
* Items comes with a few predefined system icons. Note that if you are
|
||||
* using them, the title and selectedIcon will be overridden with the
|
||||
* system ones.
|
||||
*/
|
||||
systemIcon?: ?(
|
||||
| 'bookmarks'
|
||||
| 'contacts'
|
||||
| 'downloads'
|
||||
| 'favorites'
|
||||
| 'featured'
|
||||
| 'history'
|
||||
| 'more'
|
||||
| 'most-recent'
|
||||
| 'most-viewed'
|
||||
| 'recents'
|
||||
| 'search'
|
||||
| 'top-rated'
|
||||
),
|
||||
|
||||
/**
|
||||
* A custom icon for the tab. It is ignored when a system icon is defined.
|
||||
*/
|
||||
icon?: ?ImageSource,
|
||||
|
||||
/**
|
||||
* A custom icon when the tab is selected. It is ignored when a system
|
||||
* icon is defined. If left empty, the icon will be tinted in blue.
|
||||
*/
|
||||
selectedIcon?: ?ImageSource,
|
||||
|
||||
/**
|
||||
* Callback when this tab is being selected, you should change the state of your
|
||||
* component to set selected={true}.
|
||||
*/
|
||||
onPress?: ?(event: SyntheticEvent<null>) => mixed,
|
||||
|
||||
/**
|
||||
* If set to true it renders the image as original,
|
||||
* it defaults to being displayed as a template
|
||||
*/
|
||||
renderAsOriginal?: ?boolean,
|
||||
|
||||
/**
|
||||
* It specifies whether the children are visible or not. If you see a
|
||||
* blank content, you probably forgot to add a selected one.
|
||||
*/
|
||||
selected?: ?boolean,
|
||||
|
||||
/**
|
||||
* Text that appears under the icon. It is ignored when a system icon
|
||||
* is defined.
|
||||
*/
|
||||
title?: ?string,
|
||||
|
||||
/**
|
||||
* *(Apple TV only)* When set to true, this view will be focusable
|
||||
* and navigable using the Apple TV remote.
|
||||
*
|
||||
* @platform ios
|
||||
*/
|
||||
isTVSelectable?: ?boolean,
|
||||
|}>;
|
||||
|
||||
type State = {|
|
||||
hasBeenSelected: boolean,
|
||||
|};
|
||||
|
||||
let showedDeprecationWarning = false;
|
||||
|
||||
class TabBarItemIOS extends React.Component<Props, State> {
|
||||
state = {
|
||||
hasBeenSelected: false,
|
||||
};
|
||||
|
||||
UNSAFE_componentWillMount() {
|
||||
if (this.props.selected) {
|
||||
this.setState({hasBeenSelected: true});
|
||||
}
|
||||
}
|
||||
|
||||
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
||||
if (this.state.hasBeenSelected || nextProps.selected) {
|
||||
this.setState({hasBeenSelected: true});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (!showedDeprecationWarning) {
|
||||
console.warn(
|
||||
'TabBarIOS and TabBarItemIOS are deprecated and will be removed in a future release. ' +
|
||||
'Please use react-native-tab-view instead.',
|
||||
);
|
||||
|
||||
showedDeprecationWarning = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {style, children, ...props} = this.props;
|
||||
|
||||
// if the tab has already been shown once, always continue to show it so we
|
||||
// preserve state between tab transitions
|
||||
let tabContents;
|
||||
if (this.state.hasBeenSelected) {
|
||||
tabContents = (
|
||||
<StaticContainer shouldUpdate={this.props.selected}>
|
||||
{children}
|
||||
</StaticContainer>
|
||||
);
|
||||
} else {
|
||||
tabContents = <View />;
|
||||
}
|
||||
|
||||
return (
|
||||
<RCTTabBarItemNativeComponent {...props} style={[styles.tab, style]}>
|
||||
{tabContents}
|
||||
</RCTTabBarItemNativeComponent>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tab: {
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = TabBarItemIOS;
|
||||
@@ -131,9 +131,6 @@ module.exports = {
|
||||
}
|
||||
return require('SwipeableListView');
|
||||
},
|
||||
get TabBarIOS() {
|
||||
return require('TabBarIOS');
|
||||
},
|
||||
get Text() {
|
||||
return require('Text');
|
||||
},
|
||||
|
||||
@@ -158,16 +158,6 @@ const ComponentExamples: Array<RNTesterExample> = [
|
||||
module: require('./SwitchExample'),
|
||||
supportsTVOS: false,
|
||||
},
|
||||
{
|
||||
key: 'TabBarIOSExample',
|
||||
module: require('./TabBarIOSExample'),
|
||||
supportsTVOS: true,
|
||||
},
|
||||
{
|
||||
key: 'TabBarIOSBarStyleExample',
|
||||
module: require('./TabBarIOSBarStyleExample'),
|
||||
supportsTVOS: false,
|
||||
},
|
||||
{
|
||||
key: 'TextExample',
|
||||
module: require('./TextExample.ios'),
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* The examples provided by Facebook are for non-commercial testing and
|
||||
* evaluation purposes only.
|
||||
*
|
||||
* Facebook reserves all rights not expressly granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
||||
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {StyleSheet, TabBarIOS, Text, View} = ReactNative;
|
||||
|
||||
const base64Icon =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
|
||||
|
||||
class TabBarIOSBarStyleExample extends React.Component<{}> {
|
||||
render() {
|
||||
return (
|
||||
<TabBarIOS barStyle="black">
|
||||
<TabBarIOS.Item title="Tab" icon={{uri: base64Icon, scale: 3}} selected>
|
||||
<View style={styles.tabContent}>
|
||||
<Text style={styles.tabText}>Single page</Text>
|
||||
</View>
|
||||
</TabBarIOS.Item>
|
||||
</TabBarIOS>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabContent: {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
},
|
||||
tabText: {
|
||||
color: 'white',
|
||||
margin: 50,
|
||||
},
|
||||
});
|
||||
|
||||
exports.title = '<TabBarIOS> - Custom Bar Style';
|
||||
exports.description = 'Tab-based navigation.';
|
||||
exports.displayName = 'TabBarIOSBarStyleExample';
|
||||
exports.examples = [
|
||||
{
|
||||
title: 'Custom tab bar navigation',
|
||||
render: function(): React.Element<typeof TabBarIOSBarStyleExample> {
|
||||
return <TabBarIOSBarStyleExample />;
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow strict-local
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {StyleSheet, TabBarIOS, Text, View} = ReactNative;
|
||||
|
||||
const base64Icon =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';
|
||||
|
||||
type Props = $ReadOnly<{||}>;
|
||||
type State = {|
|
||||
selectedTab: string,
|
||||
notifCount: number,
|
||||
presses: number,
|
||||
|};
|
||||
|
||||
class TabBarExample extends React.Component<Props, State> {
|
||||
state = {
|
||||
selectedTab: 'redTab',
|
||||
notifCount: 0,
|
||||
presses: 0,
|
||||
};
|
||||
|
||||
_renderContent = (color: string, pageText: string, num?: number) => {
|
||||
return (
|
||||
<View style={[styles.tabContent, {backgroundColor: color}]}>
|
||||
<Text style={styles.tabText}>{pageText}</Text>
|
||||
<Text style={styles.tabText}>
|
||||
{num} re-renders of the {pageText}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<TabBarIOS
|
||||
unselectedTintColor="yellow"
|
||||
tintColor="white"
|
||||
unselectedItemTintColor="red"
|
||||
barTintColor="darkslateblue">
|
||||
<TabBarIOS.Item
|
||||
title="Blue Tab"
|
||||
icon={{uri: base64Icon, scale: 3}}
|
||||
selected={this.state.selectedTab === 'blueTab'}
|
||||
onPress={() => {
|
||||
this.setState({
|
||||
selectedTab: 'blueTab',
|
||||
notifCount: this.state.notifCount + 1,
|
||||
});
|
||||
}}>
|
||||
{this._renderContent('#414A8C', 'Blue Tab', this.state.notifCount)}
|
||||
</TabBarIOS.Item>
|
||||
<TabBarIOS.Item
|
||||
systemIcon="history"
|
||||
badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
|
||||
badgeColor="black"
|
||||
selected={this.state.selectedTab === 'redTab'}
|
||||
onPress={() => {
|
||||
this.setState({
|
||||
selectedTab: 'redTab',
|
||||
notifCount: this.state.notifCount + 1,
|
||||
});
|
||||
}}>
|
||||
{this._renderContent('#783E33', 'Red Tab', this.state.notifCount)}
|
||||
</TabBarIOS.Item>
|
||||
<TabBarIOS.Item
|
||||
icon={require('./flux.png')}
|
||||
selectedIcon={require('./relay.png')}
|
||||
renderAsOriginal
|
||||
title="More"
|
||||
selected={this.state.selectedTab === 'greenTab'}
|
||||
onPress={() => {
|
||||
this.setState({
|
||||
selectedTab: 'greenTab',
|
||||
presses: this.state.presses + 1,
|
||||
});
|
||||
}}>
|
||||
{this._renderContent('#21551C', 'Green Tab', this.state.presses)}
|
||||
</TabBarIOS.Item>
|
||||
</TabBarIOS>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabContent: {
|
||||
flex: 1,
|
||||
alignItems: 'center',
|
||||
},
|
||||
tabText: {
|
||||
color: 'white',
|
||||
margin: 50,
|
||||
},
|
||||
});
|
||||
|
||||
exports.title = '<TabBarIOS>';
|
||||
exports.description = 'Tab-based navigation.';
|
||||
exports.displayName = 'TabBarExample';
|
||||
exports.examples = [
|
||||
{
|
||||
title: 'Simple tab navigation',
|
||||
render: function(): React.Element<typeof TabBarExample> {
|
||||
return <TabBarExample />;
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -58,10 +58,6 @@
|
||||
13513F3C1B1F43F400FCE529 /* RCTProgressViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13513F3B1B1F43F400FCE529 /* RCTProgressViewManager.m */; };
|
||||
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */; };
|
||||
1372B70A1AB030C200659ED6 /* RCTAppState.m in Sources */ = {isa = PBXBuildFile; fileRef = 1372B7091AB030C200659ED6 /* RCTAppState.m */; };
|
||||
137327E71AA5CF210034F82E /* RCTTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E01AA5CF210034F82E /* RCTTabBar.m */; };
|
||||
137327E81AA5CF210034F82E /* RCTTabBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E21AA5CF210034F82E /* RCTTabBarItem.m */; };
|
||||
137327E91AA5CF210034F82E /* RCTTabBarItemManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */; };
|
||||
137327EA1AA5CF210034F82E /* RCTTabBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E61AA5CF210034F82E /* RCTTabBarManager.m */; };
|
||||
1384E2081E806D4E00545659 /* RCTNativeModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 1384E2061E806D4E00545659 /* RCTNativeModule.h */; };
|
||||
1384E2091E806D4E00545659 /* RCTNativeModule.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1384E2071E806D4E00545659 /* RCTNativeModule.mm */; };
|
||||
1384E20A1E806D5700545659 /* RCTNativeModule.h in Headers */ = {isa = PBXBuildFile; fileRef = 1384E2061E806D4E00545659 /* RCTNativeModule.h */; };
|
||||
@@ -251,10 +247,6 @@
|
||||
2D3B5EE01D9B09AD00451313 /* RCTRootShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13BCE8081C99CB9D00DD7AAD /* RCTRootShadowView.m */; };
|
||||
2D3B5EE31D9B09B700451313 /* RCTSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 131B6AF11AF1093D00FFC3E0 /* RCTSegmentedControl.m */; };
|
||||
2D3B5EE41D9B09BB00451313 /* RCTSegmentedControlManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 131B6AF31AF1093D00FFC3E0 /* RCTSegmentedControlManager.m */; };
|
||||
2D3B5EEA1D9B09CD00451313 /* RCTTabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E01AA5CF210034F82E /* RCTTabBar.m */; };
|
||||
2D3B5EEB1D9B09D000451313 /* RCTTabBarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E21AA5CF210034F82E /* RCTTabBarItem.m */; };
|
||||
2D3B5EEC1D9B09D400451313 /* RCTTabBarItemManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */; };
|
||||
2D3B5EED1D9B09D700451313 /* RCTTabBarManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 137327E61AA5CF210034F82E /* RCTTabBarManager.m */; };
|
||||
2D3B5EEE1D9B09DA00451313 /* RCTView.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E067501A70F44B002CDEE1 /* RCTView.m */; };
|
||||
2D3B5EEF1D9B09DC00451313 /* RCTViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13E0674E1A70F44B002CDEE1 /* RCTViewManager.m */; };
|
||||
2D3B5EF01D9B09E300451313 /* RCTWrapperViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B080241A694A8400A75B9A /* RCTWrapperViewController.m */; };
|
||||
@@ -373,10 +365,6 @@
|
||||
3D302F901DF828F800D6DDAE /* RCTSliderManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */; };
|
||||
3D302F911DF828F800D6DDAE /* RCTSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F362071AABD06A001CE568 /* RCTSwitch.h */; };
|
||||
3D302F921DF828F800D6DDAE /* RCTSwitchManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F362091AABD06A001CE568 /* RCTSwitchManager.h */; };
|
||||
3D302F931DF828F800D6DDAE /* RCTTabBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327DF1AA5CF210034F82E /* RCTTabBar.h */; };
|
||||
3D302F941DF828F800D6DDAE /* RCTTabBarItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327E11AA5CF210034F82E /* RCTTabBarItem.h */; };
|
||||
3D302F951DF828F800D6DDAE /* RCTTabBarItemManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327E31AA5CF210034F82E /* RCTTabBarItemManager.h */; };
|
||||
3D302F961DF828F800D6DDAE /* RCTTabBarManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327E51AA5CF210034F82E /* RCTTabBarManager.h */; };
|
||||
3D302F971DF828F800D6DDAE /* RCTTextDecorationLineType.h in Headers */ = {isa = PBXBuildFile; fileRef = E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */; };
|
||||
3D302F981DF828F800D6DDAE /* RCTView.h in Headers */ = {isa = PBXBuildFile; fileRef = 13E0674F1A70F44B002CDEE1 /* RCTView.h */; };
|
||||
3D302F9A1DF828F800D6DDAE /* RCTViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 13E0674D1A70F44B002CDEE1 /* RCTViewManager.h */; };
|
||||
@@ -548,10 +536,6 @@
|
||||
3D80D98B1DF6FA890028D040 /* RCTSliderManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */; };
|
||||
3D80D98C1DF6FA890028D040 /* RCTSwitch.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 14F362071AABD06A001CE568 /* RCTSwitch.h */; };
|
||||
3D80D98D1DF6FA890028D040 /* RCTSwitchManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 14F362091AABD06A001CE568 /* RCTSwitchManager.h */; };
|
||||
3D80D98E1DF6FA890028D040 /* RCTTabBar.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327DF1AA5CF210034F82E /* RCTTabBar.h */; };
|
||||
3D80D98F1DF6FA890028D040 /* RCTTabBarItem.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327E11AA5CF210034F82E /* RCTTabBarItem.h */; };
|
||||
3D80D9901DF6FA890028D040 /* RCTTabBarItemManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327E31AA5CF210034F82E /* RCTTabBarItemManager.h */; };
|
||||
3D80D9911DF6FA890028D040 /* RCTTabBarManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327E51AA5CF210034F82E /* RCTTabBarManager.h */; };
|
||||
3D80D9921DF6FA890028D040 /* RCTTextDecorationLineType.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */; };
|
||||
3D80D9931DF6FA890028D040 /* RCTView.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 13E0674F1A70F44B002CDEE1 /* RCTView.h */; };
|
||||
3D80D9951DF6FA890028D040 /* RCTViewManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 13E0674D1A70F44B002CDEE1 /* RCTViewManager.h */; };
|
||||
@@ -650,10 +634,6 @@
|
||||
3D80DA851DF820620028D040 /* RCTSliderManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */; };
|
||||
3D80DA861DF820620028D040 /* RCTSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F362071AABD06A001CE568 /* RCTSwitch.h */; };
|
||||
3D80DA871DF820620028D040 /* RCTSwitchManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F362091AABD06A001CE568 /* RCTSwitchManager.h */; };
|
||||
3D80DA881DF820620028D040 /* RCTTabBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327DF1AA5CF210034F82E /* RCTTabBar.h */; };
|
||||
3D80DA891DF820620028D040 /* RCTTabBarItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327E11AA5CF210034F82E /* RCTTabBarItem.h */; };
|
||||
3D80DA8A1DF820620028D040 /* RCTTabBarItemManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327E31AA5CF210034F82E /* RCTTabBarItemManager.h */; };
|
||||
3D80DA8B1DF820620028D040 /* RCTTabBarManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 137327E51AA5CF210034F82E /* RCTTabBarManager.h */; };
|
||||
3D80DA8C1DF820620028D040 /* RCTTextDecorationLineType.h in Headers */ = {isa = PBXBuildFile; fileRef = E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */; };
|
||||
3D80DA8D1DF820620028D040 /* RCTView.h in Headers */ = {isa = PBXBuildFile; fileRef = 13E0674F1A70F44B002CDEE1 /* RCTView.h */; };
|
||||
3D80DA8F1DF820620028D040 /* RCTViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 13E0674D1A70F44B002CDEE1 /* RCTViewManager.h */; };
|
||||
@@ -766,10 +746,6 @@
|
||||
3DA982281E5B0F7F004F2374 /* RCTSliderManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 14F484541AABFCE100FDF6B9 /* RCTSliderManager.h */; };
|
||||
3DA982291E5B0F7F004F2374 /* RCTSwitch.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 14F362071AABD06A001CE568 /* RCTSwitch.h */; };
|
||||
3DA9822A1E5B0F7F004F2374 /* RCTSwitchManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 14F362091AABD06A001CE568 /* RCTSwitchManager.h */; };
|
||||
3DA9822B1E5B0F7F004F2374 /* RCTTabBar.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327DF1AA5CF210034F82E /* RCTTabBar.h */; };
|
||||
3DA9822C1E5B0F7F004F2374 /* RCTTabBarItem.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327E11AA5CF210034F82E /* RCTTabBarItem.h */; };
|
||||
3DA9822D1E5B0F7F004F2374 /* RCTTabBarItemManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327E31AA5CF210034F82E /* RCTTabBarItemManager.h */; };
|
||||
3DA9822E1E5B0F7F004F2374 /* RCTTabBarManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 137327E51AA5CF210034F82E /* RCTTabBarManager.h */; };
|
||||
3DA9822F1E5B0F7F004F2374 /* RCTTextDecorationLineType.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */; };
|
||||
3DA982301E5B0F7F004F2374 /* RCTTVView.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130443D61E401AD800D93A67 /* RCTTVView.h */; };
|
||||
3DA982311E5B0F7F004F2374 /* RCTView.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 13E0674F1A70F44B002CDEE1 /* RCTView.h */; };
|
||||
@@ -1454,10 +1430,6 @@
|
||||
3DA982281E5B0F7F004F2374 /* RCTSliderManager.h in Copy Headers */,
|
||||
3DA982291E5B0F7F004F2374 /* RCTSwitch.h in Copy Headers */,
|
||||
3DA9822A1E5B0F7F004F2374 /* RCTSwitchManager.h in Copy Headers */,
|
||||
3DA9822B1E5B0F7F004F2374 /* RCTTabBar.h in Copy Headers */,
|
||||
3DA9822C1E5B0F7F004F2374 /* RCTTabBarItem.h in Copy Headers */,
|
||||
3DA9822D1E5B0F7F004F2374 /* RCTTabBarItemManager.h in Copy Headers */,
|
||||
3DA9822E1E5B0F7F004F2374 /* RCTTabBarManager.h in Copy Headers */,
|
||||
3DA9822F1E5B0F7F004F2374 /* RCTTextDecorationLineType.h in Copy Headers */,
|
||||
3DA982301E5B0F7F004F2374 /* RCTTVView.h in Copy Headers */,
|
||||
3DA982311E5B0F7F004F2374 /* RCTView.h in Copy Headers */,
|
||||
@@ -1693,10 +1665,6 @@
|
||||
3D80D98B1DF6FA890028D040 /* RCTSliderManager.h in Copy Headers */,
|
||||
3D80D98C1DF6FA890028D040 /* RCTSwitch.h in Copy Headers */,
|
||||
3D80D98D1DF6FA890028D040 /* RCTSwitchManager.h in Copy Headers */,
|
||||
3D80D98E1DF6FA890028D040 /* RCTTabBar.h in Copy Headers */,
|
||||
3D80D98F1DF6FA890028D040 /* RCTTabBarItem.h in Copy Headers */,
|
||||
3D80D9901DF6FA890028D040 /* RCTTabBarItemManager.h in Copy Headers */,
|
||||
3D80D9911DF6FA890028D040 /* RCTTabBarManager.h in Copy Headers */,
|
||||
3D80D9921DF6FA890028D040 /* RCTTextDecorationLineType.h in Copy Headers */,
|
||||
3D80D9931DF6FA890028D040 /* RCTView.h in Copy Headers */,
|
||||
3D80D9951DF6FA890028D040 /* RCTViewManager.h in Copy Headers */,
|
||||
@@ -1882,14 +1850,6 @@
|
||||
13723B4F1A82FD3C00F88898 /* RCTStatusBarManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTStatusBarManager.m; sourceTree = "<group>"; };
|
||||
1372B7081AB030C200659ED6 /* RCTAppState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAppState.h; sourceTree = "<group>"; };
|
||||
1372B7091AB030C200659ED6 /* RCTAppState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAppState.m; sourceTree = "<group>"; };
|
||||
137327DF1AA5CF210034F82E /* RCTTabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTabBar.h; sourceTree = "<group>"; };
|
||||
137327E01AA5CF210034F82E /* RCTTabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBar.m; sourceTree = "<group>"; };
|
||||
137327E11AA5CF210034F82E /* RCTTabBarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTabBarItem.h; sourceTree = "<group>"; };
|
||||
137327E21AA5CF210034F82E /* RCTTabBarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBarItem.m; sourceTree = "<group>"; };
|
||||
137327E31AA5CF210034F82E /* RCTTabBarItemManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTabBarItemManager.h; sourceTree = "<group>"; };
|
||||
137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBarItemManager.m; sourceTree = "<group>"; };
|
||||
137327E51AA5CF210034F82E /* RCTTabBarManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTabBarManager.h; sourceTree = "<group>"; };
|
||||
137327E61AA5CF210034F82E /* RCTTabBarManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTabBarManager.m; sourceTree = "<group>"; };
|
||||
1384E2061E806D4E00545659 /* RCTNativeModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTNativeModule.h; sourceTree = "<group>"; };
|
||||
1384E2071E806D4E00545659 /* RCTNativeModule.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RCTNativeModule.mm; sourceTree = "<group>"; };
|
||||
139D7E391E25C5A300323FB7 /* bignum-dtoa.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "bignum-dtoa.cc"; path = "../third-party/double-conversion-1.1.6/src/bignum-dtoa.cc"; sourceTree = SOURCE_ROOT; };
|
||||
@@ -2649,14 +2609,6 @@
|
||||
14F362081AABD06A001CE568 /* RCTSwitch.m */,
|
||||
14F362091AABD06A001CE568 /* RCTSwitchManager.h */,
|
||||
14F3620A1AABD06A001CE568 /* RCTSwitchManager.m */,
|
||||
137327DF1AA5CF210034F82E /* RCTTabBar.h */,
|
||||
137327E01AA5CF210034F82E /* RCTTabBar.m */,
|
||||
137327E11AA5CF210034F82E /* RCTTabBarItem.h */,
|
||||
137327E21AA5CF210034F82E /* RCTTabBarItem.m */,
|
||||
137327E31AA5CF210034F82E /* RCTTabBarItemManager.h */,
|
||||
137327E41AA5CF210034F82E /* RCTTabBarItemManager.m */,
|
||||
137327E51AA5CF210034F82E /* RCTTabBarManager.h */,
|
||||
137327E61AA5CF210034F82E /* RCTTabBarManager.m */,
|
||||
E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */,
|
||||
130443D61E401AD800D93A67 /* RCTTVView.h */,
|
||||
130443D71E401AD800D93A67 /* RCTTVView.m */,
|
||||
@@ -3282,11 +3234,7 @@
|
||||
3D302F901DF828F800D6DDAE /* RCTSliderManager.h in Headers */,
|
||||
3D302F911DF828F800D6DDAE /* RCTSwitch.h in Headers */,
|
||||
3D302F921DF828F800D6DDAE /* RCTSwitchManager.h in Headers */,
|
||||
3D302F931DF828F800D6DDAE /* RCTTabBar.h in Headers */,
|
||||
3D302F941DF828F800D6DDAE /* RCTTabBarItem.h in Headers */,
|
||||
3D302F951DF828F800D6DDAE /* RCTTabBarItemManager.h in Headers */,
|
||||
59EDBCAE1FDF4E0C003573DE /* RCTScrollContentView.h in Headers */,
|
||||
3D302F961DF828F800D6DDAE /* RCTTabBarManager.h in Headers */,
|
||||
59E604A71FE9CCE300BD90C5 /* RCTScrollContentViewManager.h in Headers */,
|
||||
3D302F971DF828F800D6DDAE /* RCTTextDecorationLineType.h in Headers */,
|
||||
3D302F981DF828F800D6DDAE /* RCTView.h in Headers */,
|
||||
@@ -3569,11 +3517,7 @@
|
||||
3D80DA851DF820620028D040 /* RCTSliderManager.h in Headers */,
|
||||
3D80DA861DF820620028D040 /* RCTSwitch.h in Headers */,
|
||||
3D80DA871DF820620028D040 /* RCTSwitchManager.h in Headers */,
|
||||
3D80DA881DF820620028D040 /* RCTTabBar.h in Headers */,
|
||||
3D80DA891DF820620028D040 /* RCTTabBarItem.h in Headers */,
|
||||
3D80DA8A1DF820620028D040 /* RCTTabBarItemManager.h in Headers */,
|
||||
66CD94B51F1045E700CB3C7C /* RCTMaskedViewManager.h in Headers */,
|
||||
3D80DA8B1DF820620028D040 /* RCTTabBarManager.h in Headers */,
|
||||
3D80DA8C1DF820620028D040 /* RCTTextDecorationLineType.h in Headers */,
|
||||
6577348E1EE8354A00A0E9EA /* RCTInspector.h in Headers */,
|
||||
3D80DA8D1DF820620028D040 /* RCTView.h in Headers */,
|
||||
@@ -4235,7 +4179,6 @@
|
||||
66CD94B81F1045E700CB3C7C /* RCTMaskedViewManager.m in Sources */,
|
||||
2D3B5E991D9B089A00451313 /* RCTDisplayLink.m in Sources */,
|
||||
2D3B5EA11D9B08B600451313 /* RCTModuleData.mm in Sources */,
|
||||
2D3B5EEA1D9B09CD00451313 /* RCTTabBar.m in Sources */,
|
||||
3DCE52F41FEAB10D00613583 /* RCTRedBoxExtraDataViewController.m in Sources */,
|
||||
590D7C001EBD458B00D8A370 /* RCTShadowView+Layout.m in Sources */,
|
||||
2D3B5EAE1D9B08F800451313 /* RCTEventEmitter.m in Sources */,
|
||||
@@ -4273,7 +4216,6 @@
|
||||
2D3B5EBA1D9B092100451313 /* RCTI18nUtil.m in Sources */,
|
||||
2D3B5EB41D9B090A00451313 /* RCTDevLoadingView.m in Sources */,
|
||||
3D0B842C1EC0B4EA00B2BD8E /* RCTTVView.m in Sources */,
|
||||
2D3B5EED1D9B09D700451313 /* RCTTabBarManager.m in Sources */,
|
||||
2D3B5EEF1D9B09DC00451313 /* RCTViewManager.m in Sources */,
|
||||
13134C971E296B2A00B9F3CB /* RCTObjcExecutor.mm in Sources */,
|
||||
594F0A351FD23228007FBE96 /* RCTSurfaceHostingView.mm in Sources */,
|
||||
@@ -4281,7 +4223,6 @@
|
||||
2D3B5E951D9B087C00451313 /* RCTAssert.m in Sources */,
|
||||
59D031F81F8353D3008361F0 /* RCTSafeAreaViewLocalData.m in Sources */,
|
||||
2D3B5EB61D9B091400451313 /* RCTExceptionsManager.m in Sources */,
|
||||
2D3B5EEB1D9B09D000451313 /* RCTTabBarItem.m in Sources */,
|
||||
2D3B5ED41D9B097D00451313 /* RCTModalHostView.m in Sources */,
|
||||
599FAA391FB274980058CCF6 /* RCTSurface.mm in Sources */,
|
||||
C606692F1F3CC60500E67165 /* RCTModuleMethod.mm in Sources */,
|
||||
@@ -4329,7 +4270,6 @@
|
||||
59EDBCBC1FDF4E0C003573DE /* RCTScrollViewManager.m in Sources */,
|
||||
59EDBCB01FDF4E0C003573DE /* RCTScrollContentView.m in Sources */,
|
||||
2D3B5EF01D9B09E300451313 /* RCTWrapperViewController.m in Sources */,
|
||||
2D3B5EEC1D9B09D400451313 /* RCTTabBarItemManager.m in Sources */,
|
||||
2D3B5EB01D9B08FE00451313 /* RCTAlertManager.m in Sources */,
|
||||
13134C9B1E296B2A00B9F3CB /* RCTCxxMethod.mm in Sources */,
|
||||
2D3B5E9C1D9B08A300451313 /* RCTImageSource.m in Sources */,
|
||||
@@ -4542,7 +4482,6 @@
|
||||
1450FF881BCFF28A00208362 /* RCTProfileTrampoline-arm64.S in Sources */,
|
||||
13E41EEB1C05CA0B00CD8DAC /* RCTProfileTrampoline-i386.S in Sources */,
|
||||
3D37B5821D522B190042D5B5 /* RCTFont.mm in Sources */,
|
||||
137327EA1AA5CF210034F82E /* RCTTabBarManager.m in Sources */,
|
||||
59EDBCB71FDF4E0C003573DE /* RCTScrollView.m in Sources */,
|
||||
59EDBCAB1FDF4E0C003573DE /* (null) in Sources */,
|
||||
59EDBCBB1FDF4E0C003573DE /* RCTScrollViewManager.m in Sources */,
|
||||
@@ -4578,7 +4517,6 @@
|
||||
B233E6EA1D2D845D00BC68BA /* RCTI18nManager.m in Sources */,
|
||||
3D7BFD1F1EA8E351008DFB7A /* RCTPackagerConnection.mm in Sources */,
|
||||
13456E931ADAD2DE009F94A7 /* RCTConvert+CoreLocation.m in Sources */,
|
||||
137327E91AA5CF210034F82E /* RCTTabBarItemManager.m in Sources */,
|
||||
13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */,
|
||||
83CBBA531A601E3B00E9B192 /* RCTUtils.m in Sources */,
|
||||
130443C61E401A8C00D93A67 /* RCTConvert+Transform.m in Sources */,
|
||||
@@ -4593,7 +4531,6 @@
|
||||
66CD94B31F1045E700CB3C7C /* RCTMaskedView.m in Sources */,
|
||||
13C156061AB1A2840079392D /* RCTWebViewManager.m in Sources */,
|
||||
58114A161AAE854800E7D092 /* RCTPicker.m in Sources */,
|
||||
137327E81AA5CF210034F82E /* RCTTabBarItem.m in Sources */,
|
||||
83A1FE8C1B62640A00BE0E65 /* RCTModalHostView.m in Sources */,
|
||||
5925356A20084D0600DD584B /* RCTSurfaceSizeMeasureMode.mm in Sources */,
|
||||
1450FF871BCFF28A00208362 /* RCTProfileTrampoline-arm.S in Sources */,
|
||||
@@ -4604,7 +4541,6 @@
|
||||
68EFE4EE1CF6EB3900A1DE13 /* RCTBundleURLProvider.m in Sources */,
|
||||
B95154321D1B34B200FE7B80 /* RCTActivityIndicatorView.m in Sources */,
|
||||
5960C1BB1F0804A00066FD5B /* RCTLayoutAnimationGroup.m in Sources */,
|
||||
137327E71AA5CF210034F82E /* RCTTabBar.m in Sources */,
|
||||
13F17A851B8493E5007D4C75 /* RCTRedBox.m in Sources */,
|
||||
59D031F31F8353D3008361F0 /* RCTSafeAreaView.m in Sources */,
|
||||
83392EB31B6634E10013B15F /* RCTModalHostViewController.m in Sources */,
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface RCTTabBar : UIView
|
||||
|
||||
@property (nonatomic, strong) UIColor *unselectedTintColor;
|
||||
@property (nonatomic, strong) UIColor *tintColor;
|
||||
@property (nonatomic, strong) UIColor *barTintColor;
|
||||
@property (nonatomic, assign) BOOL translucent;
|
||||
#if !TARGET_OS_TV
|
||||
@property (nonatomic, assign) UIBarStyle barStyle;
|
||||
#endif
|
||||
|
||||
- (void)uiManagerDidPerformMounting;
|
||||
|
||||
@end
|
||||
@@ -1,237 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTTabBar.h"
|
||||
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTTabBarItem.h"
|
||||
#import "RCTUtils.h"
|
||||
#import "RCTView.h"
|
||||
#import "RCTWrapperViewController.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
@interface RCTTabBar() <UITabBarControllerDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTTabBar
|
||||
{
|
||||
BOOL _tabsChanged;
|
||||
UITabBarController *_tabController;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
_tabController = [UITabBarController new];
|
||||
_tabController.delegate = self;
|
||||
[self addSubview:_tabController.view];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
|
||||
- (UIViewController *)reactViewController
|
||||
{
|
||||
return _tabController;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
_tabController.delegate = nil;
|
||||
[_tabController removeFromParentViewController];
|
||||
}
|
||||
|
||||
- (void)insertReactSubview:(RCTTabBarItem *)subview atIndex:(NSInteger)atIndex
|
||||
{
|
||||
if (![subview isKindOfClass:[RCTTabBarItem class]]) {
|
||||
RCTLogError(@"subview should be of type RCTTabBarItem");
|
||||
return;
|
||||
}
|
||||
[super insertReactSubview:subview atIndex:atIndex];
|
||||
_tabsChanged = YES;
|
||||
}
|
||||
|
||||
- (void)removeReactSubview:(RCTTabBarItem *)subview
|
||||
{
|
||||
if (self.reactSubviews.count == 0) {
|
||||
RCTLogError(@"should have at least one view to remove a subview");
|
||||
return;
|
||||
}
|
||||
[super removeReactSubview:subview];
|
||||
_tabsChanged = YES;
|
||||
}
|
||||
|
||||
- (void)didUpdateReactSubviews
|
||||
{
|
||||
// Do nothing, as subviews are managed by `uiManagerDidPerformMounting`
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
[self reactAddControllerToClosestParent:_tabController];
|
||||
_tabController.view.frame = self.bounds;
|
||||
}
|
||||
|
||||
- (void)uiManagerDidPerformMounting
|
||||
{
|
||||
// we can't hook up the VC hierarchy in 'init' because the subviews aren't
|
||||
// hooked up yet, so we do it on demand here whenever a transaction has finished
|
||||
[self reactAddControllerToClosestParent:_tabController];
|
||||
|
||||
if (_tabsChanged) {
|
||||
|
||||
NSMutableArray<UIViewController *> *viewControllers = [NSMutableArray array];
|
||||
for (RCTTabBarItem *tab in [self reactSubviews]) {
|
||||
UIViewController *controller = tab.reactViewController;
|
||||
if (!controller) {
|
||||
controller = [[RCTWrapperViewController alloc] initWithContentView:tab];
|
||||
}
|
||||
[viewControllers addObject:controller];
|
||||
}
|
||||
|
||||
_tabController.viewControllers = viewControllers;
|
||||
_tabsChanged = NO;
|
||||
}
|
||||
|
||||
[self.reactSubviews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger index, __unused BOOL *stop) {
|
||||
|
||||
RCTTabBarItem *tab = (RCTTabBarItem *)view;
|
||||
UIViewController *controller = self->_tabController.viewControllers[index];
|
||||
if (self->_unselectedTintColor) {
|
||||
[tab.barItem setTitleTextAttributes:@{NSForegroundColorAttributeName: self->_unselectedTintColor} forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
[tab.barItem setTitleTextAttributes:@{NSForegroundColorAttributeName: self.tintColor} forState:UIControlStateSelected];
|
||||
|
||||
controller.tabBarItem = tab.barItem;
|
||||
#if TARGET_OS_TV
|
||||
// On Apple TV, disable JS control of selection after initial render
|
||||
if (tab.selected && !tab.wasSelectedInJS) {
|
||||
self->_tabController.selectedViewController = controller;
|
||||
}
|
||||
tab.wasSelectedInJS = YES;
|
||||
#else
|
||||
if (tab.selected) {
|
||||
self->_tabController.selectedViewController = controller;
|
||||
}
|
||||
#endif
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIColor *)barTintColor
|
||||
{
|
||||
return _tabController.tabBar.barTintColor;
|
||||
}
|
||||
|
||||
- (void)setBarTintColor:(UIColor *)barTintColor
|
||||
{
|
||||
_tabController.tabBar.barTintColor = barTintColor;
|
||||
}
|
||||
|
||||
- (UIColor *)tintColor
|
||||
{
|
||||
return _tabController.tabBar.tintColor;
|
||||
}
|
||||
|
||||
- (void)setTintColor:(UIColor *)tintColor
|
||||
{
|
||||
_tabController.tabBar.tintColor = tintColor;
|
||||
}
|
||||
|
||||
- (BOOL)translucent
|
||||
{
|
||||
return _tabController.tabBar.isTranslucent;
|
||||
}
|
||||
|
||||
- (void)setTranslucent:(BOOL)translucent
|
||||
{
|
||||
_tabController.tabBar.translucent = translucent;
|
||||
}
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
- (UIBarStyle)barStyle
|
||||
{
|
||||
return _tabController.tabBar.barStyle;
|
||||
}
|
||||
|
||||
- (void)setBarStyle:(UIBarStyle)barStyle
|
||||
{
|
||||
_tabController.tabBar.barStyle = barStyle;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)setUnselectedItemTintColor:(UIColor *)unselectedItemTintColor {
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
||||
if ([_tabController.tabBar respondsToSelector:@selector(unselectedItemTintColor)]) {
|
||||
_tabController.tabBar.unselectedItemTintColor = unselectedItemTintColor;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
- (UITabBarItemPositioning)itemPositioning
|
||||
{
|
||||
#if TARGET_OS_TV
|
||||
return 0;
|
||||
#else
|
||||
return _tabController.tabBar.itemPositioning;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)setItemPositioning:(UITabBarItemPositioning)itemPositioning
|
||||
{
|
||||
#if !TARGET_OS_TV
|
||||
_tabController.tabBar.itemPositioning = itemPositioning;
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - UITabBarControllerDelegate
|
||||
|
||||
#if TARGET_OS_TV
|
||||
|
||||
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(nonnull UIViewController *)viewController
|
||||
{
|
||||
NSUInteger index = [tabBarController.viewControllers indexOfObject:viewController];
|
||||
RCTTabBarItem *tab = (RCTTabBarItem *)self.reactSubviews[index];
|
||||
if (tab.onPress) tab.onPress(nil);
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
|
||||
{
|
||||
NSUInteger index = [tabBarController.viewControllers indexOfObject:viewController];
|
||||
RCTTabBarItem *tab = (RCTTabBarItem *)self.reactSubviews[index];
|
||||
if (tab.onPress) tab.onPress(nil);
|
||||
return NO;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_TV
|
||||
|
||||
- (BOOL)isUserInteractionEnabled
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
|
||||
{
|
||||
if (context.nextFocusedView == self) {
|
||||
[self becomeFirstResponder];
|
||||
} else {
|
||||
[self resignFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <React/RCTComponent.h>
|
||||
#import <React/RCTConvert.h>
|
||||
|
||||
@interface RCTConvert (UITabBarSystemItem)
|
||||
|
||||
+ (UITabBarSystemItem)UITabBarSystemItem:(id)json;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTTabBarItem : UIView
|
||||
|
||||
@property (nonatomic, copy) id /* NSString or NSNumber */ badge;
|
||||
@property (nonatomic, strong) UIImage *icon;
|
||||
@property (nonatomic, strong) UIImage *selectedIcon;
|
||||
@property (nonatomic, assign) UITabBarSystemItem systemIcon;
|
||||
@property (nonatomic, assign) BOOL renderAsOriginal;
|
||||
@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;
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -1,139 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTTabBarItem.h"
|
||||
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTLog.h"
|
||||
#import "UIView+React.h"
|
||||
|
||||
@implementation RCTConvert (UITabBarSystemItem)
|
||||
|
||||
RCT_ENUM_CONVERTER(UITabBarSystemItem, (@{
|
||||
@"bookmarks": @(UITabBarSystemItemBookmarks),
|
||||
@"contacts": @(UITabBarSystemItemContacts),
|
||||
@"downloads": @(UITabBarSystemItemDownloads),
|
||||
@"favorites": @(UITabBarSystemItemFavorites),
|
||||
@"featured": @(UITabBarSystemItemFeatured),
|
||||
@"history": @(UITabBarSystemItemHistory),
|
||||
@"more": @(UITabBarSystemItemMore),
|
||||
@"most-recent": @(UITabBarSystemItemMostRecent),
|
||||
@"most-viewed": @(UITabBarSystemItemMostViewed),
|
||||
@"recents": @(UITabBarSystemItemRecents),
|
||||
@"search": @(UITabBarSystemItemSearch),
|
||||
@"top-rated": @(UITabBarSystemItemTopRated),
|
||||
}), NSNotFound, integerValue)
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTTabBarItem{
|
||||
UITapGestureRecognizer *_selectRecognizer;
|
||||
}
|
||||
|
||||
@synthesize barItem = _barItem;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
_systemIcon = NSNotFound;
|
||||
#if TARGET_OS_TV
|
||||
_wasSelectedInJS = NO;
|
||||
#endif
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UITabBarItem *)barItem
|
||||
{
|
||||
if (!_barItem) {
|
||||
_barItem = [UITabBarItem new];
|
||||
_systemIcon = NSNotFound;
|
||||
}
|
||||
return _barItem;
|
||||
}
|
||||
|
||||
- (void)setTestID:(NSString *)testID
|
||||
{
|
||||
self.barItem.accessibilityIdentifier = testID;
|
||||
}
|
||||
|
||||
- (void)setBadge:(id)badge
|
||||
{
|
||||
_badge = [badge copy];
|
||||
self.barItem.badgeValue = [badge description];
|
||||
}
|
||||
|
||||
- (void)setSystemIcon:(UITabBarSystemItem)systemIcon
|
||||
{
|
||||
if (_systemIcon != systemIcon) {
|
||||
_systemIcon = systemIcon;
|
||||
UITabBarItem *oldItem = _barItem;
|
||||
_barItem = [[UITabBarItem alloc] initWithTabBarSystemItem:_systemIcon
|
||||
tag:oldItem.tag];
|
||||
_barItem.title = oldItem.title;
|
||||
_barItem.imageInsets = oldItem.imageInsets;
|
||||
_barItem.badgeValue = oldItem.badgeValue;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setIcon:(UIImage *)icon
|
||||
{
|
||||
_icon = icon;
|
||||
if (_icon && _systemIcon != NSNotFound) {
|
||||
_systemIcon = NSNotFound;
|
||||
UITabBarItem *oldItem = _barItem;
|
||||
_barItem = [UITabBarItem new];
|
||||
_barItem.title = oldItem.title;
|
||||
_barItem.imageInsets = oldItem.imageInsets;
|
||||
_barItem.selectedImage = oldItem.selectedImage;
|
||||
_barItem.badgeValue = oldItem.badgeValue;
|
||||
}
|
||||
|
||||
if (_renderAsOriginal) {
|
||||
self.barItem.image = [_icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
} else {
|
||||
self.barItem.image = _icon;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSelectedIcon:(UIImage *)selectedIcon
|
||||
{
|
||||
_selectedIcon = selectedIcon;
|
||||
|
||||
if (_renderAsOriginal) {
|
||||
self.barItem.selectedImage = [_selectedIcon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
} else {
|
||||
self.barItem.selectedImage = _selectedIcon;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setBadgeColor:(UIColor *)badgeColor
|
||||
{
|
||||
// badgeColor available since iOS 10
|
||||
if ([self.barItem respondsToSelector:@selector(badgeColor)]) {
|
||||
self.barItem.badgeColor = badgeColor;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIViewController *)reactViewController
|
||||
{
|
||||
return self.superview.reactViewController;
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
|
||||
// On Apple TV, we let native control the tab bar selection after initial render
|
||||
- (void)setSelected:(BOOL)selected
|
||||
{
|
||||
if (!_wasSelectedInJS) {
|
||||
_selected = selected;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
@@ -1,12 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@interface RCTTabBarItemManager : RCTViewManager
|
||||
|
||||
@end
|
||||
@@ -1,38 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTTabBarItemManager.h"
|
||||
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTTabBarItem.h"
|
||||
|
||||
@implementation RCTTabBarItemManager
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [RCTTabBarItem new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(badge, id /* NSString or NSNumber */)
|
||||
RCT_EXPORT_VIEW_PROPERTY(renderAsOriginal, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(selected, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(icon, UIImage)
|
||||
RCT_EXPORT_VIEW_PROPERTY(selectedIcon, UIImage)
|
||||
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;
|
||||
view.barItem.imageInsets = view.barItem.title.length ? UIEdgeInsetsZero : (UIEdgeInsets){6, 0, -6, 0};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,12 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import <React/RCTViewManager.h>
|
||||
|
||||
@interface RCTTabBarManager : RCTViewManager
|
||||
|
||||
@end
|
||||
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTTabBarManager.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTTabBar.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTUIManagerObserverCoordinator.h"
|
||||
|
||||
@implementation RCTConvert (UITabBar)
|
||||
|
||||
RCT_ENUM_CONVERTER(UITabBarItemPositioning, (@{
|
||||
@"fill" : @(UITabBarItemPositioningFill),
|
||||
@"auto" : @(UITabBarItemPositioningAutomatic),
|
||||
@"center" : @(UITabBarItemPositioningCentered)
|
||||
}), UITabBarItemPositioningAutomatic, integerValue)
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTTabBarManager () <RCTUIManagerObserver>
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTTabBarManager
|
||||
{
|
||||
// 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];
|
||||
}
|
||||
|
||||
RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
if (!_viewRegistry) {
|
||||
_viewRegistry = [NSHashTable hashTableWithOptions:NSPointerFunctionsWeakMemory];
|
||||
}
|
||||
|
||||
RCTTabBar *view = [RCTTabBar new];
|
||||
[_viewRegistry addObject:view];
|
||||
return view;
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(unselectedTintColor, UIColor)
|
||||
RCT_EXPORT_VIEW_PROPERTY(tintColor, UIColor)
|
||||
RCT_EXPORT_VIEW_PROPERTY(barTintColor, UIColor)
|
||||
RCT_EXPORT_VIEW_PROPERTY(translucent, BOOL)
|
||||
#if !TARGET_OS_TV
|
||||
RCT_EXPORT_VIEW_PROPERTY(barStyle, UIBarStyle)
|
||||
#endif
|
||||
RCT_EXPORT_VIEW_PROPERTY(itemPositioning, UITabBarItemPositioning)
|
||||
RCT_EXPORT_VIEW_PROPERTY(unselectedItemTintColor, UIColor)
|
||||
|
||||
#pragma mark - RCTUIManagerObserver
|
||||
|
||||
- (void)uiManagerDidPerformMounting:(__unused RCTUIManager *)manager
|
||||
{
|
||||
RCTExecuteOnMainQueue(^{
|
||||
for (RCTTabBar *view in self->_viewRegistry) {
|
||||
[view uiManagerDidPerformMounting];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -232,7 +232,7 @@
|
||||
"jscodeshift": "^0.6.2",
|
||||
"prettier": "1.13.6",
|
||||
"react": "16.6.3",
|
||||
"react-native-dummy": "0.1.0",
|
||||
"react-native-dummy": "0.2.0",
|
||||
"react-test-renderer": "16.7.0-alpha.2",
|
||||
"shelljs": "^0.7.8"
|
||||
},
|
||||
|
||||
@@ -6084,10 +6084,10 @@ react-is@^16.7.0-alpha.2:
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.7.0-alpha.2.tgz#0dd7f95d45ad5318b7f7bcb99dcb84da9385cb57"
|
||||
integrity sha512-1Q3qN8nMWUfFcRz/bBC1f9zSL3il9OcSxMd9CNnpJbeFf4VCX0qYxL3TuwT4f+tFk1TkidwIL11yYgk4HjldYg==
|
||||
|
||||
react-native-dummy@0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-dummy/-/react-native-dummy-0.1.0.tgz#8ec015b814df45acfac458150b67f8a947b36b93"
|
||||
integrity sha512-IVgM7ZtoQPfbduQIj8DrSaDyCkBDZBoiJMLMIqdDl5FJP3hJsakVybl3TvUOycU6bg+kPQY8znu0akugosh/gw==
|
||||
react-native-dummy@0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-dummy/-/react-native-dummy-0.2.0.tgz#fbf0ff7607506882648f1b07f76e57951b7b8f8a"
|
||||
integrity sha512-8efApfdopDKGdxbG8aMmYDXt33aZUoFIU+kRxrsdvVAtV2m121tVFrgV8pHr7M+Y7iuOl80wuxt6Xx8zclCIpQ==
|
||||
|
||||
react-proxy@^1.1.7:
|
||||
version "1.1.8"
|
||||
|
||||
Reference in New Issue
Block a user