InputModalScreen.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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,secureTextEntry, defaultVal, hasCancel, submitText, submitEvent, tips } =
  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. secureTextEntry={secureTextEntry}
  32. onChangeText={(text) => setVal(text)}
  33. />
  34. <Text color="gray500" textAlign="center" mt={3}>
  35. {tips}
  36. </Text>
  37. <Div row py={10} mt={10}>
  38. {hasCancel && (
  39. <Button
  40. flex={1}
  41. mx={3}
  42. rounded="xs"
  43. bg="white"
  44. color="black"
  45. borderWidth={1}
  46. borderColor="yellow500"
  47. fontSize="sm"
  48. onPress={() => navigation.goBack()}
  49. >
  50. {hasCancel ? t('qu-xiao') : submitText || t('que-ren')}
  51. </Button>
  52. )}
  53. <Button
  54. flex={1}
  55. mx={3}
  56. rounded="xs"
  57. bg="yellow500"
  58. fontSize="sm"
  59. onPress={() => {
  60. if (submitEvent) {
  61. submitEvent(val);
  62. }
  63. navigation.goBack();
  64. }}
  65. >
  66. {submitText || t('que-ren')}
  67. </Button>
  68. </Div>
  69. </Div>
  70. </Animatable.View>
  71. </Div>
  72. );
  73. }