Commit Graph

36 Commits

Author SHA1 Message Date
Brent Vatne
f04402e00d Pull createMaterialBottomTabNavigator into separate repo 2018-05-04 11:06:51 -07:00
Rob Allsopp
8828f438ce go back to React$, and fix real error (#4095) 2018-04-30 13:04:48 -06:00
Rob Allsopp
ce21d7db38 Fix missing/incorrect flow types (#4085)
* don’t use private global

* add missing method ‘getParam’ to navigation screen prop

* correct return type for ‘withNavigation’

* add usage of `getParam` method
2018-04-27 15:30:23 -06:00
Jed Mao
660cf973bb Fix "npm test" on Windows 10 (#4066)
* Fix Windows

* update prettier

* Explain need for assetsTransformer in comment
2018-04-27 10:57:07 -05:00
emision
3a89f44318 add isFocused helper definition (#3912) 2018-04-06 22:43:51 +03:00
Gaëtan Renaudeau
175a246543 Update Flowtype to support navigation.navigate({}) (#3843) 2018-03-26 23:17:36 +02:00
Eric Vicenti
229c9327b7 State persistence (#3716)
Adds a new state persistence mechanisms to all of the navigators via createNavigationContainer

    There are two new props that you can provide to a navigation container: `storageKey` and `renderLoading`.

    `storageKey` is the string key to be used with AsyncStorage while saving and persisting navigation state. To disable persistence, set to null.

    `renderLoading` allows you to render something while the navigator re-hydrates its state and loads its initial URL. By default this returns null, but Expo users will want to render a <AppLoading /> component for smooth app launches

    There is also functionality in this PR to observe errors that come from re-hydrating state, and gracefully recover by dispatching an init action.

    Also this revises the init action to *reset* the navigation state, rather than preserve the previous state.
2018-03-22 22:42:37 -04:00
Brent Vatne
ea1194b823 Add react-native-tabs as export from react-navigation 2018-03-18 17:50:02 -04:00
Brent Vatne
af476b6d84 Rename exports for navigators from XNavigator to createXNavigator 2018-03-14 15:21:38 -07:00
spaceye
375681a0d7 Reworked headerBackImage navigation prop and rendering (#3680)
* Added possibility to provide custom header back button's image, introduced API changes: removed old prop "headerBackImage", added new prop "backImage".

* Code style fixes.

* Renamed showcase file to for more clarity; updated the prop's name as well.

* Removed listeners code from showcase screens.
2018-03-13 23:15:11 +03:00
Brent Vatne
a0e844e311 Add dismiss helper, made possible by also adding carefullyGetParent (#3669)
* Add dismiss action, made possible by getParentState

* Add dismiss to flow interface

* Don't dispatch an action on dismiss helper if no parent state

* carefullyGetParent instead of getParentState
2018-03-12 16:01:29 -07:00
Brent Vatne
3b56ec75c0 Add SwitchNavigator to 2.x 2018-03-07 17:35:15 -08:00
Ashoat Tevosyan
10ec7f734d [Flow] Some updates, mostly from flow-typed (#3682)
1. Remove `NavigationComponent` from `NavigationScreenRouteConfig`. The only context `NavigationScreenRouteConfig` is used in is as an intersection with an object, and as such the only relevant portions of `NavigationScreenRouteConfig` are the object parts.
2. Add static `HEIGHT` variable to `Header` type.
3. In `NavigationContainerProps`, make `onNavigationStateChange` property value nullable.

PS: if in the future you guys would prefer that I separate these sort of PRs into their constituent parts, let me know.
2018-03-07 14:29:25 -05:00
Ben Styles
e6747b5554 Allow passing null to onNavigationStateChange prop (#3683)
As seen here: react-navigation/react-navigation#360, we need to be able to pass null to turn off logging.
2018-03-07 19:19:00 +00:00
Sirui Li
964300519d Flow type: SafeAreaView doesn't require children (#3670)
`children` prop should be optional.
2018-03-07 06:19:46 +08:00
corupta
03f293de3f Add activeLabelStyle and inactiveLabelStyle for DrawerItem (#3559)
* Add activeLabelStyle and inactiveLabelStyle

Adding activeLabelStyle, so that active items can be customized more.
My use case: Change font of the active item to bold.
Also, added inactiveLabelStyle which can be used for a similar purpose.

* prettier fix

* Update react-navigation.js

* prettier fix

* Update jest snapshot for DrawerNavigator - for adding a new style property to the styles array
2018-03-06 04:17:08 +03:00
Edward Drapkin
f798a75d10 More specific injected Navigation props (#3645) 2018-03-05 19:33:42 -05:00
Yordis Prieto
b15bed6529 Fix typespec of back action creator (#3659) 2018-03-05 11:10:39 -08:00
Ashoat Tevosyan
690be82d4a Fix NavigationEventPayload.lastState type (#3664)
Should be nullable, since it is initially called as `null` in `src/createNavigationContainer.js` (and in `react-navigation-redux-helpers`, where it is causing a Flow error)
2018-03-05 14:04:29 -05:00
Nicolas Beck
07c30914ed Add initialRouteKey for StackRouter (#3540)
* use initialRouteName as key when initializing StackRouter

* fix null headerLeft

* merge back

* fixed tests

* use config flag

* fixed snapshots

* implemented requested changes
2018-03-03 01:06:27 +01:00
Arseny Yankovsky
467c7ac3fa Allow modification of SafeAreaView props (#3496)
* SafeAreaView fix

* Updated to only allow modification of forceInset property of SafeAreaView
2018-03-01 22:42:19 +01:00
Eric Vicenti
58477fcf40 Drawer Router (#3618) 2018-02-27 18:34:05 -08:00
Eric Vicenti
d2271ad0f0 [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
Yordis Prieto
83ff7e4f17 fix typespec (#3583) 2018-02-26 12:25:13 -08:00
Vojtech Novak
54d0884929 remove support for deprecated navigation actions (#3595)
* remove support for deprecated navigation actions

* remove deprecated action from flow definitions
2018-02-24 21:08:14 +01:00
Brent Vatne
7cc8feaf05 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
f9d0777608 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
1b6391d83f 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-17 01:57:33 +01:00
Brent Vatne
6bb609ebea 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
Ashoat Tevosyan
b033e5d960 Run Prettier on Flow libdef on precommit (#3495) 2018-02-12 17:45:50 -05:00
Brent Vatne
2c6ce1426a 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
Eric Vicenti
72e45722d1 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
da76c35100 Add adaptive to TabBarBottom flow interface 2018-02-06 10:41:14 -08:00
Ashoat Tevosyan
8dad94e66c 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 12:34:35 -05:00
Ashoat Tevosyan
8392f67b1f 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 d71ed75133. @skevy reintroduced the mistyped function in 9436d03fe8, 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 12:29:34 -04:00
Adam Miskiewicz
1390cb8e6d Update NavigationPlayground to 0.45.1, add stub react-nav flow definition 2017-07-03 17:02:46 -07:00