From 362ddd86563f41c2f2ce6061cac7a20239330d19 Mon Sep 17 00:00:00 2001 From: KKA11010 Date: Fri, 14 Jul 2023 11:25:12 +0200 Subject: [PATCH] fix scan QR code on iOS. Fixes #7 --- src/components/Toaster.tsx | 4 ++-- src/components/nav/TopNav.tsx | 12 ------------ src/components/screens/QRScan/index.tsx | 8 +++----- src/consts/qr.ts | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/components/Toaster.tsx b/src/components/Toaster.tsx index b7ab21d2..a4556b45 100644 --- a/src/components/Toaster.tsx +++ b/src/components/Toaster.tsx @@ -2,14 +2,14 @@ import { mainColors } from '@src/styles' import { StyleSheet, Text } from 'react-native' import Animated, { FadeInUp, FadeOutUp } from 'react-native-reanimated' -export default function Toaster({ success, txt, top }: { success?: boolean, txt: string, top?: boolean }) { +export default function Toaster({ success, txt }: { success?: boolean, txt: string }) { return ( diff --git a/src/components/nav/TopNav.tsx b/src/components/nav/TopNav.tsx index c5a5f0c3..24b1fb6b 100644 --- a/src/components/nav/TopNav.tsx +++ b/src/components/nav/TopNav.tsx @@ -1,7 +1,4 @@ -import usePrompt from '@comps/hooks/Prompt' import { QRIcon } from '@comps/Icons' -import Toaster from '@comps/Toaster' -import { isIOS } from '@consts' import type { TBottomNavProps } from '@model/nav' import { useNavigation } from '@react-navigation/native' import { ThemeContext } from '@src/context/Theme' @@ -20,7 +17,6 @@ interface TTopNavProps { export default function TopNav({ screenName, withBackBtn, nav, backHandler }: TTopNavProps) { const { t } = useTranslation(['common']) const { color, highlight } = useContext(ThemeContext) - const { prompt, openPromptAutoClose } = usePrompt() const navHook = useNavigation() const handlePress = () => { if (withBackBtn) { @@ -31,13 +27,6 @@ export default function TopNav({ screenName, withBackBtn, nav, backHandler }: TT navHook.goBack() return } - if (isIOS) { - openPromptAutoClose({ - msg: t('iosQrErr', { ns: 'error' }), - ms: 4000 - }) - return - } // open QR Scan nav?.navigation.navigate('qr scan') } @@ -59,7 +48,6 @@ export default function TopNav({ screenName, withBackBtn, nav, backHandler }: TT } - {prompt.open && } ) } diff --git a/src/components/screens/QRScan/index.tsx b/src/components/screens/QRScan/index.tsx index 9f32b2cb..9ac76252 100644 --- a/src/components/screens/QRScan/index.tsx +++ b/src/components/screens/QRScan/index.tsx @@ -4,7 +4,7 @@ import usePrompt from '@comps/hooks/Prompt' import useCashuToken from '@comps/hooks/Token' import { CloseIcon, FlashlightOffIcon, ZapIcon } from '@comps/Icons' import Toaster from '@comps/Toaster' -import { QRType } from '@consts' +import { isIOS, QRType } from '@consts' import { addMint, getMintsUrls } from '@db' import { l } from '@log' import TrustMintModal from '@modal/TrustMint' @@ -118,8 +118,9 @@ export default function QRScanPage({ navigation, route }: TQRScanPageProps) { const handleBarCodeScanned = ({ type, data }: { type: string, data: string }) => { setScanned(true) + const bcType = isIOS ? 'org.iso.QRCode' : QRType // early return if barcode is not a QR - if (+type !== QRType) { + if (type !== bcType) { openPromptAutoClose({ msg: t('notQrCode') }) return } @@ -158,9 +159,6 @@ export default function QRScanPage({ navigation, route }: TQRScanPageProps) { flashMode={flash ? FlashMode.torch : FlashMode.off} style={StyleSheet.absoluteFill} ratio={'16:9'} - barCodeScannerSettings={{ - barCodeTypes: [`${QRType}`], - }} onBarCodeScanned={scanned ? undefined : handleBarCodeScanned} /> diff --git a/src/consts/qr.ts b/src/consts/qr.ts index 2d42c0a0..7c3ffd82 100644 --- a/src/consts/qr.ts +++ b/src/consts/qr.ts @@ -6,4 +6,4 @@ export const qrCodeLimits = { H: { numeric: 3057, alphanumeric: 1852, binary: 1273 } } as const -export const QRType = 256 as const \ No newline at end of file +export const QRType = '256' as const \ No newline at end of file