StepStart.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. /**
  2. * 新充电流程:充电前的模块
  3. * @邠心vbe on 2023/06/20
  4. */
  5. import React from 'react';
  6. import { View, Image, StyleSheet, ScrollView, Pressable } from 'react-native';
  7. import app from '../../../app.json';
  8. import Button, { ElevationObject } from '../../components/Button';
  9. import TextView from '../../components/TextView';
  10. import { ChargeStyle } from '../chargeV2/Charging';
  11. import { PaymentList } from '../chargeV2/Payment';
  12. import DiscountView from './DiscountView';
  13. import PaymentListV2 from '../chargeV2/PaymentListV2';
  14. import PagerUtil from '../chargeV2/PagerUtil';
  15. import utils from '../../utils/utils';
  16. export default StepStart = ({
  17. connectorInfo={},
  18. currentPayment,
  19. onPaymentMethodChanged,
  20. onAuthenticate,
  21. selectedVoucher={}
  22. }) => {
  23. return (
  24. <ScrollView
  25. style={ui.flex1}
  26. contentContainerStyle={$padding(16)}>
  27. <View style={ui.center}>
  28. <Image
  29. style={styles.stepImage}
  30. resizeMode="contain"
  31. source={require('../../images/site/charging-status-unknow.png')}/>
  32. <TextView style={styles.stepTitle}>{$t('charging.stepInsertConnector')}</TextView>
  33. <TextView style={styles.stepDesc}>{$t('charging.stepInsertConnectorDesc')}</TextView>
  34. </View>
  35. <View style={styles.infoRow}>
  36. <View style={styles.infoCard}>
  37. <TextView style={styles.infoTitle}>{$t('charging.labelType')}</TextView>
  38. <TextView
  39. numberOfLines={1}
  40. ellipsizeMode="tail"
  41. style={styles.infoText}>{connectorInfo.chargeType}{connectorInfo.wattage || "AC22"}</TextView>
  42. <TextView style={styles.infoDesc}></TextView>
  43. </View>
  44. <View style={styles.infoCard}>
  45. <TextView style={styles.infoTitle}>{$t('charging.labelPower')}</TextView>
  46. <TextView
  47. numberOfLines={1}
  48. ellipsizeMode="tail"
  49. style={styles.infoText}>{connectorInfo.wattage || "0"} kW{/*connectorInfo.rateType*/}</TextView>
  50. <TextView style={styles.infoDesc}></TextView>
  51. </View>
  52. </View>
  53. <View style={styles.infoRow}>
  54. <View style={styles.infoCard}>
  55. <DiscountView visible={connectorInfo.hasDiscount}/>
  56. <TextView style={styles.infoTitle}>{$t('charging.labelRate')}</TextView>
  57. {/* <Text
  58. numberOfLines={1}
  59. ellipsizeMode="tail"
  60. style={styles.infoText}>{connectorInfo.rate || "0.00"}/{connectorInfo.rateType || "kWh"}</Text> */}
  61. <TextView
  62. numberOfLines={2}
  63. ellipsizeMode="tail"
  64. style={styles.infoText}>{connectorInfo.rates || "S$0.00/kWh"}</TextView>
  65. {(app.modules.nationally && connectorInfo.rates != connectorInfo.userRates) && (
  66. <TextView
  67. numberOfLines={1}
  68. ellipsizeMode="tail"
  69. style={styles.infoDesc}>({connectorInfo.userRates || "S$0.00/kWh"})</TextView>)
  70. }
  71. </View>
  72. <View style={styles.infoCard}>
  73. <TextView style={styles.infoTitle}>{$t('charging.labelStatus')}</TextView>
  74. <TextView
  75. style={[ChargeStyle.statusAuthenticated, styles.infoStatus]}>
  76. {$t('charging.statusAvailable')}
  77. </TextView>
  78. </View>
  79. </View>
  80. <EndView/>
  81. <EndView half/>
  82. <View style={ui.flexc}>
  83. <TextView style={[styles.label, ui.flex1]}>{$t('charging.paymentMethod')}</TextView>
  84. { app.v3.vouchers &&
  85. <TextView style={[styles.label, {flex: 1, paddingLeft: 16}]}>{$t('voucher.vouchers')}</TextView>
  86. }
  87. </View>
  88. <View style={ui.flexc}>
  89. <View style={ui.flex1}>
  90. { app.charge.paymentMethod
  91. ? <PaymentListV2
  92. payType={currentPayment}
  93. chargeBoxId={connectorInfo.chargeBoxId}
  94. onMethodChange={onPaymentMethodChanged}/>
  95. : <PaymentList
  96. payType={currentPayment}
  97. onMethodChange={onPaymentMethodChanged}/>
  98. }
  99. </View>
  100. { app.v3.vouchers &&
  101. <Pressable
  102. style={styles.voucherLayout}
  103. onPress={() => PagerUtil.toSelectVoucher()}>
  104. <MaterialCommunityIcons
  105. name="ticket-percent"
  106. size={35}
  107. color={colorAccent}/>
  108. { utils.isNotEmpty(selectedVoucher.userVoucherId)
  109. ? <View style={styles.vouchersView}>
  110. <TextView
  111. style={styles.voucherName}
  112. numberOfLines={1}>
  113. {selectedVoucher.voucherName}
  114. </TextView>
  115. <TextView
  116. style={styles.voucherDesc}
  117. numberOfLines={1}>
  118. {selectedVoucher.voucherDesc}
  119. </TextView>
  120. </View>
  121. : <View style={styles.vouchersView}>
  122. <TextView style={styles.selectText}>{$t("voucher.selectVoucher")}</TextView>
  123. </View>
  124. }
  125. <FontAwesome6
  126. name={"angle-right"}
  127. size={16}
  128. color={colorCancel}
  129. />
  130. </Pressable>
  131. }
  132. </View>
  133. <Button
  134. style={styles.buttonView}
  135. text={$t('charging.btnAuthenticate')}
  136. elevation={1.5}
  137. borderRadius={6}
  138. onClick={onAuthenticate}/>
  139. </ScrollView>
  140. );
  141. }
  142. const styles = StyleSheet.create({
  143. stepImage: {
  144. width: $vw(70),
  145. height: $vw(16),
  146. margin: 16
  147. },
  148. stepTitle: {
  149. fontSize: 24,
  150. fontWeight: 'bold',
  151. color: colorAccent
  152. },
  153. stepDesc: {
  154. color: textPrimary,
  155. fontSize: 16,
  156. textAlign: 'center',
  157. ...$padding(0, 32, 48)
  158. },
  159. infoRow: {
  160. marginLeft: 16,
  161. marginBottom: 16,
  162. flexDirection: 'row'
  163. },
  164. infoCard: {
  165. flex: 1,
  166. paddingTop: 12,
  167. paddingBottom: 12,
  168. borderRadius: 10,
  169. marginRight: 16,
  170. overflow: 'hidden',
  171. alignItems: 'center',
  172. ...ElevationObject(5),
  173. backgroundColor: colorLight,
  174. },
  175. infoTitle: {
  176. color: textPrimary,
  177. fontSize: 12,
  178. paddingTop: 1
  179. },
  180. infoText: {
  181. color: textPrimary,
  182. fontSize: 15,
  183. textAlign: 'center',
  184. fontWeight: 'bold',
  185. ...$padding(12, 6)
  186. },
  187. infoDesc: {
  188. color: textPrimary,
  189. fontSize: 12,
  190. marginTop: -12,
  191. paddingBottom: 8
  192. },
  193. infoStatus: {
  194. fontSize: 16,
  195. fontWeight: 'bold',
  196. ...$padding(16, 8)
  197. },
  198. label: {
  199. color: '#000',
  200. fontSize: 14,
  201. fontWeight: 'bold',
  202. paddingTop: 16,
  203. paddingBottom: 8
  204. },
  205. buttonView: {
  206. marginTop: 8,
  207. marginBottom: 16
  208. },
  209. voucherLayout: {
  210. flex: 1,
  211. padding: 12,
  212. maxWidth: $vw(50) - 24,
  213. borderRadius: 10,
  214. marginLeft: 16,
  215. marginBottom: 12,
  216. alignItems: 'center',
  217. flexDirection: 'row',
  218. ...ElevationObject(5),
  219. backgroundColor: colorLight,
  220. },
  221. vouchersView: {
  222. flex: 1,
  223. paddingLeft: 8,
  224. flexWrap: 'wrap',
  225. alignItems: 'center',
  226. flexDirection: 'row'
  227. },
  228. selectText: {
  229. flex: 1,
  230. color: textSecondary,
  231. fontSize: 15,
  232. fontWeight: 'bold'
  233. },
  234. voucherName: {
  235. color: textPrimary,
  236. fontSize: 15,
  237. paddingLeft: 8,
  238. fontWeight: 'bold'
  239. },
  240. voucherDesc: {
  241. color: textSecondary,
  242. fontSize: 12,
  243. paddingLeft: 8,
  244. paddingRight: 16
  245. }
  246. })