Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

Commit f920fee

Browse files
authored
Added Tab Component (#193)
* Tab Demo Added * Tab Demo Added
1 parent defb193 commit f920fee

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/navigation/RootNavigator.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import Overlay from '../views/overlay';
2626
import CheckBox from '../views/checkbox';
2727
import FAB from '../views/fab';
2828
import Text from '../views/text';
29+
import Tabs from '../views/tabs';
2930
import Badge from '../views/badge';
3031
import WhatsappClone from '../views/whatsappClone';
3132

@@ -70,6 +71,7 @@ function RootNavigator() {
7071
<Drawer.Screen name="Buttons" component={Buttons} />
7172
<Drawer.Screen name="Inputs" component={Inputs} />
7273
<Drawer.Screen name="Text" component={Text} />
74+
<Drawer.Screen name="Tabs" component={Tabs} />
7375
<Drawer.Screen name="Lists" component={Lists} />
7476
<Drawer.Screen name="Lists2" component={Lists2} />
7577
<Drawer.Screen name="LinearProgress" component={LinearProgress} />

src/views/tabs.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react';
2+
import { Text } from 'react-native';
3+
import { Header } from './header';
4+
import { Tab } from 'react-native-elements';
5+
6+
export default () => {
7+
const [index, setIndex] = React.useState(0);
8+
9+
return (
10+
<>
11+
<Header title="Tab" />
12+
<Tab
13+
value={index}
14+
onChange={(e) => setIndex(e)}
15+
indicatorStyle={{
16+
backgroundColor: 'white',
17+
height: 3,
18+
}}
19+
variant="primary"
20+
>
21+
<Tab.Item
22+
title="Recent"
23+
icon={{ name: 'timer', type: 'ionicon', color: 'white' }}
24+
/>
25+
<Tab.Item
26+
title="favourite"
27+
icon={{ name: 'heart', type: 'ionicon', color: 'white' }}
28+
/>
29+
<Tab.Item
30+
title="cart"
31+
icon={{ name: 'cart', type: 'ionicon', color: 'white' }}
32+
/>
33+
</Tab>
34+
{(() => {
35+
switch (index) {
36+
case 0:
37+
return <Text>Recent</Text>;
38+
case 1:
39+
return <Text>favourites</Text>;
40+
case 2:
41+
return <Text>Your Cart</Text>;
42+
default:
43+
return null;
44+
}
45+
})()}
46+
</>
47+
);
48+
};

0 commit comments

Comments
 (0)