Skip to content
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

Update Navigation.md #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 68 additions & 19 deletions Docs/Navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,43 +172,92 @@ A simple view that will render a scene for the currently presented sub-state. Th

[NavigationAnimatedView](AnimatedView.md) is the spiritual successor to Navigator. In addition to adopting a declaritive API, it uses the Animated library to delegate animations and gestures to the scenes.

NavigationCard and NavigationHeader are the included implementations of scenes and overlays for NavigationAnimatedView, which are intended to look similar to platform conventions.
Basically, NavigationAnimatedView acts as a controlled component that takes the `navigationState` and redners the scenes and header (as overlay).

```
<NavigationAnimatedView
navigationState={navigationState}
renderScene={renderScene}
renderOverlay={renderOverlay}
/>
```

The interface of the functions `renderScene` and `renderOverlay` should be defines as the following snippets:

```
function renderOverlay(props: NavigationSceneRendererProps): ReactElement {
return <View><Text>overlay {props.scene.navigationState.key}</Text></View>
}

function renderScene(props: NavigationSceneRendererProps): ReactElement {
return <View><Text>scene {props.scene.navigationState.key}</Text></View>
}
```

Note that the param `props` is prepared by the NavigationAnimatedView as read-only object that contains the information we need to render the scenes, headers.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

props is a read-only object that contains the information needed to render the scenes and headers.


For your convenience, we have prepared the components NavigationCard and NavigationHeader that are the included implementations of scenes and overlays for NavigationAnimatedView, which are intended to look similar to platform conventions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop prepared. Just included sounds better.


### NavigationCard

```
<NavigationAnimatedView
navigationState={navigationState}
renderScene={(props) => (
<NavigationCard
key={props.navigationState.key}
index={props.index}
navigationState={props.navigationParentState}
position={props.position}
layout={props.layout}>
<MyInnerView info={props.navigationState} />
</NavigationCard>
)}
renderScene={renderCard}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderCard -> renderScene

/>
```

and the scene renderer

```
function renderCard(props: NavigationSceneRendererProps): ReactElement {
return (
<NavigationCard
{...props}
renderScene={renderScene}
/>
);
}

function renderScene(props: NavigationSceneRendererProps): ReactElement {
return <View><Text>scene {props.scene.navigationState.key}</Text></View>
}
```

By default, NavigationCard has built-in gesture and animation. If you'd like to use customized geesture or animation style, you can simply do this:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo geesture


```
function renderCard(props: NavigationSceneRendererProps): ReactElement {
return (
<NavigationCard
{...props}
style={NavigationCardStackStyleInterpolator.forHorizontal(props)}
pandlers={NavigationLinearPanResponder.forHorizontal(props)}
renderScene={renderScene}
/>
);
}
```

The prop `style` can be the interpolated animation style, and the prop `pandlers` can be a object that makes to the pan responder handlers.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really called pandlers? O.o


### NavigationHeader

```
<NavigationAnimatedView
navigationState={navigationState}
renderOverlay={(props) => (
<NavigationHeader
navigationState={props.navigationParentState}
position={props.position}
getTitle={state => state.key}
/>
)}
renderScene={this._renderScene}
renderOverlay={renderOverlay}
/>
```

and the header renderer

```
function renderOverlay(props: NavigationSceneRendererProps): ReactElement {
return <NavigationHeader {...props} />
}
```

### NavigationCardStack

A component that wraps `NavigationAnimatedView` and automatically renders a `NavigationCard` for each scene. Similar to the legacy `Navigator` because the animations and gestures are built-in.
Expand Down