nativebits-animated-text 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +564 -2
- package/docs/android-demo.gif +0 -0
- package/lib/commonjs/index.js +146 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/text/BlurText.js +146 -0
- package/lib/commonjs/text/BlurText.js.map +1 -0
- package/lib/commonjs/text/BounceText.js +83 -0
- package/lib/commonjs/text/BounceText.js.map +1 -0
- package/lib/commonjs/text/CountUpText.js +77 -0
- package/lib/commonjs/text/CountUpText.js.map +1 -0
- package/lib/commonjs/text/ElasticText.js +85 -0
- package/lib/commonjs/text/ElasticText.js.map +1 -0
- package/lib/commonjs/text/ExplosionText.js +191 -0
- package/lib/commonjs/text/ExplosionText.js.map +1 -0
- package/lib/commonjs/text/FlipText.js +101 -0
- package/lib/commonjs/text/FlipText.js.map +1 -0
- package/lib/commonjs/text/GlitchText.js +329 -0
- package/lib/commonjs/text/GlitchText.js.map +1 -0
- package/lib/commonjs/text/GradientText.js +73 -0
- package/lib/commonjs/text/GradientText.js.map +1 -0
- package/lib/commonjs/text/MorphText.js +192 -0
- package/lib/commonjs/text/MorphText.js.map +1 -0
- package/lib/commonjs/text/NeonText.js +134 -0
- package/lib/commonjs/text/NeonText.js.map +1 -0
- package/lib/commonjs/text/ParticleText.js +328 -0
- package/lib/commonjs/text/ParticleText.js.map +1 -0
- package/lib/commonjs/text/RevealText.js +142 -0
- package/lib/commonjs/text/RevealText.js.map +1 -0
- package/lib/commonjs/text/RotateText.js +99 -0
- package/lib/commonjs/text/RotateText.js.map +1 -0
- package/lib/commonjs/text/ScrambleText.js +82 -0
- package/lib/commonjs/text/ScrambleText.js.map +1 -0
- package/lib/commonjs/text/ShinyText.js +87 -0
- package/lib/commonjs/text/ShinyText.js.map +1 -0
- package/lib/commonjs/text/SplitText.js +81 -0
- package/lib/commonjs/text/SplitText.js.map +1 -0
- package/lib/commonjs/text/TextWave.js +130 -0
- package/lib/commonjs/text/TextWave.js.map +1 -0
- package/lib/commonjs/text/ThreeDText.js +145 -0
- package/lib/commonjs/text/ThreeDText.js.map +1 -0
- package/lib/commonjs/text/TypewriterText.js +119 -0
- package/lib/commonjs/text/TypewriterText.js.map +1 -0
- package/lib/commonjs/text/WaveText.js +79 -0
- package/lib/commonjs/text/WaveText.js.map +1 -0
- package/lib/module/index.js +23 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/text/BlurText.js +139 -0
- package/lib/module/text/BlurText.js.map +1 -0
- package/lib/module/text/BounceText.js +77 -0
- package/lib/module/text/BounceText.js.map +1 -0
- package/lib/module/text/CountUpText.js +70 -0
- package/lib/module/text/CountUpText.js.map +1 -0
- package/lib/module/text/ElasticText.js +78 -0
- package/lib/module/text/ElasticText.js.map +1 -0
- package/lib/module/text/ExplosionText.js +184 -0
- package/lib/module/text/ExplosionText.js.map +1 -0
- package/lib/module/text/FlipText.js +94 -0
- package/lib/module/text/FlipText.js.map +1 -0
- package/lib/module/text/GlitchText.js +322 -0
- package/lib/module/text/GlitchText.js.map +1 -0
- package/lib/module/text/GradientText.js +66 -0
- package/lib/module/text/GradientText.js.map +1 -0
- package/lib/module/text/MorphText.js +185 -0
- package/lib/module/text/MorphText.js.map +1 -0
- package/lib/module/text/NeonText.js +127 -0
- package/lib/module/text/NeonText.js.map +1 -0
- package/lib/module/text/ParticleText.js +321 -0
- package/lib/module/text/ParticleText.js.map +1 -0
- package/lib/module/text/RevealText.js +135 -0
- package/lib/module/text/RevealText.js.map +1 -0
- package/lib/module/text/RotateText.js +93 -0
- package/lib/module/text/RotateText.js.map +1 -0
- package/lib/module/text/ScrambleText.js +76 -0
- package/lib/module/text/ScrambleText.js.map +1 -0
- package/lib/module/text/ShinyText.js +80 -0
- package/lib/module/text/ShinyText.js.map +1 -0
- package/lib/module/text/SplitText.js +74 -0
- package/lib/module/text/SplitText.js.map +1 -0
- package/lib/module/text/TextWave.js +123 -0
- package/lib/module/text/TextWave.js.map +1 -0
- package/lib/module/text/ThreeDText.js +138 -0
- package/lib/module/text/ThreeDText.js.map +1 -0
- package/lib/module/text/TypewriterText.js +113 -0
- package/lib/module/text/TypewriterText.js.map +1 -0
- package/lib/module/text/WaveText.js +72 -0
- package/lib/module/text/WaveText.js.map +1 -0
- package/lib/typescript/index.d.ts +41 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/text/BlurText.d.ts +16 -0
- package/lib/typescript/text/BlurText.d.ts.map +1 -0
- package/lib/typescript/text/BounceText.d.ts +15 -0
- package/lib/typescript/text/BounceText.d.ts.map +1 -0
- package/lib/typescript/text/CountUpText.d.ts +20 -0
- package/lib/typescript/text/CountUpText.d.ts.map +1 -0
- package/lib/typescript/text/ElasticText.d.ts +17 -0
- package/lib/typescript/text/ElasticText.d.ts.map +1 -0
- package/lib/typescript/text/ExplosionText.d.ts +23 -0
- package/lib/typescript/text/ExplosionText.d.ts.map +1 -0
- package/lib/typescript/text/FlipText.d.ts +17 -0
- package/lib/typescript/text/FlipText.d.ts.map +1 -0
- package/lib/typescript/text/GlitchText.d.ts +19 -0
- package/lib/typescript/text/GlitchText.d.ts.map +1 -0
- package/lib/typescript/text/GradientText.d.ts +12 -0
- package/lib/typescript/text/GradientText.d.ts.map +1 -0
- package/lib/typescript/text/MorphText.d.ts +18 -0
- package/lib/typescript/text/MorphText.d.ts.map +1 -0
- package/lib/typescript/text/NeonText.d.ts +16 -0
- package/lib/typescript/text/NeonText.d.ts.map +1 -0
- package/lib/typescript/text/ParticleText.d.ts +23 -0
- package/lib/typescript/text/ParticleText.d.ts.map +1 -0
- package/lib/typescript/text/RevealText.d.ts +19 -0
- package/lib/typescript/text/RevealText.d.ts.map +1 -0
- package/lib/typescript/text/RotateText.d.ts +17 -0
- package/lib/typescript/text/RotateText.d.ts.map +1 -0
- package/lib/typescript/text/ScrambleText.d.ts +14 -0
- package/lib/typescript/text/ScrambleText.d.ts.map +1 -0
- package/lib/typescript/text/ShinyText.d.ts +15 -0
- package/lib/typescript/text/ShinyText.d.ts.map +1 -0
- package/lib/typescript/text/SplitText.d.ts +28 -0
- package/lib/typescript/text/SplitText.d.ts.map +1 -0
- package/lib/typescript/text/TextWave.d.ts +15 -0
- package/lib/typescript/text/TextWave.d.ts.map +1 -0
- package/lib/typescript/text/ThreeDText.d.ts +24 -0
- package/lib/typescript/text/ThreeDText.d.ts.map +1 -0
- package/lib/typescript/text/TypewriterText.d.ts +21 -0
- package/lib/typescript/text/TypewriterText.d.ts.map +1 -0
- package/lib/typescript/text/WaveText.d.ts +14 -0
- package/lib/typescript/text/WaveText.d.ts.map +1 -0
- package/package.json +48 -4
- package/src/index.ts +45 -0
- package/src/text/BlurText.tsx +243 -0
- package/src/text/BounceText.tsx +158 -0
- package/src/text/CountUpText.tsx +153 -0
- package/src/text/ElasticText.tsx +143 -0
- package/src/text/ExplosionText.tsx +242 -0
- package/src/text/FlipText.tsx +161 -0
- package/src/text/GlitchText.tsx +525 -0
- package/src/text/GradientText.tsx +118 -0
- package/src/text/MorphText.tsx +305 -0
- package/src/text/NeonText.tsx +205 -0
- package/src/text/ParticleText.tsx +489 -0
- package/src/text/RevealText.tsx +255 -0
- package/src/text/RotateText.tsx +179 -0
- package/src/text/ScrambleText.tsx +137 -0
- package/src/text/ShinyText.tsx +163 -0
- package/src/text/SplitText.tsx +122 -0
- package/src/text/TextWave.tsx +223 -0
- package/src/text/ThreeDText.tsx +268 -0
- package/src/text/TypewriterText.tsx +189 -0
- package/src/text/WaveText.tsx +132 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
View,
|
|
5
|
+
type TextStyle,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
|
|
9
|
+
import Animated, {
|
|
10
|
+
cancelAnimation,
|
|
11
|
+
Easing,
|
|
12
|
+
useAnimatedStyle,
|
|
13
|
+
useSharedValue,
|
|
14
|
+
withDelay,
|
|
15
|
+
withTiming,
|
|
16
|
+
} from 'react-native-reanimated';
|
|
17
|
+
|
|
18
|
+
export interface MorphTextProps {
|
|
19
|
+
words: string[];
|
|
20
|
+
duration?: number;
|
|
21
|
+
delay?: number;
|
|
22
|
+
stagger?: number;
|
|
23
|
+
pauseDuration?: number;
|
|
24
|
+
loop?: boolean;
|
|
25
|
+
enterFromY?: number;
|
|
26
|
+
exitToY?: number;
|
|
27
|
+
style?: TextStyle;
|
|
28
|
+
characterStyle?: TextStyle;
|
|
29
|
+
containerStyle?: ViewStyle;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface MorphCharacterProps {
|
|
33
|
+
character: string;
|
|
34
|
+
index: number;
|
|
35
|
+
direction: 'enter' | 'exit';
|
|
36
|
+
duration: number;
|
|
37
|
+
stagger: number;
|
|
38
|
+
enterFromY: number;
|
|
39
|
+
exitToY: number;
|
|
40
|
+
style?: TextStyle;
|
|
41
|
+
characterStyle?: TextStyle;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function MorphCharacter({
|
|
45
|
+
character,
|
|
46
|
+
index,
|
|
47
|
+
direction,
|
|
48
|
+
duration,
|
|
49
|
+
stagger,
|
|
50
|
+
enterFromY,
|
|
51
|
+
exitToY,
|
|
52
|
+
style,
|
|
53
|
+
characterStyle,
|
|
54
|
+
}: MorphCharacterProps) {
|
|
55
|
+
const progress = useSharedValue(0);
|
|
56
|
+
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
progress.value = withDelay(
|
|
59
|
+
index * stagger,
|
|
60
|
+
withTiming(1, {
|
|
61
|
+
duration,
|
|
62
|
+
easing: Easing.out(Easing.cubic),
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
cancelAnimation(progress);
|
|
68
|
+
};
|
|
69
|
+
}, [index, stagger, duration, progress]);
|
|
70
|
+
|
|
71
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
72
|
+
if (direction === 'enter') {
|
|
73
|
+
return {
|
|
74
|
+
opacity: progress.value,
|
|
75
|
+
transform: [
|
|
76
|
+
{
|
|
77
|
+
translateY: (1 - progress.value) * enterFromY,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
scale: 0.85 + progress.value * 0.15,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
opacity: 1 - progress.value,
|
|
88
|
+
transform: [
|
|
89
|
+
{
|
|
90
|
+
translateY: progress.value * exitToY,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
scale: 1 - progress.value * 0.15,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Animated.Text
|
|
101
|
+
style={[
|
|
102
|
+
style,
|
|
103
|
+
characterStyle,
|
|
104
|
+
animatedStyle,
|
|
105
|
+
]}
|
|
106
|
+
>
|
|
107
|
+
{character === ' ' ? '\u00A0' : character}
|
|
108
|
+
</Animated.Text>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface MorphWordProps {
|
|
113
|
+
word: string;
|
|
114
|
+
direction: 'enter' | 'exit';
|
|
115
|
+
duration: number;
|
|
116
|
+
stagger: number;
|
|
117
|
+
enterFromY: number;
|
|
118
|
+
exitToY: number;
|
|
119
|
+
style?: TextStyle;
|
|
120
|
+
characterStyle?: TextStyle;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function MorphWord({
|
|
124
|
+
word,
|
|
125
|
+
direction,
|
|
126
|
+
duration,
|
|
127
|
+
stagger,
|
|
128
|
+
enterFromY,
|
|
129
|
+
exitToY,
|
|
130
|
+
style,
|
|
131
|
+
characterStyle,
|
|
132
|
+
}: MorphWordProps) {
|
|
133
|
+
return (
|
|
134
|
+
<View
|
|
135
|
+
style={{
|
|
136
|
+
flexDirection: 'row',
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{word.split('').map((character, index) => (
|
|
141
|
+
<MorphCharacter
|
|
142
|
+
key={`${index}-${character}`}
|
|
143
|
+
character={character}
|
|
144
|
+
index={index}
|
|
145
|
+
direction={direction}
|
|
146
|
+
duration={duration}
|
|
147
|
+
stagger={stagger}
|
|
148
|
+
enterFromY={enterFromY}
|
|
149
|
+
exitToY={exitToY}
|
|
150
|
+
style={style}
|
|
151
|
+
characterStyle={characterStyle}
|
|
152
|
+
/>
|
|
153
|
+
))}
|
|
154
|
+
</View>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function MorphText({
|
|
159
|
+
words,
|
|
160
|
+
duration = 500,
|
|
161
|
+
delay = 0,
|
|
162
|
+
stagger = 35,
|
|
163
|
+
pauseDuration = 1200,
|
|
164
|
+
loop = true,
|
|
165
|
+
enterFromY = 16,
|
|
166
|
+
exitToY = -16,
|
|
167
|
+
style,
|
|
168
|
+
characterStyle,
|
|
169
|
+
containerStyle,
|
|
170
|
+
}: MorphTextProps) {
|
|
171
|
+
const [wordIndex, setWordIndex] = useState(0);
|
|
172
|
+
const [previousWord, setPreviousWord] = useState<string | null>(null);
|
|
173
|
+
|
|
174
|
+
const indexRef = useRef(0);
|
|
175
|
+
|
|
176
|
+
const maxLength = Math.max(
|
|
177
|
+
1,
|
|
178
|
+
...words.map(word => word.length),
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const transitionDuration =
|
|
182
|
+
duration + stagger * (maxLength - 1);
|
|
183
|
+
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
indexRef.current = 0;
|
|
186
|
+
setWordIndex(0);
|
|
187
|
+
setPreviousWord(null);
|
|
188
|
+
}, [words]);
|
|
189
|
+
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (!previousWord) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const timeout = setTimeout(() => {
|
|
196
|
+
setPreviousWord(null);
|
|
197
|
+
}, duration + stagger * Math.max(0, previousWord.length - 1));
|
|
198
|
+
|
|
199
|
+
return () => clearTimeout(timeout);
|
|
200
|
+
}, [previousWord, duration, stagger]);
|
|
201
|
+
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (words.length < 2) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let interval: ReturnType<typeof setInterval> | undefined;
|
|
208
|
+
|
|
209
|
+
const advance = () => {
|
|
210
|
+
const currentIndex = indexRef.current;
|
|
211
|
+
let nextIndex = currentIndex + 1;
|
|
212
|
+
|
|
213
|
+
if (nextIndex >= words.length) {
|
|
214
|
+
if (!loop) {
|
|
215
|
+
if (interval) {
|
|
216
|
+
clearInterval(interval);
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
nextIndex = 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
setPreviousWord(words[currentIndex]);
|
|
225
|
+
indexRef.current = nextIndex;
|
|
226
|
+
setWordIndex(nextIndex);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const timeout = setTimeout(() => {
|
|
230
|
+
advance();
|
|
231
|
+
|
|
232
|
+
interval = setInterval(
|
|
233
|
+
advance,
|
|
234
|
+
transitionDuration + pauseDuration,
|
|
235
|
+
);
|
|
236
|
+
}, delay + pauseDuration);
|
|
237
|
+
|
|
238
|
+
return () => {
|
|
239
|
+
clearTimeout(timeout);
|
|
240
|
+
|
|
241
|
+
if (interval) {
|
|
242
|
+
clearInterval(interval);
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
}, [
|
|
246
|
+
words,
|
|
247
|
+
loop,
|
|
248
|
+
delay,
|
|
249
|
+
pauseDuration,
|
|
250
|
+
transitionDuration,
|
|
251
|
+
]);
|
|
252
|
+
|
|
253
|
+
if (words.length === 0) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<View
|
|
259
|
+
style={[
|
|
260
|
+
{
|
|
261
|
+
position: 'relative',
|
|
262
|
+
alignSelf: 'flex-start',
|
|
263
|
+
overflow: 'visible',
|
|
264
|
+
},
|
|
265
|
+
containerStyle,
|
|
266
|
+
]}
|
|
267
|
+
>
|
|
268
|
+
<MorphWord
|
|
269
|
+
word={words[wordIndex] ?? ''}
|
|
270
|
+
direction="enter"
|
|
271
|
+
duration={duration}
|
|
272
|
+
stagger={stagger}
|
|
273
|
+
enterFromY={enterFromY}
|
|
274
|
+
exitToY={exitToY}
|
|
275
|
+
style={style}
|
|
276
|
+
characterStyle={characterStyle}
|
|
277
|
+
/>
|
|
278
|
+
|
|
279
|
+
{previousWord !== null && (
|
|
280
|
+
<View
|
|
281
|
+
pointerEvents="none"
|
|
282
|
+
style={{
|
|
283
|
+
position: 'absolute',
|
|
284
|
+
left: 0,
|
|
285
|
+
top: 0,
|
|
286
|
+
zIndex: 1,
|
|
287
|
+
}}
|
|
288
|
+
>
|
|
289
|
+
<MorphWord
|
|
290
|
+
word={previousWord}
|
|
291
|
+
direction="exit"
|
|
292
|
+
duration={duration}
|
|
293
|
+
stagger={stagger}
|
|
294
|
+
enterFromY={enterFromY}
|
|
295
|
+
exitToY={exitToY}
|
|
296
|
+
style={style}
|
|
297
|
+
characterStyle={characterStyle}
|
|
298
|
+
/>
|
|
299
|
+
</View>
|
|
300
|
+
)}
|
|
301
|
+
</View>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export default MorphText;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
|
|
2
|
+
import React, { useEffect, useMemo } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
View,
|
|
5
|
+
type TextStyle,
|
|
6
|
+
type ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import {
|
|
9
|
+
BlurMask,
|
|
10
|
+
Canvas,
|
|
11
|
+
matchFont,
|
|
12
|
+
Text as SkiaText,
|
|
13
|
+
} from '@shopify/react-native-skia';
|
|
14
|
+
import Animated, {
|
|
15
|
+
cancelAnimation,
|
|
16
|
+
Easing,
|
|
17
|
+
useAnimatedStyle,
|
|
18
|
+
useSharedValue,
|
|
19
|
+
withRepeat,
|
|
20
|
+
withTiming,
|
|
21
|
+
} from 'react-native-reanimated';
|
|
22
|
+
|
|
23
|
+
export interface NeonTextProps {
|
|
24
|
+
text: string;
|
|
25
|
+
neonColor?: string;
|
|
26
|
+
coreColor?: string;
|
|
27
|
+
glowRadius?: number;
|
|
28
|
+
glowIntensity?: number;
|
|
29
|
+
pulse?: boolean;
|
|
30
|
+
duration?: number;
|
|
31
|
+
loop?: boolean;
|
|
32
|
+
style?: TextStyle;
|
|
33
|
+
containerStyle?: ViewStyle;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const NeonText = ({
|
|
37
|
+
text,
|
|
38
|
+
neonColor = '#A855F7',
|
|
39
|
+
coreColor = '#FFFFFF',
|
|
40
|
+
glowRadius = 22,
|
|
41
|
+
glowIntensity = 1,
|
|
42
|
+
pulse = true,
|
|
43
|
+
duration = 1500,
|
|
44
|
+
loop = true,
|
|
45
|
+
style,
|
|
46
|
+
containerStyle,
|
|
47
|
+
}: NeonTextProps) => {
|
|
48
|
+
const pulseValue = useSharedValue(1);
|
|
49
|
+
|
|
50
|
+
const fontSize = Number(style?.fontSize ?? 36);
|
|
51
|
+
|
|
52
|
+
const fontWeight = (style?.fontWeight ?? 'bold') as
|
|
53
|
+
| 'normal' | 'bold' | '100' | '200' | '300'
|
|
54
|
+
| '400' | '500' | '600' | '700' | '800' | '900';
|
|
55
|
+
|
|
56
|
+
const font = useMemo(
|
|
57
|
+
() =>
|
|
58
|
+
matchFont({
|
|
59
|
+
fontFamily: style?.fontFamily ?? 'Arial',
|
|
60
|
+
fontSize,
|
|
61
|
+
fontWeight,
|
|
62
|
+
fontStyle: style?.fontStyle ?? 'normal',
|
|
63
|
+
}),
|
|
64
|
+
[style?.fontFamily, style?.fontStyle, fontSize, fontWeight],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const metrics = font.getMetrics();
|
|
68
|
+
const textWidth = font.measureText(text).width;
|
|
69
|
+
|
|
70
|
+
const safeGlowRadius = Math.max(0, glowRadius);
|
|
71
|
+
const safeIntensity = Math.max(0, Math.min(1, glowIntensity));
|
|
72
|
+
|
|
73
|
+
const padding = Math.ceil(safeGlowRadius * 3 + fontSize * 0.2);
|
|
74
|
+
|
|
75
|
+
const canvasWidth = Math.ceil(textWidth + padding * 2);
|
|
76
|
+
const canvasHeight = Math.ceil(
|
|
77
|
+
metrics.descent - metrics.ascent + padding * 2,
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const baseline = -metrics.ascent + padding;
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
cancelAnimation(pulseValue);
|
|
84
|
+
pulseValue.value = 1;
|
|
85
|
+
|
|
86
|
+
if (pulse) {
|
|
87
|
+
pulseValue.value = withRepeat(
|
|
88
|
+
withTiming(0.45, {
|
|
89
|
+
duration,
|
|
90
|
+
easing: Easing.inOut(Easing.sin),
|
|
91
|
+
}),
|
|
92
|
+
loop ? -1 : 1,
|
|
93
|
+
true,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return () => cancelAnimation(pulseValue);
|
|
98
|
+
}, [pulse, duration, loop, pulseValue]);
|
|
99
|
+
|
|
100
|
+
const glowStyle = useAnimatedStyle(() => ({
|
|
101
|
+
opacity: pulseValue.value * safeIntensity,
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<View style={containerStyle}>
|
|
106
|
+
<View
|
|
107
|
+
style={{
|
|
108
|
+
width: canvasWidth,
|
|
109
|
+
height: canvasHeight,
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
{/* Animated three-layer neon glow */}
|
|
113
|
+
<Animated.View
|
|
114
|
+
pointerEvents="none"
|
|
115
|
+
style={[
|
|
116
|
+
{
|
|
117
|
+
position: 'absolute',
|
|
118
|
+
width: canvasWidth,
|
|
119
|
+
height: canvasHeight,
|
|
120
|
+
},
|
|
121
|
+
glowStyle,
|
|
122
|
+
]}
|
|
123
|
+
>
|
|
124
|
+
<Canvas
|
|
125
|
+
style={{
|
|
126
|
+
width: canvasWidth,
|
|
127
|
+
height: canvasHeight,
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
{/* Layer 1: Large outer purple halo */}
|
|
131
|
+
<SkiaText
|
|
132
|
+
text={text}
|
|
133
|
+
x={padding}
|
|
134
|
+
y={baseline}
|
|
135
|
+
font={font}
|
|
136
|
+
color={neonColor}
|
|
137
|
+
opacity={0.9}
|
|
138
|
+
>
|
|
139
|
+
<BlurMask
|
|
140
|
+
blur={safeGlowRadius * 2.2}
|
|
141
|
+
style="normal"
|
|
142
|
+
/>
|
|
143
|
+
</SkiaText>
|
|
144
|
+
|
|
145
|
+
{/* Layer 2: Strong violet glow */}
|
|
146
|
+
<SkiaText
|
|
147
|
+
text={text}
|
|
148
|
+
x={padding}
|
|
149
|
+
y={baseline}
|
|
150
|
+
font={font}
|
|
151
|
+
color={neonColor}
|
|
152
|
+
opacity={0.95}
|
|
153
|
+
>
|
|
154
|
+
<BlurMask
|
|
155
|
+
blur={safeGlowRadius}
|
|
156
|
+
style="normal"
|
|
157
|
+
/>
|
|
158
|
+
</SkiaText>
|
|
159
|
+
|
|
160
|
+
{/* Layer 3: Concentrated inner glow */}
|
|
161
|
+
<SkiaText
|
|
162
|
+
text={text}
|
|
163
|
+
x={padding}
|
|
164
|
+
y={baseline}
|
|
165
|
+
font={font}
|
|
166
|
+
color="#F0ABFC"
|
|
167
|
+
opacity={1}
|
|
168
|
+
>
|
|
169
|
+
<BlurMask
|
|
170
|
+
blur={safeGlowRadius * 0.25}
|
|
171
|
+
style="normal"
|
|
172
|
+
/>
|
|
173
|
+
</SkiaText>
|
|
174
|
+
</Canvas>
|
|
175
|
+
</Animated.View>
|
|
176
|
+
|
|
177
|
+
{/* Neon tube */}
|
|
178
|
+
<Canvas
|
|
179
|
+
style={{
|
|
180
|
+
width: canvasWidth,
|
|
181
|
+
height: canvasHeight,
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
184
|
+
{/* Colored tube */}
|
|
185
|
+
<SkiaText
|
|
186
|
+
text={text}
|
|
187
|
+
x={padding}
|
|
188
|
+
y={baseline}
|
|
189
|
+
font={font}
|
|
190
|
+
color={neonColor}
|
|
191
|
+
/>
|
|
192
|
+
|
|
193
|
+
{/* Bright white tube center */}
|
|
194
|
+
<SkiaText
|
|
195
|
+
text={text}
|
|
196
|
+
x={padding}
|
|
197
|
+
y={baseline}
|
|
198
|
+
font={font}
|
|
199
|
+
color={coreColor}
|
|
200
|
+
/>
|
|
201
|
+
</Canvas>
|
|
202
|
+
</View>
|
|
203
|
+
</View>
|
|
204
|
+
);
|
|
205
|
+
};
|