Dismissable toasts (#6345)

* dismissable toast

* adjust top offset

* improve a11y

* stretchy pull-down

* Dismiss web on tap

* Simplify code

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
Samuel Newman
2024-11-22 16:11:59 +00:00
committed by GitHub
parent 5d4aaa5b5f
commit 76ca72cf72
2 changed files with 175 additions and 45 deletions
+16 -1
View File
@@ -3,7 +3,7 @@
*/
import React, {useEffect, useState} from 'react'
import {StyleSheet, Text, View} from 'react-native'
import {Pressable, StyleSheet, Text, View} from 'react-native'
import {
FontAwesomeIcon,
FontAwesomeIconStyle,
@@ -43,6 +43,14 @@ export const ToastContainer: React.FC<ToastContainerProps> = ({}) => {
style={styles.icon as FontAwesomeIconStyle}
/>
<Text style={styles.text}>{activeToast.text}</Text>
<Pressable
style={styles.dismissBackdrop}
accessibilityLabel="Dismiss"
accessibilityHint=""
onPress={() => {
setActiveToast(undefined)
}}
/>
</View>
)}
</>
@@ -77,6 +85,13 @@ const styles = StyleSheet.create({
backgroundColor: '#000c',
borderRadius: 10,
},
dismissBackdrop: {
position: 'absolute',
top: 0,
left: 0,
bottom: 0,
right: 0,
},
icon: {
color: '#fff',
flexShrink: 0,