diff --git a/FantomWallet/app.json b/FantomWallet/app.json index 7891ddaa..1fb1cd6a 100644 --- a/FantomWallet/app.json +++ b/FantomWallet/app.json @@ -1,5 +1,4 @@ { "name": "FantomWallet", - "displayName": "FantomWallet", - "expo": { "sdkVersion": "26.0.0" } + "displayName": "FantomWallet" } \ No newline at end of file diff --git a/FantomWallet/src/components/QRCodeGenerator/__snapshots__/index.test.js.snap b/FantomWallet/src/components/QRCode/QRCodeGenerator/__snapshots__/index.test.js.snap similarity index 100% rename from FantomWallet/src/components/QRCodeGenerator/__snapshots__/index.test.js.snap rename to FantomWallet/src/components/QRCode/QRCodeGenerator/__snapshots__/index.test.js.snap diff --git a/FantomWallet/src/components/QRCode/QRCodeGenerator/index.js b/FantomWallet/src/components/QRCode/QRCodeGenerator/index.js new file mode 100644 index 00000000..fb8ac40b --- /dev/null +++ b/FantomWallet/src/components/QRCode/QRCodeGenerator/index.js @@ -0,0 +1,37 @@ +// @flow +import React from 'react'; +import { View, Text, ActivityIndicator, Dimensions } from 'react-native'; + +import QRCodeWithLogo from '~/components/QRCode/QRCodeWithLogo'; + +import styles from './styles'; + +export const DEVICE_WIDTH = Dimensions.get('window').width; +export const DEVICE_HEIGHT = Dimensions.get('window').height; + +type Props = { + qrLink: ?string, + titleText: string, +}; + +const QRGenerator = ({ qrLink, titleText }: Props) => { + const renderLoader = (color: string = "#FFF") => ( + + + + ); + + return ( + + {/* Top heading */} + + {titleText} + + + {qrLink ? : renderLoader()} + + + ); +}; + +export default QRGenerator; diff --git a/FantomWallet/src/components/QRCodeGenerator/index.test.js b/FantomWallet/src/components/QRCode/QRCodeGenerator/index.test.js similarity index 100% rename from FantomWallet/src/components/QRCodeGenerator/index.test.js rename to FantomWallet/src/components/QRCode/QRCodeGenerator/index.test.js diff --git a/FantomWallet/src/components/QRCodeGenerator/styles.js b/FantomWallet/src/components/QRCode/QRCodeGenerator/styles.js similarity index 100% rename from FantomWallet/src/components/QRCodeGenerator/styles.js rename to FantomWallet/src/components/QRCode/QRCodeGenerator/styles.js diff --git a/FantomWallet/src/components/QRCode/QRCodeSave/index.js b/FantomWallet/src/components/QRCode/QRCodeSave/index.js new file mode 100644 index 00000000..13738c14 --- /dev/null +++ b/FantomWallet/src/components/QRCode/QRCodeSave/index.js @@ -0,0 +1,61 @@ +// @flow +import React, { useRef, useImperativeHandle, forwardRef } from 'react'; +import { View, Text, Alert, ActivityIndicator } from 'react-native'; +import Share from 'react-native-share'; +import ViewShot from 'react-native-view-shot'; + +import QRCodeWithLogo from '~/components/QRCode/QRCodeWithLogo'; +import styles from './styles'; + +type Props = { + content: string, + amount: string +} + +const QRCodeSave = ({ content, amount }: Props, ref: any) => { + const viewShot: any = useRef(null); + + const renderLoader = (color: string = "#FFF") => ( + + + + ); + + const save = () => { + if (!amount || amount === '0') { + Alert.alert('Error', 'Please enter billing amount.'); + return; + } + viewShot.current.capture().then(uri => { + const message = ''; + Share.open({ url: uri, title: 'Fantom', message }) + .then(() => { }) + .catch(() => { }); + }); + }; + + useImperativeHandle(ref, () => ({ + onPress: save, + })); + + return ( + + <> + {content + ? + : renderLoader('#000')} + + + Billing amount: {Math.round(Number(amount) * 10000) / 10000} FTM + + + + ); +}; + +// $FlowFixMe +export default forwardRef(QRCodeSave); \ No newline at end of file diff --git a/FantomWallet/src/components/QRCode/QRCodeSave/styles.js b/FantomWallet/src/components/QRCode/QRCodeSave/styles.js new file mode 100644 index 00000000..6a6d77e9 --- /dev/null +++ b/FantomWallet/src/components/QRCode/QRCodeSave/styles.js @@ -0,0 +1,31 @@ +import { StyleSheet, Dimensions } from 'react-native'; + +export const DEVICE_WIDTH = Dimensions.get('window').width; +export const DEVICE_HEIGHT = Dimensions.get('window').height; + +export default StyleSheet.create({ + loader: { + height: 350, + flexDirection: 'row', + alignSelf: 'center', + }, + viewShot: { + position: 'absolute', + left: -(DEVICE_WIDTH * 5), + top: -(DEVICE_HEIGHT * 5), + backgroundColor: 'white', + }, + line: { + flex: 1, + height: 2, + backgroundColor: 'rgb(50, 50, 50)', + margin: 10, + }, + textAmount: { + margin: 10, + marginTop: 0, + fontSize: 16, + fontWeight: 'bold', + width: 230, + }, +}); \ No newline at end of file diff --git a/FantomWallet/src/components/QRCodeScanner/AuthorizedView/NotAuthorizedView.js b/FantomWallet/src/components/QRCode/QRCodeScanner/AuthorizedView/NotAuthorizedView.js similarity index 100% rename from FantomWallet/src/components/QRCodeScanner/AuthorizedView/NotAuthorizedView.js rename to FantomWallet/src/components/QRCode/QRCodeScanner/AuthorizedView/NotAuthorizedView.js diff --git a/FantomWallet/src/components/QRCodeScanner/AuthorizedView/PendingAuthorizationView.js b/FantomWallet/src/components/QRCode/QRCodeScanner/AuthorizedView/PendingAuthorizationView.js similarity index 100% rename from FantomWallet/src/components/QRCodeScanner/AuthorizedView/PendingAuthorizationView.js rename to FantomWallet/src/components/QRCode/QRCodeScanner/AuthorizedView/PendingAuthorizationView.js diff --git a/FantomWallet/src/components/QRCodeScanner/index.js b/FantomWallet/src/components/QRCode/QRCodeScanner/index.js similarity index 100% rename from FantomWallet/src/components/QRCodeScanner/index.js rename to FantomWallet/src/components/QRCode/QRCodeScanner/index.js diff --git a/FantomWallet/src/components/QRCodeScanner/styles.js b/FantomWallet/src/components/QRCode/QRCodeScanner/styles.js similarity index 100% rename from FantomWallet/src/components/QRCodeScanner/styles.js rename to FantomWallet/src/components/QRCode/QRCodeScanner/styles.js diff --git a/FantomWallet/src/components/QRCodeScanner/view.js b/FantomWallet/src/components/QRCode/QRCodeScanner/view.js similarity index 100% rename from FantomWallet/src/components/QRCodeScanner/view.js rename to FantomWallet/src/components/QRCode/QRCodeScanner/view.js diff --git a/FantomWallet/src/components/QRCode/QRCodeWithLogo/index.js b/FantomWallet/src/components/QRCode/QRCodeWithLogo/index.js new file mode 100644 index 00000000..a8be2f55 --- /dev/null +++ b/FantomWallet/src/components/QRCode/QRCodeWithLogo/index.js @@ -0,0 +1,44 @@ +// @flow +import React from 'react'; +import { View, Image } from 'react-native'; +import { QRCode } from 'react-native-custom-qr-codes'; + +import FantomLogoTranparentWhite from '~/images/fantom_logo_TranparentWhite.png'; + + +const size = 250; +const logoWidth = 146; +const logoHeight = 35; +const logoConatinerStyle = { + flexDirection: 'row', + width: logoWidth, + height: logoHeight, + position: 'absolute', + left: size / 2 - logoWidth / 2, + top: size / 2 - logoHeight / 2, + padding: 15, + backgroundColor: 'rgb(14,14,18)', +}; +const logoImgStyle = { + alignSelf: 'center', + backgroundColor: 'rgb(14,14,18)', + flex: 1, + height: logoHeight, +}; + +type Props = { + content: string, +} + +export default ({ content }: Props) => ( + + + + + + +); diff --git a/FantomWallet/src/components/QRCodeGenerator/index.js b/FantomWallet/src/components/QRCodeGenerator/index.js deleted file mode 100644 index 4dffe679..00000000 --- a/FantomWallet/src/components/QRCodeGenerator/index.js +++ /dev/null @@ -1,136 +0,0 @@ -// @flow -import React, { useRef, useImperativeHandle, forwardRef } from 'react'; -import { QRCode } from 'react-native-custom-qr-codes'; -import ViewShot from 'react-native-view-shot'; -import Share from 'react-native-share'; -import { View, Image, Text, ActivityIndicator, Alert, Dimensions } from 'react-native'; -import FantomLogoTranparentWhite from '~/images/fantom_logo_TranparentWhite.png'; - -import styles from './styles'; - -export const DEVICE_WIDTH = Dimensions.get('window').width; -export const DEVICE_HEIGHT = Dimensions.get('window').height; - -type Props = { - qrLink: ?string, - titleText: string, - billingAmount: string, -}; - -const QRGenerator = ({ qrLink, titleText, billingAmount }: Props, ref) => { - let viewShot = useRef(null); - - useImperativeHandle(ref, () => ({ - onPress: () => { - if (!billingAmount || billingAmount === '0') { - Alert.alert('Error', 'Please enter billing amount.'); - return; - } - // $FlowFixMe: - viewShot.capture().then(uri => { - const message = ''; - Share.open({ url: uri, title: 'Fantom', message }) - .then(() => { }) - .catch(() => { }); - }); - }, - })); - - const renderLogo = () => { - if (qrLink) { - const size = 250; - const logoWidth = 146; - const logoHeight = 35; - const logoConatinerStyle = { - flexDirection: 'row', - width: logoWidth, - height: logoHeight, - position: 'absolute', - left: size / 2 - logoWidth / 2, - top: size / 2 - logoHeight / 2, - padding: 15, - backgroundColor: 'rgb(14,14,18)', - }; - const logoImgStyle = { - alignSelf: 'center', - backgroundColor: 'rgb(14,14,18)', - flex: 1, - height: logoHeight, - }; - return ( - - - - ); - } - return null; - }; - - const renderLoader = () => ( - - - - ); - - const renderQrCode = () => { - if (qrLink) { - // return null; - return ; - } - // If link is not present, start loader - return renderLoader(); - }; - - const updatedBillingAmount = Math.round(Number(billingAmount) * 10000) / 10000; - return ( - - {/* Top heading */} - - {titleText} - - - - {renderQrCode()} - - {/* Displays fantom log in center of QR code */} - {renderLogo()} - - - {/* For sharing */} - { - viewShot = _viewShot; - }} - options={{ format: 'jpg' }} - style={{ - position: 'absolute', - left: -(DEVICE_WIDTH * 5), - top: -(DEVICE_HEIGHT * 5), - backgroundColor: 'white', - }} - > - <> - {!!qrLink && ( - - )} - {renderLogo()} - {(qrLink === undefined || qrLink === '') && ( - - - - )} - - - Billing amount: {updatedBillingAmount} FTM - - - - - ); -}; -// $FlowFixMe -export default forwardRef(QRGenerator); diff --git a/FantomWallet/src/components/QRCodeShare/index.js b/FantomWallet/src/components/QRCodeShare/index.js deleted file mode 100644 index fcd29b43..00000000 --- a/FantomWallet/src/components/QRCodeShare/index.js +++ /dev/null @@ -1,46 +0,0 @@ -// @flow -import React, { useRef, useImperativeHandle, forwardRef } from 'react'; -import { View, Text, TouchableOpacity } from 'react-native'; -import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; - -import styles from './styles'; -import QRGenerator from '~/components/QRCodeGenerator'; - -type Props = { - qrLink: string, - billingAmount: string, - copyAddress: () => void -} -/** - * QRCodeShare: This component is meant for displaying QR code and QR address. - */ -const QRCodeShare = ({ qrLink = '', billingAmount, copyAddress }: Props, ref) => { - const _generator = useRef(null); - - useImperativeHandle(ref, () => ({ - shareQR: () => _generator.current.onPress(), - })); - return ( - - {/* QR code */} - - - - {/* Copy Address Field */} - {qrLink && qrLink !== '' && qrLink !== undefined && qrLink !== null ? ( - copyAddress()} style={styles.qrLinkViewStyle}> - - {qrLink} - - ) : null} - - ); -}; -// $FlowFixMe -export default forwardRef(QRCodeShare); - diff --git a/FantomWallet/src/components/QRCodeShare/styles.js b/FantomWallet/src/components/QRCodeShare/styles.js deleted file mode 100644 index de5449e9..00000000 --- a/FantomWallet/src/components/QRCodeShare/styles.js +++ /dev/null @@ -1,32 +0,0 @@ -import { StyleSheet } from 'react-native'; -import { DEVICE_WIDTH, DEVICE_HEIGHT } from '~/common/constants/index'; - -export default StyleSheet.create({ - containerViewStyle: { - flex: 1, - marginBottom: DEVICE_HEIGHT * 0.02, - }, - qrGeneratorstyle: { - marginTop: 12, - padding: 16, - marginBottom: DEVICE_HEIGHT * 0.02, - }, - // Link style - qrLinkViewStyle: { - width: DEVICE_WIDTH - 32, - padding: 12, - backgroundColor: 'rgb(32, 37, 42)', - borderRadius: 4, - flexDirection: 'row', - alignItems: 'center', - alignSelf: 'center', - justifyContent: 'center', - }, - qrLinkTextStyle: { - textAlign: 'center', - fontFamily: 'SFProDisplay-Semibold', - color: '#fff', - fontSize: 14, - paddingLeft: 5, - }, -}); diff --git a/FantomWallet/src/navigation/RootNavigator.js b/FantomWallet/src/navigation/RootNavigator.js index 2d6eb218..5ccb41d5 100644 --- a/FantomWallet/src/navigation/RootNavigator.js +++ b/FantomWallet/src/navigation/RootNavigator.js @@ -5,8 +5,8 @@ import HomeNavigator from './HomeNavigator'; import PrivacyPolicy from '~/views/Other/PrivacyPolicy'; import TermsConditions from '~/views/Other/TermsConditions'; import AddressBook from '~/views/Settings/AddressBook'; -import QRScanner from '~/components/QRCodeScanner/view'; -import QRGenerator from '~/components/QRCodeGenerator'; +import QRScanner from '~/components/QRCode/QRCodeScanner/view'; +import QRGenerator from '~/components/QRCode/QRCodeGenerator'; import EditContact from '~/views/Settings/AddressBook/EditContact'; import SendMoney from '~/views/Home/Withdraw/SendMoney'; import Settings from '~/views/Settings'; diff --git a/FantomWallet/src/views/Home/Deposit/depositViewInfo/index.js b/FantomWallet/src/views/Home/Deposit/depositViewInfo/index.js index 22167d4e..f8a98734 100644 --- a/FantomWallet/src/views/Home/Deposit/depositViewInfo/index.js +++ b/FantomWallet/src/views/Home/Deposit/depositViewInfo/index.js @@ -5,12 +5,14 @@ import React, { useState, useEffect, useRef } from 'react'; import { ScrollView, View, Text, Keyboard, Clipboard, TouchableOpacity } from 'react-native'; import { connect } from 'react-redux'; import EvilIcons from 'react-native-vector-icons/EvilIcons'; +import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; // Style import styles from './styles'; // Components -import QRCodeShare from '~/components/QRCodeShare'; -import BillingAmountScreen from '../BillingAmountView'; +import QRGenerator from '~/components/QRCode/QRCodeGenerator'; +import QRCodeSave from '~/components/QRCode/QRCodeSave'; +import BillingAmountScreen from '../BillingAmountView/index'; import { DEVICE_HEIGHT, DEVICE_WIDTH } from '~/common/constants'; type Props = { @@ -54,7 +56,7 @@ export const DepositViewInfoContainer = ({ publicKey, renderToastNotification }: }; // called on click of share button - const onShare = () => qrcode.current.shareQR(); + const onShare = () => qrcode.current.onPress(); const qrLink = qrAddress; const headerText = 'FTM'; @@ -65,12 +67,22 @@ export const DepositViewInfoContainer = ({ publicKey, renderToastNotification }: style={styles.fantomViewStyle} showsVerticalScrollIndicator={false} > - onCopyAddress()} - qrLink={qrLink} - billingAmount={amount} - /> + {/* QR code */} + + + + + {qrLink ? ( + + + {qrLink} + + ) : null}