InfoDialog.js 8.1 KB

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