Skip to content

Commit 85edddd

Browse files
authored
Merge pull request #6271 from sidferreira/sidferreira/issue_5873
Improve inline icons - Address 5873
2 parents d2eadd4 + 707531f commit 85edddd

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

src/components/CopyTextToClipboard.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import * as Expensicons from './Icon/Expensicons';
55
import Clipboard from '../libs/Clipboard';
66
import Icon from './Icon';
77
import styles from '../styles/styles';
8+
import themeColors from '../styles/themes/default';
9+
import variables from '../styles/variables';
810

911
const propTypes = {
1012
/** The text to display and copy to the clipboard */
@@ -51,9 +53,13 @@ class CopyTextToClipboard extends React.Component {
5153
style={[styles.flexRow, styles.cursorPointer]}
5254
>
5355
<Text style={this.props.textStyles}>{this.props.text}</Text>
54-
{this.state.showCheckmark
55-
? <Icon src={Expensicons.Checkmark} height={14} width={14} />
56-
: <Icon src={Expensicons.Clipboard} height={14} width={14} />}
56+
<Icon
57+
src={this.state.showCheckmark ? Expensicons.Checkmark : Expensicons.Clipboard}
58+
fill={this.state.showCheckmark ? themeColors.iconSuccessFill : themeColors.icon}
59+
width={variables.iconSizeSmall}
60+
height={variables.iconSizeSmall}
61+
inline
62+
/>
5763
</Text>
5864
);
5965
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {top: 1};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default {top: 2};

src/components/Icon/index.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React, {PureComponent} from 'react';
2+
import {View} from 'react-native';
23
import PropTypes from 'prop-types';
4+
import styles from '../../styles/styles';
35
import themeColors from '../../styles/themes/default';
46
import variables from '../../styles/variables';
7+
import * as StyleUtils from '../../styles/StyleUtils';
8+
import IconWrapperStyles from './IconWrapperStyles';
59

610
const propTypes = {
711
/** The asset to render. */
@@ -18,13 +22,17 @@ const propTypes = {
1822

1923
/** Is small icon */
2024
small: PropTypes.bool,
25+
26+
/** Is inline icon */
27+
inline: PropTypes.bool,
2128
};
2229

2330
const defaultProps = {
2431
width: variables.iconSizeNormal,
2532
height: variables.iconSizeNormal,
2633
fill: themeColors.icon,
2734
small: false,
35+
inline: false,
2836
};
2937

3038
// We must use a class component to create an animatable component with the Animated API
@@ -34,13 +42,26 @@ class Icon extends PureComponent {
3442
const width = this.props.small ? variables.iconSizeSmall : this.props.width;
3543
const height = this.props.small ? variables.iconSizeSmall : this.props.height;
3644
const IconToRender = this.props.src;
37-
return (
45+
46+
const icon = (
3847
<IconToRender
3948
width={width}
4049
height={height}
4150
fill={this.props.fill}
4251
/>
4352
);
53+
54+
if (this.props.inline) {
55+
return (
56+
<View style={[StyleUtils.getWidthAndHeightStyle(width, height), styles.bgTransparent, styles.overflowVisible]}>
57+
<View style={[StyleUtils.getWidthAndHeightStyle(width, height), IconWrapperStyles, styles.pAbsolute]}>
58+
{icon}
59+
</View>
60+
</View>
61+
);
62+
}
63+
64+
return icon;
4465
}
4566
}
4667

0 commit comments

Comments
 (0)