Commit 4bd6e25d by Giang Tran

merge

parent e2aef260
......@@ -234,6 +234,17 @@ export const toPriceVnd = (str) => {
}
};
export const floatToPriceVnd = (str) => {
if (str) {
let stringPrice = str.toString().split('.')
let headStringPrice = `${stringPrice[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,')}`
return stringPrice.length === 1 ? headStringPrice : headStringPrice.concat(`.${stringPrice[1]}`)
} else {
return ''
}
}
// cắt chuỗi dạng something...
export const ellipsis = (str = '', max = 30) =>
str.length > max ? `${str.substring(0, max)}...` : str;
......
......@@ -5,7 +5,7 @@ import HeaderBack from '../../components/Header/HeaderBack';
import PickerItem from '../../components/Picker/PickerItem';
import I18n from '../../helper/i18/i18n';
import AppText from '../../components/AppText';
import {getFontXD, HEIGHTXD, toPriceVnd, WIDTHXD} from '../../Config/Functions';
import {floatToPriceVnd, getFontXD, HEIGHTXD, toPriceVnd, WIDTHXD} from '../../Config/Functions';
import R from '../../assets/R';
import {getUnitList} from '../../apis/Functions/Transaction';
import {showAlert, TYPE} from '../../components/DropdownAlert';
......@@ -71,16 +71,12 @@ const ConvertUnit = (props) => {
const onChangeToUnit = (value, item) => {
setToUnit(item);
if (number && number != '' && parseFloat(number) > 0) {
let result = parseFloat(number) * item.rate;
setResult(`${parseFloat(number)} ${fromUnit.name} = ${result} ${item.name}`);
}
};
const calcultorResult = () => {
if (number && number != '' && parseFloat(number) > 0) {
let result = parseFloat(number) * toUnit.rate;
setResult(`${parseFloat(number)} ${fromUnit.name} = ${result} ${toUnit.name}`);
setResult(`${floatToPriceVnd(number.toString())} ${fromUnit.name} = ${floatToPriceVnd(result.toString())} ${toUnit.name}`);
} else {
setResult('')
}
......@@ -98,7 +94,7 @@ const ConvertUnit = (props) => {
keyboardType={'number-pad'}
style={styles.wrapInput}
maxLength={12}
value={toPriceVnd(number)}
value={floatToPriceVnd(number)}
/>
</View>
</View>
......@@ -179,6 +175,7 @@ const styles = StyleSheet.create({
fontSize: getFontXD(42),
borderRadius: 5,
paddingHorizontal: 10,
paddingVertical: 0,
shadowColor: '#000',
shadowOffset: {
width: 0,
......
......@@ -129,15 +129,15 @@ const VersionChecker = (props) => {
marginHorizontal: WIDTHXD(100),
}]}>
<TouchableOpacity onPress={() => cancelUpdate()}
style={[styles.btnButton, {paddingRight: WIDTHXD(90)}]}>
style={[styles.btnButton, {paddingRight: WIDTHXD(60) }]}>
<Text
style={[styles.textNotNowStyle, {color: R.colors.color777}]}>{I18n.t('Cancel')}</Text>
style={[styles.textNotNowStyle, {color: R.colors.color777, textAlign: 'right'}]}>{I18n.t('Cancel')}</Text>
</TouchableOpacity>
<View style={styles.dividerStyleVertical}></View>
<TouchableOpacity onPress={() => onUpdatePressed()}
style={[styles.btnButton, {paddingLeft: WIDTHXD(90)}]}>
style={[styles.btnButton, {paddingLeft: WIDTHXD(60)}]}>
<Text
style={[styles.textNotNowStyle, {color: R.colors.main}]}>{I18n.t('Update')}</Text>
style={[styles.textNotNowStyle, {color: R.colors.main, textAlign: 'left'}]}>{I18n.t('Update')}</Text>
</TouchableOpacity>
</View>
}
......@@ -216,7 +216,7 @@ const styles = StyleSheet.create({
},
btnButton: {
flex: 0,
flex: 1,
},
textNotNowStyle: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment