AddressScreen.jsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* eslint-disable react/style-prop-object */
  2. import * as WebBrowser from 'expo-web-browser';
  3. import * as React from 'react';
  4. import { StatusBar } from 'expo-status-bar';
  5. import { Div, Button, Image, Text, Avatar, Icon } from 'react-native-magnus';
  6. import { Appbar } from 'react-native-paper';
  7. import { ScrollView } from 'react-native-gesture-handler';
  8. import { useCreation } from '@umijs/hooks';
  9. import { useTranslation } from 'react-i18next';
  10. import useModel from 'flooks';
  11. import HomeModel from './Home/model';
  12. import MapModel from '../Map/model';
  13. import HomeAddressCom from '../Address/HomeAddressCom';
  14. export default function AddressScreen({ navigation }) {
  15. const { locationInfo, getNowLocation, changeChooseInfo } = useModel(
  16. MapModel,
  17. ['locationInfo', 'getNowLocation']
  18. );
  19. const { t } = useTranslation();
  20. const addressName = useCreation(() => {
  21. if (locationInfo) {
  22. return locationInfo.addressName;
  23. } else {
  24. return '';
  25. }
  26. }, [locationInfo]);
  27. return (
  28. <>
  29. <Div bg="white" pb={10} borderBottomWidth={1} borderColor="gray200">
  30. <StatusBar backgroundColor="#fff" style="dark" translucent />
  31. <Appbar.Header
  32. theme={{ colors: { primary: '#fff' } }}
  33. style={{
  34. elevation: 0,
  35. shadowOffset: {
  36. width: 0,
  37. height: 0,
  38. },
  39. shadowOpacity: 0,
  40. zIndex: 2,
  41. }}
  42. >
  43. <Appbar.BackAction onPress={navigation.goBack} />
  44. <Appbar.Content
  45. title={t('xuan-ze-shou-huo-di-zhi')}
  46. titleStyle={{ textAlign: 'center', fontSize: 16 }}
  47. />
  48. <Button alignSelf="center" bg="hide" color="brand500" px={20}>
  49. {t('guan-li')}
  50. </Button>
  51. </Appbar.Header>
  52. <Button
  53. rounded="circle"
  54. block
  55. bg="gray200"
  56. mx={15}
  57. mt={10}
  58. onPress={() => navigation.navigate('SearchMap')}
  59. >
  60. <Div row alignItems="center">
  61. <Icon name="search1" color="gray500" />
  62. <Text color="gray500" fontSize="xs">
  63. {t('xiao-qu-xie-zi-lou-xue-xiao-deng')}
  64. </Text>
  65. </Div>
  66. </Button>
  67. </Div>
  68. <ScrollView
  69. contentContainerStyle={{
  70. flexGrow: 1,
  71. backgroundColor: '#fff',
  72. }}
  73. >
  74. <Div px={15} py={10}>
  75. <Text color="gray500" fontSize="sm">
  76. {t('dang-qian-ding-wei')}
  77. </Text>
  78. <Div row>
  79. <Button
  80. onPress={() => {
  81. navigation.navigate('Home');
  82. if (addressName) {
  83. changeChooseInfo(locationInfo);
  84. }
  85. }}
  86. block
  87. bg="hiden"
  88. p={0}
  89. flex={1}
  90. >
  91. <Div flex={1} row>
  92. <Icon name="navigation" color="brand500" fontFamily="Feather" />
  93. <Text
  94. numberOfLines={1}
  95. ellipsizeMode="tail"
  96. fontSize="xl"
  97. ml={5}
  98. fontWeight="bold"
  99. flex={1}
  100. >
  101. {getNowLocation.loading
  102. ? t('jia-zai-zhong')
  103. : addressName || t('ding-wei-shi-bai')}
  104. </Text>
  105. </Div>
  106. </Button>
  107. <Button onPress={getNowLocation} bg="hiden" color="brand500">
  108. {t('zhong-xin-ding-wei')}
  109. </Button>
  110. </Div>
  111. </Div>
  112. <HomeAddressCom />
  113. </ScrollView>
  114. </>
  115. );
  116. }