Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as React from "react"
- import {Platform, Image, Text, View, KeyboardAvoidingView, Linking, PermissionsAndroid} from "react-native"
- import {MKButton, MKTextField} from 'react-native-material-kit'
- import firebase from "react-native-firebase"
- import {EventRegister} from "react-native-event-listeners"
- import {showMessage} from "react-native-flash-message"
- import * as shadows from "../../../theme";
- import {font} from "../../../theme";
- import Button from "../button/button";
- import QRCode from 'react-native-qrcode-svg';
- import modelUser from "../../../models/modelUser/modelUser";
- import modelPartner from "../../../models/modelPartner/modelPartner";
- import {logMessage} from "../../../services/logging";
- import { RNCamera } from 'react-native-camera';
- const style = require("./style");
- let idFire;
- let userObj = {};
- export interface ShareDialogProps {
- userObj: object,
- modelType: string,
- currentId: string,
- currentUpdatedIdIsValid: boolean,
- hideShareDialog: any
- }
- let updatedId = "";
- let appName = "getintro.app/";
- let modelType = "";
- let toggleCamera = false;
- export function ShareDialog(props: ShareDialogProps) {
- // Setup dialog
- userObj = props.userObj;
- idFire = props.userObj.idFire;
- modelType = props.modelType;
- logMessage("props.currentId: " + props.currentId);
- if (props.currentId !== undefined && props.currentId.length > 0) {
- updatedId = props.currentId
- } else if ("firstName" in props.userObj && "lastName" in props.userObj) {
- // Generate Id as no Id already
- let firstIdToTest = props.userObj.firstName.toLowerCase() + props.userObj.lastName.toLowerCase();
- updatedId = firstIdToTest;
- }
- function cancelUpdates() {
- props.hideShareDialog()
- }
- function activateCamera(){
- toggleCamera = true;
- logMessage(toggleCamera);
- }
- function disableCamera(){
- toggleCamera = false;
- logMessage(toggleCamera);
- }
- return (
- <KeyboardAvoidingView behavior={(Platform.OS === 'ios') ? "padding" : null}
- style={style.shareDialogContainerOuter}>
- <View style={[style.shareDialogContainer, shadows.shadowLarge]}>
- {toggleCamera === false ?
- <View style={style.shareDialogContainerInner}>
- <View style={style.shareDialogContentContainer}>
- <Image
- style={style.shareDialogImage}
- source={require("Intro/src/images/im_qr.png")}
- />
- <Text style={style.shareDialogHeader}>Share Your Profile</Text>
- <Text style={style.shareDialogTextBody}>No app? No problem. Get your new mate to scan your
- QR
- code with their camera app and they'll get all your details, instantly.</Text>
- </View>
- <View style={[style.shareDialogBoxContainerOuter, shadows.shadowStandard]}>
- <View style={style.shareDialogBoxContainerInner}>
- <View style={style.shareDialogBoxQr}>
- <QRCode
- value={"https://getintro.app/p/" + userObj.id}
- size={140}
- logo={require("Intro/src/images/ic_logo_bw.png")}
- logoSize={25}
- logoMargin={3}
- />
- </View>
- <Text style={style.shareDialogTextBody}>{appName + props.currentId}</Text>
- <Button
- type="material"
- text={"Scan Intro QR Code"}
- onPress={() => activateCamera()}
- iconLeft={require("Intro/src/images/ic_camera.png")}
- />
- </View>
- </View>
- {/*<View style={style.shareDialogLinkContainer}>*/}
- {/*<View style={style.shareDialogIconContainerOuter}>*/}
- {/* {props.currentUpdatedIdIsValid ?*/}
- {/* <View style={[style.shareDialogIconContainerInner, style.shareDialogIconContainerInnerValid]}>*/}
- {/* <Image pointerEvents="none" style={style.shareDialogIcon} source={require("Intro/src/images/ic_user.png")} />*/}
- {/* </View>*/}
- {/* :*/}
- {/* <View style={style.shareDialogIconContainerInner}>*/}
- {/* <Image pointerEvents="none" style={style.shareDialogIcon} source={require("Intro/src/images/ic_user.png")} />*/}
- {/* </View>*/}
- {/* }*/}
- {/*</View>*/}
- </View>
- :
- <View style={style.shareDialogContainer}>
- <RNCamera
- ref={ref => {
- this.camera = ref;
- }}
- style={{
- flex: 1,
- width: '100%',
- }}
- >
- </RNCamera>
- </View>
- }
- <View style={style.shareDialogButtonCancel}>
- <Button
- type="materialIconSecondary"
- icon={require("Intro/src/images/ic_cross.png")}
- onPress={() => cancelUpdates()}
- />
- </View>
- </View>
- </KeyboardAvoidingView>
- )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement