AlertModalScreen.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { StackScreenProps } from '@react-navigation/stack';
  2. import * as React from 'react';
  3. import * as Animatable from 'react-native-animatable';
  4. import { Div, Button, Image, Text, Avatar } from 'react-native-magnus';
  5. import { ScrollView } from 'react-native-gesture-handler';
  6. import { useTranslation } from 'react-i18next';
  7. import { RootStackParamList } from '../types';
  8. export default function AlertModalScreen({
  9. navigation,
  10. route,
  11. }: StackScreenProps<RootStackParamList, 'AlertModal'>) {
  12. const { params } = route;
  13. const { title, msg, hasCancel, submitText, submitEvent, dangers } = params;
  14. const { t } = useTranslation();
  15. return (
  16. <Div flex={1} bg="black600" alignItems="center" justifyContent="center">
  17. <Animatable.View animation="slideInUp" duration={300}>
  18. <Div bg="white" p={10} rounded="sm" minW={287}>
  19. <Text fontSize="lg" textAlign="center">
  20. {title || t('ti-shi')}
  21. </Text>
  22. <Text
  23. fontSize="md"
  24. color={dangers ? 'red500' : 'black'}
  25. p={10}
  26. textAlign="center"
  27. >
  28. {msg}
  29. </Text>
  30. <Div row py={10} mt={10}>
  31. {hasCancel && (
  32. <Button
  33. flex={1}
  34. mx={3}
  35. rounded="xs"
  36. bg="white"
  37. color="black"
  38. borderWidth={1}
  39. borderColor="yellow500"
  40. fontSize="sm"
  41. onPress={() => navigation.goBack()}
  42. >
  43. {hasCancel ? t('qu-xiao') : submitText || t('que-ren')}
  44. </Button>
  45. )}
  46. <Button
  47. flex={1}
  48. mx={3}
  49. rounded="xs"
  50. bg="yellow500"
  51. fontSize="sm"
  52. onPress={() => {
  53. if (submitEvent) {
  54. submitEvent();
  55. }
  56. navigation.goBack();
  57. }}
  58. >
  59. {submitText || t('que-ren')}
  60. </Button>
  61. </Div>
  62. </Div>
  63. </Animatable.View>
  64. </Div>
  65. );
  66. }