BottomSiteInfo.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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/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. onPress={() => startPage(PageList.chargeDetailPage, {stationInfo: stationInfo, action: 'view', from: PageList.home})}>
  51. <Text
  52. ellipsizeMode='tail'
  53. numberOfLines={1}
  54. style={styles.stationTitle}>{stationInfo.name}</Text>
  55. <Text
  56. style={styles.stationAddress}
  57. ellipsizeMode='tail'
  58. numberOfLines={2}>{stationInfo.address}</Text>
  59. </Pressable>
  60. {/* <View style={styles.stationAvailable}>
  61. <Image
  62. style={styles.availableIcon}
  63. source={require('../../../images/charge/icon-type-stops.png')}/>
  64. <Text style={styles.availableText}>{getAvailable('box')}</Text>
  65. </View>
  66. <View style={styles.stationAvailable}>
  67. <Image
  68. style={styles.availableIcon}
  69. source={require('../../../images/charge/icon-type-interfaces.png')}/>
  70. <Text style={styles.availableText}>{getAvailable('inc')}</Text>
  71. </View> */}
  72. <Pressable
  73. style={styles.directView}
  74. onPress={() => {
  75. utils.directMaps(stationInfo.latitude, stationInfo.longitude, stationInfo.address);
  76. }}>
  77. <MaterialIcons
  78. name='directions'
  79. size={28}
  80. color={colorAccent}/>
  81. <Text style={styles.distanceText}>{stationInfo.distance}</Text>
  82. </Pressable>
  83. </View>
  84. <View style={ui.flex}>
  85. <View style={styles.connectView}>
  86. <ConnectType {...stationInfo.acConnector}/>
  87. <ConnectType {...stationInfo.dcConnector}/>
  88. </View>
  89. <View style={styles.stationStatusView}>
  90. { stationInfo.allConnector && stationInfo.allConnector.available > 0 &&
  91. <Text style={[ChargeStyle.infoStatus, ChargeStyle.statusAvailable, styles.stationStatus]}>Available</Text>
  92. }
  93. <Text style={[ChargeStyle.infoStatus, stationInfo.siteType == 'Public' ? ChargeStyle.statusAvailable : ChargeStyle.statusWarning, styles.siteTypes]}>{stationInfo.siteType}</Text>
  94. </View>
  95. </View>
  96. <View style={styles.divideLine}></View>
  97. <Pressable
  98. style={styles.infoDetailsView}
  99. onPress={() => startPage(PageList.chargeDetailPage, {stationInfo: stationInfo, action: 'view', from: PageList.home})}>
  100. <View style={ui.flex1}>
  101. <Text style={styles.infoTitle}>Operating Hours</Text>
  102. <View style={styles.infoView}>
  103. <Text style={styles.infoText}>{getOperatingHours()}</Text>
  104. </View>
  105. </View>
  106. <View style={{width: 4}}></View>
  107. <View style={ui.flex1}>
  108. <Text style={styles.infoTitle}>Parking Charges</Text>
  109. <View style={styles.infoView}>
  110. <Text style={styles.infoText}>{getParkingFee()}</Text>
  111. </View>
  112. </View>
  113. <View style={{width: 4}}></View>
  114. <View style={ui.flex1}>
  115. <Text style={styles.infoTitle}>Additional Info</Text>
  116. <View style={styles.infoView}>
  117. <Text style={styles.infoText}>{stationInfo.additionalNotes}</Text>
  118. </View>
  119. </View>
  120. </Pressable>
  121. </View>
  122. );
  123. } else {
  124. return <></>;
  125. }
  126. }
  127. const styles = StyleSheet.create({
  128. stationBarView: {
  129. left: 16,
  130. right: 16,
  131. bottom: 48,
  132. zIndex: 10,
  133. borderRadius: 6,
  134. ...$padding(12, 9),
  135. position: 'absolute',
  136. backgroundColor: colorLight,
  137. ...ElevationObject(1.5)
  138. },
  139. stationInfo: {
  140. flex: 1,
  141. height: 45,
  142. paddingLeft: 4,
  143. paddingRight: 8,
  144. justifyContent: 'space-around'
  145. },
  146. stationTitle: {
  147. color: '#000',
  148. fontSize: 16,
  149. paddingBottom: 2
  150. },
  151. stationAddress: {
  152. color: '#999',
  153. fontSize: 12,
  154. },
  155. stationAvailable: {
  156. height: 45,
  157. paddingLeft: 8,
  158. paddingRight: 8,
  159. alignItems: 'center',
  160. justifyContent: 'space-between'
  161. },
  162. stationStatusView: {
  163. marginRight: 4,
  164. alignItems: 'center',
  165. flexDirection: 'row-reverse'
  166. },
  167. stationStatus: {
  168. fontSize: 10,
  169. ...$padding(2, 6)
  170. },
  171. siteTypes: {
  172. fontSize: 10,
  173. marginTop: 0,
  174. marginRight: 4,
  175. ...$padding(2, 6)
  176. },
  177. availableIcon: {
  178. width: 23,
  179. height: 23,
  180. },
  181. availableText: {
  182. color: textPrimary,
  183. fontSize: 13,
  184. textAlign: 'center'
  185. },
  186. directView: {
  187. zIndex: 1,
  188. height: 45,
  189. marginLeft: 8,
  190. marginRight: 4,
  191. alignItems: 'center',
  192. justifyContent: 'space-between'
  193. },
  194. distanceText: {
  195. color: textPrimary,
  196. fontSize: 12,
  197. },
  198. connectView: {
  199. flex: 1,
  200. paddingTop: 12,
  201. paddingBottom: 12,
  202. alignItems: 'center',
  203. flexDirection: 'row'
  204. },
  205. divideLine: {
  206. height: 1,
  207. backgroundColor: '#AEAEAE'
  208. },
  209. infoDetailsView: {
  210. flexDirection: 'row'
  211. },
  212. infoTitle: {
  213. color: '#000',
  214. fontSize: 12,
  215. fontWeight: 'bold',
  216. ...$padding(8, 0, 8)
  217. },
  218. infoView: {
  219. paddingBottom: 8
  220. },
  221. infoText: {
  222. color: '#444',
  223. fontSize: 10
  224. }
  225. })