forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
184 additions
and
210 deletions.
There are no files selected for viewing
File renamed without changes.
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
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
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
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
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
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
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
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 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 | ||
{...rest} | ||
ref={ref} | ||
onLongPress={onSecondaryInteraction ? executeSecondaryInteraction : undefined} | ||
needsOffscreenAlphaCompositing={needsOffscreenAlphaCompositing} | ||
pressDimmingValue={activeOpacity} | ||
> | ||
{children} | ||
</PressableWithFeedback> | ||
); | ||
} | ||
|
||
PressableWithSecondaryInteraction.displayName = 'PressableWithSecondaryInteraction'; | ||
|
||
export default forwardRef(PressableWithSecondaryInteraction); |
Oops, something went wrong.