-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcountdown-timer.js
More file actions
66 lines (55 loc) · 1.46 KB
/
countdown-timer.js
File metadata and controls
66 lines (55 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var React = require('react-native');
var {
requireNativeComponent,
NativeMethodsMixin,
View,
} = React;
var CountdownView = React.createClass({
mixins: [NativeMethodsMixin],
propTypes: {
...View.propTypes,
time: React.PropTypes.number,
radius: React.PropTypes.number,
fillColor: React.PropTypes.string,
fillAlpha: React.PropTypes.number,
strokeColor: React.PropTypes.string,
tapCancel: React.PropTypes.bool,
onTimerUpdate: React.PropTypes.func,
onTimerCompleted: React.PropTypes.func,
onPress: React.PropTypes.func,
},
getDefaultProps: function() {
return {
time: 10,
radius: 20,
fillColor: '#000000',
fillAlpha: 1.0,
strokeColor: '#ffffff',
tapCancel: false,
};
},
_onTimerUpdate: function(event: Event) {
this.props.onTimerUpdate && this.props.onTimerUpdate(event.nativeEvent);
},
_onTimerCompleted: function(event: Event) {
this.props.onTimerCompleted && this.props.onTimerCompleted(event.nativeEvent);
},
_onPress: function(event: Event) {
this.props.onPress && this.props.onPress(event.nativeEvent);
},
render: function() {
return <NativeCountdownView
{...this.props}
onTimerUpdate={this._onTimerUpdate}
onTimerCompleted={this._onTimerCompleted}
onPress={this._onPress} />
},
});
var NativeCountdownView = requireNativeComponent('CountdownView', CountdownView, {
nativeOnly: {
onTimerUpdate: true,
onTimerCompleted: true,
onPress: true,
},
});
module.exports = CountdownView;