2019-05-15 19:33:30 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Alert, StyleSheet } from 'react-native';
|
|
|
|
import EasyToast from 'react-native-easy-toast';
|
2018-01-15 20:43:52 +00:00
|
|
|
|
2019-05-15 19:33:30 +00:00
|
|
|
import { COLOR_TOAST, COLOR_WHITE } from '../constants/colors';
|
|
|
|
import { isNotch } from './deviceInfo';
|
|
|
|
import sharedStyles from '../views/Styles';
|
2018-01-15 20:43:52 +00:00
|
|
|
|
2019-05-15 19:33:30 +00:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
toast: {
|
|
|
|
backgroundColor: COLOR_TOAST
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
...sharedStyles.textRegular,
|
|
|
|
color: COLOR_WHITE,
|
|
|
|
fontSize: 14
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const positionValue = isNotch ? 230 : 200;
|
|
|
|
|
|
|
|
export const Toast = React.forwardRef((props, ref) => (
|
|
|
|
<EasyToast
|
|
|
|
{...props}
|
|
|
|
ref={ref}
|
|
|
|
positionValue={positionValue}
|
|
|
|
style={styles.toast}
|
|
|
|
textStyle={styles.text}
|
|
|
|
opacity={0.8}
|
|
|
|
/>
|
|
|
|
));
|
2019-06-21 16:38:26 +00:00
|
|
|
export const showErrorAlert = (message, title, onPress = () => {}) => Alert.alert(title, message, [{ text: 'OK', onPress }], { cancelable: true });
|