-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix: web compatibility #406
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
kmagiera
merged 34 commits into
software-mansion:master
from
jaulz:fix/web-compatibility
Feb 25, 2019
Merged
Changes from 6 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
94670f3
fix: web compatibility
96c8515
fix: implement TapGestureHandler
3867bfa
fix: treat enabled property as true if not set explicitely
a9cd8fb
fix: move Directions and State to separate modules
97236fd
fix: add dummy setNativeProps
ee685df
fix: use responder events
cd9bc75
fix: map Responder event properties
c62c1ee
fix: reduce memory footprint
b8bcc54
fix: support maxDurationMs in TapGestureHandler
f508722
fix: improve TapGestureHandler
107f5d7
fix: add web platform to example app
0dd754a
fix: change babel preset to react-native
59d1586
fix: remove GestureHandler.web.js and instead reuse GestureHandler.js
a586cea
fix: remove View wrapper from TapGestureHandler
b4343e0
fix: remove inheritance
f6bd3a9
fix: rename file suffixes
9fd9071
fix: rename file suffixes
c74b441
Merge branch 'master' into fix/web-compatibility
jaulz 4b485d4
fix: remove suffix
5cbb2c9
fix: remove suffix
251f13d
fix: remove suffix
ba0cdfc
fix(example): update android compile sdk version to 28
Jekiwijaya 19bb6b2
Merge pull request #1 from Jekiwijaya/fix/android/sdk-version
jaulz 831c3aa
fix: add new files to package.json
81019e2
fix: restore original binding
172f8df
fix: add files to package.json
jaulz 9d6dc77
fix: read directions from native module
362b23b
fix: add unsupported warnings
868ed93
fix: remove Alert.alert
23af89f
fix: remove drawer style
9304881
fix: improve structure for rendering
945c296
fix: force rerendering if public methods of Drawer are used
376b5b4
fix: use global alert
4f568bc
fix: add createHandler file
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import AnimatedEvent from 'react-native/Libraries/Animated/src/AnimatedEvent'; | ||
|
||
export default AnimatedEvent; |
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,3 @@ | ||
import AnimatedEvent from 'react-native-web/dist/vendor/react-native/Animated/AnimatedEvent'; | ||
|
||
export default AnimatedEvent; |
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,6 @@ | ||
export default { | ||
RIGHT: 1, | ||
LEFT: 2, | ||
UP: 4, | ||
DOWN: 8, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import React from 'react'; | ||
import { | ||
ScrollView, | ||
Slider, | ||
Switch, | ||
TextInput, | ||
ToolbarAndroid, | ||
ViewPagerAndroid, | ||
DrawerLayoutAndroid, | ||
FlatList, | ||
TouchableWithoutFeedback, | ||
} from 'react-native'; | ||
import gestureHandlerRootHOC from './gestureHandlerRootHOC'; | ||
import Directions from './Directions'; | ||
import State from './State'; | ||
|
||
// Factory for stub Handler components | ||
function createStubHandler(name) { | ||
return class NativeViewGestureHandler extends React.Component { | ||
static displayName = name; | ||
|
||
container = React.createRef(); | ||
jaulz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
setNativeProps() { | ||
// Since this is a stub we do not need to pass on native props. | ||
// However, we need to implement it here to avoid null calls. | ||
// If for any reason we need to pass on native props we can fallback to this: | ||
// this.container.current.setNativeProps(...args) | ||
} | ||
|
||
render() { | ||
const { children, ...rest } = this.props; | ||
|
||
// We don't want to create another layer, so instead we clone it only but keep the reference | ||
const child = React.Children.only(children); | ||
return React.cloneElement(child, { | ||
jaulz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ref: this.container, | ||
...rest, | ||
}); | ||
} | ||
}; | ||
} | ||
|
||
// Create all Handler components with their respective handler functions | ||
// (at the moment only TapGestureHandler is properly supported) | ||
const NativeViewGestureHandler = createStubHandler('NativeViewGestureHandler'); | ||
|
||
class TapGestureHandler extends React.Component { | ||
setNativeProps() {} | ||
|
||
render() { | ||
const { children, enabled, onHandlerStateChange, style } = this.props; | ||
|
||
return ( | ||
<TouchableWithoutFeedback | ||
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. And can't we use |
||
style={style} | ||
onPress={({ x }) => { | ||
jaulz marked this conversation as resolved.
Show resolved
Hide resolved
jaulz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
enabled !== false && | ||
onHandlerStateChange && | ||
onHandlerStateChange({ | ||
nativeEvent: { | ||
oldState: State.ACTIVE, | ||
state: State.UNDETERMINED, | ||
x, | ||
}, | ||
}); | ||
}}> | ||
{children} | ||
</TouchableWithoutFeedback> | ||
); | ||
} | ||
} | ||
|
||
const FlingGestureHandler = createStubHandler('FlingGestureHandler'); | ||
|
||
const ForceTouchGestureHandler = createStubHandler('ForceTouchGestureHandler'); | ||
|
||
const LongPressGestureHandler = createStubHandler('LongPressGestureHandler'); | ||
|
||
const PanGestureHandler = createStubHandler('PanGestureHandler'); | ||
|
||
const PinchGestureHandler = createStubHandler('PinchGestureHandler'); | ||
|
||
const RotationGestureHandler = createStubHandler('RotationGestureHandler'); | ||
|
||
// Factory for stub Button component | ||
// (at the moment this is a plain TouchableWithoutFeedback) | ||
function createStubButton(name) { | ||
return class Button extends React.Component { | ||
static displayName = name; | ||
|
||
render() { | ||
return ( | ||
<TouchableWithoutFeedback accessibilityRole="button" {...this.props} /> | ||
); | ||
} | ||
}; | ||
} | ||
|
||
const RawButton = createStubButton('RawButton'); | ||
const BaseButton = createStubButton('BaseButton'); | ||
const RectButton = createStubButton('RectButton'); | ||
const BorderlessButton = createStubButton('BorderlessButton'); | ||
|
||
// Export same components as in GestureHandler.js | ||
export { | ||
ScrollView, | ||
Slider, | ||
Switch, | ||
TextInput, | ||
ToolbarAndroid, | ||
ViewPagerAndroid, | ||
DrawerLayoutAndroid, | ||
NativeViewGestureHandler, | ||
TapGestureHandler, | ||
FlingGestureHandler, | ||
ForceTouchGestureHandler, | ||
LongPressGestureHandler, | ||
PanGestureHandler, | ||
PinchGestureHandler, | ||
RotationGestureHandler, | ||
State, | ||
/* Buttons */ | ||
RawButton, | ||
BaseButton, | ||
RectButton, | ||
BorderlessButton, | ||
/* Other */ | ||
FlatList, | ||
gestureHandlerRootHOC, | ||
Directions, | ||
}; |
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,8 @@ | ||
export default { | ||
UNDETERMINED: 0, | ||
FAILED: 1, | ||
BEGAN: 2, | ||
CANCELLED: 3, | ||
ACTIVE: 4, | ||
END: 5, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// At the moment no swipe is supported | ||
export default function Swipeable({ children }) { | ||
return children; | ||
kmagiera marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
If
AnimatedEvent
needs to be used directly, you may want to ask that it is added to theAnimated
export from React Native rather than relying on the fragility of reaching into internals.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.
Okay, I will check on their repository and raise a PR.
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.
Will keep track here: facebook/react-native#22984