Last active
October 19, 2024 20:55
-
-
Save IgorMing/e53c3f2088720e27cb9937fc747ea9e4 to your computer and use it in GitHub Desktop.
Barcode Scanner on React Native (with expo), stylized with opaque edges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { StyleSheet, Text, View } from 'react-native'; | |
import { BarCodeScanner } from 'expo'; | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<BarCodeScanner | |
onBarCodeRead={(scan) => alert(scan.data)} | |
style={[StyleSheet.absoluteFill, styles.container]} | |
> | |
<View style={styles.layerTop} /> | |
<View style={styles.layerCenter}> | |
<View style={styles.layerLeft} /> | |
<View style={styles.focused} /> | |
<View style={styles.layerRight} /> | |
</View> | |
<View style={styles.layerBottom} /> | |
</BarCodeScanner> | |
); | |
} | |
} | |
const opacity = 'rgba(0, 0, 0, .6)'; | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
flexDirection: 'column' | |
}, | |
layerTop: { | |
flex: 2, | |
backgroundColor: opacity | |
}, | |
layerCenter: { | |
flex: 1, | |
flexDirection: 'row' | |
}, | |
layerLeft: { | |
flex: 1, | |
backgroundColor: opacity | |
}, | |
focused: { | |
flex: 10 | |
}, | |
layerRight: { | |
flex: 1, | |
backgroundColor: opacity | |
}, | |
layerBottom: { | |
flex: 2, | |
backgroundColor: opacity | |
}, | |
}); |
Thanks a bunch
Thank you so much!
For what 'width'?
Thanks.
"some border-radius on focused" ???
thank you!
For what 'width'?
I just removed it, thank you!
thank you!
How can I modify it for a square instead of rectangle?
thanks, I had a custom: https://github.com/LuuCongQuangVu/snappy-ship-component/blob/master/BarCodeScanner.tsx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great, thanks