188 Commits

Author SHA1 Message Date
Tien Pham
c0d76755e7 Update goBack docs (#2834)
* Update goBack docs

* Update Screen-Navigation-Prop.md
2018-01-21 02:07:24 +05:30
Adam Miskiewicz
f895564605
Revert "Move examples to https://github.com/react-navigation/examples"
This reverts commit 36775007b0de67b2cd2e4889554372b32b09fd03.
2018-01-17 14:43:28 -08:00
Brent Vatne
36775007b0 Move examples to https://github.com/react-navigation/examples 2018-01-17 12:43:24 -08:00
Satyajit Sahoo
8329e269b6 Upgrade react-native-tab-view (#3064) 2018-01-04 14:15:35 +00:00
Axel Eirola
41b587ca65 Enable configuration of gesture direction (#3077)
* Enable configuration of gesture direction

* Fix documentation and code style

* Invert behaviour of I18nManager.isRTL instead of overriding
2017-12-18 16:25:16 -05:00
Nicolas Charpentier
7fe76fb7c6 Fix handling the Hardware Back Button link in Redux section (#3134) 2017-12-16 13:17:43 -06:00
Denis Evgrafov
9cf9e25661 Update Navigation-Actions.md (#3126) 2017-12-15 00:37:22 +01:00
Axel Eirola
363f93fc4d Add support for custom header transitions (#3075)
* Add support for custom header transitions

* Use default props for header transition default values
2017-12-14 22:14:38 +01:00
Sergei
5a26506595 Disable / enable swipe depending on screen. (#2906)
* Disable / enable swipe depending on screen.

react-community#1760

* Updated to master

* Revert "Updated to master"

This reverts commit a3aede19588cdbc7fc9148d148260f51d6316e6f.

* - Fixed CircleCI errors

* - Fixed CircleCI errors
2017-12-01 15:53:26 -06:00
James Reggio
5cb42bdf5d Await promise from Transitioner onTransitionStart (#2946)
* Await promise from onTransitionStart

* Review feedback

* Update docs for onTransitionEnd
2017-12-01 15:42:53 -06:00
mukunzidd
04c075c1bb Fix typo On "Getting Started 3." (#3022)
Browse the official example app, which will `demonstrates` various patterns with React Navigation. 
demonstrates should be `demonstrate`
2017-11-21 15:40:01 +01:00
londonoliver
7ae6908428 Update Guide-Quick-Start.md (#3015) 2017-11-21 08:34:39 +01:00
Dave Rogers
0a662c9835 Allow transition configuration between tabs (#2222)
* allow transition configuration between tabs

* we don't need to pass configureTransition to TabBarComponent

* Update TabAnimations.js

* Update TabNavigator.md
2017-11-21 00:16:43 +01:00
pietro909
88dfd84cf5 Add previous scene to tabBarOnPress - fix #2787 (#2790)
* Add previous scene to tabBarOnPress - fix #2787

* Update docs for tabBarOnPress
2017-11-19 16:00:10 -06:00
Iain Diamond
e0704e48a1 Guide-Headers.md (#3000)
Spelling/Typos fixes
2017-11-19 18:24:27 +01:00
Vojtech Novak
65f44ae003
Update withNavigation.md (#2988) 2017-11-17 00:03:27 +01:00
Shubhnik Singh
24a3a79996 Improvement in redux-integration documentation. (#2964)
* Added a guide to intermediate concepts.

* Documentation improvement for redux integration.

* redux-integration feedback incorporated

* incorporated feedback

* heading style changes
2017-11-16 23:21:56 +01:00
Daniel Friesen
e25bdd2ed2 Fix default width of drawer (#2978)
* Fix default width of drawer

Current implementation is simplified / broken.

- The drawerWidth doesn't work for tablets, the drawer becomes massively large
- Header size changes (and thus drawer width changes) in landscape mode on iOS are not accounted for
- An incorrect 64px header size is used for iOS (this includes the status bar height that doesn't belong in the calculation)

Implement a default drawerWidth as a function that follows the Material Design spec closer:
- Screen width - header height
- Use the correct iOS app bar height in portrait and landscape mode
- Drawer max height of 280 on mobile and 320 on tablet

* Update snapshot for drawer width change
2017-11-15 12:04:15 -08:00
James Reggio
346264e132 Add toString() with type for each NavigationAction (#2260)
* Add toString() with type for each NavigationAction

* Add documentation for toString() on NavigationActions
2017-11-15 04:19:55 +01:00
Dave Pack
f2f4e5ce44 Move SafeAreaView out of DrawerNavigatorItems to DrawerSidebar. (#2967)
* Move SafeAreaView out of DrawerNavigatorItems to DrawerSidebar.

The SafeAreaView was breaking custom contentContainers in drawers. Fixes #2963.

* Fix SafeAreaView in DrawerItems and Drawer contentComponent

* Fix flow error and tests.

* Update Drawer documentation with SafeAreaView recommendation. Remove one of the examples for `contentComponent`.

* Put the View back.

* Update snapshot.
2017-11-14 14:09:59 -06:00
Vojtech Novak
931677781e Allow custom header and back button to use the props from react-navigation (#2712)
* allow custom header components

* nicer condtition

* trigger another build

* trigger another build

* distinguist headerLeft component and element

* add docs

* fix typo

* suppress flow
2017-11-14 13:31:21 -06:00
Vojtech Novak
dec79f6a99 Update Guide-Headers.md (#2949)
* Update Guide-Headers.md

* Update Guide-Headers.md
2017-11-14 16:52:39 +00:00
Spencer Carli
f0e9f70320 Improve Contributing Guide (#2960)
* Put contributing file in a place where github will pick it up

* New contributing guide
2017-11-10 23:55:33 +00:00
Vojtech Novak
b9d1d0d021
improve wording in router docs (#2894) 2017-11-03 20:59:00 +01:00
Dave Pack
c0474bb644 SafeAreaView padding from style prop (#2889)
* SafeAreaView now adds padding from style object. If height is specified, inset padding is added to height.

* Header now only accepts headerStyle prop, backgroundColor works as expected.

* TabBarBottom now only accepts style prop, backgroundColor works as expected. Fixes top inset bug.

* Update snapshot.

* Add clarifying comment.

* Support padding with percentage.
2017-11-02 18:14:15 -07:00
Dave Pack
c5f8eb20d8
Override forceInset on DrawerItems. (#2872)
Fixes second part of issue #2854.

`itemsContainerForceInset` takes the same object as `forceInset` on SafeAreaView. It overrides the SafeAreaView container in DrawerItems.
2017-11-01 15:48:39 -07:00
Dave Pack
313ec7ab76 Fix backgroundColor in Header and TabBar (#2871)
* Add headerBackgroundColor to navigationOptions

* Add backgroundColor to tabBarOptions

* Update snapshots.

* Update docs.
2017-11-01 16:33:50 -05:00
Ashoat Tevosyan
d1c434b54c Update to react-native@0.49 and flow-bin@0.53 (#2845)
* Update root package to react-native@0.49 and flow-bin@0.53

* Update NavigationPlayground package to react-native@0.49 and flow-bin@0.53

* Update ReduxExample package to react-native@0.49 and flow-bin@0.53

* flow-typed update (code-gen)

* Find-and-replace old types with new types

- `React.Element<*>` as the result of a render function is now `React.Node`
- `ReactClass<T>` as the type of a Component is now `React.ComponentType<typeof T>`
- `extends React.Component<DP, P, S>` is now `extends React.Component<P, S>`
- `React.Children<*>` as the type of a children prop is now `React.ChildrenArray<*>`
- Refs are now typed with `React.Ref`

There are also several tiny typo fixes in here.

* Avoid assuming state is NavigationRoute in addNavigationHelpers

For the root, top-level Navigator, the state is a simple `NavigationState` (with no route info) and we still use `addNavigationHelpers` for it. We can't assume `navigation.state.key` is accessible for this type, so we need to do runtime checks here.

* Fix type of NavigationScreenConfig

`navigationOptions` was incorrectly typed

* Give createNavigationContainer's State a type parameter

We want to be able to specifically type this guy so we can use specific NavigationState for things like the Drawer views without having to do runtime assertions about the state type

* Fix typing of NavigationAction

First of all, `NavigationAction` was being used as two different types, so I had to create the new `PossiblyDeprecatedNavigationAction` and add it as a type parameter everywhere. Second of all, generics and implied types were being used far more than they need to be, and they're hard to work with because Flow doesn't really explain things well when they go wrong.

* Make sure children scenes of CardStack have NavigationProp typed with NavigationRoute

CardStack's `NavigationScreenProp` is typed with `NavigationState`, but the children need `NavigationRoute`. Flow gets confused by the spread operator, even if the individual property is replaced later, so we need to explicitly list each property individually (just `dispatch`, actually).

* Allow prevTransitionProps parameter to be nullable

* Allow prevTransitionProps parameter to be nullable

* Narrow down a couple type parameters

* Move NavigationStateRoute cast to within Component.router check in createConfigGetter

* Update withCachedChildNavigation so it's typed correctly with React.ComponentType

* Add a $FlowFixMe for displayName

`React.StatelessFunctionalComponent` is missing `displayName` before Flow 0.54.0

See de37062ea2

* Make TouchableItem's onPress prop optional

`HeaderBackButton` can pass in an undefined onPress, and the React Native `Touchable*` components allow it too

* Simplify withCachedChildNavigation and get rid of generics

The generics don't help us here and they make the types more confusing

* Redefine NavigationComponent as direct intersection

The new type is technically identical to the old type, but Flow is confused by the old type...

* Save router to local var before checking createConfigGetter

Flow seems to think Component.router can change after the check

* Fix DrawerSidebar's navigation prop's type

In order for us to be able to generate a childNavigationProp, the original navigation prop has to have a NavigationState state.

* Colocate action.key check with action.type check in getStateForAction

For some reason, Flow thinks `action` can change sometime after `action.type` is checked. As a result, it's not properly concluding that `action.key` should exist. To avoid this, we pull `action.key` out immediately after doing the `action.type` check.

* Use bounded polymorphism to pass down all props in withCachedChildNavigation

Also makes sure the injected props are specified first in the union

Also removes an unused `eslint-disable-line` in `getScreenForRouteName`

* Make TabRouter's getComponentForState return NavigationComponent

`NavigationScreenComponent` is a subtype of `NavigationComponent`, but it's not clear that `getComponentForState` always returns a `NavigationScreenComponent`, as `getScreenForRouteName` returns `NavigationComponent`

* Define NavigationComponent's props using NavigationNavigatorProps

Right now the types ask Flow to infer the types of `NavigationComponent`'s props. (`NavigationComponent` is the union of `NavigationNavigator` and NavigationScreenComponent.) Instead, we type the props as subtypes of `NavigationNavigatorProps`, so we can properly access those props without type errors. We used bounded polymorphism in `createNavigationContainer` and `createNavigator` to pass down these props. We also explicitly type the action in `createNavigationContainer` so we can properly pass in a `NavigationInitAction` to the dispatch function.

* Parameterize NavigationTabRouterConfig

`NavigationTabRouterConfig` doesn't always take `NavigationTabScreenOptions`; sometimes, it takes `NavigationDrawerScreenOptions`.

* Make all NavigationOptions Exact types

We're seeing weird behavior when these are merged together. By making them Exact types, we make types don't get mangled when they're unioned.

https://flow.org/en/docs/types/unions/#toc-disjoint-unions-with-exact-types

* Silence errors in tests

These errors are unavoidable since we can't type the precise shape of a particular `NavigationState`.

* Include NavigationSetParamsAction in NavigationTabAction

`TabNavigator`'s `getStateForAction` definitely takes `NavigationSetParamsAction`.

* Explicitly list router as void in NavigationScreenComponent

This is so Flow knows that if a `NavigationComponent` has a `router` property, then it is definitely a `NavigationNavigator`.

* Fix website app navigator's type

* Fix createDocPage type in App

In an earlier commit I attempted to fix the types here, but I incorrectly read it as returning a navigator when it just returns a screen. For some reason the error didn't immediately show up.

* Fix NavigationComponent types

Five changes:
1. No longer parameterizing the props of `NavigationComponent`; directly specifying as `NavigationNavigatorProps`
2. Specify the two distinct kinds of route types (leaf and state) directly in `NavigationComponent`
3. Have `SceneView` directly take `NavigationComponent` and allow inferring of `NavigationSceneProp` type
4. Have `CardStack` directly take `NavigationComponent` as well

* Allow Flow to infer `NavigationAction` type in `createNavigator`

* Silence Flow in router code that handles navigator sub-routes

There's no way for us to tell Flow that routes that correspond to navigators should be `NavigationStateRoute`s

* Allow DrawerSidebar to take a null contentComponent

The way `DrawerNavigator` is set up, it's possible to pass in a null `contentComponent` in the config.

If somebody want to do this, we'll just make the `DrawerSidebar` not appear altogether. This is simpler than splitting the types so there's a possibly-unspecified one for the user input, but a definitely-specified one in `DrawerSidebar`.

* Specify missing screenProps prop in DrawerView

* Thread full NavigationStateRoute in to DrawerSidebar

This requiring making `withCachedChildNavigation` use bounded polymorphism to thread the `NavigationStateRoute` through instead of downgrading it to a `NavigationState`

* Make NavigationStateProp's state prop covariant

This means that `NavigationStateProp<NavigationStateRoute>` will be a subtype of `NavigationStateProp<NavigationRoute>` and `NavigationStateProp<NavigationState>`

* Silence Flow's complaints about a route not being a NavigationStateRoute

As mentioned in previous commits and in the comment, there is no way to type a specific navigation state shape, so we have to cast it and silence Flow's complaints.

* Get rid of style prop in CardStack

It looks like at some point, it was possible to specify a `style` prop that got passed all the way down to `Header`, the `TransitionConfig`'s `screenInterpolator`, and `Transitioner`. Doesn't look like we're using it anywhere, and there's a todo saying to remove it, and it's causing a type error.

* Infer type of options instead of using a subtype of {}

I think this has to do with {} allowing for unsealed objects. I'm not 100% sure, but this fixes 4/6 of the remaining errors!

* Fix two type errors in NavigationPlayground

One was just requiring an outdated type (`React.Children` instead of `React.ChildrenArray`), and the other was getting confused regarding types because of a spread operator.

* Use a covariant property to simplify withCachedChildNavigation's InputProps

This doesn't reduce any errors, but it's a bit simpler and cleaner.

* Silence last two Flow errors regarding withCachedChildNavigation injecting childNavigationProps

These are the only two errors I haven't been able to figure out at all. If I had more time I'd try and figure out the simplest case and report it to the Flow team, but I've been working on this for a week already and have to move on.

The issue at hand is that `withCachedChildNavigation` injects `childNavigationProps`, but Flow doesn't see this and thinks it needs to be specified by the view component. We're using the HOC pattern suggested by the Flow docs, and I've tried several other patterns to no avail.

* Use stock react-native instead of Expo's in NavigationPlayground

Expo's causes Flow errors, and apparently this is normal practice because the person who switched us to Expo did this too.

* Silence react-native-gesture-handler Flow errors in NavigationPlayground

Expo requires this package, but it causes Flow errors.

* Fix index check in DrawerSidebar

Silly me, falling for the typical "0 is falsey" problem...

* Rework deprecated action tests

In an earlier commit I moved the `NavigationActions.mapDeprecatedActionAndWarn` out from `getStateForAction` and into `createNavigationContainer`'s `dispatch` function. The tests need to be reworked to support this, as they were previously calling `getStateForAction` directly. I don't imagine any users are calling `getStateForAction` directly.

* Re-record two snapshots

The changes in these snapshots are by design and don't affect anything.

* Infer type of options in NavigationScreenConfig

The issue is that sometimes we include options for different navigators in a single blob.

* Infer types of action and options in createNavigationContainer

Particulary helps with Options. Makes the types more specific and gets rid of an error that only shows up when using the library

* Don't use generics for NavigationState in createNavigationContainer

There's no particular reason for having those generics there, since there's no way we'd be able to get Flow to understand the exact shape of particular navigation states anyways. This fixes a bug when integrating this version of the project into my repo.

* Move ReduxExample to react-native@0.49.3 instead of custom Expo version
2017-10-31 09:41:17 -05:00
Terrance Wood
817e360a53 Avoid one frame delay using TabNavigator (#2385)
* Added optional initialLayout func prop to TabNavigatorConfig.

* Fix default initialLayout prop type.

* Fix default initialLayout prop type.

* Fix lint error.

* Normalized capitalization and punctuation for TabNavigator.md.

* Added react-native-tab-view link to initialLayout prop documentation in TabNavigator.md.

* Update TabView.js
2017-10-28 16:21:55 +01:00
Bruno
468a8ca9be Added iconContainerStyle prop to Drawer (#2825)
* Added iconContainerStyle prop to Drawer

* Updated DrawerNavigator docs

* Improved code quality

* Improved code with eslint
2017-10-28 10:07:17 -05:00
Duong Le
3a63950ec8 Add custom style for DrawerItem (#2764)
* Add custom style of DrawerItem

* Update itemStyle to DrawerNavigator doc

* rename style to itemsContainerStyle [BREAKING CHANGE]

* update

* update

* fix issue comma

* update DrawerNavigator-test
2017-10-25 09:38:31 +01:00
Jacob Lauritzen
4df002daab Add 'save-pattern' to docs (#2806)
* Add save-pattern to docs, #145

* Sync style

* Language clarity

* Typo
2017-10-24 20:19:58 -05:00
Anthony Garritano
2ee85482ba Pass transition and modal props to transitionConfigurer (#2383)
* Pass transition and modal props to transitionConfigurer

* Make arguments passed to transitionConfigurer required

* Update docs with params passed to transitionConfigurer
2017-10-24 15:55:38 +01:00
Spencer Carli
5e26ced280 Add a "Quick Start" guide. (#2775)
* Give docs some more room to breath

* Working on the new docs

* New intro

* Writing installation guide

* Finish tab intro.

* Write intro to drawernavigator.

* Add some space

* Rename guide

* Minimize changes

* Fix links

* Edits
2017-10-24 09:51:00 +01:00
Tien Pham
6a9ed3414a Fix typos (#2811) 2017-10-23 13:44:15 +02:00
Lorenzo Sciandra
4951a6d9d1 Revert "fix broken link to the Navigation Actions guide (#2809)" (#2812)
This reverts commit 34ede7c79fccc17e9e7dd40fec1192781f729350.
2017-10-23 13:27:44 +02:00
Octavian
34ede7c79f fix broken link to the Navigation Actions guide (#2809) 2017-10-23 10:12:08 +01:00
Finian
f84fe15272 Add allowFontScaling option for TabView and headerTitleAllowFontScaling for HeaderTitle (#2377) (#2721) 2017-10-15 09:57:09 +01:00
Chid Gilovitz
5576b84d8a Update Routers.md (#2750)
Added import line to code example.
2017-10-14 12:31:46 +01:00
Lucas Padilha
09e396002f added drawerBackgroundColor for documentation (#2723)
* added property inside drawerConfig to backgroundColor (drawerBackgroundColor)

* Adjusting documentation for PR deployment (# 2698)

* add example in the doc
2017-10-11 14:04:22 +01:00
Akshay Kadam
2dca5b2135 Typo: 'create' was written twice 😂 (#2727) 2017-10-11 14:00:49 +01:00
David Lewis
c08be7fb43 Suggest flex: 1 for embedded navigator (#2639) 2017-10-03 17:01:52 -05:00
Neo
81d8d91085 add doc for transitionConfig (#1827)
* add doc for transitionConfig

* address review
2017-10-03 16:54:19 -05:00
Dan Gurney
5e001155fb Fix "drawerLockMode" terminology for screenProps (#2667)
Should be "drawerLockMode" instead of "lockMode"
2017-10-03 17:21:49 +01:00
Lorenzo Sciandra
c1d181eccd Fixing Intro Guide (#2679)
* Fixing Intro Guide

Fixes #832 - the code in this page was wrong, that export default was causing errors.

I've also modified a few phrases here and there to help the comprehension.

* more fixes, for CRNA
2017-10-03 09:05:39 -05:00
Alessandro Annini
2f0e386a24 Added js highlighting (#2610) 2017-09-25 15:23:47 -05:00
Masayuki Iwai
69397af74d Make GESTURE_RESPONSE_DISTANCE_* configurable. (#2172)
* Make gestureResponseDistance configurable.

* Fix format.

* Set vertical and horizontal distance individually.

* Fix type error.

* Move gestureResponseDistance to NavigationStackScreenOptions.

* Add documentation.
2017-09-25 20:16:13 +01:00
Jeff Mendez
17c910fb5d drawerLockMode (#1377)
* added drawerLockMode with cabilities to update it on the fly

* fixed incorrect name on markdown for usage

* added handling if screenProps is not being used

* Fix linting error

* Use drawerLockMode instead of lockMode

* Correct docs

* Fix flow issues

* Make drawerLockMode optional
2017-09-21 12:53:46 -05:00
andry-baka
500c8a07ac Doc Improvement: goBack key doc improvement (#2035)
* chore(Doc Improvement): goBack key doc improvement

* chore(Doc improvement): fix wording

* chore(Doc Improvement): fix uppercase/lowercase wording
2017-09-15 16:43:35 -05:00
Tomas Reimers
3ad142b818 Update documentation on Title. (#2092) 2017-09-15 16:36:44 -05:00