Skip to content

Commit

Permalink
[Wallet] Limit QR code scanner to 1 code per second (#1676)
Browse files Browse the repository at this point in the history
* Limit QR code scanner to 1 code per second
* Disable Dark mode for iOS
  • Loading branch information
i1skn authored Nov 13, 2019
1 parent b2761bb commit ca40512
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
11 changes: 4 additions & 7 deletions packages/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -491,22 +491,19 @@ DEPENDENCIES:
- Yoga (from `../../../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
https://cdn.cocoapods.org/:
https://github.com/cocoapods/specs.git:
- Analytics
- boost-for-react-native
- Fabric
- Firebase
- FirebaseCore
- FirebaseInstanceID
- GoogleUtilities
https://github.com/cocoapods/specs.git:
- Crashlytics
- Fabric
- Firebase
- FirebaseAnalytics
- FirebaseAnalyticsInterop
- FirebaseAuth
- FirebaseAuthInterop
- FirebaseCore
- FirebaseDatabase
- FirebaseInstanceID
- FirebaseMessaging
- FirebaseStorage
- GoogleAppMeasurement
Expand Down
2 changes: 2 additions & 0 deletions packages/mobile/ios/celo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
31 changes: 28 additions & 3 deletions packages/mobile/src/qrcode/QRScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,50 @@ interface DispatchProps {
handleBarcodeDetected: typeof handleBarcodeDetected
}

interface State {
isScanningEnabled: boolean
}

type Props = DispatchProps & WithNamespaces & NavigationFocusInjectedProps

class QRScanner extends React.Component<Props> {
class QRScanner extends React.Component<Props, State> {
static navigationOptions = () => ({
...headerWithBackButton,
headerTitle: i18n.t('sendFlow7:scanCode'),
})

timeout: undefined | number = undefined

state = {
isScanningEnabled: true,
}

camera: RNCamera | null = null

// This method would be called multiple times with the same
// QR code, so we need to catch only the first one
onBardCodeDetected = (rawData: any) => {
Logger.debug('QRScanner', 'Bar code detected')
this.props.handleBarcodeDetected(rawData)
if (this.state.isScanningEnabled) {
this.setState({ isScanningEnabled: false }, () => {
Logger.debug('QRScanner', 'Bar code detected')
this.props.handleBarcodeDetected(rawData)
})
this.timeout = setTimeout(() => {
this.setState({ isScanningEnabled: true })
}, 1000)
}
}

onPressShowYourCode = () => {
navigate(Screens.QRCode)
}

componentWillUnmount() {
if (this.timeout) {
clearTimeout(this.timeout)
}
}

render() {
const { t } = this.props
return (
Expand Down

0 comments on commit ca40512

Please sign in to comment.