This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathRNDownloadButton.js
68 lines (56 loc) · 2.03 KB
/
RNDownloadButton.js
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
67
68
import React, { Component } from "react";
import { StyleSheet, ViewPropTypes, Platform, TouchableWithoutFeedback } from "react-native";
import PropTypes from "prop-types";
import { requireNativeComponent } from "react-native";
class RNDownloadButton extends Component {
constructor (props) {
super(props)
this.state = {
start: this.props.start
}
}
startAnimation = () => {
this.setState({
start: true
})
}
_onPress = () => {
this.props.onPress && this.props.onPress()
this.startAnimation()
}
render() {
if (Platform.OS === "ios") {
return <TouchableWithoutFeedback onPress={this._onPress}>
<DownloadButton style={{ width: this.props.size, height: this.props.size }} props={{ size: this.props.size, lineWidth: this.props.lineWidth, tickColor: this.props.tickColor, tintColor: this.props.tintColor, backgroundColor: this.props.backgroundColor }} startAnimation={this.state.start} progress={this.props.progress} reset={this.props.reset} />
</TouchableWithoutFeedback>
} else if (Platform.OS === "android") {
return <TouchableWithoutFeedback onPress={this._onPress}>
<DownloadButton style={{ width: this.props.size, height: this.props.size }} startAnimation={this.state.start} progress={this.props.progress} reset={this.props.reset} lineWidth={this.props.lineWidth} tickColor={this.props.tickColor} tintColor={this.props.tintColor} backgroundColor={this.props.backgroundColor} />
</TouchableWithoutFeedback>;
}
}
}
RNDownloadButton.propTypes = {
...ViewPropTypes,
startAnimation: PropTypes.bool,
progress: PropTypes.number,
reset: PropTypes.bool,
props: PropTypes.object,
lineWidth: PropTypes.number,
tickColor: PropTypes.string,
tintColor: PropTypes.string,
backgroundColor: PropTypes.string
};
RNDownloadButton.defaultProps = {
startAnimation: false,
reset: false,
lineWidth: 2
};
const DownloadButton = requireNativeComponent(
"RNDownloadButton",
RNDownloadButton,
{
nativeOnly: { }
}
);
export default RNDownloadButton;