@mehul214/react-native-flash-toast 0.0.0-stage → 1.0.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/dist/index.mjs ADDED
@@ -0,0 +1,730 @@
1
+ import React, { useState, useRef, useCallback, useImperativeHandle, useEffect, createContext, useMemo, useContext } from 'react';
2
+ import { StyleSheet, Platform, Animated, PanResponder, View, Pressable, Text, Dimensions, StatusBar } from 'react-native';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+
5
+ // src/FlashMessage.tsx
6
+
7
+ // src/FlashMessageManager.ts
8
+ var FlashMessageManager = class {
9
+ constructor() {
10
+ this.defaultInstance = null;
11
+ this.instances = /* @__PURE__ */ new Map();
12
+ this.pendingQueue = [];
13
+ }
14
+ register(ref, id = "default") {
15
+ this.instances.set(id, ref);
16
+ if (!this.defaultInstance || id === "default") {
17
+ this.defaultInstance = ref;
18
+ }
19
+ if (this.pendingQueue.length > 0) {
20
+ const next = this.pendingQueue.shift();
21
+ if (next) {
22
+ ref.showMessage(next);
23
+ }
24
+ }
25
+ }
26
+ unregister(id = "default") {
27
+ this.instances.delete(id);
28
+ if (this.defaultInstance === this.instances.get(id)) {
29
+ this.defaultInstance = this.instances.values().next().value || null;
30
+ }
31
+ }
32
+ showMessage(options, targetId) {
33
+ const target = targetId ? this.instances.get(targetId) : this.defaultInstance;
34
+ if (target) {
35
+ target.showMessage(options);
36
+ } else {
37
+ this.pendingQueue.push(options);
38
+ }
39
+ }
40
+ hideMessage(targetId) {
41
+ const target = targetId ? this.instances.get(targetId) : this.defaultInstance;
42
+ if (target) {
43
+ target.hideMessage();
44
+ }
45
+ }
46
+ };
47
+ var flashManager = new FlashMessageManager();
48
+ function showMessage(options) {
49
+ flashManager.showMessage(options);
50
+ }
51
+ function hideMessage() {
52
+ flashManager.hideMessage();
53
+ }
54
+ var flash = showMessage;
55
+ var dismissFlash = hideMessage;
56
+ var BuiltInIcon = ({
57
+ type,
58
+ size = 18,
59
+ color = "#FFFFFF"
60
+ }) => {
61
+ switch (type) {
62
+ case "success": {
63
+ const checkWidth = size * 0.36;
64
+ const checkHeight = size * 0.65;
65
+ const stroke = Math.max(2, size * 0.12);
66
+ return /* @__PURE__ */ jsx(View, { style: [styles.center, { width: size, height: size }], children: /* @__PURE__ */ jsx(
67
+ View,
68
+ {
69
+ style: {
70
+ width: checkWidth,
71
+ height: checkHeight,
72
+ borderColor: color,
73
+ borderBottomWidth: stroke,
74
+ borderRightWidth: stroke,
75
+ borderRadius: 1,
76
+ transform: [{ rotate: "45deg" }, { translateY: -size * 0.08 }]
77
+ }
78
+ }
79
+ ) });
80
+ }
81
+ case "danger": {
82
+ const crossThickness = Math.max(2, size * 0.12);
83
+ const crossLength = size * 0.72;
84
+ return /* @__PURE__ */ jsxs(View, { style: [styles.center, { width: size, height: size }], children: [
85
+ /* @__PURE__ */ jsx(
86
+ View,
87
+ {
88
+ style: [
89
+ styles.crossBar,
90
+ {
91
+ width: crossLength,
92
+ height: crossThickness,
93
+ backgroundColor: color,
94
+ borderRadius: crossThickness / 2,
95
+ transform: [{ rotate: "45deg" }]
96
+ }
97
+ ]
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsx(
101
+ View,
102
+ {
103
+ style: [
104
+ styles.crossBar,
105
+ {
106
+ width: crossLength,
107
+ height: crossThickness,
108
+ backgroundColor: color,
109
+ borderRadius: crossThickness / 2,
110
+ transform: [{ rotate: "-45deg" }]
111
+ }
112
+ ]
113
+ }
114
+ )
115
+ ] });
116
+ }
117
+ case "warning": {
118
+ const warnThickness = Math.max(2, size * 0.13);
119
+ const dotSize = warnThickness * 1.1;
120
+ return /* @__PURE__ */ jsxs(View, { style: [styles.center, { width: size, height: size }], children: [
121
+ /* @__PURE__ */ jsx(
122
+ View,
123
+ {
124
+ style: {
125
+ width: warnThickness,
126
+ height: size * 0.46,
127
+ backgroundColor: color,
128
+ borderRadius: warnThickness / 2,
129
+ marginBottom: size * 0.14
130
+ }
131
+ }
132
+ ),
133
+ /* @__PURE__ */ jsx(
134
+ View,
135
+ {
136
+ style: {
137
+ width: dotSize,
138
+ height: dotSize,
139
+ borderRadius: dotSize / 2,
140
+ backgroundColor: color
141
+ }
142
+ }
143
+ )
144
+ ] });
145
+ }
146
+ case "info": {
147
+ const infoThickness = Math.max(2, size * 0.13);
148
+ const infoDotSize = infoThickness * 1.1;
149
+ return /* @__PURE__ */ jsxs(View, { style: [styles.center, { width: size, height: size }], children: [
150
+ /* @__PURE__ */ jsx(
151
+ View,
152
+ {
153
+ style: {
154
+ width: infoDotSize,
155
+ height: infoDotSize,
156
+ borderRadius: infoDotSize / 2,
157
+ backgroundColor: color,
158
+ marginBottom: size * 0.14
159
+ }
160
+ }
161
+ ),
162
+ /* @__PURE__ */ jsx(
163
+ View,
164
+ {
165
+ style: {
166
+ width: infoThickness,
167
+ height: size * 0.46,
168
+ backgroundColor: color,
169
+ borderRadius: infoThickness / 2
170
+ }
171
+ }
172
+ )
173
+ ] });
174
+ }
175
+ case "default":
176
+ default: {
177
+ const defaultDot = size * 0.44;
178
+ return /* @__PURE__ */ jsx(View, { style: [styles.center, { width: size, height: size }], children: /* @__PURE__ */ jsx(
179
+ View,
180
+ {
181
+ style: {
182
+ width: defaultDot,
183
+ height: defaultDot,
184
+ borderRadius: defaultDot / 2,
185
+ backgroundColor: color
186
+ }
187
+ }
188
+ ) });
189
+ }
190
+ }
191
+ };
192
+ var styles = StyleSheet.create({
193
+ center: {
194
+ justifyContent: "center",
195
+ alignItems: "center"
196
+ },
197
+ crossBar: {
198
+ position: "absolute"
199
+ }
200
+ });
201
+ var COLORS = {
202
+ default: {
203
+ background: "#1F2937",
204
+ // Slate 800
205
+ text: "#FFFFFF",
206
+ icon: "#9CA3AF"
207
+ },
208
+ success: {
209
+ background: "#059669",
210
+ // Emerald 600
211
+ text: "#FFFFFF",
212
+ icon: "#D1FAE5"
213
+ },
214
+ danger: {
215
+ background: "#DC2626",
216
+ // Red 600
217
+ text: "#FFFFFF",
218
+ icon: "#FEE2E2"
219
+ },
220
+ warning: {
221
+ background: "#D97706",
222
+ // Amber 600
223
+ text: "#FFFFFF",
224
+ icon: "#FEF3C7"
225
+ },
226
+ info: {
227
+ background: "#2563EB",
228
+ // Blue 600
229
+ text: "#FFFFFF",
230
+ icon: "#DBEAFE"
231
+ }
232
+ };
233
+ var styles2 = StyleSheet.create({
234
+ rootOverlay: {
235
+ position: "absolute",
236
+ left: 0,
237
+ right: 0,
238
+ zIndex: 99999,
239
+ elevation: 99999
240
+ },
241
+ rootTop: {
242
+ top: 0
243
+ },
244
+ rootBottom: {
245
+ bottom: 0
246
+ },
247
+ rootCenter: {
248
+ top: 0,
249
+ bottom: 0,
250
+ justifyContent: "center",
251
+ alignItems: "center"
252
+ },
253
+ toastContainer: {
254
+ flexDirection: "row",
255
+ alignItems: "center",
256
+ overflow: "hidden",
257
+ ...Platform.select({
258
+ ios: {
259
+ shadowColor: "#000000",
260
+ shadowOffset: { width: 0, height: 6 },
261
+ shadowOpacity: 0.2,
262
+ shadowRadius: 14
263
+ },
264
+ android: {
265
+ elevation: 8
266
+ },
267
+ web: {
268
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15)"
269
+ }
270
+ })
271
+ },
272
+ floatingContainer: {
273
+ marginHorizontal: 16,
274
+ borderRadius: 16,
275
+ borderWidth: 1,
276
+ borderColor: "rgba(255, 255, 255, 0.16)"
277
+ },
278
+ edgeToEdgeContainer: {
279
+ marginHorizontal: 0,
280
+ borderRadius: 0
281
+ },
282
+ contentWrapper: {
283
+ flex: 1,
284
+ flexDirection: "row",
285
+ alignItems: "center",
286
+ paddingVertical: 13,
287
+ paddingHorizontal: 16
288
+ },
289
+ iconContainer: {
290
+ marginRight: 12,
291
+ justifyContent: "center",
292
+ alignItems: "center"
293
+ },
294
+ iconBadge: {
295
+ width: 32,
296
+ height: 32,
297
+ borderRadius: 16,
298
+ backgroundColor: "rgba(255, 255, 255, 0.22)",
299
+ justifyContent: "center",
300
+ alignItems: "center"
301
+ },
302
+ textContainer: {
303
+ flex: 1,
304
+ justifyContent: "center"
305
+ },
306
+ titleText: {
307
+ fontSize: 15,
308
+ fontWeight: "600",
309
+ letterSpacing: -0.2,
310
+ lineHeight: 20,
311
+ color: "#FFFFFF"
312
+ },
313
+ descriptionText: {
314
+ fontSize: 13,
315
+ fontWeight: "400",
316
+ color: "rgba(255, 255, 255, 0.9)",
317
+ marginTop: 2,
318
+ lineHeight: 18
319
+ },
320
+ actionButton: {
321
+ marginLeft: 12,
322
+ paddingHorizontal: 12,
323
+ paddingVertical: 6,
324
+ borderRadius: 8,
325
+ backgroundColor: "rgba(255, 255, 255, 0.22)",
326
+ borderWidth: 1,
327
+ borderColor: "rgba(255, 255, 255, 0.2)"
328
+ },
329
+ actionButtonText: {
330
+ fontSize: 13,
331
+ fontWeight: "600",
332
+ color: "#FFFFFF"
333
+ },
334
+ progressBarContainer: {
335
+ position: "absolute",
336
+ bottom: 0,
337
+ left: 0,
338
+ right: 0,
339
+ height: 3,
340
+ backgroundColor: "rgba(255, 255, 255, 0.2)"
341
+ },
342
+ progressBarFill: {
343
+ height: "100%",
344
+ backgroundColor: "rgba(255, 255, 255, 0.9)"
345
+ }
346
+ });
347
+ function getDefaultSafeAreaInsets() {
348
+ const { width, height } = Dimensions.get("window");
349
+ const isLandscape = width > height;
350
+ if (Platform.OS === "android") {
351
+ return {
352
+ top: StatusBar.currentHeight ?? 24,
353
+ bottom: 16,
354
+ left: 0,
355
+ right: 0
356
+ };
357
+ }
358
+ if (Platform.OS === "ios") {
359
+ const isModernIphone = !Platform.isPad && !Platform.isTV && (height >= 812 || width >= 812);
360
+ return {
361
+ top: isModernIphone ? isLandscape ? 0 : 50 : 20,
362
+ bottom: isModernIphone ? 34 : 0,
363
+ left: 0,
364
+ right: 0
365
+ };
366
+ }
367
+ return {
368
+ top: 16,
369
+ bottom: 16,
370
+ left: 0,
371
+ right: 0
372
+ };
373
+ }
374
+ var FlashMessage = React.forwardRef(
375
+ (props, ref) => {
376
+ const {
377
+ position: defaultPosition = "top",
378
+ duration: defaultDuration = 3e3,
379
+ floating: defaultFloating = true,
380
+ statusBarOffset,
381
+ bottomOffset,
382
+ style: containerCustomStyle
383
+ } = props;
384
+ const [currentMessage, setCurrentMessage] = useState(null);
385
+ const [isVisible, setIsVisible] = useState(false);
386
+ const currentMessageRef = useRef(null);
387
+ const translateY = useRef(new Animated.Value(-150)).current;
388
+ const opacity = useRef(new Animated.Value(0)).current;
389
+ const progress = useRef(new Animated.Value(1)).current;
390
+ const hideTimeoutRef = useRef(null);
391
+ const progressAnimationRef = useRef(null);
392
+ const remainingTimeRef = useRef(0);
393
+ const timerStartedAtRef = useRef(0);
394
+ const safeInsets = getDefaultSafeAreaInsets();
395
+ const clearTimers = useCallback(() => {
396
+ if (hideTimeoutRef.current) {
397
+ clearTimeout(hideTimeoutRef.current);
398
+ hideTimeoutRef.current = null;
399
+ }
400
+ if (progressAnimationRef.current) {
401
+ progressAnimationRef.current.stop();
402
+ progressAnimationRef.current = null;
403
+ }
404
+ }, []);
405
+ const animateHide = useCallback(
406
+ (callback) => {
407
+ clearTimers();
408
+ const pos = currentMessageRef.current?.position ?? defaultPosition;
409
+ const targetY = pos === "top" ? -180 : pos === "bottom" ? 180 : 0;
410
+ Animated.parallel([
411
+ Animated.timing(translateY, {
412
+ toValue: targetY,
413
+ duration: 220,
414
+ useNativeDriver: true
415
+ }),
416
+ Animated.timing(opacity, {
417
+ toValue: 0,
418
+ duration: 200,
419
+ useNativeDriver: true
420
+ })
421
+ ]).start(() => {
422
+ setIsVisible(false);
423
+ const onHide = currentMessageRef.current?.onHide;
424
+ currentMessageRef.current = null;
425
+ setCurrentMessage(null);
426
+ if (onHide) {
427
+ onHide();
428
+ }
429
+ callback?.();
430
+ });
431
+ },
432
+ [clearTimers, defaultPosition, opacity, translateY]
433
+ );
434
+ const startAutoHideTimer = useCallback(
435
+ (durationMs) => {
436
+ clearTimers();
437
+ if (durationMs <= 0) return;
438
+ remainingTimeRef.current = durationMs;
439
+ timerStartedAtRef.current = Date.now();
440
+ progress.setValue(1);
441
+ progressAnimationRef.current = Animated.timing(progress, {
442
+ toValue: 0,
443
+ duration: durationMs,
444
+ useNativeDriver: false
445
+ });
446
+ progressAnimationRef.current.start();
447
+ hideTimeoutRef.current = setTimeout(() => {
448
+ animateHide();
449
+ }, durationMs);
450
+ },
451
+ [animateHide, clearTimers, progress]
452
+ );
453
+ const pauseTimer = useCallback(() => {
454
+ if (hideTimeoutRef.current && timerStartedAtRef.current > 0) {
455
+ clearTimeout(hideTimeoutRef.current);
456
+ hideTimeoutRef.current = null;
457
+ const elapsed = Date.now() - timerStartedAtRef.current;
458
+ remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
459
+ if (progressAnimationRef.current) {
460
+ progressAnimationRef.current.stop();
461
+ }
462
+ }
463
+ }, []);
464
+ const resumeTimer = useCallback(() => {
465
+ if (remainingTimeRef.current > 0) {
466
+ startAutoHideTimer(remainingTimeRef.current);
467
+ }
468
+ }, [startAutoHideTimer]);
469
+ const show = useCallback(
470
+ (options) => {
471
+ clearTimers();
472
+ currentMessageRef.current = options;
473
+ setCurrentMessage(options);
474
+ setIsVisible(true);
475
+ const pos = options.position ?? defaultPosition;
476
+ const initialY = pos === "top" ? -150 : pos === "bottom" ? 150 : 0;
477
+ translateY.setValue(initialY);
478
+ opacity.setValue(0);
479
+ progress.setValue(1);
480
+ Animated.parallel([
481
+ Animated.spring(translateY, {
482
+ toValue: 0,
483
+ tension: 70,
484
+ friction: 9,
485
+ useNativeDriver: true
486
+ }),
487
+ Animated.timing(opacity, {
488
+ toValue: 1,
489
+ duration: 200,
490
+ useNativeDriver: true
491
+ })
492
+ ]).start(() => {
493
+ if (options.onShow) {
494
+ options.onShow();
495
+ }
496
+ });
497
+ const shouldAutoHide = options.autoHide ?? true;
498
+ const dur = shouldAutoHide ? options.duration !== void 0 ? options.duration : defaultDuration : 0;
499
+ if (dur > 0) {
500
+ startAutoHideTimer(dur);
501
+ }
502
+ },
503
+ [clearTimers, defaultDuration, defaultPosition, opacity, progress, startAutoHideTimer, translateY]
504
+ );
505
+ const showRef = useRef(show);
506
+ const animateHideRef = useRef(animateHide);
507
+ showRef.current = show;
508
+ animateHideRef.current = animateHide;
509
+ useImperativeHandle(
510
+ ref,
511
+ () => ({
512
+ showMessage: (options) => showRef.current(options),
513
+ hideMessage: () => animateHideRef.current()
514
+ }),
515
+ []
516
+ );
517
+ useEffect(() => {
518
+ const instanceRef = {
519
+ showMessage: (options) => showRef.current(options),
520
+ hideMessage: () => animateHideRef.current()
521
+ };
522
+ flashManager.register(instanceRef);
523
+ return () => {
524
+ flashManager.unregister();
525
+ clearTimers();
526
+ };
527
+ }, [clearTimers]);
528
+ const panResponder = useRef(
529
+ PanResponder.create({
530
+ onStartShouldSetPanResponder: () => false,
531
+ onMoveShouldSetPanResponder: (_, gestureState) => {
532
+ const swipeEnabled = currentMessageRef.current?.swipeToDismiss ?? true;
533
+ return swipeEnabled && Math.abs(gestureState.dy) > 8;
534
+ },
535
+ onPanResponderGrant: () => {
536
+ if (currentMessageRef.current?.pauseOnPress ?? true) {
537
+ pauseTimer();
538
+ }
539
+ },
540
+ onPanResponderMove: (_, gestureState) => {
541
+ if (!(currentMessageRef.current?.swipeToDismiss ?? true)) return;
542
+ const pos = currentMessageRef.current?.position ?? defaultPosition;
543
+ if (pos === "top" && gestureState.dy < 0) {
544
+ translateY.setValue(gestureState.dy);
545
+ } else if (pos === "bottom" && gestureState.dy > 0) {
546
+ translateY.setValue(gestureState.dy);
547
+ }
548
+ },
549
+ onPanResponderRelease: (_, gestureState) => {
550
+ const pos = currentMessageRef.current?.position ?? defaultPosition;
551
+ const swipeThreshold = 30;
552
+ const isDismissGesture = pos === "top" && gestureState.dy < -swipeThreshold || pos === "bottom" && gestureState.dy > swipeThreshold;
553
+ if (isDismissGesture && (currentMessageRef.current?.swipeToDismiss ?? true)) {
554
+ animateHide();
555
+ } else {
556
+ Animated.spring(translateY, {
557
+ toValue: 0,
558
+ tension: 80,
559
+ friction: 8,
560
+ useNativeDriver: true
561
+ }).start();
562
+ if (currentMessageRef.current?.pauseOnPress ?? true) {
563
+ resumeTimer();
564
+ }
565
+ }
566
+ }
567
+ })
568
+ ).current;
569
+ if (!isVisible || !currentMessage) {
570
+ return null;
571
+ }
572
+ const position = currentMessage.position ?? defaultPosition;
573
+ const isTop = position === "top";
574
+ const isBottom = position === "bottom";
575
+ const type = currentMessage.type ?? "default";
576
+ const typeColors = COLORS[type];
577
+ const backgroundColor = currentMessage.backgroundColor ?? typeColors.background;
578
+ const textColor = currentMessage.color ?? typeColors.text;
579
+ const floating = currentMessage.floating ?? defaultFloating;
580
+ const topInset = currentMessage.statusBarHeight ?? statusBarOffset ?? (isTop ? safeInsets.top + (floating ? 8 : 0) : 0);
581
+ const bottomInset = bottomOffset ?? (isBottom ? safeInsets.bottom + (floating ? 8 : 0) : 0);
582
+ const rootPositionStyle = isTop ? [styles2.rootTop, { paddingTop: topInset }] : isBottom ? [styles2.rootBottom, { paddingBottom: bottomInset }] : styles2.rootCenter;
583
+ const renderIcon = () => {
584
+ if (currentMessage.icon === "none") return null;
585
+ if (typeof currentMessage.icon === "function") {
586
+ return /* @__PURE__ */ jsx(View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsx(View, { style: styles2.iconBadge, children: currentMessage.icon({ size: 18, color: textColor }) }) });
587
+ }
588
+ if (React.isValidElement(currentMessage.icon)) {
589
+ return /* @__PURE__ */ jsx(View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsx(View, { style: styles2.iconBadge, children: currentMessage.icon }) });
590
+ }
591
+ const iconType = typeof currentMessage.icon === "string" ? currentMessage.icon : type;
592
+ return /* @__PURE__ */ jsx(View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsx(View, { style: styles2.iconBadge, children: /* @__PURE__ */ jsx(BuiltInIcon, { type: iconType, color: textColor, size: 18 }) }) });
593
+ };
594
+ const handlePress = () => {
595
+ if (currentMessage.onPress) {
596
+ currentMessage.onPress();
597
+ }
598
+ if (currentMessage.hideOnPress ?? true) {
599
+ animateHide();
600
+ }
601
+ };
602
+ const progressWidthInterpolation = progress.interpolate({
603
+ inputRange: [0, 1],
604
+ outputRange: ["0%", "100%"]
605
+ });
606
+ return /* @__PURE__ */ jsx(
607
+ View,
608
+ {
609
+ pointerEvents: "box-none",
610
+ style: [styles2.rootOverlay, rootPositionStyle, containerCustomStyle],
611
+ children: /* @__PURE__ */ jsxs(
612
+ Animated.View,
613
+ {
614
+ ...panResponder.panHandlers,
615
+ style: [
616
+ styles2.toastContainer,
617
+ floating ? styles2.floatingContainer : styles2.edgeToEdgeContainer,
618
+ { backgroundColor },
619
+ currentMessage.style,
620
+ {
621
+ transform: [{ translateY }],
622
+ opacity
623
+ }
624
+ ],
625
+ children: [
626
+ currentMessage.customComponent ? currentMessage.customComponent(currentMessage, () => animateHide()) : /* @__PURE__ */ jsxs(
627
+ Pressable,
628
+ {
629
+ onPress: handlePress,
630
+ onPressIn: () => {
631
+ if (currentMessage.pauseOnPress ?? true) {
632
+ pauseTimer();
633
+ }
634
+ },
635
+ onPressOut: () => {
636
+ if (currentMessage.pauseOnPress ?? true) {
637
+ resumeTimer();
638
+ }
639
+ },
640
+ onLongPress: currentMessage.onLongPress,
641
+ style: styles2.contentWrapper,
642
+ children: [
643
+ renderIcon(),
644
+ /* @__PURE__ */ jsxs(View, { style: styles2.textContainer, children: [
645
+ typeof currentMessage.message === "string" ? /* @__PURE__ */ jsx(
646
+ Text,
647
+ {
648
+ style: [styles2.titleText, { color: textColor }, currentMessage.titleStyle],
649
+ numberOfLines: 2,
650
+ children: currentMessage.message
651
+ }
652
+ ) : currentMessage.message,
653
+ currentMessage.description ? typeof currentMessage.description === "string" ? /* @__PURE__ */ jsx(
654
+ Text,
655
+ {
656
+ style: [
657
+ styles2.descriptionText,
658
+ { color: textColor },
659
+ currentMessage.textStyle
660
+ ],
661
+ numberOfLines: 3,
662
+ children: currentMessage.description
663
+ }
664
+ ) : currentMessage.description : null
665
+ ] }),
666
+ currentMessage.action ? /* @__PURE__ */ jsx(
667
+ Pressable,
668
+ {
669
+ onPress: () => {
670
+ currentMessage.action?.onPress();
671
+ animateHide();
672
+ },
673
+ style: [styles2.actionButton, currentMessage.action.style],
674
+ children: /* @__PURE__ */ jsx(Text, { style: [styles2.actionButtonText, currentMessage.action.textStyle], children: currentMessage.action.label })
675
+ }
676
+ ) : null
677
+ ]
678
+ }
679
+ ),
680
+ currentMessage.showProgressBar && /* @__PURE__ */ jsx(View, { style: styles2.progressBarContainer, children: /* @__PURE__ */ jsx(
681
+ Animated.View,
682
+ {
683
+ style: [
684
+ styles2.progressBarFill,
685
+ { width: progressWidthInterpolation }
686
+ ]
687
+ }
688
+ ) })
689
+ ]
690
+ }
691
+ )
692
+ }
693
+ );
694
+ }
695
+ );
696
+ FlashMessage.displayName = "FlashMessage";
697
+ var FlashMessageContext = createContext(null);
698
+ var FlashMessageProvider = ({
699
+ children,
700
+ ...containerProps
701
+ }) => {
702
+ const contextValue = useMemo(
703
+ () => ({
704
+ show: (options) => flashManager.showMessage(options),
705
+ hide: () => flashManager.hideMessage()
706
+ }),
707
+ []
708
+ );
709
+ return /* @__PURE__ */ jsxs(FlashMessageContext.Provider, { value: contextValue, children: [
710
+ children,
711
+ /* @__PURE__ */ jsx(FlashMessage, { ...containerProps })
712
+ ] });
713
+ };
714
+ function useFlashMessage() {
715
+ const context = useContext(FlashMessageContext);
716
+ if (!context) {
717
+ return {
718
+ show: (options) => flashManager.showMessage(options),
719
+ hide: () => flashManager.hideMessage()
720
+ };
721
+ }
722
+ return context;
723
+ }
724
+
725
+ // src/index.ts
726
+ var index_default = FlashMessage;
727
+
728
+ export { BuiltInIcon, COLORS, FlashMessage, FlashMessageProvider, index_default as default, dismissFlash, flash, flashManager, hideMessage, showMessage, styles2 as styles, useFlashMessage };
729
+ //# sourceMappingURL=index.mjs.map
730
+ //# sourceMappingURL=index.mjs.map