AddressScreen.jsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import * as WebBrowser from 'expo-web-browser';
  2. import * as React from 'react';
  3. import { StatusBar } from 'expo-status-bar';
  4. import { Div, Button, Image, Text, Avatar, Icon } from 'react-native-magnus';
  5. import { Appbar } from 'react-native-paper';
  6. import { ScrollView } from 'react-native-gesture-handler';
  7. import { useCreation } from '@umijs/hooks';
  8. import useModel from 'flooks';
  9. import HomeModel from './Home/model';
  10. import MapModel from '../Map/model';
  11. import HomeAddressCom from '../Address/HomeAddressCom';
  12. export default function AddressScreen({ navigation }) {
  13. const { locationInfo, getNowLocation, changeChooseInfo } = useModel(
  14. MapModel,
  15. ['locationInfo', 'getNowLocation']
  16. );
  17. const addressName = useCreation(() => {
  18. if (locationInfo) {
  19. return locationInfo.addressName;
  20. } else {
  21. return '';
  22. }
  23. }, [locationInfo]);
  24. return (
  25. <>
  26. <Div bg="white" pb={10} borderBottomWidth={1} borderColor="gray200">
  27. <StatusBar backgroundColor="#fff" style="dark" translucent />
  28. <Appbar.Header
  29. theme={{ colors: { primary: '#fff' } }}
  30. style={{
  31. elevation: 0,
  32. shadowOffset: {
  33. width: 0,
  34. height: 0,
  35. },
  36. shadowOpacity: 0,
  37. zIndex: 2,
  38. }}
  39. >
  40. <Appbar.BackAction onPress={navigation.goBack} />
  41. <Appbar.Content
  42. title="选择收货地址"
  43. titleStyle={{ textAlign: 'center', fontSize: 16 }}
  44. />
  45. <Button alignSelf="center" bg="hide" color="brand500" px={20}>
  46. 管理
  47. </Button>
  48. </Appbar.Header>
  49. <Button
  50. rounded="circle"
  51. block
  52. bg="gray200"
  53. mx={15}
  54. mt={10}
  55. onPress={() => navigation.navigate('SearchMap')}
  56. >
  57. <Div row alignItems="center">
  58. <Icon name="search1" color="gray500" />
  59. <Text color="gray500" fontSize="xs">
  60. 小区/写字楼/学校 等
  61. </Text>
  62. </Div>
  63. </Button>
  64. </Div>
  65. <ScrollView
  66. contentContainerStyle={{
  67. flexGrow: 1,
  68. backgroundColor: '#fff',
  69. }}
  70. >
  71. <Div px={15} py={10}>
  72. <Text color="gray500" fontSize="sm">
  73. 当前定位
  74. </Text>
  75. <Div row>
  76. <Button
  77. onPress={() => {
  78. navigation.navigate('Home');
  79. if (addressName) {
  80. changeChooseInfo(locationInfo);
  81. }
  82. }}
  83. block
  84. bg="hiden"
  85. p={0}
  86. flex={1}
  87. >
  88. <Div flex={1} row>
  89. <Icon name="navigation" color="brand500" fontFamily="Feather" />
  90. <Text
  91. numberOfLines={1}
  92. ellipsizeMode="tail"
  93. fontSize="xl"
  94. ml={5}
  95. fontWeight="bold"
  96. flex={1}
  97. >
  98. {getNowLocation.loading
  99. ? '加载中...'
  100. : addressName || '定位失败'}
  101. </Text>
  102. </Div>
  103. </Button>
  104. <Button onPress={getNowLocation} bg="hiden" color="brand500">
  105. 重新定位
  106. </Button>
  107. </Div>
  108. </Div>
  109. <HomeAddressCom />
  110. </ScrollView>
  111. </>
  112. );
  113. }