UNPKG

@darthmaim/react-native-barcode

Version:
45 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BarCode = void 0; const react_1 = require("react"); const react_native_1 = require("react-native"); const barcode_1 = require("@darthmaim/barcode"); const styles = react_native_1.StyleSheet.create({ wrapper: { height: 70, }, bar: { position: 'absolute', top: 0, width: 1, backgroundColor: '#000', }, text: { top: 60, position: 'absolute', textAlign: 'center', width: 100, marginLeft: -50, fontSize: 10, color: '#000', fontFamily: 'monospace', } }); const BarCode = ({ value, flat }) => { const encoded = (0, barcode_1.encode)(value); let left = 0; return (<react_native_1.View style={[styles.wrapper]}> {encoded.groups.map((group, groupIndex) => { const groupElement = (group.type !== 'quietZone' || group.text) && (<react_1.Fragment key={groupIndex}> {group.type !== 'quietZone' && group.data.split('').map((bar, index) => bar === '1' ? ( // eslint-disable-next-line react-native/no-inline-styles <react_native_1.View key={index} style={[styles.bar, { left: left + index, height: group.type === 'marker' && !flat ? 66 : 60 }]}/>) : null)} {group.text && (<react_native_1.Text style={[styles.text, { left: left + group.width / 2 }]}>{group.text}</react_native_1.Text>)} </react_1.Fragment>); left += group.width; return groupElement; })} </react_native_1.View>); }; exports.BarCode = BarCode; //# sourceMappingURL=index.js.map