SettingScreen.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { StackScreenProps } from '@react-navigation/stack';
  2. import * as React from 'react';
  3. import { Div, Button, Image, Text, Avatar, Icon } from 'react-native-magnus';
  4. import { ScrollView } from 'react-native-gesture-handler';
  5. import { useTranslation } from 'react-i18next';
  6. import useModel from 'flooks';
  7. import User from '../stores/User';
  8. import { alert } from '../utils/SystemUtils';
  9. export default function SettingScreen({ navigation }: StackScreenProps) {
  10. const { t, i18n } = useTranslation();
  11. const { logout } = useModel(User, []);
  12. return (
  13. <Div bg="gray100">
  14. <ScrollView
  15. contentContainerStyle={{
  16. flexGrow: 1,
  17. backgroundColor: '#f2f2f2',
  18. }}
  19. >
  20. <Button
  21. bg="white"
  22. px={12}
  23. h={52}
  24. py={0}
  25. block
  26. mt={10}
  27. rounded="none"
  28. onPress={() => {
  29. navigation.navigate('SettingSys');
  30. }}
  31. >
  32. <Div row justifyContent="space-between" flex={1}>
  33. <Text fontSize="sm">{t('tong-zhi-he-ti-shi-yin-she-zhi')}</Text>
  34. <Icon name="right" />
  35. </Div>
  36. </Button>
  37. <Button bg="white" px={12} h={52} py={0} block mt={10} rounded="none">
  38. <Div row justifyContent="space-between" flex={1}>
  39. <Text fontSize="sm">
  40. {t('ding-dong-wai-mai-qi-shou-zhu-ce-xie-yi')}
  41. </Text>
  42. <Icon name="right" />
  43. </Div>
  44. </Button>
  45. <Button bg="white" px={12} h={52} py={0} block mt={10} rounded="none">
  46. <Div row justifyContent="space-between" flex={1}>
  47. <Text fontSize="sm">
  48. {t('ding-dong-wai-mai-qi-shou-yin-si-zheng-ce')}
  49. </Text>
  50. <Icon name="right" />
  51. </Div>
  52. </Button>
  53. <Button bg="white" px={12} h={52} py={0} block mt={10} rounded="none">
  54. <Div row justifyContent="space-between" flex={1}>
  55. <Text fontSize="sm">{t('qi-shou-fu-wu-he-zuo-xie-yi')}</Text>
  56. <Icon name="right" />
  57. </Div>
  58. </Button>
  59. <Button
  60. bg="white"
  61. px={12}
  62. h={52}
  63. py={0}
  64. block
  65. mt={10}
  66. rounded="none"
  67. onPress={() => {
  68. const languages = ['zh', 'en', 'th'];
  69. console.log(i18n.languages);
  70. const index = languages.findIndex((item) => {
  71. return i18n.languages.indexOf(item) != -1;
  72. });
  73. console.log(index);
  74. i18n.changeLanguage(languages[(index + 1) % 3]);
  75. }}
  76. >
  77. <Div row justifyContent="space-between" flex={1}>
  78. <Text fontSize="sm">当前语言为{i18n.language}</Text>
  79. <Icon name="right" />
  80. </Div>
  81. </Button>
  82. <Button
  83. // w={112}
  84. minW={112}
  85. bg="white"
  86. color="black"
  87. borderWidth={1}
  88. borderColor="yellow500"
  89. fontSize="sm"
  90. alignSelf="center"
  91. my={30}
  92. onPress={() => {
  93. alert(navigation, {
  94. msg: t('que-ren-yao-tui-chu-dang-qian-zhang-hao-ma'),
  95. hasCancel: true,
  96. submitEvent: () => logout(),
  97. });
  98. }}
  99. >
  100. {t('tui-chu-dang-qian-zhang-hu')}
  101. </Button>
  102. </ScrollView>
  103. </Div>
  104. );
  105. }