-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Update the chat UI to reflect drag-and-drop #12056
Changes from 15 commits
01c1842
0758179
c1b9509
71460f3
7fcda67
84bb0e9
9bc383f
411f8f5
0d5f39f
1d434eb
5f003de
9f08a8b
1773538
46ba48a
f7cf158
c40edc4
9de5e0d
fc3955d
5b711b3
dff0b37
e78d327
2fd78ed
f993781
af18a84
75d6fa2
d52f7f6
2cfdac3
2ae2283
9d4a08a
21e91d0
bb38bf9
f871dd2
671cc2b
c6efec0
988a207
9b1097b
4373518
6167642
cf7b3a6
4f1a80f
936ead2
f1b191d
d8103e1
8f81203
5e12ced
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ import ExceededCommentLength from '../../../components/ExceededCommentLength'; | |
import withNavigationFocus from '../../../components/withNavigationFocus'; | ||
import * as EmojiUtils from '../../../libs/EmojiUtils'; | ||
import reportPropTypes from '../../reportPropTypes'; | ||
import ReportDropUI from './ReportDropUI'; | ||
|
||
const propTypes = { | ||
/** Beta features list */ | ||
|
@@ -618,21 +619,12 @@ class ReportActionCompose extends React.Component { | |
placeholderTextColor={themeColors.placeholderText} | ||
onChangeText={comment => this.updateComment(comment, true)} | ||
onKeyPress={this.triggerHotkeyActions} | ||
onDragEnter={(e, isOriginComposer) => { | ||
if (!isOriginComposer) { | ||
return; | ||
} | ||
|
||
onDragEnter={() => { | ||
this.setState({isDraggingOver: true}); | ||
}} | ||
onDragOver={(e, isOriginComposer) => { | ||
if (!isOriginComposer) { | ||
return; | ||
} | ||
|
||
this.setState({isDraggingOver: true}); | ||
onDragLeave={() => { | ||
this.setState({isDraggingOver: false}); | ||
}} | ||
onDragLeave={() => this.setState({isDraggingOver: false})} | ||
onDrop={(e) => { | ||
e.preventDefault(); | ||
|
||
|
@@ -703,6 +695,7 @@ class ReportActionCompose extends React.Component { | |
<ReportTypingIndicator reportID={this.props.reportID} /> | ||
<ExceededCommentLength commentLength={this.comment.length} /> | ||
</View> | ||
{this.state.isDraggingOver && <ReportDropUI />} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would require larger restructuring since we depend on displayFileInModal inside onDrop which is provided from AttachmentModal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you can put the whole merged component in the ReportActionCompose component. |
||
</View> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import {createPortal} from 'react-dom'; | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import {View} from 'react-native'; | ||
import CONST from '../../../CONST'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; | ||
import DragAndDropIcon from '../../../../assets/images/drag-and-drop.svg'; | ||
vladamx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import styles from '../../../styles/styles'; | ||
import Text from '../../../components/Text'; | ||
|
||
const propTypes = { | ||
...withLocalizePropTypes, | ||
}; | ||
|
||
const DropZone = ({children}) => createPortal( | ||
children, | ||
document.getElementById(CONST.REPORT.DROP_NATIVE_ID), | ||
); | ||
|
||
const ReportDropUI = props => ( | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<DropZone> | ||
<View style={[styles.dragAndDropOverlay, styles.alignItemsCenter, styles.justifyContentCenter]}> | ||
<View style={[styles.alignItemsCenter, styles.justifyContentCenter]}> | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<View style={[styles.mb3]}> | ||
<DragAndDropIcon width={100} height={100} /> | ||
</View> | ||
<Text style={[styles.h1]}> | ||
{props.translate('reportActionCompose.dropToUpload')} | ||
</Text> | ||
</View> | ||
</View> | ||
</DropZone> | ||
); | ||
|
||
ReportDropUI.displayName = 'ReportDropUI'; | ||
ReportDropUI.propTypes = propTypes; | ||
|
||
export default withLocalize(ReportDropUI); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2699,6 +2699,19 @@ const styles = { | |
alignSelf: 'center', | ||
}, | ||
|
||
dragAndDropOverlay: { | ||
vladamx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
position: 'absolute', | ||
width: '100%', | ||
height: '100%', | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
backgroundColor: themeColors.dragAndDropBackground, | ||
opacity: 0.96, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this opacity should be defined in the theme file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
zIndex: 2, | ||
}, | ||
|
||
textPill: { | ||
ellipsizeMode: 'end', | ||
backgroundColor: colors.gray2, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain how it is avoiding children dragEnter event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By using dropZoneDragState which is last detected drag state on the dropzone -> we start with dragleave since user is not dragging initially.
This state is updated when drop zone is left/entered entirely(not taking the children in the account) or entire window is left
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant in the comment. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that as well :)