Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add square mask for workspace image upload #15975

Merged
merged 10 commits into from
Mar 20, 2023
23 changes: 23 additions & 0 deletions assets/images/image-crop-circle-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions assets/images/image-crop-mask.svg
PrashantMangukiya marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

24 changes: 24 additions & 0 deletions assets/images/image-crop-square-mask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/components/AvatarCropModal/AvatarCropModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const propTypes = {
/** Modal visibility */
isVisible: PropTypes.bool.isRequired,

/** Image crop vector mask */
maskImage: PropTypes.func,
PrashantMangukiya marked this conversation as resolved.
Show resolved Hide resolved

...withLocalizePropTypes,
...windowDimensionsPropTypes,
};
Expand All @@ -60,6 +63,7 @@ const defaultProps = {
imageType: '',
onClose: () => {},
onSave: () => {},
maskImage: undefined,
};

// This component can't be written using class since reanimated API uses hooks.
Expand Down Expand Up @@ -339,6 +343,7 @@ const AvatarCropModal = (props) => {
translateY={translateY}
translateX={translateX}
rotation={rotation}
maskImage={props.maskImage}
/>
<View style={[styles.mt5, styles.justifyContentBetween, styles.alignItemsCenter, styles.flexRow, StyleUtils.getWidthStyle(imageContainerSize)]}>
<Icon src={Expensicons.Zoom} fill={themeColors.icons} />
Expand Down
6 changes: 5 additions & 1 deletion src/components/AvatarCropModal/ImageCropView.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ const propTypes = {

/** React-native-reanimated lib handler which executes when the user is panning image */
panGestureEventHandler: gestureHandlerPropTypes,

/** Image crop vector mask */
maskImage: PropTypes.func,
PrashantMangukiya marked this conversation as resolved.
Show resolved Hide resolved
};

const defaultProps = {
imageUri: '',
containerSize: 0,
panGestureEventHandler: () => {},
maskImage: Expensicons.CircleCropMask,
};

const ImageCropView = (props) => {
Expand Down Expand Up @@ -71,7 +75,7 @@ const ImageCropView = (props) => {
<Animated.View ref={ControlSelection.blockElement} style={[containerStyle, styles.imageCropContainer]}>
<Animated.Image style={[imageStyle, styles.h100, styles.w100]} source={{uri: props.imageUri}} resizeMode="contain" />
<View style={[containerStyle, styles.l0, styles.b0, styles.pAbsolute]}>
<Icon src={Expensicons.ImageCropMask} width={props.containerSize} height={props.containerSize} />
<Icon src={props.maskImage} width={props.containerSize} height={props.containerSize} />
</View>
</Animated.View>
</PanGestureHandler>
Expand Down
5 changes: 5 additions & 0 deletions src/components/AvatarWithImagePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const propTypes = {
/** Denotes whether it is an avatar or a workspace avatar */
type: PropTypes.oneOf([CONST.ICON_TYPE_AVATAR, CONST.ICON_TYPE_WORKSPACE]),

/** Image crop vector mask */
editorMaskImage: PropTypes.func,

...withLocalizePropTypes,
};

Expand All @@ -74,6 +77,7 @@ const defaultProps = {
size: CONST.AVATAR_SIZE.DEFAULT,
fallbackIcon: Expensicons.FallbackAvatar,
type: CONST.ICON_TYPE_AVATAR,
editorMaskImage: undefined,
};

class AvatarWithImagePicker extends React.Component {
Expand Down Expand Up @@ -309,6 +313,7 @@ class AvatarWithImagePicker extends React.Component {
imageUri={this.state.imageUri}
imageName={this.state.imageName}
imageType={this.state.imageType}
maskImage={this.props.editorMaskImage}
/>
</View>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/Icon/Expensicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ import Globe from '../../../assets/images/globe.svg';
import Hashtag from '../../../assets/images/hashtag.svg';
import History from '../../../assets/images/history.svg';
import Hourglass from '../../../assets/images/hourglass.svg';
import ImageCropMask from '../../../assets/images/image-crop-mask.svg';
import CircleCropMask from '../../../assets/images/image-crop-circle-mask.svg';
import ImageCropSquareMask from '../../../assets/images/image-crop-square-mask.svg';
import Info from '../../../assets/images/info.svg';
import Invoice from '../../../assets/images/invoice.svg';
import Key from '../../../assets/images/key.svg';
Expand Down Expand Up @@ -163,7 +164,8 @@ export {
Hashtag,
History,
Hourglass,
ImageCropMask,
CircleCropMask,
ImageCropSquareMask,
PrashantMangukiya marked this conversation as resolved.
Show resolved Hide resolved
Info,
Invoice,
Key,
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class WorkspaceSettingsPage extends React.Component {
isUsingDefaultAvatar={!lodashGet(this.props.policy, 'avatar', null)}
onImageSelected={file => Policy.updateWorkspaceAvatar(lodashGet(this.props.policy, 'id', ''), file)}
onImageRemoved={() => Policy.deleteWorkspaceAvatar(lodashGet(this.props.policy, 'id', ''))}
editorMaskImage={Expensicons.ImageCropSquareMask}
/>
</OfflineWithFeedback>
<OfflineWithFeedback
Expand Down
1 change: 0 additions & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,6 @@ const styles = {
},

imageCropContainer: {
borderRadius: variables.componentBorderRadiusCard,
overflow: 'hidden',
alignItems: 'center',
justifyContent: 'center',
Expand Down