Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface BarcodeMaskProps {
edgeColor?: string;
edgeBorderWidth?: number | string;
edgeRadius?: number;
edgeOffset?: number;
backgroundColor?: string;
outerMaskOpacity?: number;
showAnimatedLine?: boolean;
Expand Down
46 changes: 16 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
topLeftEdge: {
position: 'absolute',
top: 0,
left: 0,
},
topRightEdge: {
position: 'absolute',
top: 0,
right: 0,
},
bottomLeftEdge: {
position: 'absolute',
bottom: 0,
left: 0,
},
bottomRightEdge: {
position: 'absolute',
bottom: 0,
right: 0,
},
maskOuter: {
position: 'absolute',
top: 0,
Expand Down Expand Up @@ -123,9 +103,13 @@ class BarcodeMask extends React.Component {
};

_renderEdge = (edgePosition) => {
const { edgeWidth, edgeHeight, edgeColor, edgeBorderWidth, edgeRadius } = this.props;
const { edgeWidth, edgeHeight, edgeColor, edgeBorderWidth, edgeRadius, edgeOffset } = this.props;
const { edgeRadiusOffset } = this.state;

const offset = edgeRadiusOffset - edgeOffset;

const defaultStyle = {
position: 'absolute',
width: edgeWidth,
height: edgeHeight,
borderColor: edgeColor
Expand All @@ -135,32 +119,32 @@ class BarcodeMask extends React.Component {
borderRightWidth: edgeBorderWidth,
borderTopWidth: edgeBorderWidth,
borderTopRightRadius: edgeRadius,
top: edgeRadiusOffset,
right: edgeRadiusOffset,
top: offset,
right: offset,
},
topLeft: {
borderLeftWidth: edgeBorderWidth,
borderTopWidth: edgeBorderWidth,
borderTopLeftRadius: edgeRadius,
top: edgeRadiusOffset,
left: edgeRadiusOffset
top: offset,
left: offset
},
bottomRight: {
borderRightWidth: edgeBorderWidth,
borderBottomWidth: edgeBorderWidth,
borderBottomRightRadius: edgeRadius,
bottom: edgeRadiusOffset,
right: edgeRadiusOffset
bottom: offset,
right: offset
},
bottomLeft: {
borderLeftWidth: edgeBorderWidth,
borderBottomWidth: edgeBorderWidth,
borderBottomLeftRadius: edgeRadius,
bottom: edgeRadiusOffset,
left: edgeRadiusOffset,
bottom: offset,
left: offset,
},
};
return <View style={[defaultStyle, styles[edgePosition + 'Edge'], edgeBorderStyle[edgePosition]]} />;
return <View style={[defaultStyle, edgeBorderStyle[edgePosition]]} />;
};

_calculateLineTravelWindowDistance({ layout, isHorizontalOrientation }) {
Expand Down Expand Up @@ -255,6 +239,7 @@ const propTypes = {
edgeColor: PropTypes.string,
edgeBorderWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
edgeRadius: PropTypes.number,
edgeOffset: PropTypes.number,
backgroundColor: PropTypes.string,
outerMaskOpacity: PropTypes.number,
showAnimatedLine: PropTypes.bool,
Expand All @@ -274,6 +259,7 @@ const defaultProps = {
edgeHeight: 20,
edgeColor: '#FFF',
edgeBorderWidth: 4,
edgeOffset: 0,
backgroundColor: 'rgb(0, 0, 0)',
outerMaskOpacity: 0.6,
showAnimatedLine: true,
Expand Down