@mehul214/react-native-flash-toast 0.0.0-stage → 1.0.0
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 +22 -0
- package/README.md +251 -2
- package/dist/index.d.mts +229 -0
- package/dist/index.d.ts +231 -0
- package/dist/index.js +613 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +594 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +87 -4
- package/src/FlashMessage.tsx +398 -0
- package/src/FlashMessageManager.ts +71 -0
- package/src/FlashMessageProvider.tsx +48 -0
- package/src/hooks/useFlashMessage.ts +2 -0
- package/src/icons.tsx +74 -0
- package/src/index.ts +31 -0
- package/src/styles.ts +135 -0
- package/src/types.ts +101 -0
- package/src/utils/safeArea.ts +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/FlashMessageManager.ts","../src/icons.tsx","../src/styles.ts","../src/utils/safeArea.ts","../src/FlashMessage.tsx","../src/FlashMessageProvider.tsx","../src/index.ts"],"names":["View","jsx","Text","StyleSheet","styles","Platform","Dimensions","StatusBar","React","useState","useRef","Animated","useCallback","useImperativeHandle","useEffect","PanResponder","jsxs","Pressable","createContext","useMemo","useContext"],"mappings":";;;;;;;;;;;;;;;AAEA,IAAM,sBAAN,MAA0B;AAAA,EAA1B,WAAA,GAAA;AACE,IAAA,IAAA,CAAQ,eAAA,GAA0C,IAAA;AAClD,IAAA,IAAA,CAAQ,SAAA,uBAA8C,GAAA,EAAI;AAC1D,IAAA,IAAA,CAAQ,eAAsC,EAAC;AAAA,EAAA;AAAA,EAExC,QAAA,CAAS,GAAA,EAAsB,EAAA,GAAa,SAAA,EAAiB;AAClE,IAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,EAAA,EAAI,GAAG,CAAA;AAC1B,IAAA,IAAI,CAAC,IAAA,CAAK,eAAA,IAAmB,EAAA,KAAO,SAAA,EAAW;AAC7C,MAAA,IAAA,CA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AAmB,CAAA;AAC9C,EAAA,IAAI,CAAC,OAAA,EAAS;AAEZ,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,CAAC,OAAA,KAAiC,YAAA,CAAa,YAAY,OAAO,CAAA;AAAA,MACxE,IAAA,EAAM,MAAM,YAAA,CAAa,WAAA;AAAY,KACvC;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;;;AC3CA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import type { FlashMessageOptions, FlashMessageRef } from './types';\n\nclass FlashMessageManager {\n private defaultInstance: FlashMessageRef | null = null;\n private instances: Map<string, FlashMessageRef> = new Map();\n private pendingQueue: FlashMessageOptions[] = [];\n\n public register(ref: FlashMessageRef, id: string = 'default'): void {\n this.instances.set(id, ref);\n if (!this.defaultInstance || id === 'default') {\n this.defaultInstance = ref;\n }\n\n // Flush any pending messages that arrived before mount\n if (this.pendingQueue.length > 0) {\n const next = this.pendingQueue.shift();\n if (next) {\n ref.showMessage(next);\n }\n }\n }\n\n public unregister(id: string = 'default'): void {\n this.instances.delete(id);\n if (this.defaultInstance === this.instances.get(id)) {\n this.defaultInstance = this.instances.values().next().value || null;\n }\n }\n\n public showMessage(options: FlashMessageOptions, targetId?: string): void {\n const target = targetId ? this.instances.get(targetId) : this.defaultInstance;\n\n if (target) {\n target.showMessage(options);\n } else {\n // Buffer if component hasn't mounted yet\n this.pendingQueue.push(options);\n }\n }\n\n public hideMessage(targetId?: string): void {\n const target = targetId ? this.instances.get(targetId) : this.defaultInstance;\n if (target) {\n target.hideMessage();\n }\n }\n}\n\nexport const flashManager = new FlashMessageManager();\n\n/**\n * Imperative helper to trigger a flash message from anywhere in the app\n * (services, Zustand, Redux, API handlers, navigation screens).\n */\nexport function showMessage(options: FlashMessageOptions): void {\n flashManager.showMessage(options);\n}\n\n/**\n * Imperative helper to dismiss the currently displayed flash message.\n */\nexport function hideMessage(): void {\n flashManager.hideMessage();\n}\n\n/**\n * Modern alias for showMessage\n */\nexport const flash = showMessage;\nexport const dismissFlash = hideMessage;\n\n","import React from 'react';\nimport { View, Text, StyleSheet } from 'react-native';\nimport type { FlashMessageType } from './types';\n\ninterface BuiltInIconProps {\n type: FlashMessageType;\n size?: number;\n color?: string;\n}\n\nexport const BuiltInIcon: React.FC<BuiltInIconProps> = ({\n type,\n size = 22,\n color = '#FFFFFF',\n}) => {\n const containerStyle = [\n styles.circle,\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n borderColor: color,\n },\n ];\n\n switch (type) {\n case 'success':\n return (\n <View style={containerStyle}>\n <Text style={[styles.symbol, { color, fontSize: size * 0.65 }]}>✓</Text>\n </View>\n );\n case 'danger':\n return (\n <View style={containerStyle}>\n <Text style={[styles.symbol, { color, fontSize: size * 0.65 }]}>✕</Text>\n </View>\n );\n case 'warning':\n return (\n <View style={containerStyle}>\n <Text style={[styles.symbol, { color, fontSize: size * 0.65 }]}>!</Text>\n </View>\n );\n case 'info':\n return (\n <View style={containerStyle}>\n <Text style={[styles.symbol, { color, fontSize: size * 0.65 }]}>ℹ</Text>\n </View>\n );\n case 'default':\n default:\n return (\n <View style={containerStyle}>\n <Text style={[styles.symbol, { color, fontSize: size * 0.6 }]}>●</Text>\n </View>\n );\n }\n};\n\nconst styles = StyleSheet.create({\n circle: {\n borderWidth: 1.5,\n justifyContent: 'center',\n alignItems: 'center',\n },\n symbol: {\n fontWeight: '800',\n textAlign: 'center',\n includeFontPadding: false,\n lineHeight: 22,\n },\n});\n\n","import { StyleSheet, Platform } from 'react-native';\nimport type { FlashMessageType } from './types';\n\nexport const COLORS: Record<FlashMessageType, { background: string; text: string; icon: string }> = {\n default: {\n background: '#1F2937', // Slate 800\n text: '#FFFFFF',\n icon: '#9CA3AF',\n },\n success: {\n background: '#059669', // Emerald 600\n text: '#FFFFFF',\n icon: '#D1FAE5',\n },\n danger: {\n background: '#DC2626', // Red 600\n text: '#FFFFFF',\n icon: '#FEE2E2',\n },\n warning: {\n background: '#D97706', // Amber 600\n text: '#FFFFFF',\n icon: '#FEF3C7',\n },\n info: {\n background: '#2563EB', // Blue 600\n text: '#FFFFFF',\n icon: '#DBEAFE',\n },\n};\n\nexport const styles = StyleSheet.create({\n rootOverlay: {\n position: 'absolute',\n left: 0,\n right: 0,\n zIndex: 99999,\n elevation: 99999,\n },\n rootTop: {\n top: 0,\n },\n rootBottom: {\n bottom: 0,\n },\n rootCenter: {\n top: 0,\n bottom: 0,\n justifyContent: 'center',\n alignItems: 'center',\n },\n toastContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n overflow: 'hidden',\n ...Platform.select({\n ios: {\n shadowColor: '#000000',\n shadowOffset: { width: 0, height: 6 },\n shadowOpacity: 0.18,\n shadowRadius: 12,\n },\n android: {\n elevation: 8,\n },\n web: {\n boxShadow: '0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1)',\n } as any,\n }),\n },\n floatingContainer: {\n marginHorizontal: 16,\n borderRadius: 14,\n borderWidth: StyleSheet.hairlineWidth,\n borderColor: 'rgba(255, 255, 255, 0.15)',\n },\n edgeToEdgeContainer: {\n marginHorizontal: 0,\n borderRadius: 0,\n },\n contentWrapper: {\n flex: 1,\n flexDirection: 'row',\n alignItems: 'center',\n paddingVertical: 14,\n paddingHorizontal: 16,\n },\n iconContainer: {\n marginRight: 12,\n justifyContent: 'center',\n alignItems: 'center',\n },\n textContainer: {\n flex: 1,\n justifyContent: 'center',\n },\n titleText: {\n fontSize: 15,\n fontWeight: '600',\n letterSpacing: -0.2,\n color: '#FFFFFF',\n },\n descriptionText: {\n fontSize: 13,\n fontWeight: '400',\n color: 'rgba(255, 255, 255, 0.88)',\n marginTop: 2,\n lineHeight: 18,\n },\n actionButton: {\n marginLeft: 10,\n paddingHorizontal: 12,\n paddingVertical: 6,\n borderRadius: 8,\n backgroundColor: 'rgba(255, 255, 255, 0.2)',\n },\n actionButtonText: {\n fontSize: 13,\n fontWeight: '700',\n color: '#FFFFFF',\n },\n progressBarContainer: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n height: 3,\n backgroundColor: 'rgba(255, 255, 255, 0.25)',\n },\n progressBarFill: {\n height: '100%',\n backgroundColor: '#FFFFFF',\n },\n});\n\n","import { Platform, StatusBar, Dimensions } from 'react-native';\n\nexport interface EdgeInsets {\n top: number;\n bottom: number;\n left: number;\n right: number;\n}\n\n/**\n * Returns safe default insets when react-native-safe-area-context is not present.\n * If the user's app wraps FlashMessage in SafeAreaProvider, safe-area context takes precedence.\n */\nexport function getDefaultSafeAreaInsets(): EdgeInsets {\n const { width, height } = Dimensions.get('window');\n const isLandscape = width > height;\n\n if (Platform.OS === 'android') {\n return {\n top: StatusBar.currentHeight ?? 24,\n bottom: 16,\n left: 0,\n right: 0,\n };\n }\n\n if (Platform.OS === 'ios') {\n // Dynamic island & modern notch iPhones typically have 47-59pt top inset\n const isModernIphone = !Platform.isPad && !Platform.isTV && (height >= 812 || width >= 812);\n return {\n top: isModernIphone ? (isLandscape ? 0 : 50) : 20,\n bottom: isModernIphone ? 34 : 0,\n left: 0,\n right: 0,\n };\n }\n\n return {\n top: 16,\n bottom: 16,\n left: 0,\n right: 0,\n };\n}\n\n","import React, {\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport {\n Animated,\n PanResponder,\n Pressable,\n Text,\n View,\n} from 'react-native';\nimport { flashManager } from './FlashMessageManager';\nimport { BuiltInIcon } from './icons';\nimport { COLORS, styles } from './styles';\nimport type {\n FlashMessageContainerProps,\n FlashMessageOptions,\n FlashMessageRef,\n} from './types';\nimport { getDefaultSafeAreaInsets } from './utils/safeArea';\n\nexport const FlashMessage = React.forwardRef<FlashMessageRef, FlashMessageContainerProps>(\n (props, ref) => {\n const {\n position: defaultPosition = 'top',\n duration: defaultDuration = 3000,\n floating: defaultFloating = true,\n statusBarOffset,\n bottomOffset,\n style: containerCustomStyle,\n } = props;\n\n const [currentMessage, setCurrentMessage] = useState<FlashMessageOptions | null>(null);\n const [isVisible, setIsVisible] = useState(false);\n\n // Animation values\n const translateY = useRef(new Animated.Value(-150)).current;\n const opacity = useRef(new Animated.Value(0)).current;\n const progress = useRef(new Animated.Value(1)).current;\n\n // Timers & gesture tracking\n const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const progressAnimationRef = useRef<Animated.CompositeAnimation | null>(null);\n const remainingTimeRef = useRef<number>(0);\n const timerStartedAtRef = useRef<number>(0);\n\n const safeInsets = getDefaultSafeAreaInsets();\n\n const position = currentMessage?.position ?? defaultPosition;\n const isTop = position === 'top';\n const isBottom = position === 'bottom';\n\n const clearTimers = useCallback(() => {\n if (hideTimeoutRef.current) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n }\n if (progressAnimationRef.current) {\n progressAnimationRef.current.stop();\n progressAnimationRef.current = null;\n }\n }, []);\n\n const animateHide = useCallback(\n (callback?: () => void) => {\n clearTimers();\n\n const targetY = isTop ? -180 : isBottom ? 180 : 0;\n\n Animated.parallel([\n Animated.timing(translateY, {\n toValue: targetY,\n duration: 220,\n useNativeDriver: true,\n }),\n Animated.timing(opacity, {\n toValue: 0,\n duration: 200,\n useNativeDriver: true,\n }),\n ]).start(() => {\n setIsVisible(false);\n if (currentMessage?.onHide) {\n currentMessage.onHide();\n }\n setCurrentMessage(null);\n callback?.();\n });\n },\n [clearTimers, isTop, isBottom, opacity, translateY, currentMessage]\n );\n\n const startAutoHideTimer = useCallback(\n (durationMs: number) => {\n clearTimers();\n if (durationMs <= 0) return;\n\n remainingTimeRef.current = durationMs;\n timerStartedAtRef.current = Date.now();\n\n // Start progress bar animation\n progress.setValue(1);\n progressAnimationRef.current = Animated.timing(progress, {\n toValue: 0,\n duration: durationMs,\n useNativeDriver: false, // width needs layout or scaleX\n });\n progressAnimationRef.current.start();\n\n hideTimeoutRef.current = setTimeout(() => {\n animateHide();\n }, durationMs);\n },\n [animateHide, clearTimers, progress]\n );\n\n const pauseTimer = useCallback(() => {\n if (hideTimeoutRef.current && timerStartedAtRef.current > 0) {\n clearTimeout(hideTimeoutRef.current);\n hideTimeoutRef.current = null;\n const elapsed = Date.now() - timerStartedAtRef.current;\n remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);\n if (progressAnimationRef.current) {\n progressAnimationRef.current.stop();\n }\n }\n }, []);\n\n const resumeTimer = useCallback(() => {\n if (remainingTimeRef.current > 0) {\n startAutoHideTimer(remainingTimeRef.current);\n }\n }, [startAutoHideTimer]);\n\n const show = useCallback(\n (options: FlashMessageOptions) => {\n clearTimers();\n setCurrentMessage(options);\n setIsVisible(true);\n\n const pos = options.position ?? defaultPosition;\n const initialY = pos === 'top' ? -150 : pos === 'bottom' ? 150 : 0;\n\n translateY.setValue(initialY);\n opacity.setValue(0);\n progress.setValue(1);\n\n Animated.parallel([\n Animated.spring(translateY, {\n toValue: 0,\n tension: 70,\n friction: 9,\n useNativeDriver: true,\n }),\n Animated.timing(opacity, {\n toValue: 1,\n duration: 200,\n useNativeDriver: true,\n }),\n ]).start(() => {\n if (options.onShow) {\n options.onShow();\n }\n });\n\n const shouldAutoHide = options.autoHide ?? true;\n const dur = shouldAutoHide ? options.duration ?? defaultDuration : 0;\n if (dur > 0) {\n startAutoHideTimer(dur);\n }\n },\n [clearTimers, defaultDuration, defaultPosition, opacity, progress, startAutoHideTimer, translateY]\n );\n\n // Register with manager and imperative ref\n useImperativeHandle(\n ref,\n () => ({\n showMessage: show,\n hideMessage: () => animateHide(),\n }),\n [show, animateHide]\n );\n\n useEffect(() => {\n const instanceRef: FlashMessageRef = {\n showMessage: show,\n hideMessage: () => animateHide(),\n };\n flashManager.register(instanceRef);\n return () => {\n flashManager.unregister();\n clearTimers();\n };\n }, [show, animateHide, clearTimers]);\n\n // PanResponder for smooth swipe-to-dismiss gesture\n const panResponder = useRef(\n PanResponder.create({\n onStartShouldSetPanResponder: () => true,\n onMoveShouldSetPanResponder: (_, gestureState) => {\n return Math.abs(gestureState.dy) > 5;\n },\n onPanResponderGrant: () => {\n if (currentMessage?.pauseOnPress ?? true) {\n pauseTimer();\n }\n },\n onPanResponderMove: (_, gestureState) => {\n if (!(currentMessage?.swipeToDismiss ?? true)) return;\n\n // Only allow dragging upwards for top, downwards for bottom\n if (isTop && gestureState.dy < 0) {\n translateY.setValue(gestureState.dy);\n } else if (isBottom && gestureState.dy > 0) {\n translateY.setValue(gestureState.dy);\n }\n },\n onPanResponderRelease: (_, gestureState) => {\n const swipeThreshold = 30;\n const isDismissGesture =\n (isTop && gestureState.dy < -swipeThreshold) ||\n (isBottom && gestureState.dy > swipeThreshold);\n\n if (isDismissGesture && (currentMessage?.swipeToDismiss ?? true)) {\n animateHide();\n } else {\n // Spring back to center\n Animated.spring(translateY, {\n toValue: 0,\n tension: 80,\n friction: 8,\n useNativeDriver: true,\n }).start();\n\n if (currentMessage?.pauseOnPress ?? true) {\n resumeTimer();\n }\n }\n },\n })\n ).current;\n\n if (!isVisible || !currentMessage) {\n return null;\n }\n\n const type = currentMessage.type ?? 'default';\n const typeColors = COLORS[type];\n const backgroundColor = currentMessage.backgroundColor ?? typeColors.background;\n const textColor = currentMessage.color ?? typeColors.text;\n const floating = currentMessage.floating ?? defaultFloating;\n\n const topInset =\n currentMessage.statusBarHeight ??\n statusBarOffset ??\n (isTop ? safeInsets.top + (floating ? 8 : 0) : 0);\n\n const bottomInset =\n bottomOffset ?? (isBottom ? safeInsets.bottom + (floating ? 8 : 0) : 0);\n\n const rootPositionStyle = isTop\n ? [styles.rootTop, { paddingTop: topInset }]\n : isBottom\n ? [styles.rootBottom, { paddingBottom: bottomInset }]\n : styles.rootCenter;\n\n const renderIcon = () => {\n if (currentMessage.icon === 'none') return null;\n\n if (typeof currentMessage.icon === 'function') {\n return (\n <View style={styles.iconContainer}>\n {currentMessage.icon({ size: 22, color: textColor })}\n </View>\n );\n }\n\n if (React.isValidElement(currentMessage.icon)) {\n return <View style={styles.iconContainer}>{currentMessage.icon}</View>;\n }\n\n const iconType = typeof currentMessage.icon === 'string' ? currentMessage.icon : type;\n return (\n <View style={styles.iconContainer}>\n <BuiltInIcon type={iconType as any} color={textColor} size={22} />\n </View>\n );\n };\n\n const handlePress = () => {\n if (currentMessage.onPress) {\n currentMessage.onPress();\n }\n if (currentMessage.hideOnPress ?? true) {\n animateHide();\n }\n };\n\n const progressWidthInterpolation = progress.interpolate({\n inputRange: [0, 1],\n outputRange: ['0%', '100%'],\n });\n\n return (\n <View\n pointerEvents=\"box-none\"\n style={[styles.rootOverlay, rootPositionStyle, containerCustomStyle]}\n >\n <Animated.View\n {...panResponder.panHandlers}\n style={[\n styles.toastContainer,\n floating ? styles.floatingContainer : styles.edgeToEdgeContainer,\n { backgroundColor },\n currentMessage.style,\n {\n transform: [{ translateY }],\n opacity,\n },\n ]}\n >\n {currentMessage.customComponent ? (\n currentMessage.customComponent(currentMessage, () => animateHide())\n ) : (\n <Pressable\n onPress={handlePress}\n onLongPress={currentMessage.onLongPress}\n style={styles.contentWrapper}\n >\n {renderIcon()}\n\n <View style={styles.textContainer}>\n {typeof currentMessage.message === 'string' ? (\n <Text\n style={[styles.titleText, { color: textColor }, currentMessage.titleStyle]}\n numberOfLines={2}\n >\n {currentMessage.message}\n </Text>\n ) : (\n currentMessage.message\n )}\n\n {currentMessage.description ? (\n typeof currentMessage.description === 'string' ? (\n <Text\n style={[\n styles.descriptionText,\n { color: textColor },\n currentMessage.textStyle,\n ]}\n numberOfLines={3}\n >\n {currentMessage.description}\n </Text>\n ) : (\n currentMessage.description\n )\n ) : null}\n </View>\n\n {currentMessage.action ? (\n <Pressable\n onPress={() => {\n currentMessage.action?.onPress();\n animateHide();\n }}\n style={[styles.actionButton, currentMessage.action.style]}\n >\n <Text style={[styles.actionButtonText, currentMessage.action.textStyle]}>\n {currentMessage.action.label}\n </Text>\n </Pressable>\n ) : null}\n </Pressable>\n )}\n\n {currentMessage.showProgressBar && (\n <View style={styles.progressBarContainer}>\n <Animated.View\n style={[\n styles.progressBarFill,\n { width: progressWidthInterpolation },\n ]}\n />\n </View>\n )}\n </Animated.View>\n </View>\n );\n }\n);\n\nFlashMessage.displayName = 'FlashMessage';\n","import React, { createContext, useContext, useMemo } from 'react';\nimport { FlashMessage } from './FlashMessage';\nimport { flashManager } from './FlashMessageManager';\nimport type { FlashMessageContainerProps, FlashMessageOptions } from './types';\n\ninterface FlashMessageContextValue {\n show: (options: FlashMessageOptions) => void;\n hide: () => void;\n}\n\nconst FlashMessageContext = createContext<FlashMessageContextValue | null>(null);\n\nexport interface FlashMessageProviderProps extends FlashMessageContainerProps {\n children: React.ReactNode;\n}\n\nexport const FlashMessageProvider: React.FC<FlashMessageProviderProps> = ({\n children,\n ...containerProps\n}) => {\n const contextValue = useMemo<FlashMessageContextValue>(\n () => ({\n show: (options: FlashMessageOptions) => flashManager.showMessage(options),\n hide: () => flashManager.hideMessage(),\n }),\n []\n );\n\n return (\n <FlashMessageContext.Provider value={contextValue}>\n {children}\n <FlashMessage {...containerProps} />\n </FlashMessageContext.Provider>\n );\n};\n\nexport function useFlashMessage(): FlashMessageContextValue {\n const context = useContext(FlashMessageContext);\n if (!context) {\n // Graceful fallback to global manager even if Provider is omitted\n return {\n show: (options: FlashMessageOptions) => flashManager.showMessage(options),\n hide: () => flashManager.hideMessage(),\n };\n }\n return context;\n}\n\n","import { FlashMessage } from './FlashMessage';\n\nexport { FlashMessage };\nexport default FlashMessage;\n\nexport {\n flashManager,\n showMessage,\n hideMessage,\n flash,\n dismissFlash,\n} from './FlashMessageManager';\n\nexport {\n FlashMessageProvider,\n useFlashMessage,\n} from './FlashMessageProvider';\n\nexport { BuiltInIcon } from './icons';\nexport { COLORS, styles } from './styles';\n\nexport type {\n FlashMessageAction,\n FlashMessageContainerProps,\n FlashMessageIcon,\n FlashMessageOptions,\n FlashMessagePosition,\n FlashMessageRef,\n FlashMessageTransition,\n FlashMessageType,\n} from './types';\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,594 @@
|
|
|
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 = 22,
|
|
59
|
+
color = "#FFFFFF"
|
|
60
|
+
}) => {
|
|
61
|
+
const containerStyle = [
|
|
62
|
+
styles.circle,
|
|
63
|
+
{
|
|
64
|
+
width: size,
|
|
65
|
+
height: size,
|
|
66
|
+
borderRadius: size / 2,
|
|
67
|
+
borderColor: color
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
switch (type) {
|
|
71
|
+
case "success":
|
|
72
|
+
return /* @__PURE__ */ jsx(View, { style: containerStyle, children: /* @__PURE__ */ jsx(Text, { style: [styles.symbol, { color, fontSize: size * 0.65 }], children: "\u2713" }) });
|
|
73
|
+
case "danger":
|
|
74
|
+
return /* @__PURE__ */ jsx(View, { style: containerStyle, children: /* @__PURE__ */ jsx(Text, { style: [styles.symbol, { color, fontSize: size * 0.65 }], children: "\u2715" }) });
|
|
75
|
+
case "warning":
|
|
76
|
+
return /* @__PURE__ */ jsx(View, { style: containerStyle, children: /* @__PURE__ */ jsx(Text, { style: [styles.symbol, { color, fontSize: size * 0.65 }], children: "!" }) });
|
|
77
|
+
case "info":
|
|
78
|
+
return /* @__PURE__ */ jsx(View, { style: containerStyle, children: /* @__PURE__ */ jsx(Text, { style: [styles.symbol, { color, fontSize: size * 0.65 }], children: "\u2139" }) });
|
|
79
|
+
case "default":
|
|
80
|
+
default:
|
|
81
|
+
return /* @__PURE__ */ jsx(View, { style: containerStyle, children: /* @__PURE__ */ jsx(Text, { style: [styles.symbol, { color, fontSize: size * 0.6 }], children: "\u25CF" }) });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var styles = StyleSheet.create({
|
|
85
|
+
circle: {
|
|
86
|
+
borderWidth: 1.5,
|
|
87
|
+
justifyContent: "center",
|
|
88
|
+
alignItems: "center"
|
|
89
|
+
},
|
|
90
|
+
symbol: {
|
|
91
|
+
fontWeight: "800",
|
|
92
|
+
textAlign: "center",
|
|
93
|
+
includeFontPadding: false,
|
|
94
|
+
lineHeight: 22
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
var COLORS = {
|
|
98
|
+
default: {
|
|
99
|
+
background: "#1F2937",
|
|
100
|
+
// Slate 800
|
|
101
|
+
text: "#FFFFFF",
|
|
102
|
+
icon: "#9CA3AF"
|
|
103
|
+
},
|
|
104
|
+
success: {
|
|
105
|
+
background: "#059669",
|
|
106
|
+
// Emerald 600
|
|
107
|
+
text: "#FFFFFF",
|
|
108
|
+
icon: "#D1FAE5"
|
|
109
|
+
},
|
|
110
|
+
danger: {
|
|
111
|
+
background: "#DC2626",
|
|
112
|
+
// Red 600
|
|
113
|
+
text: "#FFFFFF",
|
|
114
|
+
icon: "#FEE2E2"
|
|
115
|
+
},
|
|
116
|
+
warning: {
|
|
117
|
+
background: "#D97706",
|
|
118
|
+
// Amber 600
|
|
119
|
+
text: "#FFFFFF",
|
|
120
|
+
icon: "#FEF3C7"
|
|
121
|
+
},
|
|
122
|
+
info: {
|
|
123
|
+
background: "#2563EB",
|
|
124
|
+
// Blue 600
|
|
125
|
+
text: "#FFFFFF",
|
|
126
|
+
icon: "#DBEAFE"
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var styles2 = StyleSheet.create({
|
|
130
|
+
rootOverlay: {
|
|
131
|
+
position: "absolute",
|
|
132
|
+
left: 0,
|
|
133
|
+
right: 0,
|
|
134
|
+
zIndex: 99999,
|
|
135
|
+
elevation: 99999
|
|
136
|
+
},
|
|
137
|
+
rootTop: {
|
|
138
|
+
top: 0
|
|
139
|
+
},
|
|
140
|
+
rootBottom: {
|
|
141
|
+
bottom: 0
|
|
142
|
+
},
|
|
143
|
+
rootCenter: {
|
|
144
|
+
top: 0,
|
|
145
|
+
bottom: 0,
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
alignItems: "center"
|
|
148
|
+
},
|
|
149
|
+
toastContainer: {
|
|
150
|
+
flexDirection: "row",
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
overflow: "hidden",
|
|
153
|
+
...Platform.select({
|
|
154
|
+
ios: {
|
|
155
|
+
shadowColor: "#000000",
|
|
156
|
+
shadowOffset: { width: 0, height: 6 },
|
|
157
|
+
shadowOpacity: 0.18,
|
|
158
|
+
shadowRadius: 12
|
|
159
|
+
},
|
|
160
|
+
android: {
|
|
161
|
+
elevation: 8
|
|
162
|
+
},
|
|
163
|
+
web: {
|
|
164
|
+
boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1)"
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
},
|
|
168
|
+
floatingContainer: {
|
|
169
|
+
marginHorizontal: 16,
|
|
170
|
+
borderRadius: 14,
|
|
171
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
172
|
+
borderColor: "rgba(255, 255, 255, 0.15)"
|
|
173
|
+
},
|
|
174
|
+
edgeToEdgeContainer: {
|
|
175
|
+
marginHorizontal: 0,
|
|
176
|
+
borderRadius: 0
|
|
177
|
+
},
|
|
178
|
+
contentWrapper: {
|
|
179
|
+
flex: 1,
|
|
180
|
+
flexDirection: "row",
|
|
181
|
+
alignItems: "center",
|
|
182
|
+
paddingVertical: 14,
|
|
183
|
+
paddingHorizontal: 16
|
|
184
|
+
},
|
|
185
|
+
iconContainer: {
|
|
186
|
+
marginRight: 12,
|
|
187
|
+
justifyContent: "center",
|
|
188
|
+
alignItems: "center"
|
|
189
|
+
},
|
|
190
|
+
textContainer: {
|
|
191
|
+
flex: 1,
|
|
192
|
+
justifyContent: "center"
|
|
193
|
+
},
|
|
194
|
+
titleText: {
|
|
195
|
+
fontSize: 15,
|
|
196
|
+
fontWeight: "600",
|
|
197
|
+
letterSpacing: -0.2,
|
|
198
|
+
color: "#FFFFFF"
|
|
199
|
+
},
|
|
200
|
+
descriptionText: {
|
|
201
|
+
fontSize: 13,
|
|
202
|
+
fontWeight: "400",
|
|
203
|
+
color: "rgba(255, 255, 255, 0.88)",
|
|
204
|
+
marginTop: 2,
|
|
205
|
+
lineHeight: 18
|
|
206
|
+
},
|
|
207
|
+
actionButton: {
|
|
208
|
+
marginLeft: 10,
|
|
209
|
+
paddingHorizontal: 12,
|
|
210
|
+
paddingVertical: 6,
|
|
211
|
+
borderRadius: 8,
|
|
212
|
+
backgroundColor: "rgba(255, 255, 255, 0.2)"
|
|
213
|
+
},
|
|
214
|
+
actionButtonText: {
|
|
215
|
+
fontSize: 13,
|
|
216
|
+
fontWeight: "700",
|
|
217
|
+
color: "#FFFFFF"
|
|
218
|
+
},
|
|
219
|
+
progressBarContainer: {
|
|
220
|
+
position: "absolute",
|
|
221
|
+
bottom: 0,
|
|
222
|
+
left: 0,
|
|
223
|
+
right: 0,
|
|
224
|
+
height: 3,
|
|
225
|
+
backgroundColor: "rgba(255, 255, 255, 0.25)"
|
|
226
|
+
},
|
|
227
|
+
progressBarFill: {
|
|
228
|
+
height: "100%",
|
|
229
|
+
backgroundColor: "#FFFFFF"
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
function getDefaultSafeAreaInsets() {
|
|
233
|
+
const { width, height } = Dimensions.get("window");
|
|
234
|
+
const isLandscape = width > height;
|
|
235
|
+
if (Platform.OS === "android") {
|
|
236
|
+
return {
|
|
237
|
+
top: StatusBar.currentHeight ?? 24,
|
|
238
|
+
bottom: 16,
|
|
239
|
+
left: 0,
|
|
240
|
+
right: 0
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (Platform.OS === "ios") {
|
|
244
|
+
const isModernIphone = !Platform.isPad && !Platform.isTV && (height >= 812 || width >= 812);
|
|
245
|
+
return {
|
|
246
|
+
top: isModernIphone ? isLandscape ? 0 : 50 : 20,
|
|
247
|
+
bottom: isModernIphone ? 34 : 0,
|
|
248
|
+
left: 0,
|
|
249
|
+
right: 0
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
top: 16,
|
|
254
|
+
bottom: 16,
|
|
255
|
+
left: 0,
|
|
256
|
+
right: 0
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
var FlashMessage = React.forwardRef(
|
|
260
|
+
(props, ref) => {
|
|
261
|
+
const {
|
|
262
|
+
position: defaultPosition = "top",
|
|
263
|
+
duration: defaultDuration = 3e3,
|
|
264
|
+
floating: defaultFloating = true,
|
|
265
|
+
statusBarOffset,
|
|
266
|
+
bottomOffset,
|
|
267
|
+
style: containerCustomStyle
|
|
268
|
+
} = props;
|
|
269
|
+
const [currentMessage, setCurrentMessage] = useState(null);
|
|
270
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
271
|
+
const translateY = useRef(new Animated.Value(-150)).current;
|
|
272
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
273
|
+
const progress = useRef(new Animated.Value(1)).current;
|
|
274
|
+
const hideTimeoutRef = useRef(null);
|
|
275
|
+
const progressAnimationRef = useRef(null);
|
|
276
|
+
const remainingTimeRef = useRef(0);
|
|
277
|
+
const timerStartedAtRef = useRef(0);
|
|
278
|
+
const safeInsets = getDefaultSafeAreaInsets();
|
|
279
|
+
const position = currentMessage?.position ?? defaultPosition;
|
|
280
|
+
const isTop = position === "top";
|
|
281
|
+
const isBottom = position === "bottom";
|
|
282
|
+
const clearTimers = useCallback(() => {
|
|
283
|
+
if (hideTimeoutRef.current) {
|
|
284
|
+
clearTimeout(hideTimeoutRef.current);
|
|
285
|
+
hideTimeoutRef.current = null;
|
|
286
|
+
}
|
|
287
|
+
if (progressAnimationRef.current) {
|
|
288
|
+
progressAnimationRef.current.stop();
|
|
289
|
+
progressAnimationRef.current = null;
|
|
290
|
+
}
|
|
291
|
+
}, []);
|
|
292
|
+
const animateHide = useCallback(
|
|
293
|
+
(callback) => {
|
|
294
|
+
clearTimers();
|
|
295
|
+
const targetY = isTop ? -180 : isBottom ? 180 : 0;
|
|
296
|
+
Animated.parallel([
|
|
297
|
+
Animated.timing(translateY, {
|
|
298
|
+
toValue: targetY,
|
|
299
|
+
duration: 220,
|
|
300
|
+
useNativeDriver: true
|
|
301
|
+
}),
|
|
302
|
+
Animated.timing(opacity, {
|
|
303
|
+
toValue: 0,
|
|
304
|
+
duration: 200,
|
|
305
|
+
useNativeDriver: true
|
|
306
|
+
})
|
|
307
|
+
]).start(() => {
|
|
308
|
+
setIsVisible(false);
|
|
309
|
+
if (currentMessage?.onHide) {
|
|
310
|
+
currentMessage.onHide();
|
|
311
|
+
}
|
|
312
|
+
setCurrentMessage(null);
|
|
313
|
+
callback?.();
|
|
314
|
+
});
|
|
315
|
+
},
|
|
316
|
+
[clearTimers, isTop, isBottom, opacity, translateY, currentMessage]
|
|
317
|
+
);
|
|
318
|
+
const startAutoHideTimer = useCallback(
|
|
319
|
+
(durationMs) => {
|
|
320
|
+
clearTimers();
|
|
321
|
+
if (durationMs <= 0) return;
|
|
322
|
+
remainingTimeRef.current = durationMs;
|
|
323
|
+
timerStartedAtRef.current = Date.now();
|
|
324
|
+
progress.setValue(1);
|
|
325
|
+
progressAnimationRef.current = Animated.timing(progress, {
|
|
326
|
+
toValue: 0,
|
|
327
|
+
duration: durationMs,
|
|
328
|
+
useNativeDriver: false
|
|
329
|
+
// width needs layout or scaleX
|
|
330
|
+
});
|
|
331
|
+
progressAnimationRef.current.start();
|
|
332
|
+
hideTimeoutRef.current = setTimeout(() => {
|
|
333
|
+
animateHide();
|
|
334
|
+
}, durationMs);
|
|
335
|
+
},
|
|
336
|
+
[animateHide, clearTimers, progress]
|
|
337
|
+
);
|
|
338
|
+
const pauseTimer = useCallback(() => {
|
|
339
|
+
if (hideTimeoutRef.current && timerStartedAtRef.current > 0) {
|
|
340
|
+
clearTimeout(hideTimeoutRef.current);
|
|
341
|
+
hideTimeoutRef.current = null;
|
|
342
|
+
const elapsed = Date.now() - timerStartedAtRef.current;
|
|
343
|
+
remainingTimeRef.current = Math.max(0, remainingTimeRef.current - elapsed);
|
|
344
|
+
if (progressAnimationRef.current) {
|
|
345
|
+
progressAnimationRef.current.stop();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}, []);
|
|
349
|
+
const resumeTimer = useCallback(() => {
|
|
350
|
+
if (remainingTimeRef.current > 0) {
|
|
351
|
+
startAutoHideTimer(remainingTimeRef.current);
|
|
352
|
+
}
|
|
353
|
+
}, [startAutoHideTimer]);
|
|
354
|
+
const show = useCallback(
|
|
355
|
+
(options) => {
|
|
356
|
+
clearTimers();
|
|
357
|
+
setCurrentMessage(options);
|
|
358
|
+
setIsVisible(true);
|
|
359
|
+
const pos = options.position ?? defaultPosition;
|
|
360
|
+
const initialY = pos === "top" ? -150 : pos === "bottom" ? 150 : 0;
|
|
361
|
+
translateY.setValue(initialY);
|
|
362
|
+
opacity.setValue(0);
|
|
363
|
+
progress.setValue(1);
|
|
364
|
+
Animated.parallel([
|
|
365
|
+
Animated.spring(translateY, {
|
|
366
|
+
toValue: 0,
|
|
367
|
+
tension: 70,
|
|
368
|
+
friction: 9,
|
|
369
|
+
useNativeDriver: true
|
|
370
|
+
}),
|
|
371
|
+
Animated.timing(opacity, {
|
|
372
|
+
toValue: 1,
|
|
373
|
+
duration: 200,
|
|
374
|
+
useNativeDriver: true
|
|
375
|
+
})
|
|
376
|
+
]).start(() => {
|
|
377
|
+
if (options.onShow) {
|
|
378
|
+
options.onShow();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
const shouldAutoHide = options.autoHide ?? true;
|
|
382
|
+
const dur = shouldAutoHide ? options.duration ?? defaultDuration : 0;
|
|
383
|
+
if (dur > 0) {
|
|
384
|
+
startAutoHideTimer(dur);
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
[clearTimers, defaultDuration, defaultPosition, opacity, progress, startAutoHideTimer, translateY]
|
|
388
|
+
);
|
|
389
|
+
useImperativeHandle(
|
|
390
|
+
ref,
|
|
391
|
+
() => ({
|
|
392
|
+
showMessage: show,
|
|
393
|
+
hideMessage: () => animateHide()
|
|
394
|
+
}),
|
|
395
|
+
[show, animateHide]
|
|
396
|
+
);
|
|
397
|
+
useEffect(() => {
|
|
398
|
+
const instanceRef = {
|
|
399
|
+
showMessage: show,
|
|
400
|
+
hideMessage: () => animateHide()
|
|
401
|
+
};
|
|
402
|
+
flashManager.register(instanceRef);
|
|
403
|
+
return () => {
|
|
404
|
+
flashManager.unregister();
|
|
405
|
+
clearTimers();
|
|
406
|
+
};
|
|
407
|
+
}, [show, animateHide, clearTimers]);
|
|
408
|
+
const panResponder = useRef(
|
|
409
|
+
PanResponder.create({
|
|
410
|
+
onStartShouldSetPanResponder: () => true,
|
|
411
|
+
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
412
|
+
return Math.abs(gestureState.dy) > 5;
|
|
413
|
+
},
|
|
414
|
+
onPanResponderGrant: () => {
|
|
415
|
+
if (currentMessage?.pauseOnPress ?? true) {
|
|
416
|
+
pauseTimer();
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
onPanResponderMove: (_, gestureState) => {
|
|
420
|
+
if (!(currentMessage?.swipeToDismiss ?? true)) return;
|
|
421
|
+
if (isTop && gestureState.dy < 0) {
|
|
422
|
+
translateY.setValue(gestureState.dy);
|
|
423
|
+
} else if (isBottom && gestureState.dy > 0) {
|
|
424
|
+
translateY.setValue(gestureState.dy);
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
onPanResponderRelease: (_, gestureState) => {
|
|
428
|
+
const swipeThreshold = 30;
|
|
429
|
+
const isDismissGesture = isTop && gestureState.dy < -swipeThreshold || isBottom && gestureState.dy > swipeThreshold;
|
|
430
|
+
if (isDismissGesture && (currentMessage?.swipeToDismiss ?? true)) {
|
|
431
|
+
animateHide();
|
|
432
|
+
} else {
|
|
433
|
+
Animated.spring(translateY, {
|
|
434
|
+
toValue: 0,
|
|
435
|
+
tension: 80,
|
|
436
|
+
friction: 8,
|
|
437
|
+
useNativeDriver: true
|
|
438
|
+
}).start();
|
|
439
|
+
if (currentMessage?.pauseOnPress ?? true) {
|
|
440
|
+
resumeTimer();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
})
|
|
445
|
+
).current;
|
|
446
|
+
if (!isVisible || !currentMessage) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
const type = currentMessage.type ?? "default";
|
|
450
|
+
const typeColors = COLORS[type];
|
|
451
|
+
const backgroundColor = currentMessage.backgroundColor ?? typeColors.background;
|
|
452
|
+
const textColor = currentMessage.color ?? typeColors.text;
|
|
453
|
+
const floating = currentMessage.floating ?? defaultFloating;
|
|
454
|
+
const topInset = currentMessage.statusBarHeight ?? statusBarOffset ?? (isTop ? safeInsets.top + (floating ? 8 : 0) : 0);
|
|
455
|
+
const bottomInset = bottomOffset ?? (isBottom ? safeInsets.bottom + (floating ? 8 : 0) : 0);
|
|
456
|
+
const rootPositionStyle = isTop ? [styles2.rootTop, { paddingTop: topInset }] : isBottom ? [styles2.rootBottom, { paddingBottom: bottomInset }] : styles2.rootCenter;
|
|
457
|
+
const renderIcon = () => {
|
|
458
|
+
if (currentMessage.icon === "none") return null;
|
|
459
|
+
if (typeof currentMessage.icon === "function") {
|
|
460
|
+
return /* @__PURE__ */ jsx(View, { style: styles2.iconContainer, children: currentMessage.icon({ size: 22, color: textColor }) });
|
|
461
|
+
}
|
|
462
|
+
if (React.isValidElement(currentMessage.icon)) {
|
|
463
|
+
return /* @__PURE__ */ jsx(View, { style: styles2.iconContainer, children: currentMessage.icon });
|
|
464
|
+
}
|
|
465
|
+
const iconType = typeof currentMessage.icon === "string" ? currentMessage.icon : type;
|
|
466
|
+
return /* @__PURE__ */ jsx(View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsx(BuiltInIcon, { type: iconType, color: textColor, size: 22 }) });
|
|
467
|
+
};
|
|
468
|
+
const handlePress = () => {
|
|
469
|
+
if (currentMessage.onPress) {
|
|
470
|
+
currentMessage.onPress();
|
|
471
|
+
}
|
|
472
|
+
if (currentMessage.hideOnPress ?? true) {
|
|
473
|
+
animateHide();
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
const progressWidthInterpolation = progress.interpolate({
|
|
477
|
+
inputRange: [0, 1],
|
|
478
|
+
outputRange: ["0%", "100%"]
|
|
479
|
+
});
|
|
480
|
+
return /* @__PURE__ */ jsx(
|
|
481
|
+
View,
|
|
482
|
+
{
|
|
483
|
+
pointerEvents: "box-none",
|
|
484
|
+
style: [styles2.rootOverlay, rootPositionStyle, containerCustomStyle],
|
|
485
|
+
children: /* @__PURE__ */ jsxs(
|
|
486
|
+
Animated.View,
|
|
487
|
+
{
|
|
488
|
+
...panResponder.panHandlers,
|
|
489
|
+
style: [
|
|
490
|
+
styles2.toastContainer,
|
|
491
|
+
floating ? styles2.floatingContainer : styles2.edgeToEdgeContainer,
|
|
492
|
+
{ backgroundColor },
|
|
493
|
+
currentMessage.style,
|
|
494
|
+
{
|
|
495
|
+
transform: [{ translateY }],
|
|
496
|
+
opacity
|
|
497
|
+
}
|
|
498
|
+
],
|
|
499
|
+
children: [
|
|
500
|
+
currentMessage.customComponent ? currentMessage.customComponent(currentMessage, () => animateHide()) : /* @__PURE__ */ jsxs(
|
|
501
|
+
Pressable,
|
|
502
|
+
{
|
|
503
|
+
onPress: handlePress,
|
|
504
|
+
onLongPress: currentMessage.onLongPress,
|
|
505
|
+
style: styles2.contentWrapper,
|
|
506
|
+
children: [
|
|
507
|
+
renderIcon(),
|
|
508
|
+
/* @__PURE__ */ jsxs(View, { style: styles2.textContainer, children: [
|
|
509
|
+
typeof currentMessage.message === "string" ? /* @__PURE__ */ jsx(
|
|
510
|
+
Text,
|
|
511
|
+
{
|
|
512
|
+
style: [styles2.titleText, { color: textColor }, currentMessage.titleStyle],
|
|
513
|
+
numberOfLines: 2,
|
|
514
|
+
children: currentMessage.message
|
|
515
|
+
}
|
|
516
|
+
) : currentMessage.message,
|
|
517
|
+
currentMessage.description ? typeof currentMessage.description === "string" ? /* @__PURE__ */ jsx(
|
|
518
|
+
Text,
|
|
519
|
+
{
|
|
520
|
+
style: [
|
|
521
|
+
styles2.descriptionText,
|
|
522
|
+
{ color: textColor },
|
|
523
|
+
currentMessage.textStyle
|
|
524
|
+
],
|
|
525
|
+
numberOfLines: 3,
|
|
526
|
+
children: currentMessage.description
|
|
527
|
+
}
|
|
528
|
+
) : currentMessage.description : null
|
|
529
|
+
] }),
|
|
530
|
+
currentMessage.action ? /* @__PURE__ */ jsx(
|
|
531
|
+
Pressable,
|
|
532
|
+
{
|
|
533
|
+
onPress: () => {
|
|
534
|
+
currentMessage.action?.onPress();
|
|
535
|
+
animateHide();
|
|
536
|
+
},
|
|
537
|
+
style: [styles2.actionButton, currentMessage.action.style],
|
|
538
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles2.actionButtonText, currentMessage.action.textStyle], children: currentMessage.action.label })
|
|
539
|
+
}
|
|
540
|
+
) : null
|
|
541
|
+
]
|
|
542
|
+
}
|
|
543
|
+
),
|
|
544
|
+
currentMessage.showProgressBar && /* @__PURE__ */ jsx(View, { style: styles2.progressBarContainer, children: /* @__PURE__ */ jsx(
|
|
545
|
+
Animated.View,
|
|
546
|
+
{
|
|
547
|
+
style: [
|
|
548
|
+
styles2.progressBarFill,
|
|
549
|
+
{ width: progressWidthInterpolation }
|
|
550
|
+
]
|
|
551
|
+
}
|
|
552
|
+
) })
|
|
553
|
+
]
|
|
554
|
+
}
|
|
555
|
+
)
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
);
|
|
560
|
+
FlashMessage.displayName = "FlashMessage";
|
|
561
|
+
var FlashMessageContext = createContext(null);
|
|
562
|
+
var FlashMessageProvider = ({
|
|
563
|
+
children,
|
|
564
|
+
...containerProps
|
|
565
|
+
}) => {
|
|
566
|
+
const contextValue = useMemo(
|
|
567
|
+
() => ({
|
|
568
|
+
show: (options) => flashManager.showMessage(options),
|
|
569
|
+
hide: () => flashManager.hideMessage()
|
|
570
|
+
}),
|
|
571
|
+
[]
|
|
572
|
+
);
|
|
573
|
+
return /* @__PURE__ */ jsxs(FlashMessageContext.Provider, { value: contextValue, children: [
|
|
574
|
+
children,
|
|
575
|
+
/* @__PURE__ */ jsx(FlashMessage, { ...containerProps })
|
|
576
|
+
] });
|
|
577
|
+
};
|
|
578
|
+
function useFlashMessage() {
|
|
579
|
+
const context = useContext(FlashMessageContext);
|
|
580
|
+
if (!context) {
|
|
581
|
+
return {
|
|
582
|
+
show: (options) => flashManager.showMessage(options),
|
|
583
|
+
hide: () => flashManager.hideMessage()
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
return context;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// src/index.ts
|
|
590
|
+
var index_default = FlashMessage;
|
|
591
|
+
|
|
592
|
+
export { BuiltInIcon, COLORS, FlashMessage, FlashMessageProvider, index_default as default, dismissFlash, flash, flashManager, hideMessage, showMessage, styles2 as styles, useFlashMessage };
|
|
593
|
+
//# sourceMappingURL=index.mjs.map
|
|
594
|
+
//# sourceMappingURL=index.mjs.map
|