forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetting.js
More file actions
185 lines (171 loc) · 4.45 KB
/
Setting.js
File metadata and controls
185 lines (171 loc) · 4.45 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import React, {Component} from 'react'
import {View, StyleSheet, Text, TouchableOpacity, Dimensions, Platform} from 'react-native'
import PropTypes from 'prop-types'
import Icon from 'react-native-vector-icons/Ionicons'
import Modal from './base/Modal'
import Button from 'react-native-button'
import Row from './base/Row'
const {height, width} = Dimensions.get('window')
const iconSize = 17
const rowHeight = 50
class Setting extends Component {
static propTypes = {
router: PropTypes.object,
actions: PropTypes.object
};
constructor (props) {
super(props)
this.state = {
visible: false
}
}
onAboutPress () {
this.props.router.toAbout()
}
onLogoutPress () {
this.props.router.pop()
this.props.actions.logout()
}
onClearPress () {
const {actions} = this.props
actions.clear()
actions.toast('缓存清除成功')
}
show () {
this.setState({
visible: true
})
}
render () {
if (!this.state.visible) { return null }
return (
<Modal blur blurStyle={styles.modalStyle} style={styles.container}>
<View style={styles.body}>
<View style={styles.contentWrapper}>
<View style={[styles.row, styles.header]}>
<Icon
name='ios-gear'
size={iconSize}
color='rgba(255,255,255,0.5)'
style={styles.Icon} />
<View style={styles.rowTextWrapper}>
<Text style={styles.rowText}>
设置
</Text>
</View>
</View>
<Row key='about' style={styles.row} onPress={this.onAboutPress.bind(this)}>
<Icon
name='ios-eye'
size={iconSize}
color='rgba(255,255,255,0.5)'
style={styles.Icon} />
<View style={styles.rowTextWrapper}>
<Text style={styles.rowText}>
关于
</Text>
</View>
</Row>
<Row key='clean' style={styles.row} onPress={this.onClearPress.bind(this)}>
<Icon
name='ios-trash'
size={iconSize}
color='rgba(255,255,255,0.5)'
style={styles.Icon} />
<View style={styles.rowTextWrapper}>
<Text style={styles.rowText}>
清除缓存
</Text>
</View>
</Row>
<Row key='power' style={styles.row} onPress={this.onLogoutPress.bind(this)}>
<Icon
name='power'
size={iconSize}
color='#E74C3C'
style={styles.Icon} />
<View style={styles.rowTextWrapper}>
<Text style={[styles.rowText, styles.logoutText]}>
退出
</Text>
</View>
</Row>
</View>
<Row style={styles.closeButton} onPress={() => this.setState({ visible: false })}>
<Icon
name='ios-close-outline'
size={30}
color='rgba(255,255,255,0.9)'
style={styles.closeIcon} />
</Row>
</View>
</Modal>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center'
},
modalStyle: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center'
},
contentWrapper: {
flex: 4,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: Platform.OS === 'ios' ? 'rgba(0,0,0,0.3)' : '#292829',
borderRadius: 3,
margin: 30
},
body: {
flex: 1,
height: rowHeight * 6,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center'
},
closeButton: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
row: {
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-start',
alignItems: 'center',
borderRadius: 2,
paddingLeft: 20,
backgroundColor: 'rgba(0,0,0,0.1)',
width: width - 30 * 2
},
rowText: {
color: 'rgba(255,255,255,0.7)'
},
rowTextWrapper: {
paddingLeft: 20
},
logoutText: {
color: '#E74C3C'
},
header: {
backgroundColor: 'rgba(0,0,0,0.5)'
},
closeIcon: {
height: 30,
width: 30,
borderRadius: 30 / 2,
borderColor: 'rgba(255,255,255,0.2)',
textAlign: 'center'
}
})
export default Setting