forked from keepping/react-native-living
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
122 lines (104 loc) · 2.97 KB
/
main.js
File metadata and controls
122 lines (104 loc) · 2.97 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* Created by buhe on 2016/10/18.
*/
import React, {
Component,
} from 'react';
import {
StyleSheet,
Text,
View,
Image,
Dimensions,
StatusBar,
Alert
} from 'react-native';
import {
StackNavigation,
DrawerNavigation,
DrawerNavigationItem,
NavigationProvider
} from '@exponent/ex-navigation';
import Router from './screens';
import { connect } from 'react-redux';
import * as wechat from 'react-native-wechat';
import user from './img/user.png';
// Treat the DrawerNavigationLayout route like any other route -- you may want to set
// it as the intiial route for a top-level StackNavigation
const WE_ID = 'wx34bceb3237aba44e';
class DrawerNavigationLayout extends React.Component {
componentDidMount() {
wechat.registerApp(WE_ID);
//wechat.sendAuthRequest('snsapi_userinfo');
//wechat.addListener('SendAuth.Resp', function (resp) {
// Alert.alert('wechat login successfull,resp id is ' + JSON.stringify(resp));
//});
}
render() {
return (
<NavigationProvider router={Router}>
<StatusBar hidden={true}/>
<DrawerNavigation
id='main'
initialItem='home'
drawerWidth={200}
renderHeader={this._renderHeader}
drawerStyle={{backgroundColor:'black'}}
>
<DrawerNavigationItem
id='home'
//selectedStyle={styles.selectedItemStyle}
renderTitle={()=><View style={{flex:1,alignItems:'center'}} ><Text style={styles.titleText} >直播</Text></View>}
>
<StackNavigation
id='home'
initialRoute={Router.getRoute('home')}
/>
</DrawerNavigationItem>
<DrawerNavigationItem
id='about'
//selectedStyle={styles.selectedItemStyle}
renderTitle={()=><View style={{flex:1,alignItems:'center'}}><Text style={styles.titleText}>设置</Text></View>}
>
<StackNavigation
id='about'
initialRoute={Router.getRoute('about')}
/>
</DrawerNavigationItem>
</DrawerNavigation>
</NavigationProvider>
);
}
_renderHeader = () => {
return (
<View style={styles.header}>
<Image source={user} style={{marginTop:39 + 44,marginBottom:13}}/>
<Text style={styles.title}>Linda</Text>
</View>
);
};
_renderTitle(text:string, isSelected:boolean) {
return (
<Text style={[styles.titleText, isSelected ? styles.selectedTitleText : {}]}>
{text}
</Text>
);
}
;
}
const styles = StyleSheet.create({
header: {
height: 276,
flex:1,
alignItems:'center'
},
titleText: {
fontWeight: 'bold',
textAlign: 'center',
fontSize: 16,
marginBottom: 5,
marginTop:5,
color:'white',
}
});
export default connect()(DrawerNavigationLayout);