InfoDialog.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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}>Oops!</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='Login'
  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}>Sign Up</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}>Oops!</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='Okay'
  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}>Low Credits</Text>
  89. <Text style={styles.message}>Your credit is below S$5.</Text>
  90. <Text style={styles.message}>{"This charging session will end if there is insufficient credits.\n"}</Text>
  91. <View style={$padding(12,0)}>
  92. <Button
  93. text="Top-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}>Cancel</Text>
  115. <Text style={styles.message}>Are you sure you want to cancel the reservation?</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='Confirm'
  127. onClick={() => onClose(true)}/>
  128. <Button
  129. textSize={17}
  130. style={styles.cancelCloseBtn}
  131. text='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}>Thank you for registering with</Text>
  152. <Image
  153. source={require('../../images/app-logo.png')}
  154. style={Styles.logo}
  155. />
  156. <Text style={styles.regMessageText}>a confirmation email has been sent to</Text>
  157. <Text style={styles.regMessageLink}>{address}</Text>
  158. </View>
  159. <View style={$padding(12,0)}>
  160. <Button
  161. text="Back to Login"
  162. onClick={onClose}/>
  163. </View>
  164. <Ionicons
  165. name='close-outline'
  166. size={30}
  167. color={'#999'}
  168. style={styles.closeIcon}
  169. onPress={onClose} />
  170. </View>
  171. );
  172. }
  173. const ErrorImage = ({code}) => {
  174. switch (code) {
  175. case 'A1':
  176. return (
  177. <Image
  178. style={styles.errorImage}
  179. source={require('../../images/site/error-A1.jpg')}/>
  180. );
  181. case 'A4':
  182. return (
  183. <Image
  184. style={styles.errorImage}
  185. source={require('../../images/site/error-A4.jpg')}/>
  186. );
  187. case 'A5':
  188. return (
  189. <Image
  190. style={styles.errorImage}
  191. source={require('../../images/site/error-A5.jpg')}/>
  192. );
  193. case 'A9':
  194. return (
  195. <Image
  196. style={styles.errorImage}
  197. source={require('../../images/site/error-A9.jpg')}/>
  198. );
  199. default:
  200. return (
  201. <Image
  202. style={styles.errorImage}
  203. source={require('../../images/site/error-A9.jpg')}/>
  204. );
  205. }
  206. }
  207. const styles = StyleSheet.create({
  208. dialog: {
  209. width: DialogMaxWidth,
  210. paddingTop: 16,
  211. paddingLeft: 20,
  212. paddingRight: 20,
  213. paddingBottom: 16,
  214. marginLeft: 'auto',
  215. marginRight: 'auto',
  216. borderRadius: isIOS ? 20 : 3,
  217. backgroundColor: 'white'
  218. },
  219. title: {
  220. color: '#000',
  221. fontSize: 24,
  222. textAlign: "center"
  223. },
  224. message: {
  225. zIndex: 2,
  226. color: '#333',
  227. fontSize: 14,
  228. lineHeight: 22,
  229. paddingTop: 16,
  230. paddingLeft: 32,
  231. paddingRight: 32,
  232. paddingBottom: 2,
  233. textAlign: "center"
  234. },
  235. loginTipView: {
  236. zIndex: 1,
  237. marginTop: -18,
  238. paddingLeft: 12,
  239. paddingRight: 12,
  240. alignItems: 'flex-end',
  241. flexDirection: "row"
  242. },
  243. tipText: {
  244. flex: 1,
  245. color: '#999',
  246. fontSize: 12,
  247. paddingBottom: 12
  248. },
  249. tipImage: {
  250. width: 96.6,
  251. height: 83.4
  252. },
  253. loginButton: {
  254. marginTop: -2,
  255. borderRadius: 10
  256. },
  257. loginButtonView: {
  258. flex: 1,
  259. height: 54,
  260. alignItems: 'center',
  261. justifyContent: 'center'
  262. },
  263. signUpView: {
  264. color: '#333',
  265. paddingTop: 16,
  266. flexDirection: "row",
  267. alignItems: "center",
  268. justifyContent: "center"
  269. },
  270. signUpText: {
  271. color: '#333',
  272. fontSize: 12
  273. },
  274. signUpLink: {
  275. fontSize: 12,
  276. padding: 8,
  277. ...ui.link,
  278. textDecorationLine: "underline"
  279. },
  280. closeIcon: {
  281. top: 12,
  282. right: 12,
  283. position: "absolute"
  284. },
  285. errorImage: {
  286. width: DialogMaxWidth,
  287. height: DialogMaxWidth * 0.2,
  288. marginTop: 4,
  289. marginLeft: -20
  290. },
  291. regTitleText: {
  292. color: '#000',
  293. fontSize: 20,
  294. ...$padding(32, 0, 16),
  295. textAlign: 'center'
  296. },
  297. regMessageText: {
  298. color: '#000',
  299. fontSize: 14,
  300. paddingTop: 24,
  301. lineHeight: 20
  302. },
  303. regMessageLink: {
  304. ...ui.link,
  305. fontSize: 14,
  306. paddingBottom: 16
  307. },
  308. cancelCloseBtn: {
  309. flex: 1,
  310. marginLeft: 16,
  311. backgroundColor: '#ddd'
  312. }
  313. })