Commit 64a81713 by Giang Tran

Merge branch 'dev_phase2' of http://git.dcv.vn/tdgiangdev/InvestCustomer into dev_phase2

parents 7d089f9a 49c2f416
......@@ -17,7 +17,15 @@ const Home = (props) => {
const [dataPriceFilter, setDataPriceFilter] = useState([]);
const [listImage, setListImage] = useState([]);
const [filters, setFilters] = useState([]);
const [filterId, setFilterId] = useState(-1);
const [filterId, setFilterId] = useState(null);
const [isSortName, setIsSortName] = useState(null);
const [isSortPercent, setIsSortPercent] = useState(null);
const [isSortPriceOpenClose, setIsSortPriceOpenClose] = useState(null);
const [isSortPriceHighLow, setIsSortPriceHighLow] = useState(null);
const SORT_TYPE = {
DESC: 'DESC',
ASC: 'ASC'
}
useEffect(() => {
getData();
initSocket();
......@@ -91,6 +99,51 @@ const Home = (props) => {
console.log(id, newList);
};
const onSortByName = () => {
let type = 'ASC'
if(!isSortName || isSortName == SORT_TYPE.ASC) type = SORT_TYPE.DESC
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.name > b.name ? 1 : -1 )
: [...dataPriceFilter].sort((a, b) => a.name < b.name ? 1 : -1 )
setDataPriceFilter(newData)
setIsSortPriceOpenClose(null)
setIsSortName(type)
setIsSortPercent(null)
setIsSortPriceHighLow(null)
}
const onSortByPercent = () => {
let type = 'ASC'
if(!isSortPercent || isSortPercent == SORT_TYPE.ASC) type = SORT_TYPE.DESC
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.change > b.change ? 1 : -1 )
: [...dataPriceFilter].sort((a, b) => a.change < b.change ? 1 : -1 )
setDataPriceFilter(newData)
setIsSortPriceOpenClose(null)
setIsSortName(null)
setIsSortPercent(type)
setIsSortPriceHighLow(null)
}
const onSortByPriceOpenClose = () => {
let type = 'ASC'
if(!isSortPriceOpenClose || isSortPriceOpenClose == SORT_TYPE.ASC) type = SORT_TYPE.DESC
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.open_price > b.open_price ? 1 : -1 )
: [...dataPriceFilter].sort((a, b) => a.open_price < b.open_price ? 1 : -1 )
setDataPriceFilter(newData)
setIsSortPriceOpenClose(type)
setIsSortName(null)
setIsSortPercent(null)
setIsSortPriceHighLow(null)
}
const onSortByPriceHighLow = () => {
let type = 'ASC'
if(!isSortPriceHighLow || isSortPriceHighLow == SORT_TYPE.ASC) type = SORT_TYPE.DESC
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.high_price > b.high_price ? 1 : -1 )
: [...dataPriceFilter].sort((a, b) => a.high_price < b.high_price ? 1 : -1 )
setDataPriceFilter(newData)
setIsSortPriceOpenClose(null)
setIsSortName(null)
setIsSortPercent(null)
setIsSortPriceHighLow(type)
}
return <HomeView
data={data}
dataPrice={dataPriceFilter}
......@@ -98,6 +151,10 @@ const Home = (props) => {
filterId={filterId}
filters={filters}
setFilterId={changeFilter}
onSortByName={onSortByName}
onSortByPercent={onSortByPercent}
onSortByPriceOpenClose={onSortByPriceOpenClose}
onSortByPriceHighLow={onSortByPriceHighLow}
/>;
};
......
......@@ -29,6 +29,10 @@ const HomeView = (props) => {
filterId={props.filterId}
filters={props.filters}
dataPrice={props.dataPrice}
onSortByName={props.onSortByName}
onSortByPercent={props.onSortByPercent}
onSortByPriceOpenClose={props.onSortByPriceOpenClose}
onSortByPriceHighLow={props.onSortByPriceHighLow}
/>
</ScrollView>
</ImageBackground>
......
......@@ -15,7 +15,7 @@ import {PRODUCTDETAIL} from '../../routers/ScreenNames';
import {useNavigation} from '@react-navigation/native';
const PriceListView = (props) => {
const {setFilterId, filters, dataPrice, filterId} = props;
const {setFilterId, filters, dataPrice, filterId, onSortByName, onSortByPercent, onSortByPriceOpenClose, onSortByPriceHighLow} = props;
const navigate = useNavigation();
return (
<View style={{flex: 1}}>
......@@ -44,26 +44,34 @@ const PriceListView = (props) => {
data={dataPrice}
ListHeaderComponent={() =>
<View style={[styles.container]}>
<View style={[styles.headerContent, {
flex: 0.3,
justifyContent: 'flex-start',
alignItems: 'center',
}]}>
<Text>Tên</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
<View style={[styles.headerContent, {flex: 1.5}]}>
<Text>T l thay đổi</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
<View style={[styles.headerContent]}>
<Text>Giá m/đóng</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
<View style={[styles.headerContent]}>
<Text>Giá cao/thp</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
<TouchableOpacity style={{flex: 0.3}} onPress={() => onSortByName()}>
<View style={[styles.headerContent, {
flex: 0.3,
justifyContent: 'flex-start',
alignItems: 'center',
}]}>
<Text>Tên</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
</TouchableOpacity>
<TouchableOpacity style={[styles.headerContent, {flex: 1.5}]} onPress={() => onSortByPercent()}>
<View style={[styles.headerContent]}>
<Text>T l thay đổi</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
</TouchableOpacity>
<TouchableOpacity style={styles.headerContent} onPress={() => onSortByPriceOpenClose()}>
<View style={[styles.headerContent]}>
<Text>Giá m/đóng</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
</TouchableOpacity>
<TouchableOpacity style={{flex: 1}} onPress={() => onSortByPriceHighLow()}>
<View style={[styles.headerContent]}>
<Text>Giá cao/thp</Text>
<Image source={R.images.iconSort} style={styles.imgIcon}/>
</View>
</TouchableOpacity>
</View>}
renderItem={({item}) => <ItemPrice item={item}
onPress={() => navigate.navigate(PRODUCTDETAIL, {
......
......@@ -155,12 +155,13 @@ const menus = [
];
const Drawer = (props) => {
const [imgAvatart, setImgAvatart] = useState(props.user.picture_url);
const navigate = useNavigation();
const [listMenu, setListMenu] = useState(menus);
return (
<View style={styles.container}>
<View style={styles.header}>
<Image source={R.images.avartar} style={styles.imgAvatar} />
<Image source={imgAvatart ? {uri: imgAvatart} : R.images.avartar} style={styles.imgAvatar} />
<TouchableOpacity
onPress={() => {
props.toggleModal();
......
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