-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Separate logic native detector #3732
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
Open
akwasniewski
wants to merge
101
commits into
next
Choose a base branch
from
@akwasniewski/separate-logic-native-detector
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 99 commits
Commits
Show all changes
101 commits
Select commit
Hold shift + click to select a range
7d9de2e
logic detector web
akwasniewski 4ccf49e
avoiding propsRef
akwasniewski 69e1c5d
refactor
akwasniewski 9959d8b
logicChildren in specs
akwasniewski 1f1f681
ios
akwasniewski a982767
merge with next
akwasniewski 81bf405
fix reanimated version
akwasniewski a90b83c
yarn lock
akwasniewski 8c03f58
worklets
akwasniewski a3256d4
detach handlers
akwasniewski 6f45a33
worklets fix
akwasniewski 66390ab
android
akwasniewski 1ef1969
Merge branch 'next' into @akwasniewski/logic-detector
akwasniewski 3379714
yarn lock fix
akwasniewski e9795cc
removed circular dependency
akwasniewski 7fb8ea9
simplify ios
akwasniewski 5c24151
removed logic events web/android
akwasniewski 593c44f
android and web refactor
akwasniewski fe1d67d
one path
akwasniewski b147c7b
merge with next
akwasniewski 4e718b3
merge fix
akwasniewski 8e9d2dc
adjust for reanimated/animated separation
akwasniewski 97b7369
general refactor
akwasniewski 8b6df8c
simplified attaching
akwasniewski dab9e5f
tag in callback
akwasniewski 089bbf2
not sharing web invoke
akwasniewski 5fbe993
renamed logic props
akwasniewski ddce1fb
logic animated event
akwasniewski 50c1af4
removed child tag from web
akwasniewski 5f3f1eb
safe detaching
akwasniewski 1f22ef4
typo fix
akwasniewski 3e7bc43
more typos
akwasniewski cd4d158
comment styling
akwasniewski 164c4e8
moved detector context
akwasniewski 84bdf3d
renamed helper function
akwasniewski 4365e3e
explained invoke method
akwasniewski 33fe818
isV3Api helper function
akwasniewski 6c42eae
renamed logic children
akwasniewski a11b6d3
renamed var containing logic handlers
akwasniewski a70f868
action type helper on android
akwasniewski c0c9bb0
simplify logic children to delete creation
akwasniewski a2ee13d
removed redundant check
akwasniewski f0f24b8
renamed parent tag to host detector tag
akwasniewski f0fb458
removed unnecessary variable
akwasniewski 5e5e917
renamed set
akwasniewski abcac98
separate function to detach all handlers
akwasniewski 5c367b5
fix testing remnant
akwasniewski b1d620a
non default useDetectorContext
akwasniewski 157d87b
android action type whitespace
akwasniewski a1b94d5
clean up extension
akwasniewski 75f218b
removed remnants
akwasniewski 344617a
renamed logic children web
akwasniewski 03b37c7
android whitespace
akwasniewski 9420ead
removed unnecessary annotation
akwasniewski 06bb0e1
whitespace
akwasniewski 474e301
delete obsolete
akwasniewski 1fef44a
Fallthrough comment
akwasniewski cb9ab7a
defining registry outside of loop
akwasniewski 76fd9ff
merge with next
akwasniewski 2a727cb
cleaner extension function
akwasniewski e6fbdba
extract repetition
akwasniewski 6fa67e3
moved file
akwasniewski 31fad02
fix bad merge
akwasniewski c9ffbdb
better error
akwasniewski f00e0dd
Merge branch 'next' into @akwasniewski/logic-detector
akwasniewski 72e7813
updating logic children
akwasniewski 79f1d96
removed unnecessary return
akwasniewski 86ff725
hostGestureDetector property
akwasniewski 7213108
extracted update logic children
akwasniewski 8015ea5
rename logic children deleton set
akwasniewski e589043
move invoke detector event
akwasniewski 57b6b57
auto type
akwasniewski a8fa637
rename isv3api
akwasniewski 468e23f
no put
akwasniewski 63d44f7
simplify mapping
akwasniewski 0b362be
better web detaching
akwasniewski 20038b1
typing
akwasniewski f3f985c
Merge branch 'next' into @akwasniewski/logic-detector
akwasniewski 832a039
passing helper function directly
akwasniewski 1d96fa1
Merge branch 'next' into @akwasniewski/logic-detector
akwasniewski 590a5cd
resolved workaround
akwasniewski f25cd9e
Merge branch 'next' into @akwasniewski/logic-detector
akwasniewski 0f58258
empty set array
akwasniewski 93412f4
avoiding indentation
akwasniewski df8c9b7
reformated native children detach
akwasniewski 0cabeb7
fix logic error
akwasniewski adc3c22
send event refactor
akwasniewski 149c323
moved empty set to utils
akwasniewski 1bcda3c
fix can coalesce check to v3
akwasniewski f0ea23f
coalesce check in touch event
akwasniewski 153385c
simplify logic props creation
akwasniewski 765e326
Merge branch 'next' into @akwasniewski/logic-detector
akwasniewski fae6478
added delegate detector
akwasniewski f084754
extract common
akwasniewski c9b90f0
Merge branch 'next' into @akwasniewski/separate-logic-native-detector
akwasniewski 3a994b0
Merge branch 'next' into @akwasniewski/separate-logic-native-detector
akwasniewski 94d9079
merge could have been better
akwasniewski a9ab3a5
changed folder structure
akwasniewski 743124e
extracted common
akwasniewski 88d4290
renamed detectors folder
akwasniewski b7e9fcd
detector index
akwasniewski 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
2 changes: 1 addition & 1 deletion
2
packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.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
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
File renamed without changes.
File renamed without changes.
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
10 changes: 5 additions & 5 deletions
10
...-gesture-handler/src/v3/LogicDetector.tsx → ...Detectors/LogicDetector/LogicDetector.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
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
58 changes: 58 additions & 0 deletions
58
packages/react-native-gesture-handler/src/v3/Detectors/NativeDetector.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,58 @@ | ||
import React from 'react'; | ||
import HostGestureDetector from './HostGestureDetector'; | ||
import { configureRelations, ensureNativeDetectorComponent } from './utils'; | ||
import { isComposedGesture } from '../hooks/utils/relationUtils'; | ||
import { | ||
AnimatedNativeDetector, | ||
NativeDetectorProps, | ||
nativeDetectorStyles, | ||
ReanimatedNativeDetector, | ||
} from './common'; | ||
|
||
export function NativeDetector<THandlerData, TConfig>({ | ||
gesture, | ||
children, | ||
}: NativeDetectorProps<THandlerData, TConfig>) { | ||
const NativeDetectorComponent = gesture.config.dispatchesAnimatedEvents | ||
? AnimatedNativeDetector | ||
: gesture.config.shouldUseReanimated | ||
? ReanimatedNativeDetector | ||
: HostGestureDetector; | ||
|
||
ensureNativeDetectorComponent(NativeDetectorComponent); | ||
configureRelations(gesture); | ||
|
||
return ( | ||
<NativeDetectorComponent | ||
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types | ||
onGestureHandlerStateChange={ | ||
gesture.gestureEvents.onGestureHandlerStateChange | ||
} | ||
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types | ||
onGestureHandlerEvent={gesture.gestureEvents.onGestureHandlerEvent} | ||
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types | ||
onGestureHandlerTouchEvent={ | ||
gesture.gestureEvents.onGestureHandlerTouchEvent | ||
} | ||
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types | ||
onGestureHandlerReanimatedStateChange={ | ||
gesture.gestureEvents.onReanimatedStateChange | ||
} | ||
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types | ||
onGestureHandlerReanimatedEvent={ | ||
gesture.gestureEvents.onReanimatedUpdateEvent | ||
} | ||
// @ts-ignore This is a type mismatch between RNGH types and RN Codegen types | ||
onGestureHandlerReanimatedTouchEvent={ | ||
gesture.gestureEvents.onReanimatedTouchEvent | ||
} | ||
onGestureHandlerAnimatedEvent={ | ||
gesture.gestureEvents.onGestureHandlerAnimatedEvent | ||
} | ||
moduleId={globalThis._RNGH_MODULE_ID} | ||
handlerTags={isComposedGesture(gesture) ? gesture.tags : [gesture.tag]} | ||
style={nativeDetectorStyles.detector}> | ||
{children} | ||
</NativeDetectorComponent> | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/react-native-gesture-handler/src/v3/Detectors/common.ts
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,24 @@ | ||
import React from 'react'; | ||
import { Gesture } from '../types'; | ||
import { Reanimated } from '../../handlers/gestures/reanimatedWrapper'; | ||
import { Animated, StyleSheet } from 'react-native'; | ||
import HostGestureDetector from './HostGestureDetector'; | ||
|
||
export interface NativeDetectorProps<THandlerData, TConfig> { | ||
children?: React.ReactNode; | ||
gesture: Gesture<THandlerData, TConfig>; | ||
} | ||
|
||
export const AnimatedNativeDetector = | ||
Animated.createAnimatedComponent(HostGestureDetector); | ||
|
||
export const ReanimatedNativeDetector = | ||
Reanimated?.default.createAnimatedComponent(HostGestureDetector); | ||
|
||
export const nativeDetectorStyles = StyleSheet.create({ | ||
detector: { | ||
display: 'contents', | ||
// TODO: remove, debug info only | ||
backgroundColor: 'red', | ||
}, | ||
}); |
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
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.
Maybe let's also create
index.ts
inv3/detectors
(and yes, I'd use lowercase for that directory 😅) which will export these?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.
Oki-dokie, I renamed directory in 88d4290 and created
detectors/index
in b7e9fcd