52 Commits

Author SHA1 Message Date
Brent Vatne
77c30d543b Bump @react-navigation/native and re-export scroll related modules 2018-10-23 11:52:21 -07:00
Brent Vatne
93ce7f4e9e Release 3.0.0-alpha.10 2018-10-22 21:01:39 -07:00
Brent Vatne
eb54371306 Bump dependency versions 2018-10-22 19:50:33 -07:00
Brent Vatne
0c9014e52f Bump versions 2018-10-17 15:35:57 -07:00
Brent Vatne
89b01f2211 Bump dependency versions 2018-10-16 21:29:01 -07:00
Brent Vatne
ffae3efe42 Use RNGH buttons 2018-10-16 13:21:56 -07:00
Brent Vatne
550d4fb676 Update for new alpha versions of navigators, release new alpha 2018-10-15 14:15:01 -07:00
Brent Vatne
0b698ae5d6 Update playground to expo sdk 30 and add commented out screens option in App.js 2018-09-14 11:48:34 +02:00
Nicolas Charpentier
0c56b21b46 Remove duplicate private key (#4819)
A package can't be more private than that, so let's remove duplicates.
2018-08-21 16:13:22 -07:00
Brent Vatne
ec52c884c5 Update NavigationPlayground to Expo SDK 28 2018-07-19 15:46:24 -07:00
Vladislav Shabanov
e1df2c6c4a Make headers of non-standard heights work correctly in StackNavigator when header is null (Fixes #4208) (#4353)
* Measure header height dynamically

* Add comment

* StacksOverTopTabs playground example
2018-06-15 08:10:43 -07:00
Ashoat Tevosyan
118c19dcce [flow] Update NavigationActions and introduce StackActions and DrawerActions (#4345) 2018-06-04 13:58:14 -07:00
Brent Vatne
aa3c13891e Bump some versions 2018-05-25 15:26:25 -07:00
Ashoat Tevosyan
046a9f8930 [flow] Make StackRouter action creators optional and add DrawerRouter ones (#4257)
This will force all Flow users to do runtime assertions if they want to use these action creators. Open to any better solutions.
2018-05-23 10:18:35 -07:00
Brent Vatne
2643f690a9 Pull createMaterialBottomTabNavigator into separate repo 2018-05-04 11:06:51 -07:00
Brent Vatne
6f04bdffa6 Update NavigationPlayground dependencies 2018-04-04 19:33:01 -07:00
Adam Miskiewicz
828e7f2d43 Update react-native-scripts in NavigationPlayground (#3820)
We were pretty far behind in react-native-script versions for the playground, so I updated them.

Test Plan:

Run `yarn`.
2018-03-23 12:25:53 -07:00
Eric Vicenti
a9d8f2e03e
Temporarily disable broken test in NavigationPlayground 2018-03-18 12:22:56 -04:00
Eric Vicenti
aee16b91a4 Improve consistency of jest version
Hopefully will fix build on Circle
2018-03-16 16:21:17 -07:00
Vojtech Novak
6b3968b601 Playground facelift (#3708)
* wip

* fix imports

* use stylesheet for margin

stylesheet now correct

* also remove old headerLeft

* improve header buttons color

* remove ios button margin
2018-03-13 13:13:19 -07:00
Brent Vatne
065fdf61d8
Several improvements to StackNavigation Header (#3568)
* Refactor to remove unused variables, styles, and outer Animated view

* Style cleanup

* Proof of concept blur background

* Clean it up and add flow interface

* Update snapshots
2018-02-21 18:29:43 -08:00
Brent Vatne
4388b6403c Remove console logs from published version of navigation playground 2018-02-08 12:48:28 -08:00
Ashoat Tevosyan
441b9ffe10 Add NavigationPlayground Flow test to CI (#3385)
In order to make sure that contributors don't making breaking changes to our Flow types without corresponding updates to the libdefs, we should make sure these breaking changes get caught by CI. Right now our libdefs are any-typed, but I'll put up a PR later that will refine the libdef (located at `flow-typed/npm/react-navigation_vx.x.x.js`).
2018-01-30 15:57:06 -08:00
Ashoat Tevosyan
d1d81d7033 Update to RN 0.52 and Expo 25 (#3383)
* Update to RN 0.52 and Expo 25

* Rerecord snapshots for failing Jest tests

* jest-expo@25.1.0-beta.0

* jest-expo@25.1.0
2018-01-30 10:22:20 -08:00
Brent Vatne
6f430b2f1e Revert updates to example package.json 2018-01-26 16:48:02 -08:00
Ashoat Tevosyan
427e89480f Bring back TypeDefinition.js and re-add Flow to NavigationPlayground (#3363)
* Bring back TypeDefinition.js and re-add Flow to NavigationPlayground

* Type EventListener correctly and ignore metro errors
2018-01-26 16:15:49 -08:00
Adam Miskiewicz
b221afc80b
Make examples use linked copy of react-navigation 2018-01-17 19:11:04 -08:00
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
Lorenzo Sciandra
450a1e3ba5
removing react-addons-test-utils (#3221) 2018-01-04 14:08:58 +00:00
Brent Vatne
6af770d644 Fix example project 2017-12-20 13:35:35 -08:00
Ashoat Tevosyan
3cff180224 Update to react-native@0.50 and flow-bin@0.56 (#2998)
* Update to React Native 0.50

* Type Promise used in PlatformHelpers.web.js

* Move $FlowFixMe in CardStack.js

The line number Flow is using for this error changed. The underlying problem has not, but I don't have time to fix it now unfortunately.

* Type TouchableItem's children prop as React.Node

This was my bad. `React.ChildrenArray` should only really be used in the case of having multiple of the same type of child.

* Type HeaderTitle's children prop as React.Node

Same as last commit.

* Add assertion in StackRouter that StateUtils.indexOf returns valid index

Flow doesn't realize that `StateUtils.indexOf` is guaranteed to return a valid index, so we use `invariant` to assert it.

* Remove unused type DrawerNavigationState from TypeDefinition

* Remove unused type parameter T in DrawerView

* Type NavigationStateRoute as NavigationLeafRoute & NavigationState

* Don't constrain generic action types to NavigationAction

By constraining to subtypes of `NavigationAction`, we actually are requiring that any router satisfying our type constraints has to take all of the `NavigationAction` types. Instead, we want to say that it will only take some of them. Changing the types here to be inferred.

* Fix types of NavigationScreenProp and withCachedChildNavigation

1. `NavigationScreenProp` needs to have its type parameter annotated with a `+` to actually indicate covariance on that type parameter, apparently
2. `withCachedChildNavigation` needs to thread through more-specific `NavigationState`s, and right now it just discards that specificity, which breaks `DrawerSidebar` because it needs a `NavigationStateRoute`

* Ignore website/build from Flow

* Fix type of DrawerItems activeItemKey prop

- Even when specified, it can be `null`
- Use a ternary expression instead of `x && x.param` approach

* Get rid of NavigationRouter & NavigationNavigator parameterization on NavigationAction

Since `NavigationRouter`'s `getStateForAction` functionality is a standard Redux reducer, it knows to forward on any actions it doesn't know how to deal with. We can widen the types of these functions to be `NavigationAction` without any negative consequence.

* Explicitly specify null navigationOptions in createNavigator

Not sure why, but Flow doesn't like us leaving it unspecified

* Fix createNavigationContainer/createNavigator/StackNavigator types

* Fix up flow types for TabNavigator and DrawerNavigator

* Properly type defaultContentComponent

* Fix more flow errors in createNavigationContainer

* Replace NavigatorProps with NavigationNavigatorProps

* Type SceneView's navigation prop as NavigationScreenProp<any>

There is an unavoidable* type problem here. A `NavigationComponent` is either a navigator with a `NavigationStateRoute` or a scene with a `NavigationRoute`. The navigation prop it gets passed must match the component's `NavigationState`. However, there's no way for us to say that "`this.props.router.getComponentForRouteName` will have a `NavigationNavigator` iff the corresponding `childNavigationProps` is a `NavigationStateRoute`".

The cleanest way to make this work is to throw an "any" specifically for the navigation prop's state type param.

* We could probably avoid it with sufficient refactoring. If the routers were charged with keeping track of `childNavigationProps` instead of leaving it to the views, they could return the child navigation prop and child `NavigationComponent` in pairs whose types were coupled.

* Pass in screenProps to NavigationComponent in NavigationPlayground's CustomTabs

Flow wants `screenProps` to be passed in here for some reason...

It cites `SceneView`, but that doesn't really make much sense to me. But this is some custom logic that most people aren't likely to run into, so I'm not gonna worry too much about it.

* Patch mismatch with react-native-tab-view type for now

* Use generic NavigationState in createNavigationContainer's _nav var

We made the NavigationState generic while #1313 added a new instance variable. This updates the new instance variable to be generic.

* Fix failing tests
2017-11-20 13:53:48 -06:00
Dave Pack
185289ad66 Add iPhone X SafeAreaView (#2833)
* Add SafeAreaView - JS only version

* Add SafeAreaView

* Looking pretty good

* Small refactor

* Remove console.log

* Fix merge conflict with Header flow types.

* Fix conflict with itemsContainerStyle.

* Fix merge conflict.

* Fix merge conflict, yarn and package.json from fixflow

* Fix merge conflict, navigation playground yarn.lock and package.json with fixflow

* Now it can work on lower versions of RN

* Snapshots merge conflict.

* Update DrawerNavigator snapshot.

* Fix conflict with iconContainerStyle

* Add support for correct status bar height on iPad.

* Update jest snapshots.

* Update StackNavigator snapshot.

* Use modulo instead of while

* Fix landscape tab bar width on < iOS 11
2017-10-31 13:33:40 -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
Dave Pack
c4541f44af Updates examples to react-native 0.48.4 and expo sdk 21. (#2675) 2017-09-29 16:06:56 -05:00
Ashoat Tevosyan
b759d3136e Fix Flow types (and update RN version) (#2619)
* Fix .flowconfig to stop ignoring modules and properly include React Native libraries

Currently, there are numerous ignored libraries that are hiding type errors. Actually, they're causing type errors too. This sort of thing only patches over actual problems, so we have to revert them to get a config we can build upon.

* Update react-native/flow-bin dependencies

We want to have Flow types working with the latest packages.

* Update flow-typed libraries (auto-generated)

* Fix typing of navigation prop used by withNavigation HOC

The current typing is clearly a typo, as it is circular. `NavigationScreenProp` should be used to type the navigation prop

* Fix typing of easing function

What's funny is that I fixed this before in d71ed75133b97e33a8a683eda334b3005107d379. @skevy reintroduced the mistyped function in 9436d03fe8fface09001a5a40ce0aa8a01ad9e7e, which didn't trigger any Flow errors because .flowconfig was ignoring the entire react-native package

* Correct typing of View and Text style prop

The current code thinks it can import these, but this isn't true, and was being hidden because the .flowconfig ignored the whole react-native package. There's no easy to type Text and View at the current moment, as far as I can tell. Importing the highly generic `StyleObj` seems like the best bet, and is what I have being using in my projects.

* Import NavigationScreenComponent using full path

* Updating yarn.lock files

* Get rid of library overrides in flow-typed/react-native.js and flow/react-navigation.js

* Add @flow to src/react-navigation.js and make last three params to createNavigator optional

* Make screenProps and navigationOptions optional in NavigationNavigatorProps

* yarn run format

* Readd react-navigation/node_modules ignore to NavigationPlayground's .flowconfig

Realized this line I removed in the first commit is necessary when using npm link/yarn link, which is what the CircleCI build does

* Make all DrawerViewConfig's params optional

Some of these params are marked as optional because they have defaults. However, the only place `DrawerViewConfig` is used is as the input the function that then applies the defaults

* Make all props in NavigationNavigatorProps optional

`NavigationNavigatorProps` is used to type the props of the component that is output by the `StackNavigator`, `TabNavigator`, etc. component factories. This component does not need to have any props specified.

* Make second param to `DrawerNavigator` factory optional

`DrawerNavigator`, just like `TabNavigator` and `StackNavigator`, can be called with just a single argument (ie. omitting the config)

* Upgrade to RN 0.48.4 to address https://github.com/facebook/react-native/issues/15810
2017-09-25 11:29:34 -05:00
Kevin Cooper
19babadf38 Fix the NavigationPlayground example! (#2170)
* [Playground] Commit auto-changes to package.json, yarn.lock

* [Playground] Rerun create-react-native-app

Preserving rn-cli.js and transformer.js

Still not quite working.

* [Playground] Fix the Expo loading issue by removing projectRoots

Now it looks in the right place to find its resources, including 'entryPoint'.

* [Playground] Add postinstall script to clean up files Yarn copies in

Yarn copies them when installing locally, causing lots of @providesModule collisions.

* Update the Contributors guide to explain how to use the example app

And recommend Yarn by default

* [Playground] Remove now-obsolete rn-cli.config.js

* [Playground] Upgrade expo and other dependencies

* [Playground] Don't delete .git just in case
2017-09-06 10:36:20 -05:00
Adam Miskiewicz
e2afc982da
Fix tests in NavigationPlayground 2017-07-19 14:03:58 -07:00
Adam Miskiewicz
ebf1e2e893
Update NavigationPlayground to 0.45.1, add stub react-nav flow definition 2017-07-19 12:59:40 -07:00
Adam Miskiewicz
83e2cf007b
Fix tests in examples 2017-05-15 19:36:04 -07:00
Adam Miskiewicz
de6396facd
Don't use jest-setup on NavigationPlayground 2017-05-15 19:16:00 -07:00
Adam Miskiewicz
518f491727
Install react-navigation in NavigationPlayground 2017-05-15 19:12:52 -07:00
Adam Miskiewicz
4632e1c348
Fix path to Jest in NavigationPlayground 2017-05-15 19:08:16 -07:00
Adam Miskiewicz
44dac9b629
Don't run Jest watch in CI 2017-05-15 19:06:17 -07:00
Adam Miskiewicz
1cd16bcf4a
Convert NavigationPlayground project to a CRNA project 2017-05-15 18:57:22 -07:00
Daniel Schmidt
b19beda0a7 Add NavigationPlayground Expo Demo (#1523)
* use react-navigation as dependency
* add expo based playground app
* name expo playground demo in the docs
* add ci task to deploy playground demo
2017-05-15 16:55:10 -07:00
Adam Miskiewicz
fe9e30d8a8 Change react-navigation path in example package.json to relative 2017-05-14 21:28:38 -07:00
Adam Miskiewicz
1ae3798137 Upgrade to React Native 0.44 + Flow 0.42 2017-05-14 21:28:38 -07:00
Kevin Cooper
85c2235a3c Improve CircleCI infrastructure (#1173)
* [Example] Get tests passing on ReduxExample and NavigationPlayground

* [CI] Use more vague versioning so we're always up to date

* [CI] Test that the example apps run without error

* [CI] Install the current local version of react-nav before testing

* Fix tabs => spaces in ReduxExample/package.json

* Remove LinkingExample entirely

It's now part of NavigationPlayground.
2017-04-24 10:54:58 -07:00
Joe McKie
2bbfc03cd0 Bump dependency versions to reflect current RN 2017-04-18 15:04:47 +02:00