@mehul214/react-native-flash-toast 1.0.0 → 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.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +204 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/FlashMessage.tsx +71 -33
- package/src/icons.tsx +115 -35
- package/src/styles.ts +24 -14
package/dist/index.d.mts
CHANGED
|
@@ -183,6 +183,14 @@ declare const styles: {
|
|
|
183
183
|
justifyContent: "center";
|
|
184
184
|
alignItems: "center";
|
|
185
185
|
};
|
|
186
|
+
iconBadge: {
|
|
187
|
+
width: number;
|
|
188
|
+
height: number;
|
|
189
|
+
borderRadius: number;
|
|
190
|
+
backgroundColor: string;
|
|
191
|
+
justifyContent: "center";
|
|
192
|
+
alignItems: "center";
|
|
193
|
+
};
|
|
186
194
|
textContainer: {
|
|
187
195
|
flex: number;
|
|
188
196
|
justifyContent: "center";
|
|
@@ -191,6 +199,7 @@ declare const styles: {
|
|
|
191
199
|
fontSize: number;
|
|
192
200
|
fontWeight: "600";
|
|
193
201
|
letterSpacing: number;
|
|
202
|
+
lineHeight: number;
|
|
194
203
|
color: string;
|
|
195
204
|
};
|
|
196
205
|
descriptionText: {
|
|
@@ -206,10 +215,12 @@ declare const styles: {
|
|
|
206
215
|
paddingVertical: number;
|
|
207
216
|
borderRadius: number;
|
|
208
217
|
backgroundColor: string;
|
|
218
|
+
borderWidth: number;
|
|
219
|
+
borderColor: string;
|
|
209
220
|
};
|
|
210
221
|
actionButtonText: {
|
|
211
222
|
fontSize: number;
|
|
212
|
-
fontWeight: "
|
|
223
|
+
fontWeight: "600";
|
|
213
224
|
color: string;
|
|
214
225
|
};
|
|
215
226
|
progressBarContainer: {
|
package/dist/index.d.ts
CHANGED
|
@@ -183,6 +183,14 @@ declare const styles: {
|
|
|
183
183
|
justifyContent: "center";
|
|
184
184
|
alignItems: "center";
|
|
185
185
|
};
|
|
186
|
+
iconBadge: {
|
|
187
|
+
width: number;
|
|
188
|
+
height: number;
|
|
189
|
+
borderRadius: number;
|
|
190
|
+
backgroundColor: string;
|
|
191
|
+
justifyContent: "center";
|
|
192
|
+
alignItems: "center";
|
|
193
|
+
};
|
|
186
194
|
textContainer: {
|
|
187
195
|
flex: number;
|
|
188
196
|
justifyContent: "center";
|
|
@@ -191,6 +199,7 @@ declare const styles: {
|
|
|
191
199
|
fontSize: number;
|
|
192
200
|
fontWeight: "600";
|
|
193
201
|
letterSpacing: number;
|
|
202
|
+
lineHeight: number;
|
|
194
203
|
color: string;
|
|
195
204
|
};
|
|
196
205
|
descriptionText: {
|
|
@@ -206,10 +215,12 @@ declare const styles: {
|
|
|
206
215
|
paddingVertical: number;
|
|
207
216
|
borderRadius: number;
|
|
208
217
|
backgroundColor: string;
|
|
218
|
+
borderWidth: number;
|
|
219
|
+
borderColor: string;
|
|
209
220
|
};
|
|
210
221
|
actionButtonText: {
|
|
211
222
|
fontSize: number;
|
|
212
|
-
fontWeight: "
|
|
223
|
+
fontWeight: "600";
|
|
213
224
|
color: string;
|
|
214
225
|
};
|
|
215
226
|
progressBarContainer: {
|
package/dist/index.js
CHANGED
|
@@ -63,43 +63,147 @@ var flash = showMessage;
|
|
|
63
63
|
var dismissFlash = hideMessage;
|
|
64
64
|
var BuiltInIcon = ({
|
|
65
65
|
type,
|
|
66
|
-
size =
|
|
66
|
+
size = 18,
|
|
67
67
|
color = "#FFFFFF"
|
|
68
68
|
}) => {
|
|
69
|
-
const containerStyle = [
|
|
70
|
-
styles.circle,
|
|
71
|
-
{
|
|
72
|
-
width: size,
|
|
73
|
-
height: size,
|
|
74
|
-
borderRadius: size / 2,
|
|
75
|
-
borderColor: color
|
|
76
|
-
}
|
|
77
|
-
];
|
|
78
69
|
switch (type) {
|
|
79
|
-
case "success":
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
case "success": {
|
|
71
|
+
const checkWidth = size * 0.36;
|
|
72
|
+
const checkHeight = size * 0.65;
|
|
73
|
+
const stroke = Math.max(2, size * 0.12);
|
|
74
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles.center, { width: size, height: size }], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
75
|
+
reactNative.View,
|
|
76
|
+
{
|
|
77
|
+
style: {
|
|
78
|
+
width: checkWidth,
|
|
79
|
+
height: checkHeight,
|
|
80
|
+
borderColor: color,
|
|
81
|
+
borderBottomWidth: stroke,
|
|
82
|
+
borderRightWidth: stroke,
|
|
83
|
+
borderRadius: 1,
|
|
84
|
+
transform: [{ rotate: "45deg" }, { translateY: -size * 0.08 }]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
) });
|
|
88
|
+
}
|
|
89
|
+
case "danger": {
|
|
90
|
+
const crossThickness = Math.max(2, size * 0.12);
|
|
91
|
+
const crossLength = size * 0.72;
|
|
92
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles.center, { width: size, height: size }], children: [
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
+
reactNative.View,
|
|
95
|
+
{
|
|
96
|
+
style: [
|
|
97
|
+
styles.crossBar,
|
|
98
|
+
{
|
|
99
|
+
width: crossLength,
|
|
100
|
+
height: crossThickness,
|
|
101
|
+
backgroundColor: color,
|
|
102
|
+
borderRadius: crossThickness / 2,
|
|
103
|
+
transform: [{ rotate: "45deg" }]
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
+
reactNative.View,
|
|
110
|
+
{
|
|
111
|
+
style: [
|
|
112
|
+
styles.crossBar,
|
|
113
|
+
{
|
|
114
|
+
width: crossLength,
|
|
115
|
+
height: crossThickness,
|
|
116
|
+
backgroundColor: color,
|
|
117
|
+
borderRadius: crossThickness / 2,
|
|
118
|
+
transform: [{ rotate: "-45deg" }]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
] });
|
|
124
|
+
}
|
|
125
|
+
case "warning": {
|
|
126
|
+
const warnThickness = Math.max(2, size * 0.13);
|
|
127
|
+
const dotSize = warnThickness * 1.1;
|
|
128
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles.center, { width: size, height: size }], children: [
|
|
129
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
+
reactNative.View,
|
|
131
|
+
{
|
|
132
|
+
style: {
|
|
133
|
+
width: warnThickness,
|
|
134
|
+
height: size * 0.46,
|
|
135
|
+
backgroundColor: color,
|
|
136
|
+
borderRadius: warnThickness / 2,
|
|
137
|
+
marginBottom: size * 0.14
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
142
|
+
reactNative.View,
|
|
143
|
+
{
|
|
144
|
+
style: {
|
|
145
|
+
width: dotSize,
|
|
146
|
+
height: dotSize,
|
|
147
|
+
borderRadius: dotSize / 2,
|
|
148
|
+
backgroundColor: color
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
case "info": {
|
|
155
|
+
const infoThickness = Math.max(2, size * 0.13);
|
|
156
|
+
const infoDotSize = infoThickness * 1.1;
|
|
157
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles.center, { width: size, height: size }], children: [
|
|
158
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
159
|
+
reactNative.View,
|
|
160
|
+
{
|
|
161
|
+
style: {
|
|
162
|
+
width: infoDotSize,
|
|
163
|
+
height: infoDotSize,
|
|
164
|
+
borderRadius: infoDotSize / 2,
|
|
165
|
+
backgroundColor: color,
|
|
166
|
+
marginBottom: size * 0.14
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
171
|
+
reactNative.View,
|
|
172
|
+
{
|
|
173
|
+
style: {
|
|
174
|
+
width: infoThickness,
|
|
175
|
+
height: size * 0.46,
|
|
176
|
+
backgroundColor: color,
|
|
177
|
+
borderRadius: infoThickness / 2
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
] });
|
|
182
|
+
}
|
|
87
183
|
case "default":
|
|
88
|
-
default:
|
|
89
|
-
|
|
184
|
+
default: {
|
|
185
|
+
const defaultDot = size * 0.44;
|
|
186
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles.center, { width: size, height: size }], children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
187
|
+
reactNative.View,
|
|
188
|
+
{
|
|
189
|
+
style: {
|
|
190
|
+
width: defaultDot,
|
|
191
|
+
height: defaultDot,
|
|
192
|
+
borderRadius: defaultDot / 2,
|
|
193
|
+
backgroundColor: color
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
) });
|
|
197
|
+
}
|
|
90
198
|
}
|
|
91
199
|
};
|
|
92
200
|
var styles = reactNative.StyleSheet.create({
|
|
93
|
-
|
|
94
|
-
borderWidth: 1.5,
|
|
201
|
+
center: {
|
|
95
202
|
justifyContent: "center",
|
|
96
203
|
alignItems: "center"
|
|
97
204
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
textAlign: "center",
|
|
101
|
-
includeFontPadding: false,
|
|
102
|
-
lineHeight: 22
|
|
205
|
+
crossBar: {
|
|
206
|
+
position: "absolute"
|
|
103
207
|
}
|
|
104
208
|
});
|
|
105
209
|
var COLORS = {
|
|
@@ -162,22 +266,22 @@ var styles2 = reactNative.StyleSheet.create({
|
|
|
162
266
|
ios: {
|
|
163
267
|
shadowColor: "#000000",
|
|
164
268
|
shadowOffset: { width: 0, height: 6 },
|
|
165
|
-
shadowOpacity: 0.
|
|
166
|
-
shadowRadius:
|
|
269
|
+
shadowOpacity: 0.2,
|
|
270
|
+
shadowRadius: 14
|
|
167
271
|
},
|
|
168
272
|
android: {
|
|
169
273
|
elevation: 8
|
|
170
274
|
},
|
|
171
275
|
web: {
|
|
172
|
-
boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.
|
|
276
|
+
boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.15)"
|
|
173
277
|
}
|
|
174
278
|
})
|
|
175
279
|
},
|
|
176
280
|
floatingContainer: {
|
|
177
281
|
marginHorizontal: 16,
|
|
178
|
-
borderRadius:
|
|
179
|
-
borderWidth:
|
|
180
|
-
borderColor: "rgba(255, 255, 255, 0.
|
|
282
|
+
borderRadius: 16,
|
|
283
|
+
borderWidth: 1,
|
|
284
|
+
borderColor: "rgba(255, 255, 255, 0.16)"
|
|
181
285
|
},
|
|
182
286
|
edgeToEdgeContainer: {
|
|
183
287
|
marginHorizontal: 0,
|
|
@@ -187,7 +291,7 @@ var styles2 = reactNative.StyleSheet.create({
|
|
|
187
291
|
flex: 1,
|
|
188
292
|
flexDirection: "row",
|
|
189
293
|
alignItems: "center",
|
|
190
|
-
paddingVertical:
|
|
294
|
+
paddingVertical: 13,
|
|
191
295
|
paddingHorizontal: 16
|
|
192
296
|
},
|
|
193
297
|
iconContainer: {
|
|
@@ -195,6 +299,14 @@ var styles2 = reactNative.StyleSheet.create({
|
|
|
195
299
|
justifyContent: "center",
|
|
196
300
|
alignItems: "center"
|
|
197
301
|
},
|
|
302
|
+
iconBadge: {
|
|
303
|
+
width: 32,
|
|
304
|
+
height: 32,
|
|
305
|
+
borderRadius: 16,
|
|
306
|
+
backgroundColor: "rgba(255, 255, 255, 0.22)",
|
|
307
|
+
justifyContent: "center",
|
|
308
|
+
alignItems: "center"
|
|
309
|
+
},
|
|
198
310
|
textContainer: {
|
|
199
311
|
flex: 1,
|
|
200
312
|
justifyContent: "center"
|
|
@@ -203,25 +315,28 @@ var styles2 = reactNative.StyleSheet.create({
|
|
|
203
315
|
fontSize: 15,
|
|
204
316
|
fontWeight: "600",
|
|
205
317
|
letterSpacing: -0.2,
|
|
318
|
+
lineHeight: 20,
|
|
206
319
|
color: "#FFFFFF"
|
|
207
320
|
},
|
|
208
321
|
descriptionText: {
|
|
209
322
|
fontSize: 13,
|
|
210
323
|
fontWeight: "400",
|
|
211
|
-
color: "rgba(255, 255, 255, 0.
|
|
324
|
+
color: "rgba(255, 255, 255, 0.9)",
|
|
212
325
|
marginTop: 2,
|
|
213
326
|
lineHeight: 18
|
|
214
327
|
},
|
|
215
328
|
actionButton: {
|
|
216
|
-
marginLeft:
|
|
329
|
+
marginLeft: 12,
|
|
217
330
|
paddingHorizontal: 12,
|
|
218
331
|
paddingVertical: 6,
|
|
219
332
|
borderRadius: 8,
|
|
220
|
-
backgroundColor: "rgba(255, 255, 255, 0.
|
|
333
|
+
backgroundColor: "rgba(255, 255, 255, 0.22)",
|
|
334
|
+
borderWidth: 1,
|
|
335
|
+
borderColor: "rgba(255, 255, 255, 0.2)"
|
|
221
336
|
},
|
|
222
337
|
actionButtonText: {
|
|
223
338
|
fontSize: 13,
|
|
224
|
-
fontWeight: "
|
|
339
|
+
fontWeight: "600",
|
|
225
340
|
color: "#FFFFFF"
|
|
226
341
|
},
|
|
227
342
|
progressBarContainer: {
|
|
@@ -230,11 +345,11 @@ var styles2 = reactNative.StyleSheet.create({
|
|
|
230
345
|
left: 0,
|
|
231
346
|
right: 0,
|
|
232
347
|
height: 3,
|
|
233
|
-
backgroundColor: "rgba(255, 255, 255, 0.
|
|
348
|
+
backgroundColor: "rgba(255, 255, 255, 0.2)"
|
|
234
349
|
},
|
|
235
350
|
progressBarFill: {
|
|
236
351
|
height: "100%",
|
|
237
|
-
backgroundColor: "
|
|
352
|
+
backgroundColor: "rgba(255, 255, 255, 0.9)"
|
|
238
353
|
}
|
|
239
354
|
});
|
|
240
355
|
function getDefaultSafeAreaInsets() {
|
|
@@ -276,6 +391,7 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
276
391
|
} = props;
|
|
277
392
|
const [currentMessage, setCurrentMessage] = React.useState(null);
|
|
278
393
|
const [isVisible, setIsVisible] = React.useState(false);
|
|
394
|
+
const currentMessageRef = React.useRef(null);
|
|
279
395
|
const translateY = React.useRef(new reactNative.Animated.Value(-150)).current;
|
|
280
396
|
const opacity = React.useRef(new reactNative.Animated.Value(0)).current;
|
|
281
397
|
const progress = React.useRef(new reactNative.Animated.Value(1)).current;
|
|
@@ -284,9 +400,6 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
284
400
|
const remainingTimeRef = React.useRef(0);
|
|
285
401
|
const timerStartedAtRef = React.useRef(0);
|
|
286
402
|
const safeInsets = getDefaultSafeAreaInsets();
|
|
287
|
-
const position = currentMessage?.position ?? defaultPosition;
|
|
288
|
-
const isTop = position === "top";
|
|
289
|
-
const isBottom = position === "bottom";
|
|
290
403
|
const clearTimers = React.useCallback(() => {
|
|
291
404
|
if (hideTimeoutRef.current) {
|
|
292
405
|
clearTimeout(hideTimeoutRef.current);
|
|
@@ -300,7 +413,8 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
300
413
|
const animateHide = React.useCallback(
|
|
301
414
|
(callback) => {
|
|
302
415
|
clearTimers();
|
|
303
|
-
const
|
|
416
|
+
const pos = currentMessageRef.current?.position ?? defaultPosition;
|
|
417
|
+
const targetY = pos === "top" ? -180 : pos === "bottom" ? 180 : 0;
|
|
304
418
|
reactNative.Animated.parallel([
|
|
305
419
|
reactNative.Animated.timing(translateY, {
|
|
306
420
|
toValue: targetY,
|
|
@@ -314,14 +428,16 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
314
428
|
})
|
|
315
429
|
]).start(() => {
|
|
316
430
|
setIsVisible(false);
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
431
|
+
const onHide = currentMessageRef.current?.onHide;
|
|
432
|
+
currentMessageRef.current = null;
|
|
320
433
|
setCurrentMessage(null);
|
|
434
|
+
if (onHide) {
|
|
435
|
+
onHide();
|
|
436
|
+
}
|
|
321
437
|
callback?.();
|
|
322
438
|
});
|
|
323
439
|
},
|
|
324
|
-
[clearTimers,
|
|
440
|
+
[clearTimers, defaultPosition, opacity, translateY]
|
|
325
441
|
);
|
|
326
442
|
const startAutoHideTimer = React.useCallback(
|
|
327
443
|
(durationMs) => {
|
|
@@ -334,7 +450,6 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
334
450
|
toValue: 0,
|
|
335
451
|
duration: durationMs,
|
|
336
452
|
useNativeDriver: false
|
|
337
|
-
// width needs layout or scaleX
|
|
338
453
|
});
|
|
339
454
|
progressAnimationRef.current.start();
|
|
340
455
|
hideTimeoutRef.current = setTimeout(() => {
|
|
@@ -362,6 +477,7 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
362
477
|
const show = React.useCallback(
|
|
363
478
|
(options) => {
|
|
364
479
|
clearTimers();
|
|
480
|
+
currentMessageRef.current = options;
|
|
365
481
|
setCurrentMessage(options);
|
|
366
482
|
setIsVisible(true);
|
|
367
483
|
const pos = options.position ?? defaultPosition;
|
|
@@ -387,55 +503,62 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
387
503
|
}
|
|
388
504
|
});
|
|
389
505
|
const shouldAutoHide = options.autoHide ?? true;
|
|
390
|
-
const dur = shouldAutoHide ? options.duration
|
|
506
|
+
const dur = shouldAutoHide ? options.duration !== void 0 ? options.duration : defaultDuration : 0;
|
|
391
507
|
if (dur > 0) {
|
|
392
508
|
startAutoHideTimer(dur);
|
|
393
509
|
}
|
|
394
510
|
},
|
|
395
511
|
[clearTimers, defaultDuration, defaultPosition, opacity, progress, startAutoHideTimer, translateY]
|
|
396
512
|
);
|
|
513
|
+
const showRef = React.useRef(show);
|
|
514
|
+
const animateHideRef = React.useRef(animateHide);
|
|
515
|
+
showRef.current = show;
|
|
516
|
+
animateHideRef.current = animateHide;
|
|
397
517
|
React.useImperativeHandle(
|
|
398
518
|
ref,
|
|
399
519
|
() => ({
|
|
400
|
-
showMessage:
|
|
401
|
-
hideMessage: () =>
|
|
520
|
+
showMessage: (options) => showRef.current(options),
|
|
521
|
+
hideMessage: () => animateHideRef.current()
|
|
402
522
|
}),
|
|
403
|
-
[
|
|
523
|
+
[]
|
|
404
524
|
);
|
|
405
525
|
React.useEffect(() => {
|
|
406
526
|
const instanceRef = {
|
|
407
|
-
showMessage:
|
|
408
|
-
hideMessage: () =>
|
|
527
|
+
showMessage: (options) => showRef.current(options),
|
|
528
|
+
hideMessage: () => animateHideRef.current()
|
|
409
529
|
};
|
|
410
530
|
flashManager.register(instanceRef);
|
|
411
531
|
return () => {
|
|
412
532
|
flashManager.unregister();
|
|
413
533
|
clearTimers();
|
|
414
534
|
};
|
|
415
|
-
}, [
|
|
535
|
+
}, [clearTimers]);
|
|
416
536
|
const panResponder = React.useRef(
|
|
417
537
|
reactNative.PanResponder.create({
|
|
418
|
-
onStartShouldSetPanResponder: () =>
|
|
538
|
+
onStartShouldSetPanResponder: () => false,
|
|
419
539
|
onMoveShouldSetPanResponder: (_, gestureState) => {
|
|
420
|
-
|
|
540
|
+
const swipeEnabled = currentMessageRef.current?.swipeToDismiss ?? true;
|
|
541
|
+
return swipeEnabled && Math.abs(gestureState.dy) > 8;
|
|
421
542
|
},
|
|
422
543
|
onPanResponderGrant: () => {
|
|
423
|
-
if (
|
|
544
|
+
if (currentMessageRef.current?.pauseOnPress ?? true) {
|
|
424
545
|
pauseTimer();
|
|
425
546
|
}
|
|
426
547
|
},
|
|
427
548
|
onPanResponderMove: (_, gestureState) => {
|
|
428
|
-
if (!(
|
|
429
|
-
|
|
549
|
+
if (!(currentMessageRef.current?.swipeToDismiss ?? true)) return;
|
|
550
|
+
const pos = currentMessageRef.current?.position ?? defaultPosition;
|
|
551
|
+
if (pos === "top" && gestureState.dy < 0) {
|
|
430
552
|
translateY.setValue(gestureState.dy);
|
|
431
|
-
} else if (
|
|
553
|
+
} else if (pos === "bottom" && gestureState.dy > 0) {
|
|
432
554
|
translateY.setValue(gestureState.dy);
|
|
433
555
|
}
|
|
434
556
|
},
|
|
435
557
|
onPanResponderRelease: (_, gestureState) => {
|
|
558
|
+
const pos = currentMessageRef.current?.position ?? defaultPosition;
|
|
436
559
|
const swipeThreshold = 30;
|
|
437
|
-
const isDismissGesture =
|
|
438
|
-
if (isDismissGesture && (
|
|
560
|
+
const isDismissGesture = pos === "top" && gestureState.dy < -swipeThreshold || pos === "bottom" && gestureState.dy > swipeThreshold;
|
|
561
|
+
if (isDismissGesture && (currentMessageRef.current?.swipeToDismiss ?? true)) {
|
|
439
562
|
animateHide();
|
|
440
563
|
} else {
|
|
441
564
|
reactNative.Animated.spring(translateY, {
|
|
@@ -444,7 +567,7 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
444
567
|
friction: 8,
|
|
445
568
|
useNativeDriver: true
|
|
446
569
|
}).start();
|
|
447
|
-
if (
|
|
570
|
+
if (currentMessageRef.current?.pauseOnPress ?? true) {
|
|
448
571
|
resumeTimer();
|
|
449
572
|
}
|
|
450
573
|
}
|
|
@@ -454,6 +577,9 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
454
577
|
if (!isVisible || !currentMessage) {
|
|
455
578
|
return null;
|
|
456
579
|
}
|
|
580
|
+
const position = currentMessage.position ?? defaultPosition;
|
|
581
|
+
const isTop = position === "top";
|
|
582
|
+
const isBottom = position === "bottom";
|
|
457
583
|
const type = currentMessage.type ?? "default";
|
|
458
584
|
const typeColors = COLORS[type];
|
|
459
585
|
const backgroundColor = currentMessage.backgroundColor ?? typeColors.background;
|
|
@@ -465,13 +591,13 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
465
591
|
const renderIcon = () => {
|
|
466
592
|
if (currentMessage.icon === "none") return null;
|
|
467
593
|
if (typeof currentMessage.icon === "function") {
|
|
468
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconContainer, children: currentMessage.icon({ size:
|
|
594
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconBadge, children: currentMessage.icon({ size: 18, color: textColor }) }) });
|
|
469
595
|
}
|
|
470
596
|
if (React__default.default.isValidElement(currentMessage.icon)) {
|
|
471
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconContainer, children: currentMessage.icon });
|
|
597
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconBadge, children: currentMessage.icon }) });
|
|
472
598
|
}
|
|
473
599
|
const iconType = typeof currentMessage.icon === "string" ? currentMessage.icon : type;
|
|
474
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsxRuntime.jsx(BuiltInIcon, { type: iconType, color: textColor, size:
|
|
600
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconContainer, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles2.iconBadge, children: /* @__PURE__ */ jsxRuntime.jsx(BuiltInIcon, { type: iconType, color: textColor, size: 18 }) }) });
|
|
475
601
|
};
|
|
476
602
|
const handlePress = () => {
|
|
477
603
|
if (currentMessage.onPress) {
|
|
@@ -509,6 +635,16 @@ var FlashMessage = React__default.default.forwardRef(
|
|
|
509
635
|
reactNative.Pressable,
|
|
510
636
|
{
|
|
511
637
|
onPress: handlePress,
|
|
638
|
+
onPressIn: () => {
|
|
639
|
+
if (currentMessage.pauseOnPress ?? true) {
|
|
640
|
+
pauseTimer();
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
onPressOut: () => {
|
|
644
|
+
if (currentMessage.pauseOnPress ?? true) {
|
|
645
|
+
resumeTimer();
|
|
646
|
+
}
|
|
647
|
+
},
|
|
512
648
|
onLongPress: currentMessage.onLongPress,
|
|
513
649
|
style: styles2.contentWrapper,
|
|
514
650
|
children: [
|