Commit 5dbad8fd authored by pramod.nichelabs's avatar pramod.nichelabs

auction list props added

parent 6a22fee9
...@@ -4,7 +4,8 @@ const themeColors = { ...@@ -4,7 +4,8 @@ const themeColors = {
TERTIARY_COLOR : '#CECECE', TERTIARY_COLOR : '#CECECE',
BLACK : '#191919', BLACK : '#191919',
WHITE : '#FFFFFF', WHITE : '#FFFFFF',
RED : '#DC143C' RED : '#DC143C',
BLUE : '#0066FF'
}; };
export default themeColors; export default themeColors;
...@@ -3,15 +3,23 @@ import { StyleSheet, TouchableOpacity, Text, View } from 'react-native'; ...@@ -3,15 +3,23 @@ import { StyleSheet, TouchableOpacity, Text, View } from 'react-native';
import themeColors from '../assets/colors'; import themeColors from '../assets/colors';
import { MaterialIcons } from '@expo/vector-icons'; import { MaterialIcons } from '@expo/vector-icons';
import AppCountDownTimer from './countdown_component'; import AppCountDownTimer from './countdown_component';
import moment from 'moment';
export const AppAuctionItem = props => { export const AppAuctionItem = props => {
const end = moment(props.expire)
const start = moment();
const duration = moment.duration(end.diff(start));
let secs = duration.asSeconds();
secs = Math.round(secs);
return( return(
<View> <View>
{props.delete ? ( {props.delete ? (
<View style={styles.container}> <View style={styles.container}>
<TouchableOpacity onPress={props.onSelect} style={styles.button}> <TouchableOpacity onPress={props.onSelect} style={styles.button}>
<Text style={styles.label}>{props.label}</Text> <Text style={styles.label}>{props.label}</Text>
<AppCountDownTimer/> <AppCountDownTimer secs={secs}/>
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity onPress={props.onDelete} style={styles.delBtn}> <TouchableOpacity onPress={props.onDelete} style={styles.delBtn}>
<MaterialIcons name="delete" size={24} color={themeColors.WHITE} /> <MaterialIcons name="delete" size={24} color={themeColors.WHITE} />
...@@ -21,7 +29,7 @@ export const AppAuctionItem = props => { ...@@ -21,7 +29,7 @@ export const AppAuctionItem = props => {
<View style={styles.container}> <View style={styles.container}>
<TouchableOpacity onPress={props.onPress} style={styles.button}> <TouchableOpacity onPress={props.onPress} style={styles.button}>
<Text style={styles.label}>{props.label}</Text> <Text style={styles.label}>{props.label}</Text>
<AppCountDownTimer/> <AppCountDownTimer secs={secs}/>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
)} )}
......
...@@ -3,25 +3,36 @@ import React from 'react'; ...@@ -3,25 +3,36 @@ import React from 'react';
import {Animated} from 'react-native'; import {Animated} from 'react-native';
import themeColors from '../assets/colors'; import themeColors from '../assets/colors';
const AppCountDownTimer = () => ( const renderTime = (time) => {
return (
<Animated.Text style={{ color: themeColors.WHITE }}>
{time}
</Animated.Text>
);
};
const getTimeDays = (time) => (time / 86400) | 0;
const AppCountDownTimer = (props) => {
return (
<CountdownCircleTimer <CountdownCircleTimer
isPlaying={false} isPlaying={true}
size={40} size={40}
strokeWidth={5} strokeWidth={5}
duration={20} duration={props.secs}
initialRemainingTime={props.days}
trailColor={themeColors.WHITE} trailColor={themeColors.WHITE}
isLinearGradient
colors={[ colors={[
[themeColors.BLACK, 0.4], [themeColors.BLACK, 0],
[themeColors.SECONDARY_COLOR, 0.4], [themeColors.SECONDARY_COLOR, 0.4],
[themeColors.RED, 0.2], [themeColors.RED, 1],
]} ]}
> >
{({ remainingTime }) => ( {({ remainingTime }) =>
<Animated.Text style={{ color: themeColors.WHITE }}> renderTime(getTimeDays(remainingTime))
{remainingTime} }
</Animated.Text>
)}
</CountdownCircleTimer> </CountdownCircleTimer>
); )}
export default AppCountDownTimer export default AppCountDownTimer
\ No newline at end of file
...@@ -9,7 +9,7 @@ import { AuctionBottomTab } from '../Navigations/AuctionBottomTab'; ...@@ -9,7 +9,7 @@ import { AuctionBottomTab } from '../Navigations/AuctionBottomTab';
const HomeAuctionScreen = ({navigation}) => { const HomeAuctionScreen = ({navigation}) => {
const [auctions, setAuctions] = useState([]); const [auctions, setAuctions] = useState([]);
useEffect(() => { useEffect(() => {
axios.get("http://localhost:5000/auctions") axios.get("http://127.0.0.1:8085/auctions")
.then( async function (response) { .then( async function (response) {
setAuctions(response.data); setAuctions(response.data);
}) })
...@@ -29,7 +29,7 @@ const HomeAuctionScreen = ({navigation}) => { ...@@ -29,7 +29,7 @@ const HomeAuctionScreen = ({navigation}) => {
<View> <View>
{auctions.map((auction) => { {auctions.map((auction) => {
return( return(
<AppAuctionItem label={auction.name} onPress = {() => navigation.navigate("AuctionDetailScreen")}/> <AppAuctionItem label={auction.name} expire={auction.expire_date} onPress = {() => navigation.navigate("AuctionDetailScreen")}/>
) )
})} })}
</View> </View>
......
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