Commit Graph

2239 Commits

Author SHA1 Message Date
Dave Pack
1bd0649ff4 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 11:33:40 -07:00
Ashoat Tevosyan
8c19471443 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 10:41:17 -04:00
Louis Lagrange
e9f044faf6 Set initialLayout in defaultProps on Android (#2843)
* Revert "Workaround nested TabNavigation swipe issue (#2733)"

This reverts commit 7b88a475bc.

* Set initialLayout in defaultProps on Android

This reverts the previous PR (#2733) and takes into account #2385
In order to fix https://github.com/react-native-community/react-native-tab-view/issues/312

* Don't use window's dimensions
2017-10-30 11:17:55 +01:00
fxwan
3932dbc497 Workaround nested TabNavigation swipe issue (#2733)
* Workaround nested TabNavigation swipe issue

* Add prop types
2017-10-29 16:37:45 +08:00
Terrance Wood
5676179d39 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 08:21:55 -07:00
Bruno
0e314d7d39 Added iconContainerStyle prop to Drawer (#2825)
* Added iconContainerStyle prop to Drawer

* Updated DrawerNavigator docs

* Improved code quality

* Improved code with eslint
2017-10-28 12:07:17 -03:00
94cstyles
236e4b7f2d Fix stack navigator animations (#1493) (#2520)
* Fix animation (#1493)

* Rewrite the file animatedInterpolate.js. To increase readability.

* Rename the variable, To increase readability.

* minor renaming
2017-10-26 15:25:59 -05:00
Freddy Harris
023b0990a9 Fix impossible to renderTitle in full width on ios (#2641)
* Fix impossible to renderTitle in full width on ios

* Fix test and add a test
2017-10-26 15:59:34 +02:00
James Lin
b0bd50e9de fix redirect bug in stacks in tab (#2674) 2017-10-25 22:58:18 +08:00
Duong Le
9da051fe5e 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 15:38:31 +07:00
Jacob Lauritzen
f6d69f9ce4 Add 'save-pattern' to docs (#2806)
* Add save-pattern to docs, #145

* Sync style

* Language clarity

* Typo
2017-10-25 03:19:58 +02:00
Anthony Garritano
2c97cd9a4c 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 10:55:38 -04:00
Spencer Carli
d1ad085183 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 03:51:00 -05:00
Lorenzo Sciandra
94f3dba635 Adding a FAQ about performance (#2802)
* adding faq about perfs

* adding to table of content

* was missing an s

* wording
2017-10-23 14:34:21 +01:00
Tien Pham
94e3a16dd7 Fix typos (#2811) 2017-10-23 18:44:15 +07:00
Lorenzo Sciandra
5d27e3b06d Revert "fix broken link to the Navigation Actions guide (#2809)" (#2812)
This reverts commit 34ede7c79f.
2017-10-23 12:27:44 +01:00
Octavian
f4d44e4ac7 fix broken link to the Navigation Actions guide (#2809) 2017-10-23 11:12:08 +02:00
Hirokazu Hata
7e6958f677 Remove unused imported vars (#2718) 2017-10-23 01:21:49 +09:00
Adam Miskiewicz
7745af4bdf Redirect to root domain 2017-10-20 15:27:36 -07:00
Adam Miskiewicz
cabb7bc7e5 Don't use docker_layer_caching option 2017-10-20 15:09:32 -07:00
Adam Miskiewicz
62029b8975 Fix circleci.yml typo 2017-10-20 15:07:17 -07:00
Adam Miskiewicz
7754d96574 Make sure Docker is installed in CircleCI deploy process 2017-10-20 15:04:35 -07:00
Adam Miskiewicz
a7015d4e3d Enabled docker support in CircleCI 2017-10-20 14:59:01 -07:00
Adam Miskiewicz
9298c524e3 Deploy to Heroku using Docker 2017-10-20 14:54:25 -07:00
Chris Hunter
a99b84f6a8 Add tests for navigators (#2796)
Add minimal unit tests for the DrawerNavigator, StackNavigator and
TabNavigator.
2017-10-20 10:35:54 -05:00
Spencer Carli
80670fcc46 1.0.0-beta.15 2017-10-18 08:24:12 -05:00
Spencer Carli
4b50c18a1f Fix tabbar bottom issue on Android. (#2774) 2017-10-18 03:16:22 -05:00
Dave Pack
94fe9fcc72 Fixes default drawerWidth to match Material UI patterns. (#2773)
* Fixes default drawerWidth to match material ui patterns.

Previously: calculated based on device width regardless of orientation and did not recalculate when orientation changed.
Now: calculates based on minimum of device height/width, remains constant and guaranteed to always fit screen regardless of orientation.

This is the expected behavior based on observing Google apps (e.g. Gmail). This is also better than recalculating on every orientation change, which would result in variable width drawers and awkward empty space when in landscape in most cases.

* Remove console.log
2017-10-17 16:24:56 -07:00
Spencer Carli
1bf98c1ddc 1.0.0-beta.14 2017-10-17 11:11:45 -05:00
Spencer Carli
6fa8115127 [iOS 11] Handle landscape tabbar correctly. (#2676)
* Handle the ios11 tabbar correctly

* Fix an issue when showLabel is false

* Add a basic test for the tabbarbottom

* Add check for ios version number

* Tests shall pass

* make things work for all the versions

* Again, fix the tests
2017-10-16 04:01:30 -05:00
robertkongsvmx
6df54480ef Issue-2662: Add support for testID and accessibilityLabel for tab bar items (#2684) 2017-10-15 17:45:22 -07:00
Lorenzo Sciandra
5b2bb884f5 Updating the README (#2752)
* update the README

* Fixing a couple formats

* rephrase intro

* reordering and relinking

* small reorder

* typo

* couple more changes

* couple tweaks

* libraries section
2017-10-15 22:20:01 +01:00
Finian
b4a13bd191 Add allowFontScaling option for TabView and headerTitleAllowFontScaling for HeaderTitle (#2377) (#2721) 2017-10-15 03:57:09 -05:00
Chid Gilovitz
cb9e05a841 Update Routers.md (#2750)
Added import line to code example.
2017-10-14 19:31:46 +08:00
Lucas Padilha
edf8ce8d6e 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 10:04:22 -03:00
Akshay Kadam
d6fef5c22c Typo: 'create' was written twice 😂 (#2727) 2017-10-11 18:30:49 +05:30
Pat Needham
4301f1e766 Fix Querystring params not set for nested URI (issue #2251) (#2695)
* fix issue #2251 by including queryString to get nested action

* only use nested query string when original queryString exists, and include test cases
2017-10-09 22:21:39 -04:00
Lucas Padilha
301ea45365 added property inside drawerConfig to backgroundColor (drawerBackgroundColor) (#2698) 2017-10-08 06:40:08 -03:00
Vojtech Novak
05b71be0fd remove ineffective invariant usages, fixes #2258 (#2693)
* remove ineffective invariant usages

* fix flow err

* fix tests

* fix tests

* use throw
2017-10-05 12:59:13 +02:00
David Lewis
49c5990244 Suggest flex: 1 for embedded navigator (#2639) 2017-10-04 00:01:52 +02:00
Neo
1c42cd69b3 add doc for transitionConfig (#1827)
* add doc for transitionConfig

* address review
2017-10-03 16:54:19 -05:00
Dan Gurney
990208b1c4 Fix "drawerLockMode" terminology for screenProps (#2667)
Should be "drawerLockMode" instead of "lockMode"
2017-10-03 12:21:49 -04:00
Lorenzo Sciandra
2187354041 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 15:05:39 +01:00
Spencer Carli
90acb9e406 Improve StatusBar/Header Behavior (#2669)
* Track orientation change

* Add tests for withOrientation

* Better variable naming
2017-09-29 16:11:30 -05:00
Dave Pack
89dc7214f1 Updates examples to react-native 0.48.4 and expo sdk 21. (#2675) 2017-09-29 14:06:56 -07:00
Vojtech Novak
38c2c06ead Update ISSUE_TEMPLATE.md (#2668)
the problem I see with many bug reports in this repo is that people write a very vague description of what their problem is and expect to get some help. I tried to:

1 . emphasise how important it is to include a runnable reproduction
2 . cut down on some extra words at the beginning of the template so it's more to the point
2017-09-29 22:51:06 +02:00
Spencer Carli
768e9d1b21 Remove RelativeImageStub providesModule 2017-09-28 14:57:17 -05:00
Ashoat Tevosyan
f5d66882ad Remove @providesModule declarations in src/utils to avoid Flow conflicts with fbjs package (#2665) 2017-09-28 15:42:14 -04:00
Spencer Carli
9952f4d633 1.0.0-beta.13 2017-09-27 09:55:06 -05:00
Alexei Malashkevich
a761d320db Adding search to docs website (#2606)
* Adding search to docs website

* fix eslint errors
2017-09-27 17:25:27 +03:00