ItemPrice.js 7.71 KB
Newer Older
Nguyễn Thị Thúy committed
1 2 3 4 5 6
import React from 'react';
import {
    View,
    Text,
    StyleSheet,
    Image,
7
    TouchableOpacity
Nguyễn Thị Thúy committed
8 9 10 11 12 13 14 15 16 17
} from 'react-native';
import {
    getFontXD,
    HEIGHTXD,
    WIDTHXD,
} from '../../Config/Functions';
import R from '../../assets/R';
import Block from '../../components/Block';

const ItemPrice = (props) => {
18
    const {item, isEndItem, onPress} = props;
Nguyễn Thị Thúy committed
19 20
    return (
        <View style={[styles.container, isEndItem && {marginBottom: HEIGHTXD(100)}, {paddingBottom: HEIGHTXD(20)}]}>
21 22 23 24 25 26 27 28 29 30 31 32 33 34
            <TouchableOpacity onPress={onPress}>
                <Block flex={1} row>
                    <View style={{flex: 0.8, flexDirection: 'column', justifyContent: 'center'}}>
                        <Text style={[styles.txtBlack, {marginBottom: HEIGHTXD(5)}]}>
                            {item.name}
                        </Text>
                        {/*<Progress.Bar progress={item.change}*/}
                        {/*              width={WIDTHXD(200)}*/}
                        {/*              height={HEIGHTXD(8)}*/}
                        {/*              color={R.colors.green}*/}
                        {/*              backgroundColor={R.colors.red}*/}
                        {/*              borderWidth={0}*/}
                        {/*              borderRadius={0}*/}
                        {/*/>*/}
Nguyễn Thị Thúy committed
35
                    </View>
36
                    <Block padding={[0, 0]} space={'between'} flex={1}>
Nguyễn Thị Thúy committed
37 38 39
                        <View
                            style={{
                                flex: 1,
40
                                flexDirection: 'column',
Nguyễn Thị Thúy committed
41
                                justifyContent: 'space-between',
42
                                alignItems: 'flex-end',
Nguyễn Thị Thúy committed
43
                            }}>
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
                            <View
                                style={{
                                    flex: 1,
                                    flexDirection: 'row',
                                    justifyContent: 'space-between',
                                    alignItems: 'center',
                                }}>
                                <Image source={item.is_up ? R.images.iconTriangleUp : R.images.iconTriangleDown}
                                       style={styles.imgIcon}/>
                                <Text style={[styles.txtBlack, {
                                    flexWrap: 'wrap',
                                    color: item.is_up ? R.colors.green : R.colors.red2,
                                }]}>
                                    {item.change}
                                </Text>
                            </View>
                            <Text
                                style={[styles.txtMoney, {color: item.is_up ? R.colors.green : R.colors.red2}]}>{`${item.change_percent}%`}</Text>
Nguyễn Thị Thúy committed
62
                        </View>
63 64
                    </Block>
                    <Block padding={[0, 0]} space={'between'} flex={1}>
Nguyễn Thị Thúy committed
65 66 67
                        <View
                            style={{
                                flex: 1,
68
                                flexDirection: 'column',
Nguyễn Thị Thúy committed
69
                                justifyContent: 'space-between',
70
                                alignItems: 'flex-end',
Nguyễn Thị Thúy committed
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
                            <View
                                style={{
                                    flex: 1,
                                    flexDirection: 'row',
                                    justifyContent: 'space-between',
                                    alignItems: 'center',
                                }}>

                                <Text style={[styles.txtBlack, {flexWrap: 'wrap'}]}
                                      ellipsizeMode='tail'>
                                    {item.open_price}
                                </Text>
                                <Image source={item.is_up ? R.images.iconTriangleUp : R.images.iconTriangleDown}
                                       style={styles.imgIcon}/>
                            </View>
                            <View
                                style={{
                                    flex: 1,
                                    flexDirection: 'row',
                                    justifyContent: 'space-between',
                                    alignItems: 'center',
                                }}>
                                <Text style={[styles.txtMoney, {color: R.colors.gray6}]}>{item.close_price}</Text>
                                <Image source={R.images.iconCheck2} style={styles.imgIcon}/>
                            </View>
Nguyễn Thị Thúy committed
97
                        </View>
98 99
                    </Block>
                    <Block padding={[0, 0]} flex={1}>
Nguyễn Thị Thúy committed
100 101 102
                        <View
                            style={{
                                flex: 1,
103
                                flexDirection: 'column',
Nguyễn Thị Thúy committed
104
                                justifyContent: 'center',
105
                                alignItems: 'flex-end',
Nguyễn Thị Thúy committed
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
                            <View
                                style={{
                                    flex: 1,
                                    flexDirection: 'row',
                                    justifyContent: 'center',
                                }}>
                                <Text style={[styles.txtBlack, {flexWrap: 'wrap'}]}>
                                    {item.high_price}
                                </Text>
                                <Text style={[styles.txtGray, {flexWrap: 'wrap'}]}>
                                    H
                                </Text>
                            </View>
                            <View
                                style={{
                                    flex: 1,
                                    flexDirection: 'row',
                                    justifyContent: 'center',
                                }}>
                                <Text style={styles.txtMoney}>{item.low_price}</Text>
                                <Text style={[styles.txtGray, {flexWrap: 'wrap'}]}>
                                    L
                                </Text>
                            </View>
Nguyễn Thị Thúy committed
131
                        </View>
132
                    </Block>
Nguyễn Thị Thúy committed
133
                </Block>
134 135 136 137 138 139 140 141 142
                <Text style={[styles.txtTime]}>
                    {item.time}</Text>
                <View style={{
                    height: HEIGHTXD(1),
                    backgroundColor: R.colors.gray,
                    marginTop: HEIGHTXD(3),
                    marginBottom: HEIGHTXD(3),
                }}></View>
            </TouchableOpacity>
Nguyễn Thị Thúy committed
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
        </View>
    );
};

export default ItemPrice;

const styles = StyleSheet.create({
    container: {
        shadowColor: '#000',
        backgroundColor: R.colors.white,
        borderRadius: HEIGHTXD(30),
        marginHorizontal: WIDTHXD(30),
    },

    wrapLeft: {
        width: WIDTHXD(16),
        borderTopLeftRadius: HEIGHTXD(30),
        borderBottomStartRadius: HEIGHTXD(30),
    },
    txtTitle: {
        fontSize: getFontXD(42),
        color: R.colors.black,
        fontWeight: 'bold',
    },
    txt: {
        fontSize: getFontXD(36),
        color: 'black',
    },
    rowBet: {
        flexDirection: 'row',
        justifyContent: 'space-between',
        alignItems: 'center',
    },
    txtBlack: {
        fontSize: getFontXD(34),
        color: 'black',
    },

    txtGray: {
182
        fontSize: getFontXD(28),
183
        color: R.colors.gray6,
Nguyễn Thị Thúy committed
184 185 186
    },

    txtTime: {
187
        marginTop: HEIGHTXD(6),
Nguyễn Thị Thúy committed
188 189 190 191
        fontSize: getFontXD(32),
        color: 'black',
    },
    txtMoney: {
192
        fontSize: getFontXD(34),
Nguyễn Thị Thúy committed
193
    },
194 195 196 197
    imgIcon: {
        width: WIDTHXD(20),
        height: WIDTHXD(20),
        resizeMode: 'contain',
198
    },
Nguyễn Thị Thúy committed
199
});