InfoDialog.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /**
  2. * 充电弹窗组件
  3. * @邠心vbe on 2021/04/25
  4. */
  5. import React from "react";
  6. import { Image, Pressable, StyleSheet, Text, View } from "react-native";
  7. import Modal from "react-native-modal";
  8. import { ModalProps } from "../../components/BottomModal";
  9. import Button from "../../components/Button";
  10. import { Styles } from "../../components/Toolbar";
  11. import { PageList } from "../Router";
  12. import app from "../../../app.json"
  13. import TextView from "../../components/TextView";
  14. export const DialogMaxWidth = $vw(85) > 500 ? 500 : $vw(85);
  15. export const LoginDialog = ({onHide, onClose}) => {
  16. return (
  17. <View style={styles.dialog}>
  18. <TextView style={styles.title}>{$t('charging.titleOops')}</TextView>
  19. <TextView style={styles.message}>You need to be registered user of {app.displayName}</TextView>
  20. <View style={styles.loginTipView}>
  21. <TextView style={styles.tipText}>Login to use this feature</TextView>
  22. <Image
  23. style={styles.tipImage}
  24. source={require('../../images/login-head.png')}/>
  25. </View>
  26. <Button
  27. textSize={17}
  28. style={styles.loginButton}
  29. viewStyle={styles.loginButtonView}
  30. text={$t('sign.btnLogin')}
  31. onClick={() => {
  32. onHide();
  33. startPage(PageList.login)
  34. }}/>
  35. <Pressable
  36. style={styles.signUpView}
  37. onPress={() => {
  38. onHide();
  39. startPage(PageList.register, {actionLogin: true});
  40. }}>
  41. <TextView style={styles.signUpText}>Don't have an account?</TextView>
  42. <TextView style={styles.signUpLink}>{$t('sign.btnSignUp')}</TextView>
  43. </Pressable>
  44. <Ionicons
  45. name='close-outline'
  46. size={30}
  47. color={'#999'}
  48. style={styles.closeIcon}
  49. onPress={onClose} />
  50. </View>
  51. );
  52. }
  53. export const ErrorDialog = ({visible, code, message, onClose}) => {
  54. return (
  55. <Modal
  56. isVisible={visible}
  57. onBackButtonPress={onClose}
  58. onBackdropPress={onClose}
  59. {...ModalProps}>
  60. <View style={styles.dialog}>
  61. <TextView style={styles.title}>{$t('charging.titleOops')}</TextView>
  62. <TextView style={styles.message}>{message}</TextView>
  63. <ErrorImage code={code}/>
  64. <Button
  65. textSize={17}
  66. style={styles.loginButton}
  67. viewStyle={styles.loginButtonView}
  68. text={$t('charging.btnOkay')}
  69. onClick={onClose}/>
  70. <TextView style={{fontSize: 12}}></TextView>
  71. <Ionicons
  72. name='close-outline'
  73. size={30}
  74. color={'#999'}
  75. style={styles.closeIcon}
  76. onPress={onClose} />
  77. </View>
  78. </Modal>
  79. );
  80. }
  81. export const LowCreditDialog = ({visible, onClose}) => {
  82. return (
  83. <Modal
  84. isVisible={visible}
  85. onBackButtonPress={onClose}
  86. onBackdropPress={onClose}
  87. {...ModalProps}>
  88. <View style={styles.dialog}>
  89. <TextView style={styles.title}>{$t('wallet.titleLowCredits')}</TextView>
  90. <TextView style={styles.message}>{$t('wallet.creditIsBelow5')}</TextView>
  91. <TextView style={styles.message}>{$t('wallet.tipsLowCredits')}</TextView>
  92. <View style={$padding(12,0)}>
  93. <Button
  94. text={$t('wallet.btnTop_Up')}
  95. onClick={() => onClose(true)}/>
  96. </View>
  97. <Ionicons
  98. name='close-outline'
  99. size={30}
  100. color={'#999'}
  101. style={styles.closeIcon}
  102. onPress={() => onClose(false)} />
  103. </View>
  104. </Modal>
  105. );
  106. }
  107. export const CancelReserveDialog = ({visible, onClose}) => {
  108. return (
  109. <Modal
  110. isVisible={visible}
  111. onBackButtonPress={onClose}
  112. onBackdropPress={onClose}
  113. {...ModalProps}>
  114. <View style={styles.dialog}>
  115. <TextView style={styles.title}>{$t('charging.cancleReservation')}</TextView>
  116. <TextView style={styles.message}>{$t('charging.comfirmCancleReservation')}</TextView>
  117. <View style={styles.loginTipView}>
  118. <TextView style={styles.tipText}></TextView>
  119. <Image
  120. style={styles.tipImage}
  121. source={require('../../images/login-head.png')}/>
  122. </View>
  123. <View style={ui.flex}>
  124. <Button
  125. textSize={17}
  126. style={ui.flex1}
  127. text={$t('common.confirm')}
  128. onClick={() => onClose(true)}/>
  129. <Button
  130. textSize={17}
  131. style={styles.cancelCloseBtn}
  132. text={$t('common.close')}
  133. onClick={() => onClose(false)}/>
  134. </View>
  135. <Pressable
  136. style={styles.closeIcon}
  137. android_ripple={rippleLess}
  138. onPress={() => onClose(false)}>
  139. <Ionicons
  140. name='close-outline'
  141. size={30}
  142. color={'#999'} />
  143. </Pressable>
  144. </View>
  145. </Modal>
  146. );
  147. }
  148. export const RegisterDialog = ({address, onClose}) => {
  149. return (
  150. <View style={styles.dialog}>
  151. <View style={ui.center}>
  152. <TextView style={styles.regTitleText}>{$t('sign.thanksRegisterWith')}</TextView>
  153. <Image
  154. source={require('../../images/app-logo.png')}
  155. style={Styles.logo}
  156. resizeMode='contain'
  157. />
  158. <TextView style={styles.regMessageText}>{$t('sign.aConfirmationEmailTo')}</TextView>
  159. <TextView style={styles.regMessageLink}>{address}</TextView>
  160. </View>
  161. <View style={$padding(12,0)}>
  162. <Button
  163. text={$t('sign.back2Login')}
  164. onClick={onClose}/>
  165. </View>
  166. <Pressable
  167. style={styles.closeIcon}
  168. android_ripple={rippleLess}
  169. onPress={onClose}>
  170. <Ionicons
  171. name='close-outline'
  172. size={30}
  173. color={'#999'}/>
  174. </Pressable>
  175. </View>
  176. );
  177. }
  178. const ErrorImage = ({code}) => {
  179. switch (code) {
  180. case 'A1':
  181. return (
  182. <Image
  183. style={styles.errorImage}
  184. source={require('../../images/site/error-A1.jpg')}/>
  185. );
  186. case 'A4':
  187. return (
  188. <Image
  189. style={styles.errorImage}
  190. source={require('../../images/site/error-A4.jpg')}/>
  191. );
  192. case 'A5':
  193. return (
  194. <Image
  195. style={styles.errorImage}
  196. resizeMode="contain"
  197. source={require('../../images/site/error-A5.jpg')}/>
  198. );
  199. case 'A9':
  200. return (
  201. <Image
  202. style={styles.errorImage}
  203. resizeMode="contain"
  204. source={require('../../images/site/error-A9.jpg')}/>
  205. );
  206. case 'none':
  207. return <EndView></EndView>;
  208. default:
  209. return (
  210. <Image
  211. style={styles.errorImage}
  212. resizeMode="contain"
  213. source={require('../../images/site/error-A9.jpg')}/>
  214. );
  215. }
  216. }
  217. const styles = StyleSheet.create({
  218. dialog: {
  219. width: DialogMaxWidth,
  220. paddingTop: 16,
  221. paddingLeft: 20,
  222. paddingRight: 20,
  223. paddingBottom: 16,
  224. marginLeft: 'auto',
  225. marginRight: 'auto',
  226. borderRadius: isIOS ? 20 : 3,
  227. backgroundColor: colorLight
  228. },
  229. title: {
  230. color: '#000',
  231. fontSize: 24,
  232. textAlign: "center"
  233. },
  234. message: {
  235. zIndex: 2,
  236. color: textPrimary,
  237. fontSize: 14,
  238. lineHeight: 22,
  239. paddingTop: 16,
  240. paddingLeft: 32,
  241. paddingRight: 32,
  242. paddingBottom: 2,
  243. textAlign: "center"
  244. },
  245. loginTipView: {
  246. zIndex: 1,
  247. marginTop: -18,
  248. paddingLeft: 12,
  249. paddingRight: 12,
  250. alignItems: 'flex-end',
  251. flexDirection: "row"
  252. },
  253. tipText: {
  254. flex: 1,
  255. color: '#999',
  256. fontSize: 12,
  257. paddingBottom: 12
  258. },
  259. tipImage: {
  260. width: 96.6,
  261. height: 83.4
  262. },
  263. loginButton: {
  264. marginTop: -2,
  265. borderRadius: 10
  266. },
  267. loginButtonView: {
  268. flex: 1,
  269. height: 54,
  270. alignItems: 'center',
  271. flexDirection: 'row',
  272. justifyContent: 'center'
  273. },
  274. signUpView: {
  275. color: textPrimary,
  276. paddingTop: 16,
  277. flexDirection: "row",
  278. alignItems: "center",
  279. justifyContent: "center"
  280. },
  281. signUpText: {
  282. color: textPrimary,
  283. fontSize: 12
  284. },
  285. signUpLink: {
  286. fontSize: 12,
  287. padding: 8,
  288. ...ui.link,
  289. textDecorationLine: "underline"
  290. },
  291. closeIcon: {
  292. top: 12,
  293. right: 12,
  294. position: "absolute"
  295. },
  296. errorImage: {
  297. width: DialogMaxWidth * 0.9,
  298. height: DialogMaxWidth * 0.2,
  299. marginTop: 4,
  300. marginLeft: 2,
  301. marginBottom: -6
  302. },
  303. regTitleText: {
  304. color: '#000',
  305. fontSize: 20,
  306. ...$padding(32, 0, 16),
  307. textAlign: 'center'
  308. },
  309. regMessageText: {
  310. color: '#000',
  311. fontSize: 14,
  312. paddingTop: 24,
  313. lineHeight: 20
  314. },
  315. regMessageLink: {
  316. ...ui.link,
  317. fontSize: 14,
  318. paddingBottom: 16
  319. },
  320. cancelCloseBtn: {
  321. flex: 1,
  322. marginLeft: 16,
  323. backgroundColor: '#ddd'
  324. }
  325. })