For anyone using expo camera (which is the recommended way of doing QRCode reading in 2024) and needing the same result. I tried some of the answers previously answered and based on those I was able to achieve the style.
It might be helpful.
This is the jsx component:
<View style={styles.container}>
{isCameraViewOpen ? (
<>
<CameraView
mode="video"
onBarcodeScanned={scanned ? undefined : handleBarCodeScanned}
barcodeScannerSettings={{
barcodeTypes: ["qr", "pdf417"],
}}
style={StyleSheet.absoluteFillObject}
/>
<View style={[styles.border]}>
<View style={[styles.corner, styles.topLeft]} />
<View style={[styles.corner, styles.topRight]} />
<View style={[styles.corner, styles.bottomLeft]} />
<View style={[styles.corner, styles.bottomRight]} />
</View>
{scanned && (
<Button
title={"Tap to Scan Again"}
onPress={() => setScanned(false)}
/>
)}
</>
) : (
<View>
<Text>Camera nao visível</Text>
</View>
)}
</View>
and this is the stylesheet for the component above. Make the adjustments that you might need:
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
},
corner: {
width: 60, // Adjust the width of the corner dashes
height: 60, // Adjust the height of the corner dashes
borderWidth: 2,
borderColor: "red",
position: "absolute",
borderRadius: 2,
},
topLeft: {
top: -1,
left: -1,
borderRightWidth: 0,
borderBottomWidth: 0,
},
topRight: {
top: -1,
right: -1,
borderLeftWidth: 0,
borderBottomWidth: 0,
},
bottomLeft: {
bottom: -1,
left: -1,
borderRightWidth: 0,
borderTopWidth: 0,
},
bottomRight: {
bottom: -2,
right: -1,
borderLeftWidth: 0,
borderTopWidth: 0,
},
border: {
width: 300,
height: 300,
borderWidth: 0,
borderRadius: 10,
borderColor: "blue",
position: "relative",
},
})