mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at switch-session-failure 87 lines 2.1 kB view raw
1import RootSiblings from 'react-native-root-siblings' 2import React from 'react' 3import {Animated, StyleSheet, View} from 'react-native' 4import {Props as FontAwesomeProps} from '@fortawesome/react-native-fontawesome' 5import {Text} from './text/Text' 6import {colors} from 'lib/styles' 7import {useTheme} from 'lib/ThemeContext' 8import {usePalette} from 'lib/hooks/usePalette' 9import {useAnimatedValue} from 'lib/hooks/useAnimatedValue' 10import {IS_TEST} from '#/env' 11 12const TIMEOUT = 4e3 13 14export function show( 15 message: string, 16 _icon: FontAwesomeProps['icon'] = 'check', 17) { 18 if (IS_TEST) return 19 const item = new RootSiblings(<Toast message={message} />) 20 setTimeout(() => { 21 item.destroy() 22 }, TIMEOUT) 23} 24 25function Toast({message}: {message: string}) { 26 const theme = useTheme() 27 const pal = usePalette('default') 28 const interp = useAnimatedValue(0) 29 30 React.useEffect(() => { 31 Animated.sequence([ 32 Animated.timing(interp, { 33 toValue: 1, 34 duration: 150, 35 useNativeDriver: true, 36 }), 37 Animated.delay(3700), 38 Animated.timing(interp, { 39 toValue: 0, 40 duration: 150, 41 useNativeDriver: true, 42 }), 43 ]).start() 44 }) 45 46 const opacityStyle = {opacity: interp} 47 return ( 48 <View style={styles.container} pointerEvents="none"> 49 <Animated.View 50 style={[ 51 pal.view, 52 pal.border, 53 styles.toast, 54 theme.colorScheme === 'dark' && styles.toastDark, 55 opacityStyle, 56 ]}> 57 <Text type="lg-medium" style={pal.text}> 58 {message} 59 </Text> 60 </Animated.View> 61 </View> 62 ) 63} 64 65const styles = StyleSheet.create({ 66 container: { 67 position: 'absolute', 68 top: 60, 69 left: 0, 70 right: 0, 71 alignItems: 'center', 72 }, 73 toast: { 74 paddingHorizontal: 18, 75 paddingVertical: 10, 76 borderRadius: 24, 77 borderWidth: 1, 78 shadowColor: '#000', 79 shadowOpacity: 0.1, 80 shadowOffset: {width: 0, height: 4}, 81 marginHorizontal: 6, 82 }, 83 toastDark: { 84 backgroundColor: colors.gray6, 85 shadowOpacity: 0.5, 86 }, 87})