| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- /**
- * 充电弹窗组件
- * @邠心vbe on 2021/04/25
- */
- import React from "react";
- import { Image, Pressable, StyleSheet, Text, View } from "react-native";
- import Modal from "react-native-modal";
- import { ModalProps } from "../../components/BottomModal";
- import Button from "../../components/Button";
- import { Styles } from "../../components/Toolbar";
- import { PageList } from "../Router";
- import app from "../../../app.json"
- export const DialogMaxWidth = $vw(85) > 500 ? 500 : $vw(85);
- export const LoginDialog = ({onHide, onClose}) => {
- return (
- <View style={styles.dialog}>
- <Text style={styles.title}>Oops!</Text>
- <Text style={styles.message}>You need to be registered user of {app.displayName}</Text>
- <View style={styles.loginTipView}>
- <Text style={styles.tipText}>Login to use this feature</Text>
- <Image
- style={styles.tipImage}
- source={require('../../images/login-head.png')}/>
- </View>
- <Button
- textSize={17}
- style={styles.loginButton}
- viewStyle={styles.loginButtonView}
- text='Login'
- onClick={() => {
- onHide();
- startPage(PageList.login)
- }}/>
- <Pressable
- style={styles.signUpView}
- onPress={() => {
- onHide();
- startPage(PageList.register, {actionLogin: true});
- }}>
- <Text style={styles.signUpText}>Don't have an account?</Text>
- <Text style={styles.signUpLink}>Sign Up</Text>
- </Pressable>
- <Ionicons
- name='close-outline'
- size={30}
- color={'#999'}
- style={styles.closeIcon}
- onPress={onClose} />
- </View>
- );
- }
- export const ErrorDialog = ({visible, code, message, onClose}) => {
- return (
- <Modal
- isVisible={visible}
- onBackButtonPress={onClose}
- onBackdropPress={onClose}
- {...ModalProps}>
- <View style={styles.dialog}>
- <Text style={styles.title}>Oops!</Text>
- <Text style={styles.message}>{message}</Text>
- <ErrorImage code={code}/>
- <Button
- textSize={17}
- style={styles.loginButton}
- viewStyle={styles.loginButtonView}
- text='Okay'
- onClick={onClose}/>
- <Text style={{fontSize: 12}}></Text>
- <Ionicons
- name='close-outline'
- size={30}
- color={'#999'}
- style={styles.closeIcon}
- onPress={onClose} />
- </View>
- </Modal>
- );
- }
- export const LowCreditDialog = ({visible, onClose}) => {
- return (
- <Modal
- isVisible={visible}
- onBackButtonPress={onClose}
- onBackdropPress={onClose}
- {...ModalProps}>
- <View style={styles.dialog}>
- <Text style={styles.title}>Low Credits</Text>
- <Text style={styles.message}>Your credit is below S$5.</Text>
- <Text style={styles.message}>{"This charging session will end if there is insufficient credits.\n"}</Text>
- <View style={$padding(12,0)}>
- <Button
- text="Top-Up"
- onClick={() => onClose(true)}/>
- </View>
- <Ionicons
- name='close-outline'
- size={30}
- color={'#999'}
- style={styles.closeIcon}
- onPress={() => onClose(false)} />
- </View>
- </Modal>
- );
- }
- export const CancelReserveDialog = ({visible, onClose}) => {
- return (
- <Modal
- isVisible={visible}
- onBackButtonPress={onClose}
- onBackdropPress={onClose}
- {...ModalProps}>
- <View style={styles.dialog}>
- <Text style={styles.title}>Cancel</Text>
- <Text style={styles.message}>Are you sure you want to cancel the reservation?</Text>
- <View style={styles.loginTipView}>
- <Text style={styles.tipText}></Text>
- <Image
- style={styles.tipImage}
- source={require('../../images/login-head.png')}/>
- </View>
- <View style={ui.flex}>
- <Button
- textSize={17}
- style={ui.flex1}
- text='Confirm'
- onClick={() => onClose(true)}/>
- <Button
- textSize={17}
- style={styles.cancelCloseBtn}
- text='Close'
- onClick={() => onClose(false)}/>
- </View>
- <Pressable
- style={styles.closeIcon}
- android_ripple={rippleLess}
- onPress={() => onClose(false)}>
- <Ionicons
- name='close-outline'
- size={30}
- color={'#999'} />
- </Pressable>
- </View>
- </Modal>
- );
- }
- export const RegisterDialog = ({address, onClose}) => {
- return (
- <View style={styles.dialog}>
- <View style={ui.center}>
- <Text style={styles.regTitleText}>Thank you for registering with</Text>
- <Image
- source={require('../../images/app-logo.png')}
- style={Styles.logo}
- />
- <Text style={styles.regMessageText}>a confirmation email has been sent to</Text>
- <Text style={styles.regMessageLink}>{address}</Text>
- </View>
- <View style={$padding(12,0)}>
- <Button
- text="Back to Login"
- onClick={onClose}/>
- </View>
- <Ionicons
- name='close-outline'
- size={30}
- color={'#999'}
- style={styles.closeIcon}
- onPress={onClose} />
- </View>
- );
- }
- const ErrorImage = ({code}) => {
- switch (code) {
- case 'A1':
- return (
- <Image
- style={styles.errorImage}
- source={require('../../images/site/error-A1.jpg')}/>
- );
- case 'A4':
- return (
- <Image
- style={styles.errorImage}
- source={require('../../images/site/error-A4.jpg')}/>
- );
- case 'A5':
- return (
- <Image
- style={styles.errorImage}
- source={require('../../images/site/error-A5.jpg')}/>
- );
- case 'A9':
- return (
- <Image
- style={styles.errorImage}
- source={require('../../images/site/error-A9.jpg')}/>
- );
- default:
- return (
- <Image
- style={styles.errorImage}
- source={require('../../images/site/error-A9.jpg')}/>
- );
- }
- }
- const styles = StyleSheet.create({
- dialog: {
- width: DialogMaxWidth,
- paddingTop: 16,
- paddingLeft: 20,
- paddingRight: 20,
- paddingBottom: 16,
- marginLeft: 'auto',
- marginRight: 'auto',
- borderRadius: isIOS ? 20 : 3,
- backgroundColor: 'white'
- },
- title: {
- color: '#000',
- fontSize: 24,
- textAlign: "center"
- },
- message: {
- zIndex: 2,
- color: '#333',
- fontSize: 14,
- lineHeight: 22,
- paddingTop: 16,
- paddingLeft: 32,
- paddingRight: 32,
- paddingBottom: 2,
- textAlign: "center"
- },
- loginTipView: {
- zIndex: 1,
- marginTop: -18,
- paddingLeft: 12,
- paddingRight: 12,
- alignItems: 'flex-end',
- flexDirection: "row"
- },
- tipText: {
- flex: 1,
- color: '#999',
- fontSize: 12,
- paddingBottom: 12
- },
- tipImage: {
- width: 96.6,
- height: 83.4
- },
- loginButton: {
- marginTop: -2,
- borderRadius: 10
- },
- loginButtonView: {
- flex: 1,
- height: 54,
- alignItems: 'center',
- justifyContent: 'center'
- },
- signUpView: {
- color: '#333',
- paddingTop: 16,
- flexDirection: "row",
- alignItems: "center",
- justifyContent: "center"
- },
- signUpText: {
- color: '#333',
- fontSize: 12
- },
- signUpLink: {
- fontSize: 12,
- padding: 8,
- ...ui.link,
- textDecorationLine: "underline"
- },
- closeIcon: {
- top: 12,
- right: 12,
- position: "absolute"
- },
- errorImage: {
- width: DialogMaxWidth,
- height: DialogMaxWidth * 0.2,
- marginTop: 4,
- marginLeft: -20
- },
- regTitleText: {
- color: '#000',
- fontSize: 20,
- ...$padding(32, 0, 16),
- textAlign: 'center'
- },
- regMessageText: {
- color: '#000',
- fontSize: 14,
- paddingTop: 24,
- lineHeight: 20
- },
- regMessageLink: {
- ...ui.link,
- fontSize: 14,
- paddingBottom: 16
- },
- cancelCloseBtn: {
- flex: 1,
- marginLeft: 16,
- backgroundColor: '#ddd'
- }
- })
|