Skip to content

Commit

Permalink
show text instead of QR code
Browse files Browse the repository at this point in the history
  • Loading branch information
gandlafbtc committed Mar 1, 2024
1 parent f743312 commit 35a7af5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
27 changes: 16 additions & 11 deletions src/components/AnimatedQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Buffer } from 'buffer'
import { useEffect, useRef, useState } from 'react'
import QRCode, { QRCodeProps } from 'react-native-qrcode-svg'

Check warning on line 5 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

'QRCode' is defined but never used

Check warning on line 5 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'QRCode' is defined but never used

Check warning on line 5 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

'QRCode' is defined but never used
import { s } from 'react-native-size-matters'

Check warning on line 6 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

's' is defined but never used

Check warning on line 6 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

's' is defined but never used

Check warning on line 6 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

's' is defined but never used
import Txt from './Txt'

export interface AnimatedQR extends QRCodeProps {
value: string;
Expand Down Expand Up @@ -34,24 +35,28 @@ export function AnimatedQR({
if (value) {
timer = setInterval(() => {
setPart(encoder.current.nextPart())
console.log(part)
}, interval)

Check warning on line 39 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement

Check warning on line 39 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 39 in src/components/AnimatedQR.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
}
return () => {
if (timer) {
clearInterval(timer)
}
}
}, [value, chunkLength, interval])
}, [value, chunkLength, interval, part])
return (
<QRCode
value={part}
size={size}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
logo={require('@assets/app-qr-icon.png')}
logoBorderRadius={10}
logoBackgroundColor={mainColors.WHITE}
logoMargin={s(6)}
onError={onError}
/>
<>
<Txt txt={part}></Txt>
</>
// <QRCode
// value={part}
// size={size}
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
// logo={require('@assets/app-qr-icon.png')}
// logoBorderRadius={10}
// logoBackgroundColor={mainColors.WHITE}
// logoMargin={s(6)}
// onError={onError}
// />
)
}
8 changes: 6 additions & 2 deletions src/components/QR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@ import { s, ScaledSheet } from 'react-native-size-matters'
import useCopy from './hooks/Copy'
import { CheckmarkIcon, CopyIcon } from './Icons'
import Txt from './Txt'
import { AnimatedQR } from './AnimatedQR'

interface QRProps {
size: number
value: string
isInvoice?: boolean
truncateNum?: number
interval?: number
onError: () => void
}

export default function QR({ size, value, isInvoice, truncateNum, onError }: QRProps) {
export default function QR({ size, value, isInvoice, truncateNum, onError,interval=100 }: QRProps) {
const { t } = useTranslation([NS.common])
const { color } = useThemeContext()
const { copied, copy } = useCopy()
const str = isInvoice ? value.toUpperCase() : value
return (
<TouchableOpacity onPress={() => void copy(str)}>
<View style={styles.qrWrap}>
<QRCode
<AnimatedQR
interval={interval}
chunkLength={100}
size={size}
value={str}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand Down
5 changes: 2 additions & 3 deletions src/screens/Payment/Send/EncodedToken.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AnimatedQR } from '@comps/AnimatedQR'
import Button from '@comps/Button'
import useCopy from '@comps/hooks/Copy'
import { CopyIcon, ShareIcon } from '@comps/Icons'
import QR from '@comps/QR'
import Txt from '@comps/Txt'
import type { TBeforeRemoveEvent, TEncodedTokenPageProps } from '@model/nav'
import TopNav from '@nav/TopNav'
Expand Down Expand Up @@ -112,9 +112,8 @@ export default function EncodedTokenPage({ navigation, route }: TEncodedTokenPag
{error.open ?
<Txt txt={error.msg} styles={[globals(color).navTxt, styles.errorMsg]} />
:
<AnimatedQR
<QR
interval={200}
chunkLength={100}
size={s(280)}
value={value}
onError={() => setError({ msg: t('bigQrMsg'), open: true })}
Expand Down

0 comments on commit 35a7af5

Please sign in to comment.