103 Commits

Author SHA1 Message Date
Eric Vicenti
e27ad22c57 [BREAKING] New createNavigator API (#3392)
* New createNavigator and View API

See the RFC here:
https://github.com/react-navigation/rfcs/blob/master/text/0002-navigator-view-api.md

* shattered dreams of flow

* fix export

* Fix tab view issues found by brent
2018-02-27 17:27:58 -08: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
29a29936bf Remove withNavigationFocus example until it's fixed 2018-02-16 18:10:33 -08:00
Brent Vatne
021c7e54be Do not use hide views when swipe or animations are enabled. Improve withNavigationFocus example 2018-02-16 18:05:39 -08:00
Brent Vatne
3600ecbd9b
Add back support for lazy tabs and use removeClippedSubviews (#3538)
* Lazy initialization of tabs and move contents off-screen when not active

* Make subview clipping and lazy both configurable

* Record snapshots again

* Update type definition

* Remove unused log
2018-02-16 16:59:19 -08:00
Sébastien Lorber
c74f001b1c add withNavigationFocus HOC (#3512)
* add withNavigationFocus HOC

See:
- https://github.com/react-navigation/react-navigation/issues/51#issuecomment-276003658
- https://github.com/react-navigation/react-navigation/issues/51#issuecomment-278761705
- https://github.com/react-navigation/react-navigation/pull/3345#issuecomment-360260067

* typos

* remove unused import

* Add withNavigationFocus export

* add example TabsWithNavigationFocus

* add example TabsWithNavigationFocus

* withNavigationFocus: get navigation from context or props

* subs => subscriptions

* fix flow issues
2018-02-16 16:57:33 -08:00
Brent Vatne
d0ef33b12f Several small changes related to header style commit 2018-02-16 12:42:44 -08:00
Brent Vatne
3c3668c952
Header transition presets with support for standard iOS transition style (#3526)
Header transition presets with approximate support for UIKit transition style
2018-02-16 12:41:59 -08:00
Sébastien Lorber
4df9198979 fix doc link (#3513) 2018-02-13 10:30:20 -08:00
Brent Vatne
5b4d11ab5d Better orientation layout on playground 2018-02-12 11:53:23 -08:00
Brent Vatne
58b77d44ae
Make Router({ RouteName: Component }) a valid way to configure a router (#3486)
* Make Router({routeName: Component}) a valid way to instantiate a route

* Update App.js in NavigationPlayground

* Fix route config flow type
2018-02-09 18:20:01 -08:00
Brent Vatne
95565487ec
Make it possible to go back to menu from key example and improve banner on menu screen (#3479)
* Make it possible to go back to menu from key example and improve banner on menu screen

* Fix NavigationPlayground flow error
2018-02-08 19:10:54 -08:00
Brent Vatne
eb39df507e Prevent navigation from getting in bad state when navigating back to route by key (#3478) 2018-02-08 18:20:14 -08:00
Brent Vatne
cca06bb530 Do not use contentInsetAdjustmentBehavior on iOS in ModalStack example 2018-02-08 16:14:45 -08:00
Brent Vatne
4388b6403c Remove console logs from published version of navigation playground 2018-02-08 12:48:28 -08:00
Brent Vatne
7385c244b7 Add custom back button example 2018-02-07 10:42:06 -08:00
Brent Vatne
20af8c688e Prevent push from bubbling up (#3454) 2018-02-06 17:49:52 -08:00
Brent Vatne
b0dccd7e88 Prevent pop and popToTop from bubbling up to parent stack (#3453) 2018-02-06 17:35:32 -08:00
Eric Vicenti
43a1c5ddbd Fix issue with StackRouter popToTop (#3451)
Previously the state was getting squashed, in this case it would destroy the routeName of the state, which was a route for the parent navigator, who could no longer render properly.
2018-02-06 15:56:39 -08:00
Eric Vicenti
333b2e4b68 StackNavigator Replace Action (#3440)
* Navigation replace action

The long awaited action to replace the a route in StackNavigator

* Fix flow maybe
2018-02-06 12:59:16 -08:00
Brent Vatne
4d2609f4a8 Use a stack inside of drawer 2018-02-05 14:48:30 -08:00
Brent Vatne
33c6ac9ae7
Remove website, docs and related commit. (#3419)
- This now lives at https://github.com/react-navigation/react-navigation.github.io
2018-02-03 10:38:43 -08:00
Ashoat Tevosyan
b013cc98be Redux middleware for new event system (#3399)
* Add Redux bindings for new event system

* construct -> create

* react-navigation-redux-helpers
2018-02-02 11:58:35 -08:00
Ashoat Tevosyan
37c3a357fc Clean up old build process and Babel config (#3406) 2018-02-02 11:57:31 -08:00
Ashoat Tevosyan
d0da40fa32 Add Flow libdef (#3391)
* Add Flow libdef

* Move libdef to flow folder in root

* Update libdef with some refinements discovered while writing test

Mostly refining navigator config types. In the past when we tried it we got in-repo Flow errors. With a libdef we can now assert it as true!

* Get rid of all imports in libdef and refine some types
2018-02-01 09:34:35 -08:00
Ashoat Tevosyan
ffcf179883 metro-bundler -> metro (#3396) 2018-01-31 18:41:35 -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
0d3d83bd90 Fix NavigationEvent types (#3384)
* Fix SimpleTabs types

dca37627a243b191fda5856aa6ce9eb1ee4957cf broke the types, but it wasn't noticed because Flow wasn't in the CI. This fixes the types; separate PR coming to add Flow to the CI.

* Refine type of NavigationEventListener callback

Instead of typing the callback as `Function`, we're now using the precise type provided by @ericvicenti

* NavigationEventListener -> NavigationEventSubscription
2018-01-30 15:49:47 -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
Eric Vicenti
dca37627a2 Add events support to redux example (#3368)
* Fixing redux

* Fix tab events and test event nested event subscriptions

* Add event support to redux example
2018-01-27 14:12:16 -08:00
Brent Vatne
50a3f8de93 Add headerBackImage, closes #1999 2018-01-27 13:53:44 -08:00
TheCodeTalker
77b5402404 navigation back fix in example (#3218) 2018-01-27 12:42:45 -08:00
Brent Vatne
afcce1a0c0 [Playground] Move sdkVersion back to 24 2018-01-26 17:34:08 -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
Eric Vicenti
0157a4c9e9
Navigation Event Subscriptions (#3345)
* Add fbemitter, keep flow passing

* Begin support for event emitter

- Adds emitter to navigation prop
- Emits top level onAction event
- stub getChildEventSubscriber for child events

* Support navigationState.isNavigating

* Focus and blur events starting to work

- Navigation completion action wired up
- Event chaining logic built in getChildEventSubscriber
- Renamed onAction evt to ‘action’

* Wrap up events progress and testing

* Rename to isTransitioning and COMPLETE_TRANSITION

* rm accidental dependency

* Suppoert event payload type
2018-01-25 00:13:28 -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
Brent Vatne
ff6d6f4e5e Update icons in playground app and add some padding to banner 2018-01-12 15:50:12 -08:00
Satyajit Sahoo
8329e269b6 Upgrade react-native-tab-view (#3064) 2018-01-04 14:15:35 +00: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
Nicolas Charpentier
89a6668595 Update Contributors Guide link (#3133) 2017-12-15 16:37:31 +00:00
Flo
d5618ebd41 Drawer Improvement, Let define a route key to open/close multiple dra… (#1803)
* Drawer Improvement, Let define a route key to open/close multiple drawer with no side effects

* fix lint issues

* fix flow issues
2017-11-29 09:01:35 -06:00
tab
368bc615c1 Set sdkVersion to 23.0.0 (#3037) 2017-11-25 16:12:51 -06: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
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
Brent Vatne
29ae6f46f6
Safe area example (#2890)
* Add SafeAreaEample for testing

* Remove portrait default lock on SafeAreaExample and add a spacer between buttons
2017-11-02 18:12:11 -07: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