|
@@ -1,133 +0,0 @@
|
1
|
|
-import React, {Component} from 'react';
|
2
|
|
-import {
|
3
|
|
- Text,
|
4
|
|
- View,
|
5
|
|
- ScrollView,
|
6
|
|
- TouchableOpacity,
|
7
|
|
- StyleSheet
|
8
|
|
-} from 'react-native';
|
9
|
|
-
|
10
|
|
-export default class SecondTabScreen extends Component {
|
11
|
|
- static navigatorStyle = {
|
12
|
|
- drawUnderTabBar: true
|
13
|
|
- };
|
14
|
|
- constructor(props) {
|
15
|
|
- super(props);
|
16
|
|
- this.buttonsCounter = 0;
|
17
|
|
- // if you want to listen on navigator events, set this up
|
18
|
|
- // this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
|
19
|
|
- }
|
20
|
|
- render() {
|
21
|
|
- return (
|
22
|
|
- <View style={{flex: 1, padding: 20}}>
|
23
|
|
-
|
24
|
|
- <TouchableOpacity onPress={ this.onChangeButtonsPress.bind(this) }>
|
25
|
|
- <Text style={styles.button}>Change Buttons</Text>
|
26
|
|
- </TouchableOpacity>
|
27
|
|
-
|
28
|
|
- <TouchableOpacity onPress={ this.onChangeTitlePress.bind(this) }>
|
29
|
|
- <Text style={styles.button}>Change Title</Text>
|
30
|
|
- </TouchableOpacity>
|
31
|
|
-
|
32
|
|
- <TouchableOpacity onPress={ this.onSwitchTabPress.bind(this) }>
|
33
|
|
- <Text style={styles.button}>Switch To Tab#1</Text>
|
34
|
|
- </TouchableOpacity>
|
35
|
|
-
|
36
|
|
- <TouchableOpacity onPress={ this.onSetTabBadgePress.bind(this) }>
|
37
|
|
- <Text style={styles.button}>Set Tab Badge</Text>
|
38
|
|
- </TouchableOpacity>
|
39
|
|
-
|
40
|
|
- <TouchableOpacity onPress={ this.onToggleTabsPress.bind(this) }>
|
41
|
|
- <Text style={styles.button}>Toggle Tabs</Text>
|
42
|
|
- </TouchableOpacity>
|
43
|
|
-
|
44
|
|
- </View>
|
45
|
|
- );
|
46
|
|
- }
|
47
|
|
- onChangeTitlePress() {
|
48
|
|
- this.props.navigator.setTitle({
|
49
|
|
- title: Math.round(Math.random() * 100000).toString()
|
50
|
|
- });
|
51
|
|
- }
|
52
|
|
- onChangeButtonsPress() {
|
53
|
|
- let buttons;
|
54
|
|
- if (this.buttonsCounter % 3 == 0) {
|
55
|
|
- buttons = [
|
56
|
|
- {
|
57
|
|
- title: 'Edit',
|
58
|
|
- id: 'edit',
|
59
|
|
- disabled: true
|
60
|
|
- },
|
61
|
|
- {
|
62
|
|
- icon: require('../../img/navicon_add.png'),
|
63
|
|
- id: 'add'
|
64
|
|
- }
|
65
|
|
- ];
|
66
|
|
- } else if (this.buttonsCounter % 3 == 1) {
|
67
|
|
- buttons = [{
|
68
|
|
- title: 'Save',
|
69
|
|
- id: 'save'
|
70
|
|
- }];
|
71
|
|
- } else {
|
72
|
|
- buttons = [];
|
73
|
|
- }
|
74
|
|
- this.buttonsCounter++;
|
75
|
|
-
|
76
|
|
- this.props.navigator.setButtons({
|
77
|
|
- rightButtons: buttons,
|
78
|
|
- animated: true
|
79
|
|
- });
|
80
|
|
- }
|
81
|
|
- onSwitchTabPress() {
|
82
|
|
- this.props.navigator.switchToTab({
|
83
|
|
- tabIndex: 0
|
84
|
|
- });
|
85
|
|
- }
|
86
|
|
- onSetTabBadgePress() {
|
87
|
|
- this.props.navigator.setTabBadge({
|
88
|
|
- badge: 12
|
89
|
|
- });
|
90
|
|
- }
|
91
|
|
- onToggleTabsPress() {
|
92
|
|
- this.props.navigator.toggleTabs({
|
93
|
|
- to: this.tabsHidden ? 'shown' : 'hidden'
|
94
|
|
- });
|
95
|
|
- this.tabsHidden = !this.tabsHidden;
|
96
|
|
- }
|
97
|
|
- onNavigatorEvent(event) {
|
98
|
|
- // handle a deep link
|
99
|
|
- if (event.type == 'DeepLink') {
|
100
|
|
- const parts = event.link.split('/');
|
101
|
|
- if (parts[0] == 'tab2') {
|
102
|
|
- this.props.navigator.resetTo({
|
103
|
|
- title: "Replaced Root",
|
104
|
|
- screen: parts[1],
|
105
|
|
- animated: true
|
106
|
|
- });
|
107
|
|
- this.props.navigator.switchToTab();
|
108
|
|
- }
|
109
|
|
- }
|
110
|
|
- // handle a button press
|
111
|
|
- // if (event.type == 'NavBarButtonPress') {
|
112
|
|
- // if (event.id == 'edit') {
|
113
|
|
- // AlertIOS.alert('NavBar', 'Dynamic Edit button pressed');
|
114
|
|
- // }
|
115
|
|
- // if (event.id == 'add') {
|
116
|
|
- // AlertIOS.alert('NavBar', 'Dynamic Add button pressed');
|
117
|
|
- // }
|
118
|
|
- // if (event.id == 'save') {
|
119
|
|
- // AlertIOS.alert('NavBar', 'Dynamic Save button pressed');
|
120
|
|
- // }
|
121
|
|
- // }
|
122
|
|
- }
|
123
|
|
-}
|
124
|
|
-
|
125
|
|
-const styles = StyleSheet.create({
|
126
|
|
- button: {
|
127
|
|
- textAlign: 'center',
|
128
|
|
- fontSize: 18,
|
129
|
|
- marginBottom: 10,
|
130
|
|
- marginTop:10,
|
131
|
|
- color: 'blue'
|
132
|
|
- }
|
133
|
|
-});
|