-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathAppToast.tsx
More file actions
72 lines (65 loc) · 1.84 KB
/
Copy pathAppToast.tsx
File metadata and controls
72 lines (65 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React from 'react';
import {
Platform,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { FullWindowOverlay } from 'react-native-screens';
import Toast, { ToastConfig } from 'react-native-toast-message';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Theme } from '../styles/colors';
import { useThemedStyles } from '../hooks/useThemedStyles';
import CloseIcon from '../assets/icons/close.svg';
import { fontFamily, fontSizes } from '../styles/fontStyles';
const AppToast: React.FC = () => {
const { styles } = useThemedStyles(createStyles);
const insets = useSafeAreaInsets();
const toastConfig: ToastConfig = {
defaultToast: ({ text1 }) => (
<View style={styles.toastContainer}>
<Text style={styles.toastText}>{text1}</Text>
<TouchableOpacity
onPress={() => Toast.hide()}
style={styles.toastCloseButton}
>
<CloseIcon width={13.33} height={13.33} style={styles.toastIcon} />
</TouchableOpacity>
</View>
),
};
const renderToast = () => {
return <Toast config={toastConfig} topOffset={insets.top + 16} />;
};
if (Platform.OS === 'ios') {
return <FullWindowOverlay>{renderToast()}</FullWindowOverlay>;
} else {
return renderToast();
}
};
export default AppToast;
const createStyles = (theme: Theme) =>
StyleSheet.create({
toastContainer: {
width: '90%',
backgroundColor: theme.bg.softSecondary,
borderRadius: 12,
padding: 16,
flexDirection: 'row',
},
toastText: {
color: theme.text.primary,
fontFamily: fontFamily.bold,
fontSize: fontSizes.sm,
width: '80%',
},
toastCloseButton: {
width: '20%',
alignItems: 'flex-end',
marginTop: 3.33,
},
toastIcon: {
color: theme.text.primary,
},
});