Repository navigation
[TS migration] Migrate 'PressableWithSecondaryInteraction' component to TypeScript #31152
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
Merged
madmax330
merged 13 commits into
Expensify:main
from
software-mansion-labs:ts/PressableWithSecondaryInteraction
Dec 5, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
10320c5
Rename files
blazejkustra 75170ea
Initial changes
blazejkustra 9079bdc
Fix PRessable ref types
blazejkustra 144ecf3
Improve the code, remove assertions, and test
blazejkustra 444eee7
restore old logic
blazejkustra e2e7d85
Merge branch 'main' into ts/PressableWithSecondaryInteraction
blazejkustra b8b4cd4
Fix after review
blazejkustra c362b5d
Merge branch 'main' into ts/PressableWithSecondaryInteraction
blazejkustra 408775e
Merge branch 'main' into ts/PressableWithSecondaryInteraction
blazejkustra 536eff1
Merge branch 'main' into ts/PressableWithSecondaryInteraction
blazejkustra 7aa845a
Merge branch 'main' into ts/PressableWithSecondaryInteraction
blazejkustra a6983e1
Add comments with descriptions
blazejkustra 7e0e46c
Merge branch 'main' into ts/PressableWithSecondaryInteraction
blazejkustra 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
51 changes: 0 additions & 51 deletions
51
src/components/PressableWithSecondaryInteraction/index.native.js
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
src/components/PressableWithSecondaryInteraction/index.native.tsx
This file contains hidden or 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,61 @@ | ||
| import React, {forwardRef} from 'react'; | ||
| import {GestureResponderEvent, TextProps} from 'react-native'; | ||
| import {PressableRef} from '@components/Pressable/GenericPressable/types'; | ||
| import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; | ||
| import Text from '@components/Text'; | ||
| import PressableWithSecondaryInteractionProps from './types'; | ||
|
|
||
| /** This is a special Pressable that calls onSecondaryInteraction when LongPressed. */ | ||
| function PressableWithSecondaryInteraction( | ||
| { | ||
| children, | ||
| onSecondaryInteraction, | ||
| inline = false, | ||
| needsOffscreenAlphaCompositing = false, | ||
| suppressHighlighting = false, | ||
| activeOpacity = 1, | ||
| preventDefaultContextMenu, | ||
| withoutFocusOnSecondaryInteraction, | ||
| enableLongPressWithHover, | ||
| ...rest | ||
| }: PressableWithSecondaryInteractionProps, | ||
| ref: PressableRef, | ||
| ) { | ||
| const executeSecondaryInteraction = (event: GestureResponderEvent) => { | ||
| event.preventDefault(); | ||
| onSecondaryInteraction?.(event); | ||
| }; | ||
|
|
||
| // Use Text node for inline mode to prevent content overflow. | ||
| if (inline) { | ||
| return ( | ||
| <Text | ||
| // ESLint is disabled here to propagate all the props, enhancing PressableWithSecondaryInteraction's versatility across different use cases. | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...(rest as TextProps)} | ||
| suppressHighlighting={suppressHighlighting} | ||
| onLongPress={onSecondaryInteraction ? executeSecondaryInteraction : undefined} | ||
| > | ||
| {children} | ||
| </Text> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <PressableWithFeedback | ||
| // ESLint is disabled here to propagate all the props, enhancing PressableWithSecondaryInteraction's versatility across different use cases. | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
|
blazejkustra marked this conversation as resolved.
Resolved
|
||
| {...rest} | ||
| ref={ref} | ||
| onLongPress={onSecondaryInteraction ? executeSecondaryInteraction : undefined} | ||
| needsOffscreenAlphaCompositing={needsOffscreenAlphaCompositing} | ||
| pressDimmingValue={activeOpacity} | ||
| > | ||
| {children} | ||
| </PressableWithFeedback> | ||
| ); | ||
| } | ||
|
|
||
| PressableWithSecondaryInteraction.displayName = 'PressableWithSecondaryInteraction'; | ||
|
|
||
| export default forwardRef(PressableWithSecondaryInteraction); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.