InfoDialog.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. resizeMode='contain'
  156. />
  157. <Text style={styles.regMessageText}>a confirmation email has been sent to</Text>
  158. <Text style={styles.regMessageLink}>{address}</Text>
  159. </View>
  160. <View style={$padding(12,0)}>
  161. <Button
  162. text="Back to Login"
  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. resizeMode="contain"
  196. source={require('../../images/site/error-A5.jpg')}/>
  197. );
  198. case 'A9':
  199. return (
  200. <Image
  201. style={styles.errorImage}
  202. resizeMode="contain"
  203. source={require('../../images/site/error-A9.jpg')}/>
  204. );
  205. default:
  206. return (
  207. <Image
  208. style={styles.errorImage}
  209. resizeMode="contain"
  210. source={require('../../images/site/error-A9.jpg')}/>
  211. );
  212. }
  213. }
  214. const styles = StyleSheet.create({
  215. dialog: {
  216. width: DialogMaxWidth,
  217. paddingTop: 16,
  218. paddingLeft: 20,
  219. paddingRight: 20,
  220. paddingBottom: 16,
  221. marginLeft: 'auto',
  222. marginRight: 'auto',
  223. borderRadius: isIOS ? 20 : 3,
  224. backgroundColor: colorLight
  225. },
  226. title: {
  227. color: '#000',
  228. fontSize: 24,
  229. textAlign: "center"
  230. },
  231. message: {
  232. zIndex: 2,
  233. color: textPrimary,
  234. fontSize: 14,
  235. lineHeight: 22,
  236. paddingTop: 16,
  237. paddingLeft: 32,
  238. paddingRight: 32,
  239. paddingBottom: 2,
  240. textAlign: "center"
  241. },
  242. loginTipView: {
  243. zIndex: 1,
  244. marginTop: -18,
  245. paddingLeft: 12,
  246. paddingRight: 12,
  247. alignItems: 'flex-end',
  248. flexDirection: "row"
  249. },
  250. tipText: {
  251. flex: 1,
  252. color: '#999',
  253. fontSize: 12,
  254. paddingBottom: 12
  255. },
  256. tipImage: {
  257. width: 96.6,
  258. height: 83.4
  259. },
  260. loginButton: {
  261. marginTop: -2,
  262. borderRadius: 10
  263. },
  264. loginButtonView: {
  265. flex: 1,
  266. height: 54,
  267. alignItems: 'center',
  268. justifyContent: 'center'
  269. },
  270. signUpView: {
  271. color: textPrimary,
  272. paddingTop: 16,
  273. flexDirection: "row",
  274. alignItems: "center",
  275. justifyContent: "center"
  276. },
  277. signUpText: {
  278. color: textPrimary,
  279. fontSize: 12
  280. },
  281. signUpLink: {
  282. fontSize: 12,
  283. padding: 8,
  284. ...ui.link,
  285. textDecorationLine: "underline"
  286. },
  287. closeIcon: {
  288. top: 12,
  289. right: 12,
  290. position: "absolute"
  291. },
  292. errorImage: {
  293. width: DialogMaxWidth * 0.9,
  294. height: DialogMaxWidth * 0.2,
  295. marginTop: 4,
  296. marginLeft: 2,
  297. marginBottom: -6
  298. },
  299. regTitleText: {
  300. color: '#000',
  301. fontSize: 20,
  302. ...$padding(32, 0, 16),
  303. textAlign: 'center'
  304. },
  305. regMessageText: {
  306. color: '#000',
  307. fontSize: 14,
  308. paddingTop: 24,
  309. lineHeight: 20
  310. },
  311. regMessageLink: {
  312. ...ui.link,
  313. fontSize: 14,
  314. paddingBottom: 16
  315. },
  316. cancelCloseBtn: {
  317. flex: 1,
  318. marginLeft: 16,
  319. backgroundColor: '#ddd'
  320. }
  321. })