BottomSiteInfo.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. import app from '../../../../app.json';
  13. import TextView from '../../../components/TextView';
  14. export default BottomSiteInfo = ({stationInfo = {}, onFavorite}) => {
  15. const getAvailable = (type) => {
  16. const all = stationInfo.allConnector;
  17. if (all) {
  18. if (type == 'box') {
  19. return all.boxAvailable + '/' + all.boxAll;
  20. } else {
  21. return all.available + '/' + all.all;
  22. }
  23. } else {
  24. return '0/0';
  25. }
  26. }
  27. const getOperatingHours = () => {
  28. if (stationInfo.endlessService) {
  29. return "24/7";
  30. } else if (stationInfo.operatingHours) {
  31. return stationInfo.operatingHours;
  32. } else {
  33. return $t('charging.toBeUpdated');
  34. }
  35. }
  36. const getParkingFee = () => {
  37. if (stationInfo.parkingFeeFree) {
  38. return $t('charging.free');
  39. } else if (stationInfo.parkingFee) {
  40. return stationInfo.parkingFee;
  41. } else {
  42. return $t('charging.toBeUpdated');
  43. }
  44. }
  45. const toChargePage = () => {
  46. startPage(PageList.chargeDetailPage, {stationInfo: stationInfo, action: 'view', from: PageList.home})
  47. }
  48. if (stationInfo.id) {
  49. return (
  50. <View style={styles.stationBarView}>
  51. <View style={ui.flexc}>
  52. <Pressable
  53. style={styles.stationInfo}
  54. //onPress={() => startPage(PageList.chargeDetail, {stationInfo: stationInfo, action: 'view'})}}
  55. onPress={toChargePage}>
  56. <TextView
  57. ellipsizeMode='tail'
  58. numberOfLines={1}
  59. style={styles.stationTitle}>{stationInfo.name}</TextView>
  60. <TextView
  61. style={styles.stationAddress}
  62. ellipsizeMode='tail'
  63. numberOfLines={2}>{stationInfo.address}</TextView>
  64. </Pressable>
  65. {/* <View style={styles.stationAvailable}>
  66. <Image
  67. style={styles.availableIcon}
  68. source={require('../../../images/charge/icon-type-stops.png')}/>
  69. <Text style={styles.availableText}>{getAvailable('box')}</Text>
  70. </View>
  71. <View style={styles.stationAvailable}>
  72. <Image
  73. style={styles.availableIcon}
  74. source={require('../../../images/charge/icon-type-interfaces.png')}/>
  75. <Text style={styles.availableText}>{getAvailable('inc')}</Text>
  76. </View> */}
  77. { app.modules.bookmarks &&
  78. <Pressable
  79. style={[styles.directIconView, {backgroundColor: stationInfo.favorite ? colorPrimary : colorCancel}]}
  80. android_ripple={rippleLess}
  81. onPress={onFavorite}>
  82. <MaterialIcons
  83. name="star"
  84. size={26}
  85. color={colorLight}/>
  86. </Pressable>
  87. }
  88. <Pressable
  89. style={styles.directIconView}
  90. android_ripple={rippleLess}
  91. onPress={() => {
  92. utils.directMaps(stationInfo.latitude, stationInfo.longitude, stationInfo.address);
  93. }}>
  94. <MaterialCommunityIcons
  95. name="navigation-variant"
  96. size={25}
  97. color={colorLight}/>
  98. {/* <MaterialIcons
  99. name='directions'
  100. size={28}
  101. color={colorAccent}/>
  102. <Text style={styles.distanceText}>{stationInfo.distance}</Text> */}
  103. </Pressable>
  104. </View>
  105. <View style={ui.flex}>
  106. <View style={styles.connectView}>
  107. <ConnectType {...stationInfo?.acConnector}/>
  108. <ConnectType {...stationInfo?.dcConnector}/>
  109. </View>
  110. <View style={styles.stationStatusView}>
  111. { (stationInfo.allConnector && stationInfo.allConnector.available > 0) &&
  112. <TextView style={[ChargeStyle.infoStatus, ChargeStyle.statusAvailable, styles.stationStatus]}>{$t("charging.statusAvailable")}</TextView>
  113. }
  114. <TextView style={[ChargeStyle.infoStatus, stationInfo.siteType == 'Public' ? ChargeStyle.statusAvailable : ChargeStyle.statusWarning, styles.siteTypes]}>{stationInfo.siteType}</TextView>
  115. </View>
  116. </View>
  117. <View style={styles.divideLine}></View>
  118. <Pressable
  119. style={styles.infoDetailsView}
  120. onPress={toChargePage}>
  121. <View style={ui.flex1}>
  122. <TextView style={styles.infoTitle}>{$t("charging.operatingHours")}</TextView>
  123. <View style={styles.infoView}>
  124. <TextView style={styles.infoText}>{getOperatingHours()}</TextView>
  125. </View>
  126. </View>
  127. <View style={{width: 4}}></View>
  128. <View style={ui.flex1}>
  129. <TextView style={styles.infoTitle}>{$t("charging.parkingFees")}</TextView>
  130. <View style={styles.infoView}>
  131. <TextView style={styles.infoText}>{getParkingFee()}</TextView>
  132. </View>
  133. </View>
  134. <View style={{width: 4}}></View>
  135. <View style={ui.flex1}>
  136. <TextView style={styles.infoTitle}>{$t("charging.additionalInfo")}</TextView>
  137. <View style={styles.infoView}>
  138. <TextView style={styles.infoText}>{stationInfo?.additionalNotes}</TextView>
  139. </View>
  140. </View>
  141. </Pressable>
  142. </View>
  143. );
  144. } else {
  145. return <></>;
  146. }
  147. }
  148. const styles = StyleSheet.create({
  149. stationBarView: {
  150. left: 16,
  151. right: 16,
  152. bottom: 48,
  153. zIndex: 10,
  154. borderRadius: 6,
  155. ...$padding(12, 9),
  156. position: 'absolute',
  157. backgroundColor: colorLight,
  158. ...ElevationObject(3)
  159. },
  160. stationInfo: {
  161. flex: 1,
  162. height: 45,
  163. paddingLeft: 4,
  164. paddingRight: 8,
  165. justifyContent: 'space-around'
  166. },
  167. stationTitle: {
  168. color: '#000',
  169. fontSize: 16,
  170. paddingBottom: 8
  171. },
  172. stationAddress: {
  173. color: '#999',
  174. fontSize: 12,
  175. },
  176. stationAvailable: {
  177. height: 45,
  178. paddingLeft: 8,
  179. paddingRight: 8,
  180. alignItems: 'center',
  181. justifyContent: 'space-between'
  182. },
  183. stationStatusView: {
  184. marginRight: 4,
  185. alignItems: 'center',
  186. flexDirection: 'row-reverse'
  187. },
  188. stationStatus: {
  189. fontSize: 10,
  190. ...$padding(2, 6)
  191. },
  192. siteTypes: {
  193. fontSize: 10,
  194. marginTop: 0,
  195. marginRight: 4,
  196. ...$padding(2, 6)
  197. },
  198. availableIcon: {
  199. width: 23,
  200. height: 23,
  201. },
  202. availableText: {
  203. color: textPrimary,
  204. fontSize: 13,
  205. textAlign: 'center'
  206. },
  207. directView: {
  208. zIndex: 1,
  209. height: 45,
  210. marginLeft: 8,
  211. marginRight: 4,
  212. alignItems: 'center',
  213. justifyContent: 'space-between'
  214. },
  215. distanceText: {
  216. color: textPrimary,
  217. fontSize: 12,
  218. },
  219. directIconView: {
  220. zIndex: 1,
  221. width: 42,
  222. height: 42,
  223. marginLeft: 8,
  224. marginRight: 8,
  225. borderRadius: 45,
  226. alignItems: 'center',
  227. justifyContent: 'center',
  228. backgroundColor: colorAccent,
  229. ...ElevationObject(2)
  230. },
  231. connectView: {
  232. flex: 1,
  233. paddingTop: 12,
  234. paddingBottom: 12,
  235. alignItems: 'center',
  236. flexDirection: 'row'
  237. },
  238. divideLine: {
  239. height: 1,
  240. backgroundColor: '#AEAEAE'
  241. },
  242. infoDetailsView: {
  243. flexDirection: 'row'
  244. },
  245. infoTitle: {
  246. color: '#000',
  247. fontSize: 12,
  248. fontWeight: 'bold',
  249. ...$padding(8, 0, 8)
  250. },
  251. infoView: {
  252. paddingBottom: 8
  253. },
  254. infoText: {
  255. color: '#444',
  256. fontSize: 10
  257. }
  258. })