InfoDialog.js 7.8 KB

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