This repository has been archived by the owner on Jul 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRNMorphingText.js
107 lines (95 loc) · 2.58 KB
/
RNMorphingText.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import React, { Component } from "react";
import { StyleSheet, ViewPropTypes, Platform } from "react-native";
import PropTypes from "prop-types";
import { requireNativeComponent } from "react-native";
class RNMorphingText extends Component {
static propTypes = {
...ViewPropTypes,
value: PropTypes.string,
effect: PropTypes.string,
color: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
colorSpace: PropTypes.number,
colorSpeed: PropTypes.number,
size: PropTypes.number,
typerSpeed: PropTypes.number,
charIncrease: PropTypes.number,
props: PropTypes.object,
animationDuration: PropTypes.number,
lineColor: PropTypes.string,
lineWidth: PropTypes.number,
font: PropTypes.string,
textAlign: PropTypes.string
};
static defaultProps = {
font: '',
textAlign: '',
value: "",
effect: "scale",
size: 12,
width: "100%",
height: "100%",
color: "#000000",
colorSpace: 150,
colorSpeed: 5,
typerSpeed: 100,
charIncrease: 2,
animationDuration: 3000,
lineColor: "#1367bc",
lineWidth: 4
};
static Effects: {
Scale: "scale",
Evaporate: "evaporate",
Fall: "fall",
Pixelate: "pixelate",
Sparkle: "sparkle",
Burn: "burn",
Anvil: "anvil",
Line: "line",
Typer: "typer",
Rainbow: "rainbow",
Fade: "fade"
}
render() {
if (Platform.OS === 'ios') {
return (
<MorphingText
style={{ width: this.props.width, height: this.props.height }}
value={this.props.children}
effect={this.props.effect}
color={this.props.color}
size={this.props.size}
/>
);
} else if (Platform.OS === 'android') {
return (
<MorphingText
style={{ width: this.props.width, height: this.props.height }}
props={{
value: this.props.children,
effect: this.props.effect,
color: this.props.color,
colorSpace: this.props.colorSpace,
colorSpeed: this.props.colorSpeed,
typerSpeed: this.props.typerSpeed,
charIncrease: this.props.charIncrease,
size: this.props.size,
animationDuration: this.props.size,
lineColor: this.props.lineColor,
lineWidth: this.props.lineWidth,
font: this.props.font,
textAlign: this.props.textAlign
}}
/>
);
}
}
}
const MorphingText = requireNativeComponent(
"RNMorphingText",
RNMorphingText,
{
nativeOnly: {}
}
);
export default RNMorphingText;