Rename cleanup
This commit is contained in:
@@ -20,19 +20,11 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
|||||||
|
|
||||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
import {Toast as BaseToast} from '#/components/Toast/Toast'
|
import {Toast} from '#/components/Toast/Toast'
|
||||||
import {type ToastType} from '#/components/Toast/types'
|
import {type ToastType} from '#/components/Toast/types'
|
||||||
|
|
||||||
const TIMEOUT = 2e3
|
const TIMEOUT = 2e3
|
||||||
const TOAST_ANIMATION_CONFIG = {
|
const TOAST_ANIMATION_DURATION = 300
|
||||||
duration: 300,
|
|
||||||
damping: 15,
|
|
||||||
stiffness: 150,
|
|
||||||
mass: 0.8,
|
|
||||||
overshootClamping: false,
|
|
||||||
restSpeedThreshold: 0.01,
|
|
||||||
restDisplacementThreshold: 0.01,
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ToastContainer() {
|
export function ToastContainer() {
|
||||||
return null
|
return null
|
||||||
@@ -45,11 +37,17 @@ export function show(message: string, type: ToastType = 'default'): void {
|
|||||||
|
|
||||||
AccessibilityInfo.announceForAccessibility(message)
|
AccessibilityInfo.announceForAccessibility(message)
|
||||||
const item = new RootSiblings(
|
const item = new RootSiblings(
|
||||||
<Toast message={message} type={type} destroy={() => item.destroy()} />,
|
(
|
||||||
|
<AnimatedToast
|
||||||
|
message={message}
|
||||||
|
type={type}
|
||||||
|
destroy={() => item.destroy()}
|
||||||
|
/>
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Toast({
|
function AnimatedToast({
|
||||||
message,
|
message,
|
||||||
type,
|
type,
|
||||||
destroy,
|
destroy,
|
||||||
@@ -166,8 +164,8 @@ function Toast({
|
|||||||
pointerEvents="box-none">
|
pointerEvents="box-none">
|
||||||
{alive && (
|
{alive && (
|
||||||
<Animated.View
|
<Animated.View
|
||||||
entering={FadeIn.duration(TOAST_ANIMATION_CONFIG.duration)}
|
entering={FadeIn.duration(TOAST_ANIMATION_DURATION)}
|
||||||
exiting={FadeOut.duration(TOAST_ANIMATION_CONFIG.duration * 0.7)}
|
exiting={FadeOut.duration(TOAST_ANIMATION_DURATION * 0.7)}
|
||||||
onLayout={evt => setCardHeight(evt.nativeEvent.layout.height)}
|
onLayout={evt => setCardHeight(evt.nativeEvent.layout.height)}
|
||||||
accessibilityRole="alert"
|
accessibilityRole="alert"
|
||||||
accessible={true}
|
accessible={true}
|
||||||
@@ -176,7 +174,7 @@ function Toast({
|
|||||||
onAccessibilityEscape={hideAndDestroyImmediately}
|
onAccessibilityEscape={hideAndDestroyImmediately}
|
||||||
style={[a.flex_1, animatedStyle]}>
|
style={[a.flex_1, animatedStyle]}>
|
||||||
<GestureDetector gesture={panGesture}>
|
<GestureDetector gesture={panGesture}>
|
||||||
<BaseToast content={message} type={type} />
|
<Toast content={message} type={type} />
|
||||||
</GestureDetector>
|
</GestureDetector>
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user