From eef6a60195ddd39bd8e043aee8e40be087071490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salom=C3=A3o=20Luiz=20de=20Ara=C3=BAjo=20Neto?= <35156345+salomaoluiz@users.noreply.github.com> Date: Wed, 16 Oct 2019 17:44:34 -0400 Subject: [PATCH 1/2] Add support to typescript --- index.d.ts | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..84780d7 --- /dev/null +++ b/index.d.ts @@ -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.PureComponent {} From 228971d824d6369abdbf1ccbdae777769ad884a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Salom=C3=A3o=20Luiz=20de=20Ara=C3=BAjo=20Neto?= <35156345+salomaoluiz@users.noreply.github.com> Date: Thu, 17 Oct 2019 07:56:18 -0400 Subject: [PATCH 2/2] Change export default to Component. Change export default from PureComponent to Component for match with lib. --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 84780d7..4fed895 100644 --- a/index.d.ts +++ b/index.d.ts @@ -98,4 +98,4 @@ export interface CountDownState { lastUntil: number | null; wentBackgroundAt: number | null; } -export default class CountDown extends React.PureComponent {} +export default class CountDown extends React.Component {}