This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 157
Add NavigationExperimental #1
Open
janicduplessis
wants to merge
2
commits into
facebookarchive:master
Choose a base branch
from
janicduplessis:navigation-experimental
base: master
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 all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,46 @@ | ||
[ignore] | ||
; We fork some components by platform | ||
.*/*[.]android.js | ||
|
||
; Ignore "BUCK" generated dirs | ||
<PROJECT_ROOT>/\.buckd/ | ||
|
||
; Ignore unexpected extra "@providesModule" | ||
.*/node_modules/.*/node_modules/fbjs/.* | ||
|
||
; Ignore duplicate module providers | ||
; For RN Apps installed via npm, "Libraries" folder is inside | ||
; "node_modules/react-native" but in the source repo it is in the root | ||
.*/Libraries/react-native/React.js | ||
.*/Libraries/react-native/ReactNative.js | ||
|
||
[include] | ||
|
||
[libs] | ||
node_modules/react-native/Libraries/react-native/react-native-interface.js | ||
node_modules/react-native/flow | ||
flow/ | ||
|
||
[options] | ||
emoji=true | ||
|
||
module.system=haste | ||
|
||
experimental.strict_type_args=true | ||
|
||
munge_underscores=true | ||
|
||
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' | ||
|
||
suppress_type=$FlowIssue | ||
suppress_type=$FlowFixMe | ||
suppress_type=$FixMe | ||
|
||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-8]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-8]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ | ||
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy | ||
|
||
unsafe.enable_getters_and_setters=true | ||
|
||
[version] | ||
^0.38.0 |
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 @@ | ||
node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,24 @@ | |
"type": "git", | ||
"url": "[email protected]:facebookarchive/react-native-custom-components.git" | ||
}, | ||
"scripts": { | ||
"flow": "flow" | ||
}, | ||
"main": "src/CustomComponents.js", | ||
"dependencies": { | ||
"clamp": "^1.0.1", | ||
"fbjs": "~0.8.9", | ||
"immutable": "~3.7.6", | ||
"react-timer-mixin": "^0.13.2", | ||
"rebound": "^0.0.13" | ||
}, | ||
"peerDependencies": { | ||
"react": "*", | ||
"react-native": "*" | ||
}, | ||
"devDependencies": { | ||
"flow-bin": "^0.38.0", | ||
"react": "~15.4.1", | ||
"react-native": "^0.42.3" | ||
} | ||
} | ||
} |
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
55 changes: 55 additions & 0 deletions
55
src/NavigationExperimental/NavigationAbstractPanResponder.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,55 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const {PanResponder} = require('react-native'); | ||
|
||
const invariant = require('fbjs/lib/invariant'); | ||
|
||
import type { | ||
NavigationPanPanHandlers, | ||
} from './NavigationTypeDefinition'; | ||
|
||
const EmptyPanHandlers = { | ||
onMoveShouldSetPanResponder: null, | ||
onPanResponderGrant: null, | ||
onPanResponderMove: null, | ||
onPanResponderRelease: null, | ||
onPanResponderTerminate: null, | ||
}; | ||
|
||
/** | ||
* Abstract class that defines the common interface of PanResponder that handles | ||
* the gesture actions. | ||
*/ | ||
class NavigationAbstractPanResponder { | ||
|
||
panHandlers: NavigationPanPanHandlers; | ||
|
||
constructor() { | ||
const config = {}; | ||
Object.keys(EmptyPanHandlers).forEach(name => { | ||
const fn: any = (this: any)[name]; | ||
|
||
invariant( | ||
typeof fn === 'function', | ||
'subclass of `NavigationAbstractPanResponder` must implement method %s', | ||
name | ||
); | ||
|
||
config[name] = fn.bind(this); | ||
}, this); | ||
|
||
this.panHandlers = PanResponder.create(config).panHandlers; | ||
} | ||
} | ||
|
||
module.exports = NavigationAbstractPanResponder; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* Facebook, Inc. ("Facebook") owns all right, title and interest, including | ||
* all intellectual property and other proprietary rights, in and to the React | ||
* Native CustomComponents software (the "Software"). Subject to your | ||
* compliance with these terms, you are hereby granted a non-exclusive, | ||
* worldwide, royalty-free copyright license to (1) use and copy the Software; | ||
* and (2) reproduce and distribute the Software as part of your own software | ||
* ("Your Software"). Facebook reserves all rights not expressly granted to | ||
* you in this license agreement. | ||
* | ||
* THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS | ||
* OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. | ||
* IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR | ||
* EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | ||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF | ||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const {Animated, StyleSheet} = require('react-native'); | ||
const NavigationCardStackPanResponder = require('./NavigationCardStackPanResponder'); | ||
const NavigationCardStackStyleInterpolator = require('./NavigationCardStackStyleInterpolator'); | ||
const NavigationPagerPanResponder = require('./NavigationPagerPanResponder'); | ||
const NavigationPagerStyleInterpolator = require('./NavigationPagerStyleInterpolator'); | ||
const NavigationPointerEventsContainer = require('./NavigationPointerEventsContainer'); | ||
const NavigationPropTypes = require('./NavigationPropTypes'); | ||
const React = require('react'); | ||
|
||
import type { | ||
NavigationPanPanHandlers, | ||
NavigationSceneRenderer, | ||
NavigationSceneRendererProps, | ||
} from './NavigationTypeDefinition'; | ||
|
||
type Props = NavigationSceneRendererProps & { | ||
onComponentRef: (ref: any) => void, | ||
onNavigateBack: ?Function, | ||
panHandlers: ?NavigationPanPanHandlers, | ||
pointerEvents: string, | ||
renderScene: NavigationSceneRenderer, | ||
style: any, | ||
}; | ||
|
||
const {PropTypes} = React; | ||
|
||
/** | ||
* Component that renders the scene as card for the <NavigationCardStack />. | ||
*/ | ||
class NavigationCard extends React.Component<any, Props, any> { | ||
props: Props; | ||
|
||
static propTypes = { | ||
...NavigationPropTypes.SceneRendererProps, | ||
onComponentRef: PropTypes.func.isRequired, | ||
onNavigateBack: PropTypes.func, | ||
panHandlers: NavigationPropTypes.panHandlers, | ||
pointerEvents: PropTypes.string.isRequired, | ||
renderScene: PropTypes.func.isRequired, | ||
style: PropTypes.any, | ||
}; | ||
|
||
render(): React.Element<any> { | ||
const { | ||
panHandlers, | ||
pointerEvents, | ||
renderScene, | ||
style, | ||
...props /* NavigationSceneRendererProps */ | ||
} = this.props; | ||
|
||
const viewStyle = style === undefined ? | ||
NavigationCardStackStyleInterpolator.forHorizontal(props) : | ||
style; | ||
|
||
const viewPanHandlers = panHandlers === undefined ? | ||
NavigationCardStackPanResponder.forHorizontal({ | ||
...props, | ||
onNavigateBack: this.props.onNavigateBack, | ||
}) : | ||
panHandlers; | ||
|
||
return ( | ||
<Animated.View | ||
{...viewPanHandlers} | ||
pointerEvents={pointerEvents} | ||
ref={this.props.onComponentRef} | ||
style={[styles.main, viewStyle]}> | ||
{renderScene(props)} | ||
</Animated.View> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
main: { | ||
backgroundColor: '#E9E9EF', | ||
bottom: 0, | ||
left: 0, | ||
position: 'absolute', | ||
right: 0, | ||
shadowColor: 'black', | ||
shadowOffset: {width: 0, height: 0}, | ||
shadowOpacity: 0.4, | ||
shadowRadius: 10, | ||
top: 0, | ||
}, | ||
}); | ||
|
||
NavigationCard = NavigationPointerEventsContainer.create(NavigationCard); | ||
|
||
NavigationCard.CardStackPanResponder = NavigationCardStackPanResponder; | ||
NavigationCard.CardStackStyleInterpolator = NavigationCardStackStyleInterpolator; | ||
NavigationCard.PagerPanResponder = NavigationPagerPanResponder; | ||
NavigationCard.PagerStyleInterpolator = NavigationPagerStyleInterpolator; | ||
|
||
module.exports = NavigationCard; |
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.
Lol, that git diff is weird. Actually deleted clamp.js and used a version from npm.