Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. import * as React from "react"
  2. import {Platform, Image, Text, View, KeyboardAvoidingView, Linking, PermissionsAndroid} from "react-native"
  3. import {MKButton, MKTextField} from 'react-native-material-kit'
  4. import firebase from "react-native-firebase"
  5. import {EventRegister} from "react-native-event-listeners"
  6. import {showMessage} from "react-native-flash-message"
  7. import * as shadows from "../../../theme";
  8. import {font} from "../../../theme";
  9. import Button from "../button/button";
  10. import QRCode from 'react-native-qrcode-svg';
  11. import modelUser from "../../../models/modelUser/modelUser";
  12. import modelPartner from "../../../models/modelPartner/modelPartner";
  13. import {logMessage} from "../../../services/logging";
  14. import { RNCamera } from 'react-native-camera';
  15.  
  16.  
  17. const style = require("./style");
  18. let idFire;
  19. let userObj = {};
  20.  
  21. export interface ShareDialogProps {
  22. userObj: object,
  23. modelType: string,
  24. currentId: string,
  25. currentUpdatedIdIsValid: boolean,
  26. hideShareDialog: any
  27. }
  28.  
  29. let updatedId = "";
  30.  
  31. let appName = "getintro.app/";
  32. let modelType = "";
  33. let toggleCamera = false;
  34.  
  35. export function ShareDialog(props: ShareDialogProps) {
  36. // Setup dialog
  37. userObj = props.userObj;
  38. idFire = props.userObj.idFire;
  39. modelType = props.modelType;
  40. logMessage("props.currentId: " + props.currentId);
  41.  
  42. if (props.currentId !== undefined && props.currentId.length > 0) {
  43. updatedId = props.currentId
  44. } else if ("firstName" in props.userObj && "lastName" in props.userObj) {
  45. // Generate Id as no Id already
  46. let firstIdToTest = props.userObj.firstName.toLowerCase() + props.userObj.lastName.toLowerCase();
  47. updatedId = firstIdToTest;
  48. }
  49.  
  50. function cancelUpdates() {
  51. props.hideShareDialog()
  52. }
  53.  
  54. function activateCamera(){
  55. toggleCamera = true;
  56. logMessage(toggleCamera);
  57. }
  58.  
  59. function disableCamera(){
  60. toggleCamera = false;
  61. logMessage(toggleCamera);
  62. }
  63.  
  64. return (
  65. <KeyboardAvoidingView behavior={(Platform.OS === 'ios') ? "padding" : null}
  66. style={style.shareDialogContainerOuter}>
  67. <View style={[style.shareDialogContainer, shadows.shadowLarge]}>
  68. {toggleCamera === false ?
  69. <View style={style.shareDialogContainerInner}>
  70. <View style={style.shareDialogContentContainer}>
  71. <Image
  72. style={style.shareDialogImage}
  73. source={require("Intro/src/images/im_qr.png")}
  74. />
  75. <Text style={style.shareDialogHeader}>Share Your Profile</Text>
  76. <Text style={style.shareDialogTextBody}>No app? No problem. Get your new mate to scan your
  77. QR
  78. code with their camera app and they'll get all your details, instantly.</Text>
  79. </View>
  80.  
  81. <View style={[style.shareDialogBoxContainerOuter, shadows.shadowStandard]}>
  82. <View style={style.shareDialogBoxContainerInner}>
  83. <View style={style.shareDialogBoxQr}>
  84. <QRCode
  85. value={"https://getintro.app/p/" + userObj.id}
  86. size={140}
  87. logo={require("Intro/src/images/ic_logo_bw.png")}
  88. logoSize={25}
  89. logoMargin={3}
  90. />
  91. </View>
  92. <Text style={style.shareDialogTextBody}>{appName + props.currentId}</Text>
  93.  
  94. <Button
  95. type="material"
  96. text={"Scan Intro QR Code"}
  97. onPress={() => activateCamera()}
  98. iconLeft={require("Intro/src/images/ic_camera.png")}
  99. />
  100.  
  101. </View>
  102. </View>
  103.  
  104. {/*<View style={style.shareDialogLinkContainer}>*/}
  105. {/*<View style={style.shareDialogIconContainerOuter}>*/}
  106. {/* {props.currentUpdatedIdIsValid ?*/}
  107. {/* <View style={[style.shareDialogIconContainerInner, style.shareDialogIconContainerInnerValid]}>*/}
  108. {/* <Image pointerEvents="none" style={style.shareDialogIcon} source={require("Intro/src/images/ic_user.png")} />*/}
  109. {/* </View>*/}
  110. {/* :*/}
  111. {/* <View style={style.shareDialogIconContainerInner}>*/}
  112. {/* <Image pointerEvents="none" style={style.shareDialogIcon} source={require("Intro/src/images/ic_user.png")} />*/}
  113. {/* </View>*/}
  114. {/* }*/}
  115. {/*</View>*/}
  116.  
  117. </View>
  118.  
  119. :
  120. <View style={style.shareDialogContainer}>
  121. <RNCamera
  122. ref={ref => {
  123. this.camera = ref;
  124. }}
  125. style={{
  126. flex: 1,
  127. width: '100%',
  128. }}
  129. >
  130. </RNCamera>
  131. </View>
  132. }
  133. <View style={style.shareDialogButtonCancel}>
  134. <Button
  135. type="materialIconSecondary"
  136. icon={require("Intro/src/images/ic_cross.png")}
  137. onPress={() => cancelUpdates()}
  138. />
  139. </View>
  140.  
  141. </View>
  142. </KeyboardAvoidingView>
  143. )
  144.  
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement