-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.js
More file actions
207 lines (188 loc) · 7.1 KB
/
Copy pathcreate.js
File metadata and controls
207 lines (188 loc) · 7.1 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import React, { Component } from 'react';
import { ScrollView, StyleSheet, View, Text, TextInput, Alert } from 'react-native';
import { connect } from 'react-redux';
import RadioForm, {RadioButton, RadioButtonInput, RadioButtonLabel} from 'react-native-simple-radio-button';
import { baseColor, lossColor, brandColor } from '../../config'
import { Button, StyleProvider, } from 'native-base';
import getTheme from '../../../native-base-theme/components';
import _platform from '../../../native-base-theme/variables/platform';
import { withDrawer } from '../../helpers/drawer';
import { createPriceAlert } from '../../reducers/alert'
const styles = StyleSheet.create({
scrollContainer: {
backgroundColor: baseColor
},
container: {
display: 'flex',
borderColor: '#fff',
justifyContent: 'space-between',
backgroundColor: baseColor,
marginBottom: 10,
flexDirection: 'row',
paddingLeft: 20
},
containerChild: {
marginBottom: 15,
flexGrow: .5,
flexBasis: 1,
display: 'flex',
justifyContent: 'space-around',
flexDirection: 'row'
},
textInput: {
height: 30,
fontSize: 14,
width: '50%',
borderColor: 'gray',
borderBottomWidth: 1,
color: '#fff'
},
horizontalLine: {
borderBottomColor: '#f5f5f5',
borderBottomWidth: 1,
marginTop: 15,
marginBottom: 15
}
})
const radioProps = [
{label: 'One Time', value: 0 },
{label: 'Continuous', value: 1 }
]
const priceLevel = [
{label: 'More than', value: 0 },
{label: 'Less than', value: 1 }
]
class CreatePriceAlert extends Component {
state = {
radioValue: 0,
frequency: 0,
price: 0,
type: 0,
}
submit = () => {
const {currencySymbol, currency, createPriceAlert } = this.props;
if(this.state.price <= 0) {
Alert.alert('Please enter a correct price value');
return
}
createPriceAlert({
fsym : currencySymbol,
tsym: currency,
price: parseFloat(this.state.price),
type: parseInt(this.state.type),
frequency: parseInt(this.state.frequency)
})
}
render() {
const { tokenDetails, edit, price } = this.props
return (
<StyleProvider style={getTheme(_platform)}>
<ScrollView
style={styles.scrollContainer}
containerStyleContent={styles.container}
>
<View style={[styles.containerChild, {justifyContent: 'flex-start', padding: 35, paddingBottom: 0}]}>
<Text style={{color: '#666'}}>THRESHOLD</Text>
</View>
<View style={styles.containerChild}>
<Text style={{color: '#fff'}}>PRICE</Text>
<TextInput
style={styles.textInput}
onChangeText={(price) => this.setState({price})}
keyboardType='numeric'
placeholder={'Enter numeric value'}
placeholderTextColor='#444'
/>
</View>
<View style={styles.containerChild}>
<Text style={{color: '#fff'}}>Current</Text>
<TextInput
style={styles.textInput}
keyboardType='numeric'
placeholder={''}
placeholderTextColor='#444'
editable={false}
value={price}
/>
</View>
<View style={[styles.containerChild, {
justifyContent: 'flex-start',
paddingHorizontal: 35,
marginTop: 20
}]
}>
<Text style={{color: '#666'}}>WHEN THE PRICE IS </Text>
</View>
<View
style={[styles.containerChild,
{
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-start',
paddingHorizontal: 35
}
]}>
<RadioForm
radio_props={priceLevel}
formHorizontal={true}
labelHorizontal={true}
labelStyle={{color: '#fff', paddingRight: 10}}
buttonColor={brandColor}
selectedButtonColor={brandColor}
initial={0}
onPress={(value) => {this.setState({type: value})}}
/>
</View>
<View style={[styles.containerChild, {
justifyContent: 'flex-start',
paddingHorizontal: 35,
marginTop: 20
}]
}>
<Text style={{color: '#666'}}>FREQUENCY</Text>
</View>
<View
style={[styles.containerChild,
{
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-start',
paddingHorizontal: 35
}
]}>
<RadioForm
radio_props={radioProps}
formHorizontal={true}
labelHorizontal={true}
labelStyle={{color: '#fff', paddingRight: 10}}
buttonColor={brandColor}
selectedButtonColor={brandColor}
initial={0}
onPress={(value) => {this.setState({frequency: value})}}
/>
</View>
<View style={{flex: 1, flexDirection: 'row', justifyContent: 'center'}}>
<Button
style={{flex: .8}}
primary
title={"Create Alert"}
block
onPress={() => { this.submit() }}>
<Text style={{color: '#000'}}>Create Alert</Text>
</Button>
</View>
</ScrollView>
</StyleProvider>
)
}
}
const mapStateToProps = (state, props) => ({
tokenDetails: state.account.tokenDetails,
portfolio: state.account.portfolio,
currency: state.account.preference.currency,
...props.navigation.state.params,
})
const mapDispatchToProps = (dispatch) => ({
createPriceAlert: (data) => dispatch(createPriceAlert(data))
})
export default connect(mapStateToProps, mapDispatchToProps)(withDrawer(CreatePriceAlert));