BottomSiteInfo.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /**
  2. * 地图底部充电站信息组件
  3. * @邠心vbe on 2022/12/23
  4. */
  5. import React from 'react';
  6. import { Pressable, StyleSheet, View, Text, Image } from 'react-native';
  7. import { ElevationObject } from '../../../components/Button';
  8. import utils from '../../../utils/utils';
  9. import { ChargeStyle } from '../../charge/Charging';
  10. import { PageList } from '../../Router';
  11. import { ConnectType } from '../Search';
  12. export default TopInfo = ({stationInfo = {}}) => {
  13. const getAvailable = (type) => {
  14. const all = stationInfo.allConnector;
  15. if (all) {
  16. if (type == 'box') {
  17. return all.boxAvailable + '/' + all.boxAll;
  18. } else {
  19. return all.available + '/' + all.all;
  20. }
  21. } else {
  22. return '0/0';
  23. }
  24. }
  25. const getOperatingHours = () => {
  26. if (stationInfo.endlessService) {
  27. return "24/7";
  28. } else if (stationInfo.operatingHours) {
  29. return stationInfo.operatingHours;
  30. } else {
  31. return 'To be updated';
  32. }
  33. }
  34. const getParkingFee = () => {
  35. if (stationInfo.parkingFeeFree) {
  36. return "Free";
  37. } else if (stationInfo.parkingFee) {
  38. return stationInfo.parkingFee;
  39. } else {
  40. return 'To be updated';
  41. }
  42. }
  43. if (stationInfo.id) {
  44. return (
  45. <View style={styles.stationBarView}>
  46. <View style={ui.flexc}>
  47. <Pressable
  48. style={styles.stationInfo}
  49. onPress={() => startPage(PageList.chargeDetail, {stationInfo: stationInfo, action: 'view'})}>
  50. <Text
  51. ellipsizeMode='tail'
  52. numberOfLines={1}
  53. style={styles.stationTitle}>{stationInfo.name}</Text>
  54. <Text
  55. style={styles.stationAddress}
  56. ellipsizeMode='tail'
  57. numberOfLines={2}>{stationInfo.address}</Text>
  58. </Pressable>
  59. {/* <View style={styles.stationAvailable}>
  60. <Image
  61. style={styles.availableIcon}
  62. source={require('../../../images/charge/icon-type-stops.png')}/>
  63. <Text style={styles.availableText}>{getAvailable('box')}</Text>
  64. </View>
  65. <View style={styles.stationAvailable}>
  66. <Image
  67. style={styles.availableIcon}
  68. source={require('../../../images/charge/icon-type-interfaces.png')}/>
  69. <Text style={styles.availableText}>{getAvailable('inc')}</Text>
  70. </View> */}
  71. <Pressable
  72. style={styles.directView}
  73. onPress={() => {
  74. utils.directMaps(stationInfo.latitude, stationInfo.longitude, stationInfo.address);
  75. }}>
  76. <MaterialIcons
  77. name='directions'
  78. size={28}
  79. color={colorAccent}/>
  80. <Text style={styles.distanceText}>{stationInfo.distance}</Text>
  81. </Pressable>
  82. </View>
  83. <View style={ui.flex}>
  84. <View style={styles.connectView}>
  85. <ConnectType {...stationInfo.acConnector}/>
  86. <ConnectType {...stationInfo.dcConnector}/>
  87. </View>
  88. <View style={styles.stationStatusView}>
  89. { stationInfo.allConnector && stationInfo.allConnector.available > 0 &&
  90. <Text style={[ChargeStyle.infoStatus, ChargeStyle.statusAvailable, styles.stationStatus]}>Available</Text>
  91. }
  92. <Text style={[ChargeStyle.infoStatus, stationInfo.siteType == 'Public' ? ChargeStyle.statusAvailable : ChargeStyle.statusWarning, styles.siteTypes]}>{stationInfo.siteType}</Text>
  93. </View>
  94. </View>
  95. <View style={styles.divideLine}></View>
  96. <Pressable
  97. style={styles.infoDetailsView}
  98. onPress={() => startPage(PageList.chargeDetail, {stationInfo: stationInfo, action: 'view'})}>
  99. <View style={ui.flex1}>
  100. <Text style={styles.infoTitle}>Operating Hours</Text>
  101. <View style={styles.infoView}>
  102. <Text style={styles.infoText}>{getOperatingHours()}</Text>
  103. </View>
  104. </View>
  105. <View style={{width: 4}}></View>
  106. <View style={ui.flex1}>
  107. <Text style={styles.infoTitle}>Parking Charges</Text>
  108. <View style={styles.infoView}>
  109. <Text style={styles.infoText}>{getParkingFee()}</Text>
  110. </View>
  111. </View>
  112. <View style={{width: 4}}></View>
  113. <View style={ui.flex1}>
  114. <Text style={styles.infoTitle}>Additional Info</Text>
  115. <View style={styles.infoView}>
  116. <Text style={styles.infoText}>{stationInfo.additionalNotes}</Text>
  117. </View>
  118. </View>
  119. </Pressable>
  120. </View>
  121. );
  122. } else {
  123. return <></>;
  124. }
  125. }
  126. const styles = StyleSheet.create({
  127. stationBarView: {
  128. left: 16,
  129. right: 16,
  130. bottom: 48,
  131. zIndex: 10,
  132. borderRadius: 6,
  133. ...$padding(12, 9),
  134. position: 'absolute',
  135. backgroundColor: 'white',
  136. ...ElevationObject(1.5)
  137. },
  138. stationInfo: {
  139. flex: 1,
  140. height: 45,
  141. paddingLeft: 4,
  142. paddingRight: 8,
  143. justifyContent: 'space-around'
  144. },
  145. stationTitle: {
  146. color: '#000',
  147. fontSize: 16,
  148. paddingBottom: 2
  149. },
  150. stationAddress: {
  151. color: '#999',
  152. fontSize: 12,
  153. },
  154. stationAvailable: {
  155. height: 45,
  156. paddingLeft: 8,
  157. paddingRight: 8,
  158. alignItems: 'center',
  159. justifyContent: 'space-between'
  160. },
  161. stationStatusView: {
  162. marginRight: 4,
  163. alignItems: 'center',
  164. flexDirection: 'row-reverse'
  165. },
  166. stationStatus: {
  167. fontSize: 10,
  168. ...$padding(2, 6)
  169. },
  170. siteTypes: {
  171. fontSize: 10,
  172. marginTop: 0,
  173. marginRight: 4,
  174. ...$padding(2, 6)
  175. },
  176. availableIcon: {
  177. width: 23,
  178. height: 23,
  179. },
  180. availableText: {
  181. color: '#333',
  182. fontSize: 13,
  183. textAlign: 'center'
  184. },
  185. directView: {
  186. zIndex: 1,
  187. height: 45,
  188. marginLeft: 8,
  189. marginRight: 4,
  190. alignItems: 'center',
  191. justifyContent: 'space-between'
  192. },
  193. distanceText: {
  194. color: '#333',
  195. fontSize: 12,
  196. },
  197. connectView: {
  198. flex: 1,
  199. paddingTop: 12,
  200. paddingBottom: 12,
  201. alignItems: 'center',
  202. flexDirection: 'row'
  203. },
  204. divideLine: {
  205. height: 1,
  206. backgroundColor: '#AEAEAE'
  207. },
  208. infoDetailsView: {
  209. flexDirection: 'row'
  210. },
  211. infoTitle: {
  212. color: '#000',
  213. fontSize: 12,
  214. fontWeight: 'bold',
  215. ...$padding(8, 0, 8)
  216. },
  217. infoView: {
  218. paddingBottom: 8
  219. },
  220. infoText: {
  221. color: '#444',
  222. fontSize: 10
  223. }
  224. })