import { CountdownCircleTimer } from 'react-native-countdown-circle-timer'
import React from 'react';
import {Animated} from 'react-native';
import themeColors from '../assets/colors';

const renderTime = (time) => {
  return (
    <Animated.Text style={{ color: themeColors.WHITE }}>
      {time}
    </Animated.Text>
  );
};

const getTimeDays = (time) => (time / 86400) | 0;

const AppCountDownTimer = (props) => {
  return (
  <CountdownCircleTimer
    isPlaying={true}
    size={40}
    strokeWidth={5}
    duration={props.secs}
    initialRemainingTime={props.days}
    trailColor={themeColors.WHITE}
    isLinearGradient
    colors={[
      [themeColors.BLUE, 0],
      [themeColors.MAGENTA, 1]
    ]}
  >
    {({ remainingTime }) =>
        renderTime(getTimeDays(remainingTime))
      }
  </CountdownCircleTimer>
  )}

export default AppCountDownTimer