Skip to content

Commit

Permalink
Fixed bad logic for custom overlay styles (#497)
Browse files Browse the repository at this point in the history
* Fixed bad logic for custom overlay styles

* lint fix

---------

Co-authored-by: souyahia-monk <[email protected]>
  • Loading branch information
souyahia-monk and souyahia-monk authored May 26, 2023
1 parent 1e71e67 commit 5552875
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
27 changes: 12 additions & 15 deletions packages/camera/src/components/Capture/capture.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ const styles = StyleSheet.create({
width: '100%',
backgroundColor: 'rgba(0,0,0,0.5)',
},
overlay: {
flex: 1,
position: 'absolute',
justifyContent: 'center',
overlayContainer: {
position: 'fixed',
height: '95vh',
top: '2.5vh',
zIndex: 99,
},
addDamageOverlay: {
fontSize: 14,
Expand All @@ -81,7 +82,6 @@ const styles = StyleSheet.create({
removePosition: {
position: 'relative',
},

});

const defaultNavigationOptions = {
Expand Down Expand Up @@ -572,16 +572,13 @@ const Capture = forwardRef(({
<>
{(isReady && overlay && loading === false
&& addDamageStatus !== AddDamageStatus.TAKE_PICTURE) ? (
<Overlay
svg={overlay}
style={[styles.overlay, overlaySize]}
rootStyles={{
position: 'fixed',
height: '95vh',
top: '2.5vh',
}}
pathStyles={overlayPathStyles}
/>
<View style={[styles.overlayContainer]}>
<Overlay
svg={overlay}
pathStyles={overlayPathStyles}
rootStyles={{ height: '100%' }}
/>
</View>
) : null}
{(isReady && overlay && loading === false
&& addDamageStatus === AddDamageStatus.TAKE_PICTURE) ? (
Expand Down
9 changes: 4 additions & 5 deletions packages/camera/src/components/Overlay/SVGElementMapper.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable react/no-array-index-key */
import PropTypes from 'prop-types';
import React, { useMemo } from 'react';

import { useInnerHTML, useJSXTransformAttributes, useCustomSVGAttributes } from './hooks';
import { useCustomSVGAttributes, useInnerHTML, useJSXTransformAttributes } from './hooks';

export default function SVGElementMapper({
element,
Expand All @@ -24,15 +23,15 @@ export default function SVGElementMapper({
...transformedAttributes?.style ?? {},
...customAttributes?.style ?? {},
},
}), []);
}), [transformedAttributes, customAttributes]);
const children = useMemo(() => [...element.children], [element]);

return (
<Tag {...attributes}>
{innerHTML}
{children.map((child, id) => (
{children.map((child) => (
<SVGElementMapper
key={id.toString()}
key={child.outerHTML}
element={child}
rootStyles={rootStyles}
pathStyles={pathStyles}
Expand Down
1 change: 1 addition & 0 deletions src/screens/InspectionCapture/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export default function InspectionCapture() {
colors={colors}
vehicleType={vehicleType}
selectedMode={selectedMode}
// overlayPathStyles={{ strokeWidth: 8 }}
/>
<Notice />
</View>
Expand Down

0 comments on commit 5552875

Please sign in to comment.