InputModalScreen.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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, Input } from 'react-native-magnus';
  5. import { ScrollView } from 'react-native-gesture-handler';
  6. import { useTranslation } from 'react-i18next';
  7. export default function InputModalScreen({
  8. navigation,
  9. route,
  10. }: StackScreenProps) {
  11. const { params } = route;
  12. const { title, defaultVal, hasCancel, submitText, submitEvent } =
  13. params || {};
  14. const { t } = useTranslation();
  15. const [val, setVal] = React.useState<string>('');
  16. const inRef = React.useRef();
  17. return (
  18. <Div flex={1} bg="black600" alignItems="center" justifyContent="center">
  19. <Animatable.View animation="slideInUp" duration={300}>
  20. <Div bg="white" p={10} rounded="sm" minW={287}>
  21. <Text fontSize="lg" textAlign="center">
  22. {title || t('ti-shi')}
  23. </Text>
  24. <Input
  25. autoFocus={true}
  26. defaultValue={defaultVal}
  27. mt={10}
  28. opacity={1}
  29. loaderColor="gray400"
  30. color="gray900"
  31. onChangeText={(text) => setVal(text)}
  32. />
  33. <Div row py={10} mt={10}>
  34. <Button
  35. flex={1}
  36. mx={3}
  37. rounded="xs"
  38. bg="white"
  39. color="black"
  40. borderWidth={1}
  41. borderColor="yellow500"
  42. fontSize="sm"
  43. onPress={() => navigation.goBack()}
  44. >
  45. {hasCancel ? t('qu-xiao') : submitText || t('que-ren')}
  46. </Button>
  47. <Button
  48. flex={1}
  49. mx={3}
  50. rounded="xs"
  51. bg="yellow500"
  52. fontSize="sm"
  53. onPress={() => {
  54. if (submitEvent) {
  55. submitEvent(val);
  56. }
  57. navigation.goBack();
  58. }}
  59. >
  60. {submitText || t('que-ren')}
  61. </Button>
  62. </Div>
  63. </Div>
  64. </Animatable.View>
  65. </Div>
  66. );
  67. }