Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to typescript #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import * as React from 'react';
import { TextStyle, ViewStyle } from 'react-native';

export interface CountDownProps {
/**
* Counter id, to determine whether to reset the counter or not
* - `default` null
*/
id?: string | null;

/**
* Override the component style
* - `default` {}
*/
style?: ViewStyle;

/**
* Digit style
* - `default`: {backgroundColor: '#FAB913'}
*/
digitStyle?: ViewStyle;

/**
* Digit Text style
* - `default`: {color: #FAB913 '#000'}
*/
digitTxtStyle?: TextStyle;

/**
* Time Label style
* - `default`: {color: #FAB913 '#000'}
*/
timeLabelStyle?: TextStyle;

/**
* Separator style
* - `default`: {color: #FAB913 '#000'}
*/
separatorStyle?: TextStyle;

/**
* Size of the countdown component
* - `default`: 15
*/
size?: number;

/**
* Number of seconds to countdown
* - `default`: 0
*/
until?: number;

/**
* What function should be invoked when the time is 0
* - `default`: null
*/
onFinish?: () => void;

/**
* What function should be invoked when the timer is changing
* - `default`: null
*/
onChange?: () => void;

/**
* What function should be invoked when clicking on the timer
* - `default`: null
*/
onPress?: () => void;

/**
* What Digits to show
* - `default`: ['D', 'H', 'M', 'S']
*/
timeToShow?: Array<'D' | 'H' | 'M' | 'S'>;

/**
* Text to show in time label
* - `default`: {d: 'Days', h: 'Hours', m: 'Minutes', s: 'Seconds'}
*/
timeLabels?: { d?: string; h?: string; m?: string; s?: string };

/**
* Should show separator
* - `default`: false
*/
showSeparator?: boolean;

/**
* A boolean to pause and resume the component
* - `default`: true
*/
running?: boolean;
}

export interface CountDownState {
until: number;
lastUntil: number | null;
wentBackgroundAt: number | null;
}
export default class CountDown extends React.Component<CountDownProps, CountDownState> {}