-
Notifications
You must be signed in to change notification settings - Fork 4.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
[RNMobile] BlockDraggable
component
#39617
Merged
fluiddot
merged 41 commits into
rnmobile/feature/drag-and-drop
from
rnmobile/feature/drag-and-drop-block-draggable-component
Mar 30, 2022
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a779e95
Use animated scroll handler in KeyboardAwareFlatList
fluiddot b71b308
Add hook for scrolling the block list while dragging
fluiddot faea4cf
Improve scroll animation in useScrollWhenDragging
fluiddot 799f077
Add draggable chip component
fluiddot 6aaae21
Add block draggable component
fluiddot f0bd8c0
Remove icon prop from draggable chip component
fluiddot 64708c5
Add draggable placeholder
fluiddot 778b10a
Fix draggable chip location
fluiddot 3822b27
Wrap BlockListItemCell with BlockDraggable
fluiddot 3688013
Fix block draggable placeholder style
fluiddot 14a9d6b
Animate scale property instead of opacity of draggable chip
fluiddot 90838fd
Fix draggable placeholder container height calculation
fluiddot ab337ef
Fix BlockDraggable height animation
fluiddot ee179a9
Move draggable to BlockDraggableWrapper
fluiddot f173ab8
Disable isDragging when long-press gesture ends
fluiddot 95fd2e1
Fix onLayout calculation in block list item cell
fluiddot 593644d
Add findBlockLayoutByPosition helper
fluiddot a910072
Set up dragging block by position
fluiddot 0ddca86
Remove animate scroll velocity
fluiddot 1492550
Remove useScrollWhenDragging hook
fluiddot 2bd4e66
Remove react-native-reanimated mock
fluiddot 9a2ae54
Rename CHIP_OFFSET_TO_TOUCH_POSITION constant
fluiddot fd0883e
Remove unused shared values of chip component
fluiddot 6bef485
Stop dragging when no block is found
fluiddot ad016ed
Fix drag position calculation
fluiddot 7fac2ec
Update html text input styles
fluiddot 5c6e21a
Unify container component within html text input
fluiddot 55e62f1
Use only a single client id in block draggable
fluiddot 258eaf3
Add documentation to block draggable components
fluiddot 78da359
Add documentation to block draggable chip component
fluiddot 8cac264
Add documentation to findBlockLayoutByPosition
fluiddot 1612b48
Update scrollOffsetTarget calculation
fluiddot b7e800a
Fix typos in block draggable
fluiddot 8c79ad3
Add draggable wrapper container style
fluiddot e9ce4e3
Add dark mode styles for draggable chip
fluiddot 4060e1a
Add dark mode styles for block draggable
fluiddot d16ce15
Get container height from blocks layout data
fluiddot 842b09b
Replace inline callback functions with useCallback hook
fluiddot bda7b24
Update collapse/expand animation when dragging a block
fluiddot b886b66
Force draggable chip to be displayed upfront
fluiddot d66fb3d
Remove refs from dependencies arrays
fluiddot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
packages/block-editor/src/components/block-draggable/draggable-chip.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { View } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { dragHandle } from '@wordpress/icons'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { getBlockType } from '@wordpress/blocks'; | ||
import { usePreferredColorSchemeStyle } from '@wordpress/compose'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockIcon from '../block-icon'; | ||
import styles from './style.scss'; | ||
import { store as blockEditorStore } from '../../store'; | ||
|
||
const shadowStyle = { | ||
shadowColor: '#000', | ||
shadowOffset: { | ||
width: 0, | ||
height: 2, | ||
}, | ||
shadowOpacity: 0.25, | ||
shadowRadius: 3.84, | ||
|
||
elevation: 5, | ||
}; | ||
|
||
/** | ||
* Block draggable chip component | ||
* | ||
* @return {JSX.Element} Chip component. | ||
*/ | ||
export default function BlockDraggableChip() { | ||
const containerStyle = usePreferredColorSchemeStyle( | ||
styles[ 'draggable-chip__container' ], | ||
styles[ 'draggable-chip__container--dark' ] | ||
); | ||
|
||
const { blockIcon } = useSelect( ( select ) => { | ||
const { getBlockName, getDraggedBlockClientIds } = select( | ||
blockEditorStore | ||
); | ||
const draggedBlockClientIds = getDraggedBlockClientIds(); | ||
const blockName = getBlockName( draggedBlockClientIds[ 0 ] ); | ||
|
||
return { | ||
blockIcon: getBlockType( blockName )?.icon, | ||
}; | ||
} ); | ||
Comment on lines
+44
to
+54
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. I thought of passing the |
||
|
||
return ( | ||
<View style={ [ containerStyle, shadowStyle ] }> | ||
<BlockIcon icon={ dragHandle } /> | ||
<BlockIcon icon={ blockIcon } /> | ||
</View> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 defined the shadow style properties here because these properties are not recognized in SCSS.