-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSimpleTabLayout.js
More file actions
61 lines (57 loc) · 1.35 KB
/
SimpleTabLayout.js
File metadata and controls
61 lines (57 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, {
Component,
} from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
import { Tab, TabLayout } from 'react-native-android-tablayout';
import Labels from './Labels';
export default class SimpleTabLayout extends Component {
constructor() {
super(...arguments);
this.state = {
tabSelected: 1
};
}
render() {
return (
<View>
<TabLayout
style={styles.tabLayout}
selectedTabIndicatorColor="green">
<Tab
name="Tab 1"
textColor="rgb(0,0,255)"
accessibilityLabel={Labels.Simple.tab1}
onTabSelected={()=>{ this.setState({tabSelected: 1}) }}/>
<Tab
name="Tab 2"
accessibilityLabel={Labels.Simple.tab2}
onTabSelected={()=>{ this.setState({tabSelected: 2}) }}/>
<Tab
name="Tab 3"
accessibilityLabel={Labels.Simple.tab3}
onTabSelected={()=>{ this.setState({tabSelected: 3}) }}/>
</TabLayout>
{this._createSelectedView()}
</View>
);
}
_createSelectedView() {
return (
<View style={styles.content}>
<Text>Tab {this.state.tabSelected} selected</Text>
</View>
);
}
}
const styles = StyleSheet.create({
tabLayout: {
backgroundColor: '#ddd'
},
content: {
padding: 10
},
});