CalculateFormulaView.js
1.71 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
import React, {Component} from 'react';
import {
View,
Text,
TextInput,
Image,
} from 'react-native';
export default class CalculateFormulaView extends Component {
constructor(props) {
super(props);
this.state = {
result: '',
};
this.title = this.props.title || '计算公式';
this.editable = this.props.editable;// 文本框是否可编辑
this.onChangeText = this.props.onChangeText;
this.inputType = this.props.inputType || 'default';// 输入类型
}
calculateValue(count) {
let _result = Number(count) * 2;
this.setState({
result: _result
})
}
render() {
return(
<View style={{width: '100%', backgroundColor: 'white', paddingHorizontal: 5, paddingVertical: 10}}>
<Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)', marginBottom: 5}}>{this.title}</Text>
<TextInput
style={{width: "100%", backgroundColor: 'white', textAlign: 'left', paddingVertical: 5}}
multiline={false}
editable={this.editable}
keyboardType={this.inputType}
onChangeText={text => {
if (this.onChangeText) {
this.onChangeText(text)
}
}}
value={this.state.result}
placeholderTextColor={'#999'}
placeholder={'自动计算数值'}
underlineColorAndroid="transparent"
/>
<Text style={{fontSize: 16, color: 'rgba(0, 0, 0, 1)'}}>大写</Text>
</View>
)
}
}