From 2385b0fa66818787121b4acf243c25ccdf5f4513 Mon Sep 17 00:00:00 2001 From: Ifiok Jr <1160934+ifiokjr@users.noreply.github.com> Date: Sun, 17 Sep 2017 22:03:21 +0100 Subject: [PATCH] feat(react-native-elements): add Tabs component --- types/react-native-elements/README.md | 2 +- types/react-native-elements/index.d.ts | 15 ++++ .../react-native-elements-tests.tsx | 70 ++++++++++++++++++- 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/types/react-native-elements/README.md b/types/react-native-elements/README.md index 692d60d17d..b042265117 100644 --- a/types/react-native-elements/README.md +++ b/types/react-native-elements/README.md @@ -13,7 +13,7 @@ List will update as typings are added - [x] ButtonGroup - [x] CheckBoxes - [x] List Element -- [ ] ~~Tab Bar Component~~ DEPRECATED +- [x] ~~Tab Bar Component~~ DEPRECATED - [x] HTML style headings - [x] Card component - [x] Pricing Component diff --git a/types/react-native-elements/index.d.ts b/types/react-native-elements/index.d.ts index 332d9284f4..f61f45b5ab 100644 --- a/types/react-native-elements/index.d.ts +++ b/types/react-native-elements/index.d.ts @@ -25,6 +25,7 @@ import { Animated, TransformsStyle } from 'react-native'; +import TabNavigator from 'react-native-tab-navigator'; /** * Supports auto complete for most used types as well as any other string type. @@ -2101,3 +2102,17 @@ export class SwipeDeck extends React.Component< SwipeDeckProps, any > {} + +/** + * @deprecated + * Warning: Tabs has been deprecated and will be removed in a future version of React Native Elements. + * For a complete navigation solution that includes Tabs as well as many other features, be sure to check out react-navigation (https://reactnavigation.org) and it's TabRouter. + */ +export class Tabs extends TabNavigator {} + +/** + * @deprecated + * Warning: Tab has been deprecated and will be removed in a future version of React Native Elements. + * For a complete navigation solution that includes Tabs as well as many other features, be sure to check out react-navigation (https://reactnavigation.org) and it's TabRouter. + */ +export class Tab extends TabNavigator.Item {} diff --git a/types/react-native-elements/react-native-elements-tests.tsx b/types/react-native-elements/react-native-elements-tests.tsx index 3c3418d9c9..2a6a9786b6 100644 --- a/types/react-native-elements/react-native-elements-tests.tsx +++ b/types/react-native-elements/react-native-elements-tests.tsx @@ -31,7 +31,9 @@ import { SideMenu, Slider, SocialIcon, - SwipeDeck + SwipeDeck, + Tabs, + Tab } from 'react-native-elements'; const { width, height } = Dimensions.get('window'); @@ -860,3 +862,69 @@ class SwipeDeckTest extends React.Component { ); } } + +class TabsTest extends React.Component { + state = { + selectedTab: 'profile' + }; + + changeTab = (selectedTab: string) => { + this.setState({ selectedTab }); + } + + render() { + const { selectedTab } = this.state; + return ( + + ( + + )} + renderSelectedIcon={() => ( + + )} + onPress={() => this.changeTab('feed')} + > + + + ( + + )} + renderSelectedIcon={() => ( + + )} + onPress={() => this.changeTab('profile')} + > + + + + ); + } +}