InfoDialog.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 { BackButton, 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, message, onClose}) => {
  82. return (
  83. <Modal
  84. isVisible={visible}
  85. onBackButtonPress={() => onClose(false)}
  86. onBackdropPress={() => onClose(false)}
  87. {...ModalProps}>
  88. <View style={styles.dialog}>
  89. <TextView style={styles.title}>{$t('wallet.titleLowCredits')}</TextView>
  90. <TextView style={styles.message}>{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. <BackButton
  98. style={styles.closeIcon}
  99. onPress={() => onClose(false)}>
  100. <Ionicons
  101. name='close-outline'
  102. size={30}
  103. color={'#999'}/>
  104. </BackButton>
  105. </View>
  106. </Modal>
  107. );
  108. }
  109. export const CancelReserveDialog = ({visible, onClose}) => {
  110. return (
  111. <Modal
  112. isVisible={visible}
  113. onBackButtonPress={() => onClose(false)}
  114. onBackdropPress={() => onClose(false)}
  115. {...ModalProps}>
  116. <View style={styles.dialog}>
  117. <TextView style={styles.title}>{$t('charging.cancelReservation')}</TextView>
  118. <TextView style={styles.message}>{$t('charging.confirmCancelReservation')}</TextView>
  119. <View style={styles.loginTipView}>
  120. <TextView style={styles.tipText}></TextView>
  121. <Image
  122. style={styles.tipImage}
  123. source={require('../../images/login-head.png')}/>
  124. </View>
  125. <View style={ui.flex}>
  126. <Button
  127. textSize={17}
  128. style={ui.flex1}
  129. text={$t('common.confirm')}
  130. onClick={() => onClose(true)}/>
  131. <Button
  132. textSize={17}
  133. style={styles.cancelCloseBtn}
  134. text={$t('common.close')}
  135. onClick={() => onClose(false)}/>
  136. </View>
  137. <Pressable
  138. style={styles.closeIcon}
  139. android_ripple={rippleLess}
  140. onPress={() => onClose(false)}>
  141. <Ionicons
  142. name='close-outline'
  143. size={30}
  144. color={'#999'} />
  145. </Pressable>
  146. </View>
  147. </Modal>
  148. );
  149. }
  150. export const RegisterDialog = ({address, onClose}) => {
  151. return (
  152. <View style={styles.dialog}>
  153. <View style={ui.center}>
  154. <TextView style={styles.regTitleText}>{$t('sign.thanksRegisterWith')}</TextView>
  155. <Image
  156. source={require('../../images/app-logo.png')}
  157. style={Styles.logo}
  158. resizeMode='contain'
  159. />
  160. <TextView style={styles.regMessageText}>{$t('sign.aConfirmationEmailTo')}</TextView>
  161. <TextView style={styles.regMessageLink}>{address}</TextView>
  162. </View>
  163. <View style={$padding(12,0)}>
  164. <Button
  165. text={$t('sign.back2Login')}
  166. onClick={onClose}/>
  167. </View>
  168. <Pressable
  169. style={styles.closeIcon}
  170. android_ripple={rippleLess}
  171. onPress={onClose}>
  172. <Ionicons
  173. name='close-outline'
  174. size={30}
  175. color={'#999'}/>
  176. </Pressable>
  177. </View>
  178. );
  179. }
  180. const ErrorImage = ({code}) => {
  181. switch (code) {
  182. case 'A1':
  183. return (
  184. <Image
  185. style={styles.errorImage}
  186. source={require('../../images/site/error-A1.jpg')}/>
  187. );
  188. case 'A4':
  189. return (
  190. <Image
  191. style={styles.errorImage}
  192. source={require('../../images/site/error-A4.jpg')}/>
  193. );
  194. case 'A5':
  195. return (
  196. <Image
  197. style={styles.errorImage}
  198. resizeMode="contain"
  199. source={require('../../images/site/error-A5.jpg')}/>
  200. );
  201. case 'A9':
  202. return (
  203. <Image
  204. style={styles.errorImage}
  205. resizeMode="contain"
  206. source={require('../../images/site/error-A9.jpg')}/>
  207. );
  208. case 'none':
  209. return <EndView></EndView>;
  210. default:
  211. return (
  212. <Image
  213. style={styles.errorImage}
  214. resizeMode="contain"
  215. source={require('../../images/site/error-A9.jpg')}/>
  216. );
  217. }
  218. }
  219. const styles = StyleSheet.create({
  220. dialog: {
  221. width: DialogMaxWidth,
  222. paddingTop: 16,
  223. paddingLeft: 20,
  224. paddingRight: 20,
  225. paddingBottom: 16,
  226. marginLeft: 'auto',
  227. marginRight: 'auto',
  228. borderRadius: isIOS ? 20 : 3,
  229. backgroundColor: colorLight
  230. },
  231. title: {
  232. color: '#000',
  233. fontSize: 20,
  234. textAlign: "center"
  235. },
  236. message: {
  237. zIndex: 2,
  238. color: textPrimary,
  239. fontSize: 14,
  240. lineHeight: 22,
  241. paddingTop: 16,
  242. paddingLeft: 32,
  243. paddingRight: 32,
  244. paddingBottom: 2,
  245. textAlign: "center"
  246. },
  247. loginTipView: {
  248. zIndex: 1,
  249. marginTop: -18,
  250. paddingLeft: 12,
  251. paddingRight: 12,
  252. alignItems: 'flex-end',
  253. flexDirection: "row"
  254. },
  255. tipText: {
  256. flex: 1,
  257. color: '#999',
  258. fontSize: 12,
  259. paddingBottom: 12
  260. },
  261. tipImage: {
  262. width: 96.6,
  263. height: 83.4
  264. },
  265. loginButton: {
  266. marginTop: -2,
  267. borderRadius: 10
  268. },
  269. loginButtonView: {
  270. flex: 1,
  271. height: 54,
  272. alignItems: 'center',
  273. flexDirection: 'row',
  274. justifyContent: 'center'
  275. },
  276. signUpView: {
  277. color: textPrimary,
  278. paddingTop: 16,
  279. flexDirection: "row",
  280. alignItems: "center",
  281. justifyContent: "center"
  282. },
  283. signUpText: {
  284. color: textPrimary,
  285. fontSize: 12
  286. },
  287. signUpLink: {
  288. fontSize: 12,
  289. padding: 8,
  290. ...ui.link,
  291. textDecorationLine: "underline"
  292. },
  293. closeIcon: {
  294. top: 12,
  295. right: 12,
  296. position: "absolute"
  297. },
  298. errorImage: {
  299. width: DialogMaxWidth * 0.9,
  300. height: DialogMaxWidth * 0.2,
  301. marginTop: 4,
  302. marginLeft: 2,
  303. marginBottom: -6
  304. },
  305. regTitleText: {
  306. color: '#000',
  307. fontSize: 20,
  308. ...$padding(32, 0, 16),
  309. textAlign: 'center'
  310. },
  311. regMessageText: {
  312. color: '#000',
  313. fontSize: 14,
  314. paddingTop: 24,
  315. lineHeight: 20
  316. },
  317. regMessageLink: {
  318. ...ui.link,
  319. fontSize: 14,
  320. paddingBottom: 16
  321. },
  322. cancelCloseBtn: {
  323. flex: 1,
  324. marginLeft: 16,
  325. backgroundColor: '#ddd'
  326. }
  327. })