BottomSiteInfo.js 6.4 KB

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