S
S
sobot2021-06-25 22:28:35
React Native
sobot, 2021-06-25 22:28:35

How to resize BarCodeScanner?

Please help!
There is code from the documentation:

import React, { useState, useEffect } from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';

export default function App() {
  const [hasPermission, setHasPermission] = useState(null);
  const [scanned, setScanned] = useState(false);

  useEffect(() => {
    (async () => {
      const { status } = await BarCodeScanner.requestPermissionsAsync();
      setHasPermission(status === 'granted');
    })();
  }, []);

  const handleBarCodeScanned = ({ type, data }) => {
    setScanned(true);
    alert(`Bar code with type ${type} and data ${data} has been scanned!`);
  };

  if (hasPermission === null) {
    return <Text>Requesting for camera permission</Text>;
  }
  if (hasPermission === false) {
    return <Text>No access to camera</Text>;
  }

  return (
    <View style={styles.container}>
      <BarCodeScanner
        onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
        style={StyleSheet.absoluteFillObject}
      />
      {scanned && <Button title={'Tap to Scan Again'} onPress={() => setScanned(false)} />}
    </View>
  );
}


https://docs.expo.io/versions/v41.0.0/sdk/bar-code...

There are Types BarCodeScanner.BarCodeSize:

Object of type BarCodeSize contains the following keys:
height (number) -- The height value.
width (number) -- The width value.


I don't understand how to use it ;c

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Makarov, 2021-07-05
@kirbi1996

If the props don't fork, just fork the lib

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question