Compare commits

..

467 Commits

Author SHA1 Message Date
Brent Vatne
57d2bbeb96 Release 3.8.1 2019-04-12 15:39:19 -07:00
Brent Vatne
e3c38aefe8 Release 3.8.0 2019-04-12 15:37:54 -07:00
Ashoat Tevosyan
fb7da05beb [flow] Update for Flow 0.92 (#5806)
Changes:

1. We can now type React components with static members as `React.ComponentType` (instead of requiring the `StatelessFunctionalComponent`) hack.
2. We can now type-parameterize React components on all of their props, instead of just the ones we care about. Not sure why this wasn't previously. Note: this is a breaking change, in the sense that people's parameterization of `NavigationScreenComponent`, `NavigationNavigator`, and `NavigationContainer` may need to change.
3. The order of object-type-spread in the `getParam` definition has been switched. It was giving errors with the old order.
4. Avoid recursive type inference `NavigationScreenProp`. This was yielding an "*** Recursion limit exceeded ***" error, which was rather difficult to debug. We can just use a `NavigationState` and let the user cast.
5. Fix `onTransitionStart`/`onTransitionEnd` types in `NavigationStackViewConfig`.
6. Add `navigationConfig` property to `NavigationView`.
2019-04-12 09:31:44 -07:00
jeffreyffs
5d097b92f4 [Typescript] Add type for 'enableURLHandling' (#5803)
* updated types for 'enableURLHandling'

* Updated Changelog
2019-04-10 17:11:32 -07:00
Brent Vatne
60618d5d1d Release 3.7.1
- Rename 3.7.0 to 3.7.1 basically because I needed to rebase
2019-04-10 11:19:50 -07:00
Brent Vatne
28e1753434 Release 3.7.0 2019-04-10 11:18:13 -07:00
guptaamol
48b1bd965b Improved TypeScript definition for bottom tab navigationOptions. (#5796) 2019-04-10 10:35:16 -07:00
Brent Vatne
6e80d7c75a Update dependencies and lockfile 2019-04-10 10:25:44 -07:00
Ashoat Tevosyan
1c75f17a86 [flow] Fix TabBar types (#5800)
1. `TabBarTop` is `MaterialTopTabBar` now
2. `MaterialTopTabBar` does not have a `getButtonComponent` prop (accidentally added in #5648)
3. `BottomTabBar`'s `getButtonComponent` prop is a `React.Component`, not a `React.Node`
2019-04-10 09:35:52 -07:00
Ashoat Tevosyan
e542c84e29 [flow] Support custom navigators using Transitioner (#5801) 2019-04-10 09:35:30 -07:00
zzzgit
a7265155bd grammar error (#5768) 2019-04-05 12:45:48 +02:00
Brent Vatne
69e40950b1 Release 3.6.1 2019-04-02 14:17:27 +02:00
Brent Vatne
3deec699ee Release 3.6.0 2019-03-31 15:40:19 +02:00
Brent Vatne
2c875e39ae Add types for back button disabled and NoAnimation transition config 2019-03-31 15:31:40 +02:00
Faustino Kialungila
8788dd77b4 Adding missing getButtonComponent props to flow (#5648) 2019-03-27 17:01:48 -07:00
Jose G
71cb16dc7f chore(typescript): export InitialLayout type (#5738) 2019-03-26 16:14:32 -07:00
alex clifton
445dcfcdf2 unhandled promise rejection failed to delete storage directory (#5727)
with:

await AsyncStorage.clear();

I'm getting this in ios:

unhandled promise rejection failed to delete storage directory

found this:

https://stackoverflow.com/questions/46736268/react-native-asyncstorage-clear-is-failing-on-ios

switched to use this instead:

await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove)

but that causes unhandled promise rejection in android.

this is working:

Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
2019-03-22 11:13:05 -07:00
Jose G
ec97b610c5 chore(typescript): export ScreenProps (#5726) 2019-03-22 11:11:05 -07:00
Jose G
b9f50bd012 [TypeScript] Export DrawerIconProps and DrawerLabelProps (#5715)
* chore(typescript): export DrawerIconProps and DrawerLabelProps

* chore: update changelog
2019-03-20 19:28:36 -07:00
Jose G
dbf165dbe7 chore(typescript): export "TabBarIconProps" and "TabBarLabelProps" (#5712) 2019-03-20 10:02:12 -07:00
Brent Vatne
bd09153448 Release 3.5.1 2019-03-19 16:22:51 -07:00
Brent Vatne
c766a66be8 Regenerate lockfile in NavigationPlayground 2019-03-19 16:17:38 -07:00
Brent Vatne
53bb89c1e3 Regenerate lockfile 2019-03-19 16:15:33 -07:00
Brent Vatne
4c29c57fe2 Export GestureContexts and add missing type for withOrientation, fix header back button title prop type 2019-03-19 13:58:18 -07:00
Brent Vatne
368b6812bf Release 3.5.0 2019-03-19 11:05:23 -07:00
Jacob Powers
73d416ec02 Issue-5701: TabBarBottom -> BottomTabBar in type definitions (#5702)
* Issue-5701: TabBarBottom -> BottomTabBar in type definitions

* BottomTabBar changelog update
2019-03-19 10:45:54 -07:00
Julian Hundeloh
89786a39ab fix: export NavigationContext in types (#5707) 2019-03-19 10:44:54 -07:00
Brent Vatne
dfa4a715a0 Release 3.4.1 2019-03-16 10:45:03 -07:00
AkiVer
6844559273 Fix missing ts def (#5689)
* fix: missing typescript definition file

* chore: update changelog for missing ts file
2019-03-16 10:41:42 -07:00
Brent Vatne
acd15dd409 Simplify CI config 2019-03-16 10:39:42 -07:00
Brent Vatne
c428b63484 Attempted fix for CI 2019-03-16 09:40:31 -07:00
Brent Vatne
7a0159ef32 Remove cache 2019-03-15 19:50:12 -07:00
Brent Vatne
c4278e5250 Remove unnecessary dependency in NavigationPlayground
- node_modules is pulled in when using file://../../ in yarn
2019-03-15 19:40:39 -07:00
Brent Vatne
2d6a284226 Fix jest test 2019-03-15 19:37:15 -07:00
Brent Vatne
23389b3774 Release 3.5.0-alpha.0 2019-03-15 16:19:19 -07:00
Brent Vatne
8bb2eeb7ad Release 3.4.0 2019-03-15 11:03:42 -07:00
Brent Vatne
91f3f93541 Fix RNGH type definition 2019-03-15 10:32:37 -07:00
Brent Vatne
a8c0f83df9 Enable tests on CI again (currently will fail because of TS error in RNGH) 2019-03-13 21:27:15 -07:00
Brent Vatne
e117bb3cde Get Jest running in NavigationPlayground 2019-03-13 21:24:15 -07:00
Brent Vatne
245d09ed1a Fix NavigationPlayground and bump some versions 2019-03-13 15:51:50 -07:00
Jan Hesters
eac5feb64e Add TypeScript declaration file and convert NavigationPlayground to TypeScript 2019-03-13 11:10:31 -07:00
Steven Black
e4902e98aa CustomTabs – consolidate all imports from react-navigation on the same line. (#5664) 2019-03-07 20:44:42 -03:00
Titus Efferian
4d5641f7be remove unused import and unused destructuring (#5622) 2019-02-28 15:11:25 -06:00
Danny Althoff
114e28b56f fixed typo in Custom TaB UI example (#5627) 2019-02-27 11:47:03 -08:00
Brent Vatne
ac04aad700 Release 3.3.2 2019-02-25 14:27:25 -08:00
Brent Vatne
b7fb44850d Release 3.3.1 2019-02-25 14:25:55 -08:00
Ashoat Tevosyan
d3040e52b3 [flow] Update Flow libdef with Feb 2019 changes (#5599)
This corresponds to three `flow-typed` PRs:

1. https://github.com/flow-typed/flow-typed/pull/3140 Get rid of deprecated Navigator exports in 3.0
2. https://github.com/flow-typed/flow-typed/pull/3147 Refine AnimatedValue type
3. https://github.com/flow-typed/flow-typed/pull/3148 Introduce SafeAreaViewInsets type
2019-02-16 16:30:36 -08:00
Brent Vatne
9e36d3e4c9 Remove autopublish from CI 2019-02-16 16:28:55 -08:00
Brent Vatne
e64d1f6b57 Release 3.3.0 2019-02-16 16:16:22 -08:00
Brent Vatne
77aa514874 Release 3.2.3 2019-02-13 21:16:19 -08:00
Brent Vatne
2733fab3ee Release 3.2.1 2019-02-09 10:31:49 -08:00
Brent Vatne
ebc18aa859 Release 3.2.0 2019-02-08 18:24:47 -08:00
Brent Vatne
a931aa3986 Release 3.1.5 2019-02-06 09:07:05 -08:00
Brent Vatne
b54874969d Release 3.1.4 2019-02-05 09:12:22 -08:00
Brent Vatne
ef0c8487b0 Release 3.1.3 2019-02-04 16:45:48 -08:00
Brent Vatne
ea002fe950 Bump @react-navigation/native and react-navigation-stack 2019-02-04 16:42:40 -08:00
NrqhEIcsRi004
41cf95941f Update CHANGELOG.md (#5554) 2019-02-02 13:45:50 -08:00
Brent Vatne
884bde0338 Release 3.1.2 2019-02-01 11:59:47 -08:00
Brent Vatne
31e07e9692 Bump @react-navigation/native and react-navigation-drawer dependencies 2019-01-09 12:29:12 -08:00
Nicolas Hart
363f06d30e fix typo "transtion" => "transition" (#5447) 2019-01-03 13:10:33 -08:00
Levi Buzolic
59c09a6040 [flow] Update withNavigation and withNavigationFocus to support defaultProps (#5398) 2019-01-02 19:42:12 -08:00
Brent Vatne
c4b039cc19 Remove README.md from examples directory 2018-12-26 12:16:39 -08:00
Brent Vatne
49e3fb0d97 Update README in NavigationPlayground 2018-12-26 12:16:17 -08:00
Brent Vatne
3367501d4d Release 3.0.9 2018-12-19 10:31:49 -08:00
Brent Vatne
4fb6b163ac Release 3.0.8 2018-12-11 11:52:19 -08:00
Brent Vatne
d0b4ba40e9 Release 3.0.7 2018-12-08 18:31:35 -08:00
Brent Vatne
1be5c7ae35 Release 3.0.6 2018-12-06 18:26:54 -08:00
Brent Vatne
bfa68ded1e Release 3.0.5 2018-12-03 16:26:04 -08:00
Brent Vatne
2d3f159c2a Release 3.0.4 2018-11-30 13:14:53 -08:00
Brent Vatne
e0fb642490 Release 3.0.3 2018-11-30 12:24:46 -08:00
Brent Vatne
d341162731 Release 3.0.2 2018-11-27 13:59:37 -08:00
Paul-Henri Koeck
4eec187d66 Fix for NavigationPlayground red box (duplicate native module) (#5294)
Solves https://github.com/react-navigation/react-navigation/issues/5293
2018-11-27 11:09:41 -08:00
Brent Vatne
03be0324a3 Release 3.0.1 2018-11-26 14:18:03 -08:00
Brent Vatne
55f326960a Release 3.0.0 2018-11-26 11:50:25 -08:00
Yu Watanabe
0641bdd656 ./src/createNavigationContainer -> @react-navigation/native/src/createAppContainer on NavigationTestUtils.js (#5266)
* ./src/createNavigationContainer deprecated , so change.

* changelog
2018-11-27 01:07:51 +07:00
Ashoat Tevosyan
087831ab71 [flow] Update libdef for 3.0 (#5234)
1. `navigationOptions` in `RouteConfig`s is now `defaultNavigationOptions`
2. `create*Navigator` no longer return a container, they return a navigator
3. Introducing `createAppContainer`

Closes #4722 by including https://github.com/flow-typed/flow-typed/pull/2522
2018-11-15 17:09:37 +01:00
Brent Vatne
23f7895792 Release 3.0.0-rc.5 2018-11-07 16:53:10 -08:00
Anne Klapwijk
cfa1eb2eff [flow] Restrict ParamName to string (#5200) 2018-11-06 09:09:18 -05:00
Brent Vatne
e34c724106 Release 3.0.0-rc.4 2018-11-05 13:02:40 -08:00
Brent Vatne
93a754a3d5 Release 3.0.0-rc.3 2018-11-03 20:07:56 -07:00
Brent Vatne
dcadbfcfa0 Release 3.0.0-rc.2 2018-11-03 14:31:15 -07:00
Brent Vatne
a393818875 Release 3.0.0-rc.1 with explicit dependency on react-native-screens 2018-11-01 16:27:11 -07:00
Brent Vatne
f16ca93521 Remove codecov badge (lives on other subrepos now) 2018-11-01 08:25:48 -07:00
Brent Vatne
b3ab5ce23c Release 3.0.0-rc.0 2018-10-31 19:27:42 -07:00
Brent Vatne
b4da1a63ce Update react-navigation-drawer and release 3.0.0-alpha.21 2018-10-31 18:21:46 -07:00
Brent Vatne
7bf6404733 Bump drawer/tabs versions, release 3.0.0-alpha.20 2018-10-31 16:49:23 -07:00
Brent Vatne
334be6021a Bump react-navigation-stack, core, and release new version 2018-10-31 15:55:26 -07:00
Brent Vatne
4254d46694 Clean up SafeAreaView in example 2018-10-31 15:54:29 -07:00
Brent Vatne
a00784ae6e Release 3.0.0-alpha.27 2018-10-30 13:25:33 -07:00
Eric Vicenti
22f3422293 chore: release 3.0.0-alpha.15 2018-10-29 20:19:26 -07:00
Eric Vicenti
4502061a10 bump versions, export context 2018-10-29 20:15:41 -07:00
Brent Vatne
5a8ebc806c Release 3.0.0-alpha.14 2018-10-26 10:57:24 -07:00
Brent Vatne
7942eecb4e Bump react-navigation-stack version 2018-10-26 10:57:09 -07:00
Brent Vatne
6b3d6c1399 Bump to 3.0.0-alpha.13 2018-10-26 07:28:53 -07:00
Ashoat Tevosyan
adcb2e5b4a [flow] Fix type of getCurrentNavigation (#5173)
As of 2.18 we seem to be okay returning `null` here.
2018-10-25 14:14:57 -07:00
Brent Vatne
352e703ea9 Release 3.0.0-alpha.12 2018-10-23 17:08:07 -07:00
Brent Vatne
308d38015d Bump core for default params 2018-10-23 17:01:43 -07:00
Brent Vatne
f34095e71a Re-export tab bar views from react-navigation 2018-10-23 14:54:00 -07:00
Brent Vatne
000f8afe8f Release 3.0.0-alpha.11 2018-10-23 11:53:15 -07:00
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
e456d29104 Release 3.0.0-alpha.9 2018-10-22 19:50:33 -07:00
Brent Vatne
eb54371306 Bump dependency versions 2018-10-22 19:50:33 -07:00
Brent Vatne
a2e053d31c Bump react-navigation-stack 2018-10-22 19:50:33 -07:00
Yao Hui Chua
af18e1c672 Fix typo in MainScreen (#5162) 2018-10-22 11:55:11 -07:00
Gregory Benner
0c4845f2ff [flow] typecheck getParam to actually check that key and fallback are valid (#5074)
* Update flow type definition for getParam to actually check key and
fallback are valid

* add changelog entry for `getParam` flow type changes

* Return "any" in `getParam` if params are not defined in the navigation state

* use void in place of any
2018-10-19 09:57:34 -07:00
Brent Vatne
0c9014e52f Bump versions 2018-10-17 15:35:57 -07:00
Brent Vatne
156f55fe34 chore: bump stack version 2018-10-17 13:20:34 -07:00
Brent Vatne
46be835351 chore: release 3.0.0-alpha.6 2018-10-16 21:29:34 -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
ccfbaedb9f Remove ReduxExample and SafeAreaExample 2018-10-15 15:27:42 -07:00
Brent Vatne
84de94d961 Fix tests 2018-10-15 14:19:32 -07:00
Brent Vatne
550d4fb676 Update for new alpha versions of navigators, release new alpha 2018-10-15 14:15:01 -07:00
Satyajit Sahoo
5acc07b9b0 chore: use release-it for automated release (#5115) 2018-10-15 11:49:48 -07:00
Eric Vicenti
d34f883180 cleanup dependencies, SafeAreaView moved to native 2018-10-11 23:02:38 -07:00
Eric Vicenti
89af1a6917 rename to createAppContainer, other deprecations
- rename createNavigationContainer to createAppContainer
- deprecate Transitioner import
- clean up old deprecated exports without create prefix
- rearrange
2018-10-11 22:40:21 -07:00
Eric Vicenti
402b201618 Fix playground 2018-10-11 20:58:39 -07:00
Eric Vicenti
df1728e13b Copy native support to @react-navigation/native 2018-10-11 20:47:20 -07:00
Eric Vicenti
b331dea1a1 Extract core codebase to @react-navigation/core 2018-10-11 14:48:58 -07:00
Tien Pham
3e827e4061 Fix unexpected route switching after the transition is complete (#5113) 2018-10-11 13:49:48 -07:00
Brent Vatne
4c168a7f73 Use dummy navigator instead of stack 2018-10-11 13:10:00 -07:00
Brent Vatne
200f596461 Add RNGH as a dependency of react-navigation 2018-10-11 12:53:49 -07:00
Brent Vatne
9e1982d8a8 Bump navigator dependencies to alpha versions 2018-10-11 12:48:47 -07:00
Brent Vatne
51d791d301 navigationOptions in navigator config is renamed to defaultNavigationOptions.
The new meaning of navigationOptions in navigator config is the navigation options for that navigator, not for screens inside of it.
2018-10-11 12:46:54 -07:00
Serge Lebedev
07afa55265 [flow] Mark key in StackActions.replace as optional (#5073) 2018-10-10 11:27:00 -07:00
Eric Vicenti
3ac5f412b7 Introduce getActiveChildNavigationOptions (#5080)
This is a utility to allow navigationOptions definition functions to access the navigation options of the active child route, which allows people to replicate the v1 behavior of deep nav configuration.
2018-10-09 15:37:57 -07:00
Ashoat Tevosyan
70a2c3b97c [flow] Update StackViewConfig to match recent changes (#5067) 2018-10-09 11:56:28 -07:00
Julian Paas
4bd6f17b46 Removes drawer actions from react-navigation-web (#4549)
* Removes drawer actions from react-navigation-web

* Lint fix
2018-10-03 15:44:28 -07:00
Nicolas Charpentier
9824e90b9f Add disableRouteNamePaths option to router configs (#4824)
* Add routeNameAsPathDisabled prop to router config

* Rename option to disableRouteNamePaths

* Update PathHandling-test.js
2018-10-03 10:11:34 -07:00
Badr Rahal
eae992467b Removed unused imports and const declarations (#5053) 2018-10-01 12:12:36 -07:00
Brent Vatne
6b4d92ca4d Release 2.17.0 2018-09-25 18:56:44 -07:00
Vojtech Novak
41d3c97cea Update CHANGELOG.md (#5023) 2018-09-24 09:36:22 -07:00
Vojtech Novak
ab3e053338 add dangerouslyGetParent() to flow typings (#5014)
* add dangerouslyGetParent() to flow typings

* Update CHANGELOG.md
2018-09-20 16:44:49 -07:00
Brent Vatne
b14262c2ef Release 2.16.0 2018-09-19 16:46:05 -07:00
Eric Vicenti
03d9133a7d Custom Tabs UI Example (#4996)
* Custom Tabs UI Example

* Clean up and add SafeAreaView
2018-09-19 21:15:34 +02:00
Brent Vatne
d0835351bd Release 2.15.0 2018-09-19 11:27:30 -07:00
Brent Vatne
f892526e7b Update react-native-safe-area-view to 0.11.0 2018-09-19 11:23:51 -07:00
Brent Vatne
1afdb799fc Release 2.14.2 2018-09-14 15:30:56 +02:00
Brent Vatne
83d36dcf7c Release 2.14.1 2018-09-14 13:03:47 +02:00
Brent Vatne
aa94038190 Update react-navigation-stack 2018-09-14 12:59:30 +02: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
Brent Vatne
dd3ce66120 Release 2.14.0 2018-09-12 16:47:03 +02:00
Brent Vatne
82754d41d9 Bump react-navigation-stack to 0.4.0 2018-09-12 16:40:13 +02:00
Thibault Malbranche
9d54ec68dd Bump Safe-Area-View to remove circular dependency. (#4980)
* Bump Safe-Area-View to remove circular dependency.

React Native 0.57 now adds a yellowbox warning due to this package, bumping to solve

* Update CHANGELOG.md

* Update CHANGELOG.md
2018-09-12 16:39:22 +02:00
Brent Vatne
460754fde1 Release 2.13.0 2018-09-06 15:07:39 -07:00
Brent Vatne
ffd1865485 Bump react-navigation-stack and react-navigation-tabs 2018-09-06 15:06:34 -07:00
Tom Spencer
50320bf0d9 Add missing types (#4836)
* Add missing types

* Added missing types to DrawerActions
2018-09-04 10:44:02 -07:00
Thibaut
74a04c3ce5 Add missing StackNavigatorConfig option (#4917) 2018-09-04 10:42:46 -07:00
Rodolfo Silva
54d0d5180d Update CHANGELOG.md (#4923)
Change dependency version
2018-09-04 10:42:27 -07:00
Cameron Knight
14eb5a1e75 Pin create-react-context at v0.2.2 (#4950)
Because `create-react-context` updated its license from MIT (read: Open
Source) to a more-restrictive, non-Open Source license without
appropriately bumping its major version in violation of semver, the
`create-react-context` version within `react-navigation` necessarily
needs to have its version pinned to a version of `create-react-context`
before the license change.

v0.2.2 is the most recent version of `create-react-context` that still
retains an Open Source license.

Note: Another solution to this would be to require `react` `16.3.x` or
higher, which includes the official `React.createContext` API without
need to rely on a third-party library.

Closes #4934
2018-09-04 10:41:42 -07:00
Rodrigo Bermúdez Schettino
222c77a360 CHANGELOG: Remove duplicate entry (#4909)
Issue link was missing in removed entry. Left the one with better format.
2018-08-27 12:00:04 -07:00
Brent Vatne
39316fc339 Fix typo in issue template 2018-08-25 15:50:55 -07:00
Brent Vatne
27eb73cc14 Release 2.12.1 2018-08-23 16:29:12 -07:00
Brent Vatne
f01b4896e6 Release 2.12.0 2018-08-22 17:17:54 -07:00
Brent Vatne
556c31626e Update react-navigation-stack, export HeaderStyleInterpolator, and add example of using it to playground 2018-08-22 17:16:39 -07:00
Brent Vatne
b6bca3ed2e Fix drawer config in Drawer + Tabs example 2018-08-22 16:04:11 -07: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
Kevin Coleman
912c7ca076 Bump react-native-safe-area-view dep to 0.9.0 (#4810)
https://github.com/react-navigation/react-navigation/issues/3992
2018-08-07 10:23:51 -07:00
Brent Vatne
73c76f1e4b Extract stack to react-navigation-stack (#4809)
* Extract stack to react-navigation-stack

* Update CHANGELOG

* Fix tests
2018-08-03 18:47:46 -07:00
Brent Vatne
d746a587b0 Release 2.11.2 2018-08-03 15:45:27 -07:00
Brent Vatne
dee03c839a Undo pathUtils rename 2018-08-03 15:33:38 -07:00
Brent Vatne
2104bf1a04 Release 2.11.1 2018-08-03 14:48:49 -07:00
Brent Vatne
4e2a409dca Fix a couple of exports and export a few more modules 2018-08-03 14:47:43 -07:00
Brent Vatne
51bfe8dd19 Release 2.11.0 2018-08-03 14:17:24 -07:00
Brent Vatne
04a4512c1b Export modules useful for moving stack navigator outside of core 2018-08-03 14:16:57 -07:00
Brent Vatne
4a5da86ce0 Release 2.10.0 2018-08-02 13:03:34 -07:00
Brent Vatne
a118122aed Update react-navigation-[tabs&drawer] 2018-08-02 13:02:01 -07:00
Justin Parker
a94f89ffe1 Fixes bug where null doesn't work in routerOptions paths object for deeplinking (#4791)
* Add test for handling null path set on router

* Allow null paths on the router config

Previously if you specified `null` in the router `paths`, the logic would actually fall back to the `path` specified on the route, which is especially bad if the latter is undefined, because then the path would be set as the default of the routeName.
2018-08-01 01:12:49 -07:00
Brent Vatne
9d77fd6d54 Add NavigationTestUtils and release 2.9.3 2018-07-26 15:49:34 -07:00
Brent Vatne
13cf4497ee Release 2.9.2 2018-07-25 11:52:39 -07:00
Tim Wang
9175118383 Export StackViewTransitionConfigs (#4761)
* export StackViewTransitionConfigs

* Add changelogs
2018-07-25 11:50:07 -07:00
Simone D'Avico
6fc21250ec Fix typo in header transition preset check (uitkit -> uikit) (#4757) 2018-07-25 11:49:24 -07:00
Yevhen
714d5eab6b Error when building with haul: ref to pathToRegexp.compile (#4658)
Error in source code that cause problem on react native using haul https://puu.sh/AT1uZ/158623d5a4.png
2018-07-25 20:28:05 +02:00
Brent Vatne
67233dc9ef Release 2.9.1 2018-07-24 10:49:56 -07:00
Brent Vatne
b0443c1861 Move more logs behind debug flag in stack playground 2018-07-24 10:47:59 -07:00
Brent Vatne
c0b637df52 Fix title offfset calculation 2018-07-24 10:47:02 -07:00
Brent Vatne
9a82706fba Fix snapshots 2018-07-20 14:44:26 -07:00
Brent Vatne
d973a26edb Release 2.9.0 2018-07-20 14:33:27 -07:00
Brent Vatne
852e7e1974 Respect custom background color in header wrapper 2018-07-20 14:30:38 -07:00
Brent Vatne
cd3707d64b Add headerLayoutPreset, add config for back button title visibility and make it have reasonable defaults, better back button ripple on Android (#4588) 2018-07-20 14:12:39 -07:00
Brent Vatne
3c36db455f Release 2.8.0 2018-07-19 15:48:09 -07:00
Brent Vatne
ec52c884c5 Update NavigationPlayground to Expo SDK 28 2018-07-19 15:46:24 -07:00
Brent Vatne
c4b3f25a0f Cleanup unused descriptors and handle the case where we might expect to have a descriptor but do not (#4723) 2018-07-19 13:16:38 -07:00
Eric Vicenti
93642e16e7 Fix createNavigator leak of old descriptors 2018-07-19 12:41:14 -07:00
Eric Vicenti
1a76556290 Fix leak in createNavigator
Previous descriptors had been retained because this binding caused `this.prevState` to remain referenced. This binds the component getter to null instead.
2018-07-19 12:21:22 -07:00
Reza Ghorbani
12b21f052e added header container styles to be customized (#4331) 2018-07-18 15:14:08 -07:00
Brent Vatne
c1f07dc167 Release 2.7.0 2018-07-17 15:50:18 -07:00
Brent Vatne
bc04b31d01 Add border for transparent header in example 2018-07-17 15:43:22 -07:00
Eric Vicenti
35307c70be Improve empty path and param handling (#4671)
* Overhaul Path handling

* Another test for deep link
2018-07-17 13:51:20 -07:00
Brent Vatne
7e3f4f3bec Fix tests 2018-07-17 13:49:12 -07:00
Brent Vatne
cbd0958e6f Remove unnecessary style array 2018-07-17 13:36:16 -07:00
Brent Vatne
cab4d71a5e Fix edge case where route was in nav state but never actually graduated to scene 2018-07-17 13:36:16 -07:00
Kenza Iraki
108ac0e2a9 Set borderBottom to transparent and of size 0 if headerTransparent is true (#4701) 2018-07-16 16:32:14 -07:00
Brent Vatne
fa4fdb9c57 Fix onTransitionStart config not being invoked with keyboard aware navigator, and use prop over config when available 2018-07-16 15:13:25 -07:00
Brent Vatne
ebdd2da79f Pull onTransitionStart from navigationConfig, fixes #4100 2018-07-16 14:55:34 -07:00
Matteo Codogno
1fe11c100e Fix #4608 - remove header left component only when a headerLeft optio… (#4679)
* Fix #4608 - remove header left component only when a headerLeft option is not specified

* Update CHANGELOG.md
2018-07-12 11:42:56 -07:00
Eric Vicenti
c4b84f1d66 Fix container referene to startup state data 2018-07-12 11:01:11 -07:00
Michael Lefkowitz
69f394be5b Feat/allow keyless replace (#4636)
* allow key to be undefined on StackNavigation.replace method

* added tests for replace action w/out key

* fix typo

* updated changelog

* updated teests for clarity

* added length check on routes to safely fallthrough to search
2018-07-10 23:41:42 -07:00
Eric Vicenti
316e4991ac Add enableURLHandling to navigation container 2018-07-10 14:47:57 -07:00
Ashoat Tevosyan
805064cb5e [flow] Make NavigationRoute types exact (#4667)
React Native 0.56 introduces Flow 0.75, which makes it impossible to refine `NavigationRoute` based on the presence of `index` or `routes` properties.

This PR turns `NavigationStateRoute` and `NavigationLeafRoute` into exact types, which addresses this issue.
2018-07-10 13:59:09 -07:00
Dariusz Łuksza
8f199980cb Fix changelog (#4651)
Fixes 2.6.1 header link
2018-07-06 20:21:00 -07:00
Brent Vatne
37ca6a92ca Release 2.6.2 2018-07-06 10:44:30 -07:00
Brent Vatne
980e0409dc Temporarily remove warnings on vertical padding in header 2018-07-06 10:42:32 -07:00
Brent Vatne
a00ba5918a Default to 0 elevation on transparent header 2018-07-05 15:17:08 -07:00
Brent Vatne
ad6b25cff9 Fix 2.6.1 changelog 2018-07-05 15:07:17 -07:00
Brent Vatne
a69b67d6d2 Release 2.6.1 2018-07-05 15:03:14 -07:00
Brent Vatne
dc436e4d01 Warn for more invalid header styles 2018-07-05 15:02:48 -07:00
Brent Vatne
fe95bdeee6 Fix regression for shadow in header on Android 2018-07-05 14:53:41 -07:00
Brent Vatne
525528e38f Release 2.6.0 2018-07-04 13:04:00 -07:00
liuqiang1357
9f5f3d994c Fix bug: params not be passed to navigator inside SwitchNavigator (#4306) 2018-07-04 12:28:01 -07:00
Eric Vicenti
e8c1833053 Fix stack router child router delegation priority (#4635)
Stack router had some aggressive logic for deferring to inactive child routers. The child router behavior should come after all of the appropriate stack actions, with the exception of the active child router.

This was causing issues such as https://github.com/react-navigation/react-navigation/issues/4623 , where inactive tab navigators would handle the back action, and cause the stack to attempt to  pop back to it.
2018-07-03 21:18:25 -07:00
Eric Vicenti
0921889f7a Avoid crash when calling isFocused on old route (#4634) 2018-07-03 12:03:54 -07:00
Sébastien Lorber
1951a3ac46 Add <NavigationEvents/> component (#4188)
* add NavigationEvents

* expose TabsWithNavigationEvents in lib entrypoints

* Add NavigationEvents example in playground

* Add NavigationEvents example in playground

* Add NavigationEvents tests

* Add NavigationEvents Flow declarations

* remove useless NavigationEvents constructor

* NavigationEvents => make tests more readable by avoiding beforeEach callback

* fix flow test error by adding <any, any> to React.Component
2018-06-29 07:34:11 -07:00
Eric Vicenti
4e384f8057 Routers: Deep Linking Overhaul (#4590)
* deep linking overhaul

* clean up PlatformHelpers

this had previously been required for old versions of react native and react-native-web
2018-06-29 07:27:12 -07:00
Eric Vicenti
3d06d19d6a clean up PlatformHelpers (#4586)
this had previously been required for old versions of react native and react-native-web
2018-06-28 10:02:52 -07:00
Brent Vatne
30ef5ef72b Release 2.5.5 2018-06-27 18:12:59 -07:00
Brent Vatne
c7fff52408 Delegate to child routers for more than just the top screen in the stack (#4587)
* Delegate to child routers for more than just the top screen in the stack. Fixes #4185

* Add CHANGELOG entry
2018-06-27 17:37:30 -07:00
Brent Vatne
bc01a4cd57 Throw error in development mode when title is not a string 2018-06-27 17:35:29 -07:00
Brent Vatne
cad3d70aed Update react-navigation-drawer to 0.4.3 2018-06-27 17:27:58 -07:00
Brent Vatne
bb5719f438 Throw an error when header is invalid 2018-06-27 17:22:00 -07:00
Brent Vatne
3dd3f5b804 Release 2.5.4 2018-06-27 15:24:34 -07:00
Julian Paas
3d8d5a0634 Adds getNavigation to web exports (#4551) 2018-06-27 13:34:45 -07:00
Brent Vatne
54448ed070 Prevent flicker in header when header is null on initial mount (when using default header sizes) (#4577)
* Prevent flicker in header in most common cases. Fixes https://github.com/react-navigation/react-navigation/issues/4264

* Update snapshots
2018-06-26 13:27:43 -07:00
Julian Paas
369ac2b568 Adds SwitchNavigator to react-navigation-web (#4550)
* Adds SwitchNavigator to react-navigation-web
2018-06-26 11:24:23 -07:00
Vojtech Novak
3dc592f679 Update ISSUE_TEMPLATE.md (#4575) 2018-06-25 15:41:56 -07:00
Brent Vatne
4f93200c91 Release 2.5.3 2018-06-25 14:37:26 -07:00
Brent Vatne
665736d754 Hoist navigation action creators for router above those for child router 2018-06-25 14:33:01 -07:00
Brent Vatne
5598c3e28f Update changelog 2018-06-23 11:03:38 -07:00
Brent Vatne
cde6e845cd Release 2.5.2 2018-06-23 11:02:14 -07:00
Brent Vatne
fb8c712ad8 Update react-navigation-drawer to 0.4.2 to fix toggle regression 2018-06-23 11:01:47 -07:00
Brent Vatne
350b7e0aed Release 2.5.1 2018-06-22 13:21:22 -07:00
Brent Vatne
de112565d3 Fix name of prop, should be lastTransitionProps instead of prevTransitionProps in StackViewLayout
- Fixes #4542
2018-06-22 13:18:26 -07:00
Brent Vatne
acdd515c13 Update example app.json 2018-06-22 12:50:50 -07:00
Rodrigo Bermúdez Schettino
452a6d2004 Improve changelog format (#4559)
Bug fixes should be listed in the "Fixed" section instead of "Changed" according to keepachangelog.
2018-06-22 10:41:58 -07:00
Brent Vatne
08c8031a71 Release 2.5.0 2018-06-22 10:32:11 -07:00
Eric Vicenti
608365266a @ericvicenti/universe (#4493)
* Isolate modules for uncontainerized navigators

* Clean up prop-types

* Fix warnings and web import friendlyness

* strip a flow

* Standalone provider/consumer navigation context

* export shallowEqual as module

* address various lint

# Conflicts:
#	src/navigators/createStackNavigator.js

* Get tests to pass
2018-06-22 10:20:27 -07:00
Rodrigo Bermúdez Schettino
247fba56e6 Fix typo in Pull Request Template (#4558)
Also link to the "Unreleased" section in CHANGELOG.
2018-06-22 10:19:41 -07:00
Brent Vatne
060f5dcecf Update PR template for changelog 2018-06-22 08:25:38 -07:00
Rodrigo Bermúdez Schettino
fdec05c87a Create CHANGELOG.md (#4544)
List all changes between versions to notify about notable changes in releases.
2018-06-22 08:22:15 -07:00
Brent Vatne
76da804574 Fixes #4491 2018-06-21 15:24:52 -07:00
Brent Vatne
dde091848a Release 2.4.1 2018-06-20 15:35:07 -07:00
Brent Vatne
824fa32416 Improve playground on Android 2018-06-20 14:20:00 -07:00
Brent Vatne
c518e7f36c Improve example 2018-06-20 13:51:34 -07:00
Brent Vatne
1cfe01dbdb Release 2.4.0 2018-06-20 13:38:05 -07:00
Brent Vatne
e62a9050fd Fix withDefaultValue 2018-06-20 13:37:33 -07:00
Christophe Hurpeau
310b909ba8 createNavigationContainer: rethrow the error instead of creating a new one (#4533)
Creating a new error makes the stack unreadable in sentry, because the stack is stringified when the error is cast to string to create a new one.
Is there another reason to do that ?
Alternative possible solution would be to add a method to be able to handle the error ourselves ?
2018-06-20 13:03:02 -07:00
Eric Vicenti
aebe8a5c23 Fix isTransitioning on nested navigate (#4520)
This bug wasnt apparent until we fixed the transitioner to fully respect isTransitioning. The router did not handle this properly until now.

Enhanced a test to verify this in the future
2018-06-20 12:17:14 -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
fa86718a24 Revert "Export getNavigationActionCreators (#4258)" (#4495)
This reverts commit 1e7d8d55c3.
2018-06-14 11:34:38 -07:00
Ashoat Tevosyan
c8e5673183 [flow] Type getNavigation (#4505)
Unrelated change in here: typing `tabBarOnPress`'s `defaultHandler`. Wasn't sure if I should make a separate PR for a single unrelated line, let me know if you'd prefer that going forward.
2018-06-14 11:33:50 -07:00
Ashoat Tevosyan
b312a5e307 [ReduxExample] Update to use react-navigation-redux-helpers@2.0.0 (#4504) 2018-06-14 11:15:11 -07:00
Brent Vatne
ee6a6c53b1 Fix incorrect methods being called in createKeyboardAwareNavigator 2018-06-13 14:50:03 -07:00
Eric Vicenti
8edec88341 Export getNavigation as public API, test redux (#4489)
This unblocks the fixing of react-navigation-redux-helpers to unbreak redux support in 2.3

https://github.com/react-navigation/react-navigation-redux-helpers/pull/37

All redux users will need to change their code to reflect the changes made here to `ReduxExample/AppNavigator`
2018-06-12 11:59:09 -07:00
Brent Vatne
b8d6d4253d Release 2.3.1 2018-06-12 11:32:08 -07:00
Eric Vicenti
0adb1ba9f1 Export getNavigation as public API, test redux (#4488)
This unblocks the fixing of react-navigation-redux-helpers to unbreak redux support in 2.3

https://github.com/react-navigation/react-navigation-redux-helpers/pull/37

All redux users will need to change their code to reflect the changes made here to `ReduxExample/AppNavigator`
2018-06-12 11:30:23 -07:00
Brent Vatne
d3ef3d1271 Release 2.3.0 2018-06-11 15:54:41 -07:00
k-murakami0609
89a24bdc12 fix broken link to Common mistakes (#4468) 2018-06-10 10:41:18 -07:00
Brent Vatne
128a95b496 Release 2.3.0-beta.1 2018-06-09 14:18:09 -07:00
Brent Vatne
470eaf3b08 Make the actions available on the navigator navigation prop the same as its children (#4467)
* Make the actions available on the navigator navigation prop the same as its children

* Fix test and improve code clarity
2018-06-09 14:13:21 -07:00
Brent Vatne
c91e8206a5 Fix ScenesReducer test 2018-06-08 17:44:32 -07:00
Brent Vatne
da283915f8 Release 2.3.0-beta.0 2018-06-08 17:36:42 -07:00
Brent Vatne
3031e7bd80 Update header when screenProps change (Fixes #4271) 2018-06-08 17:35:17 -07:00
Brent Vatne
98a4f26f26 Bump react-navigation-drawer. Fixes #4416 2018-06-08 16:27:36 -07:00
Brent Vatne
b7f5435c93 Fix withNavigation in non-floating headers 2018-06-08 15:48:21 -07:00
Brent Vatne
21ef4fcb82 Return result of dispatch from action helpers 2018-06-08 14:33:01 -07:00
Eric Vicenti
5f64a2a9cb Refactor redo, child navigation to navigation prop (#4453) 2018-06-08 14:20:07 -07:00
Brent Vatne
992d0fb267 Release 2.2.5 2018-06-08 09:40:39 -07:00
ensecoz
6f41379ed1 extract correct property for onTransitionEnd (#4459) 2018-06-08 09:35:36 -07:00
Tom Klaver
267af01e72 throw readable error when wrong navigation prop is passed (#4455)
* add warning when passing wrong navigation prop: https://github.com/react-navigation/react-navigation/issues/3598

* add test for throwing when passing wrong navigation prop

* wrong nav prop error: update snapshots, throw => throw new, update docs reference url
2018-06-08 09:31:05 -07:00
Arthur Levoyer
b68c3a755d Add missing tests about DeepLinking (#4451)
* Fix #1950 (Deep link not working when nesting have more than two levels.)

* Fix test
2018-06-07 11:37:57 -07:00
Brent Vatne
7345634493 Release 2.2.4 2018-06-07 11:33:14 -07:00
Brent Vatne
6517169119 Re-compute options when screenProps change 2018-06-07 11:31:31 -07:00
Brent Vatne
ea5d14a720 Release 2.2.3 2018-06-06 21:13:00 -07:00
Brent Vatne
313d0726a8 Add some logs to NavigationPlayground around helper dispatch return value
This is a poor substitute for tests
2018-06-06 21:12:18 -07:00
Brent Vatne
b52f153747 Return the result of dispatch from helpers. Fixes #4445 2018-06-06 21:01:51 -07:00
Brent Vatne
44621005ff Release 2.2.2 2018-06-06 14:34:59 -07:00
Brent Vatne
bf58364c3d Bump react-navigation-drawer 2018-06-06 14:34:42 -07:00
Brent Vatne
b55053cde6 Release 2.2.1 2018-06-06 13:24:50 -07:00
Brent Vatne
9abb2644a9 Bump react-navigation-tabs and rebuild yarn.lock 2018-06-06 13:24:29 -07:00
Brent Vatne
6a946d6ab7 Revert "Refactor, move child navigation to navigation prop (#4425)"
This reverts commit ba62509ff4.
2018-06-06 13:19:08 -07:00
陈然
395abe5200 Change 'React' import writing, Prevent warnings in old version React (#4428) 2018-06-06 12:51:09 -07:00
Eric Vicenti
ba62509ff4 Refactor, move child navigation to navigation prop (#4425)
* Refactor, move child navigation to navigation prop

This fixes our descriptor caching issue, and unblocks explicit nested navigation options.

As a side effect, the following APIs are introduced:

- navigation.getChildNavigation(routeKey) , which is useful for explicitly getting children config info
- navigation.router, access to the static router

- router.childRouters[routeName] , an optional way to access the children routers directly. If childRouters are not provided in a router, we will fall back on getComponentForRouteName(routeName).router, which is the previous external API for this (although it may be slower because it will require the whole screen component).

* supporting tests and top level actions

* cleanup
2018-06-06 12:50:30 -07:00
Brent Vatne
45391db7d9 Move all drawer code into react-navigation-drawer (#4435)
* Move all drawer code into react-navigation-drawer

* Remove react-native-drawer-layout-polyfill from package.json
2018-06-06 12:11:28 -07:00
Brent Vatne
7f86362e86 Release 2.2.0 2018-06-05 12:21:09 -07:00
Brent Vatne
99605737e9 Bump react-navigation-tabs to latest 2018-06-05 12:20:47 -07:00
Serge Lebedev
842f5eb7b2 [flow] Fix NavigationScreenComponent's navigationOptions (#4317) 2018-06-05 12:19:12 -07:00
Richárd Biró
183ea82416 Pass getCustomActionCreators to Drawer route (#4433) 2018-06-05 11:12:03 -07:00
Rodrigo Bermúdez Schettino
108a6504a7 Use consistent naming in README (#4427)
Use the same casing (camel case) as in the README's title for the License section.
2018-06-05 10:55:20 -07:00
Eric Vicenti
f92d671746 Fix getCustomActionCreators in drawer navigator 2018-06-05 10:51:05 -07:00
Brent Vatne
e0c4a8f7d3 Release 2.1.0 2018-06-04 14:04:00 -07:00
Rodrigo Bermúdez Schettino
bc881c8aa1 Update deprecated StackNavigator usage (#4389)
Use createStackNavigator instead.
2018-06-04 13:59:55 -07:00
Ashoat Tevosyan
118c19dcce [flow] Update NavigationActions and introduce StackActions and DrawerActions (#4345) 2018-06-04 13:58:14 -07:00
James Bechet
01b43974e6 fix swipe to go back by providing the index (#4409) 2018-06-04 13:55:26 -07:00
Brent Vatne
2f90899620 Cache descriptors in createNavigator (#4424) 2018-06-04 13:54:09 -07:00
Eric Vicenti
6cc86f66e1 Fix stack router state change without isTransitioning change (#4368) 2018-06-04 12:47:40 -07:00
Eric Vicenti
4be99b6645 Transitioner: Fix instantaneous transitions (#4404)
* Transitioner: Fix instantaneous transitions

The transitioner will always perform an animation on state change. Instead we should check if the navigation state is requesting a transition with isTransitioning. If not, we follow a similar codepath to transitioning, without any animation.

* Update .eslintrc
2018-06-04 12:46:08 -07:00
Eric Vicenti
80016b7218 Fix race condition in DrawerView (#4392) 2018-06-03 13:35:55 -07:00
Eric Vicenti
f555a9ec9a Fix drawer router logic to close drawer (#4394) 2018-06-03 13:35:30 -07:00
Brent Vatne
05cbd85d5c Temporarily stop running flow on navigation playground due to internal react-native flow errors 2018-06-01 15:02:12 -07:00
Hunkyo Jung
51965eac38 Pass getCustomActionCreators to StackRouter (#4366) 2018-05-31 19:21:11 -07:00
Brent Vatne
a3956bf3ce Update tab snapshots 2018-05-31 13:53:00 -07:00
Brent Vatne
ce24c66b5a Disable react/no-deprecated to pass CI without breaking old versions of React 2018-05-31 13:47:28 -07:00
Brent Vatne
5467f0e22d Release 2.0.4 2018-05-25 23:05:54 -07:00
Ashoat Tevosyan
1e7d8d55c3 Export getNavigationActionCreators (#4258)
* Export getNavigationActionCreators

`react-navigation-redux-helpers` generally needs to duplicate whatever `createNavigationCreator` does. As of `react-navigation@2.0`, that includes using `getNavigationActionCreators` to construct the top-level `NavigationScreenProp`.

This PR isn't strictly needed, as it's possible to import from the file directly. But that's a brittle approach, and not particularly discoverable for anybody attempting to use a "non-stateful" navigator with their state management library of choice.

* Further refinements after writing the new helper

* Final refinement of NavigationScreenProp's relationship with _DefaultActionCreators

* Resolve merge conflicts
2018-05-25 22:59:11 -07:00
Brent Vatne
1d2ce862c2 Fix Stacks over Tabs example 2018-05-25 16:07:55 -07:00
Louis Lagrange
d778479e4a Fix drawer router initial state (#4219)
* Fix drawer router initial state

* Add test

* Be concise
2018-05-25 16:01:53 -07:00
Sébastien BARBIER
352dae50e1 Apply drawerlockmode from screen options to DrawerLayout component (#4202)
Fix #4201
2018-05-25 15:50:39 -07:00
Louis Lagrange
61385cae59 Export missing Drawer components (#4221) 2018-05-25 15:49:33 -07:00
Brent Vatne
aa3c13891e Bump some versions 2018-05-25 15:26:25 -07:00
Andrei Xavier de Oliveira Calazans
9696d7220d fix(create-nav-container): pass up error on catch (#4298) 2018-05-25 15:13:18 -07:00
Louis Lagrange
2b83b44816 Remove obsolete DrawerScreen (#4222) 2018-05-25 14:45:45 -07:00
Louis Lagrange
ec749023ed [Web] Fix header height margin (#4206) 2018-05-25 14:44:46 -07:00
Sébastien Lorber
adc9389eb3 Add CircleCI Badge to README (#4318)
Displaying a badge is helpful for users but also contributors (for example to know why my upstream-rebased PR is not passing tests)
2018-05-25 14:41:27 -07:00
Sébastien Lorber
54d143fee2 Fix Codecov link -> react-community vs react-navigation (#4319) 2018-05-25 14:39:51 -07:00
Louis Lagrange
d50e74d0c7 Fix NavigatorContainer test (fixes CI) (#4327) 2018-05-24 17:43:58 +02:00
Nicolas Charpentier
22926c5230 Optimize images (#4251) 2018-05-23 16:54:23 -07:00
Ashoat Tevosyan
f6c47a6c66 [examples] Update ReduxExample (#4267)
Using two new utils:
1. `createNavigationPropConstructor`, which is now preferred over `createReduxBoundAddListener`.
2. `initializeListeners`, which is necessary to trigger the event listeners with the initial state.
2018-05-23 10:20:14 -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
Ashoat Tevosyan
72f17538c2 [flow] Fix tabBarOnPress type for react-navigation@2.0 (#4256) 2018-05-23 10:18:11 -07:00
Ashoat Tevosyan
550001b053 [flow] Fixes for v2 libdef (#4230)
* [flow] Remove "any" type from NavigationComponent

"any" cripples the typechecker, so it's best to avoid. It was introduced in #3392, but I don't think the intention was to keep it there.

* [flow] Remove `any` type from `createNavigator` return

And use objects with spread sub-types instead of unions for `React$ComponentType` type param
2018-05-23 10:17:45 -07:00
Brent Vatne
d168ab26f9 Release 2.0.2 2018-05-21 17:56:24 -07:00
Brent Vatne
99916328a1 Don't warn about multiple navigation containers on Android
This really is not ideal but it's an upstream bug on react-native Android
that we can't work around. Users may experience other unexpected behavior as a
result of this upstream bug.
2018-05-21 17:55:05 -07:00
Eric Vicenti
08e1b53f2e Update playground yarn lockfile 2018-05-12 10:48:45 -07:00
Eric Vicenti
2243528e97 Cache panResponder in StackView (#4183)
* fix swipe gesture bug

* panresponder as instance prop
2018-05-09 17:36:57 -07:00
Steven Kabbes
931271198b Remove unused code addNavigationHelpers (#4179) 2018-05-09 14:53:06 -07:00
Brent Vatne
1876706bad Release 2.0.1 2018-05-08 17:45:02 -07:00
Eric Vicenti
e97d6b26a8 Fix dispatch implementation (#4168)
Previously we had been emiting an action event with a null state when the router handles the action by returning null from getStateForAction.

- Fixes the case of null state getting emitted
- Renames a few things for clarity
- Refactors conditionals to read easier
- Comments to explain intent
2018-05-08 17:41:08 -07:00
Brent Vatne
ec1694f909 Release 2.0.0 2018-05-07 13:47:13 -07:00
Brent Vatne
93db7d0c95 Release 2.0.0-rc.14 2018-05-07 13:03:21 -07:00
Brent Vatne
589b80b2fa Update drawer example 2018-05-07 13:01:22 -07:00
Eric Vicenti
364144d639 Navigation Action Helpers at root (#4151) 2018-05-07 12:56:35 -07:00
Brent Vatne
2fd7284fe2 Release candidate lucky number 13 2018-05-07 11:54:50 -07:00
Brent Vatne
6499f02157 Only blur input when index changes on transition start (Fixes #4148) 2018-05-07 11:47:56 -07:00
Brent Vatne
39d5714ac0 Release 2.0.0-rc.12 2018-05-07 11:14:03 -07:00
Brent Vatne
1ceda5f04d Update react-navigation-deprecated-tab-navigator. Closes #4147 2018-05-07 11:13:34 -07:00
Brent Vatne
4533883ba7 Release 2.0.0-rc.11 2018-05-06 13:41:53 -07:00
spaceye
8ec2466fef Fix for broken swipe back gesture in RTL mode (#4119)
* 3127: Fixed gestureDirectionInverted variable declaration and condition in onPanResponderMove method in regards to swipe back action in RTL mode.

* - 4118: Put axis check first;
- Fixed default BackButton mask in RTL mode.
2018-05-06 12:42:22 -07:00
Brent Vatne
1bd6593ede Release 2.0.0-rc.10 2018-05-06 12:00:02 -07:00
Eric Vicenti
4e8d8ce12f Fixes to drawer router handling of child routers (#4131)
Addresses #4129, and also lets child routers swallow actions with null. Tests added
2018-05-06 11:59:40 -07:00
Eric Vicenti
9f95a7f10b Fix CompletionAction trigger (#4115) 2018-05-06 11:57:51 -07:00
Serge Lebedev
f6bd3e4306 Fix setting undefined value to isTransitioning (#4124) 2018-05-06 10:04:57 -07:00
Eric Vicenti
c1a94895f5 Fix drawer stack reset-to-top behavior (#4132)
“reset” is not a NavigationAction anymore.

The correct fix, for v3, to this is to navigate to the first screen inside the stack. With the less-pushy navigate behavior in v2, this will result in the first route getting selected if you specify it by routeName.
2018-05-06 09:51:18 -07:00
Brent Vatne
ad7cde9eb9 Release 2.0.0-rc.9 2018-05-04 11:16:34 -07:00
Brent Vatne
2643f690a9 Pull createMaterialBottomTabNavigator into separate repo 2018-05-04 11:06:51 -07:00
Brent Vatne
8e52995ef3 Release 2.0.0-rc.8 2018-05-04 10:14:34 -07:00
Eric Vicenti
8ed3817c90 Fix event unsubscription logic (#4116)
Events were getting unsubscribed too early, so that the inner willBlur event was getting skipped when trying to “dismiss” a deep navigation stack.
2018-05-04 10:14:22 -07:00
Brent Vatne
eda9bfd567 Update react-lifecycles-compat 2018-05-04 10:10:28 -07:00
Eric Vicenti
723c5f2149 Fix drawer navigation dispatch (#4121) 2018-05-04 09:48:45 -07:00
Brent Vatne
ab5481a290 Add context around a test in switchrouter 2018-05-03 15:43:37 -07:00
Brent Vatne
df281cfed0 Add router tests to clarify route resolution 2018-05-03 15:42:23 -07:00
Eric Vicenti
e0df3cf74a Fix issue with nested navigation actions in stack (#4114) 2018-05-03 10:13:43 -07:00
Vojtech Novak
2440af66e4 add a test so that #2856 can be closed (#4102)
* add test for 2856

* rename variables
2018-05-02 20:02:03 -07:00
simonbuerger
47fe858d4e StateUtils: Use Array.prototype.findIndex instead of map => indexOf (#4106)
* Use Array.prototype.findIndex instead of map => indexOf

Creating a new array and iterating over all the routes is inefficient compared to findIndex, which does not create a new array and exits as soon as it finds a match. Since the indexOf method is used extensively this should provide a minor performance improvement

* reverted yarn.lock edits
2018-05-02 20:01:20 -07:00
Eric Vicenti
c641bee11b Fix initial action dispatch for nonPersisted apps (#4104) 2018-05-02 09:17:00 -07:00
Brent Vatne
4b39e2db3c Release 2.0.0-rc.7 2018-04-30 17:08:23 -07:00
Eric Vicenti
f7533a790f Add tests to confirm setParam behavior (#4099)
Adding these tests because reports from this issue make me nervous:

https://github.com/react-navigation/react-navigation/issues/1274
2018-04-30 16:37:41 -07:00
Brent Vatne
c56122466f Release 2.0.0-rc.6 2018-04-30 16:19:28 -07:00
Brent Vatne
7fc992dc58 Container state can be out of date if we have async functions between getting it and using it (#4098) 2018-04-30 15:59:49 -07:00
Rob Allsopp
32922cdd7d go back to React$, and fix real error (#4095) 2018-04-30 12:04:48 -07:00
Rob Allsopp
eda51b3b79 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 14:30:23 -07:00
Jed Mao
921ee09587 Fix "npm test" on Windows 10 (#4066)
* Fix Windows

* update prettier

* Explain need for assetsTransformer in comment
2018-04-27 08:57:07 -07:00
Brent Vatne
7ae4c60eb8 Release 2.0.0-rc.5 2018-04-25 17:49:17 -07:00
Brent Vatne
5fff7ef5c6 Give inactive routes in stack opportunity to handle action (#4064) 2018-04-26 00:48:55 +00:00
Brent Vatne
42bb1cc317 Release 2.0.0-rc.4 2018-04-25 17:04:15 -07:00
Brent Vatne
337fd89ad5 Bump react-navigation-deprecated-tab-navigator 2018-04-25 16:57:42 -07:00
Brent Vatne
acf9b92ff7 Bump react-navigation-tabs 2018-04-25 16:49:57 -07:00
Rich Gilbank
5072130d6f Typo in deprecation notice (#4051) 2018-04-24 11:10:48 -07:00
Brent Vatne
20bbbd62ff Release 2.0.0-rc.3 2018-04-20 17:40:02 +03:00
Adam Miskiewicz
0890896824 Make StackNavigator keyboard aware (#3951)
* Make StackNavigator keyboard aware

One thing that has always annoyed me in React Navigation is the handling of the keyboard. When a keyboard is visible on screen and a navigation action occurs (either by tapping a button or using a gesture), the keyboard tends to stay on screen until the transition completes. This feels janky and broken. On native iOS, for instance, the keyboard hides immediately when the navigation starts, and if the transition is cancelled (say, when the user releases the gesture), the keyboard reappears.

This PR introduces a "KeyboardAwareNavigator" higher order component that is enabled on the StackNavigator, unless a `disableKeyboardHandling` prop is passed into the StackNavigator's configuration.

* Set status bar in keyboard handling example

* Call gesture props in keyboard aware navigator if available

* Fix formatting
2018-04-20 17:03:25 +03:00
Serhii Palash
0cf14f8e1e Fix TabNavigator export ( Issue #3962 ) (#3979) 2018-04-20 16:40:18 +03:00
Brent Vatne
e5e434c9e2 Fix _isRouteFocused so it takes a route and returns bool rather than fn 2018-04-20 16:39:03 +03:00
Janic Duplessis
e5d8d2c216 Fix header hardcoded height to accound for iPhone X and orientation changes (#4017) 2018-04-20 16:34:33 +03:00
Eric Vicenti
abd5200739 Fix header ModularLeftComponent to goBack from child navigation (#4023) 2018-04-20 16:33:36 +03:00
Brent Vatne
202609d9cf Release 2.0.0-rc.2 2018-04-09 17:26:32 -07:00
Yao Hui Chua
7b4dd98255 Shift tests to isolate routers (#3876) 2018-04-09 13:00:01 -07:00
Janic Duplessis
70c644f522 Fix transition between 2 screens with no header (#3939) 2018-04-09 12:32:27 -07:00
Janic Duplessis
5274d16e3b Use Header.HEIGHT instead of measuring to avoid flicker (#3940) 2018-04-09 12:31:43 -07:00
Janic Duplessis
e5e2cbb86d Fix header transition when mode is set to screen (#3927) 2018-04-09 11:22:51 -07:00
Brent Vatne
a8caa0d93c Release 2.0.0-rc.1 2018-04-06 15:14:32 -07:00
Eric Vicenti
f70a25a6a8 drawer router key (#3925) 2018-04-06 15:13:55 -07:00
emision
6cde6e2558 add isFocused helper definition (#3912) 2018-04-06 12:43:51 -07:00
Brent Vatne
0794c0faaa Fix typo in SwitchRouter 2018-04-06 12:42:42 -07:00
Brent Vatne
ea28e84e5a Fix stackConfig typo 2018-04-06 12:39:44 -07:00
Eric Vicenti
419ee5318d custom action creators api (#3923) 2018-04-06 12:12:39 -07:00
Brent Vatne
fbbf00875b Release 2.0.0-beta.10 2018-04-05 14:46:33 -07:00
Brent Vatne
22e09f7186 Prevent double application of navigationOptions function when using RouteName: ScreenName route config 2018-04-05 14:45:41 -07:00
Brent Vatne
ece6297e8e Release 2.0.0-beta.9 2018-04-05 12:09:55 -07:00
Eric Vicenti
ad52caf57b Immediate transition fix, avoid stale render (#3901) 2018-04-05 11:35:16 -07:00
Eric Vicenti
11f5e6e8e5 container initialization fix (#3899) 2018-04-05 11:29:59 -07:00
Eric Vicenti
1764b21f34 fix header back (#3900) 2018-04-05 11:29:15 -07:00
Eric Vicenti
bbacabeba3 avoid unnecessary navigation completion dispatches (#3902) 2018-04-05 11:27:32 -07:00
Eric Vicenti
b140b70555 no more component will mount (#3903) 2018-04-05 11:25:26 -07:00
Eric Vicenti
356646cbfa Enhance replace action creator (#3906) 2018-04-05 11:25:04 -07:00
Brent Vatne
6234b5661e Release 2.0.0-beta.8 2018-04-04 19:34:09 -07:00
Brent Vatne
270c3f0754 Bump react-navigation-tabs dependency 2018-04-04 19:33:51 -07:00
Brent Vatne
6f04bdffa6 Update NavigationPlayground dependencies 2018-04-04 19:33:01 -07:00
Brent Vatne
8415378784 Release 2.0.0-beta.7 2018-04-04 18:37:41 -07:00
Brent Vatne
9e47092d56 Fix isFocused and example 2018-04-04 18:37:08 -07:00
Brent Vatne
029d6ac4d2 Update react-navigation-tabs 2018-04-04 18:17:57 -07:00
Gaëtan Renaudeau
d57d118fda Update Flowtype to support navigation.navigate({}) (#3843) 2018-03-26 17:17:36 -04:00
Brent Vatne
2232e394bb Fix refactoring errors 2018-03-25 19:04:15 -07:00
Eric Vicenti
670d48366b Actions creators overhaul (#3619) 2018-03-25 18:31:59 -07:00
Brent Vatne
99ac5b6c08 Release 2.0.0-beta.6 2018-03-25 12:33:30 -07:00
Brent Vatne
68a2a106f3 Warn when users have multiple stateful navigation containers (#3819)
* First pass at warning when users explicitly render nested navigators

* Clean up tests around warnings

* Update comment

* Update comment again
2018-03-25 12:33:11 -07:00
Gianfrancø Palumbo
b7c6d072a5 fix(redux example readme): link to doc (#3828) 2018-03-25 10:49:22 -07:00
Eric Vicenti
ecd9fd71e9 withNavigation improvement (#3834)
The navigation prop should also pass through, and be prioritized over context because it is more explicit

This also fixes an incorrect warning/invariant
2018-03-25 10:49:09 -07:00
Adam Miskiewicz
cfc9690326 Smoothly transition header visibility in Stack
This closes #2732 (which also happens to be the top issue on canny.io).
2018-03-25 10:27:59 -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
Tom Klaver
9c3fffa47f Fix broken link behind PRs Welcome badge (#3824) 2018-03-23 11:23:10 -04:00
Brent Vatne
be524e4224 Release 2.0.0-beta.5
- Update react-navigation-tabs
2018-03-22 20:52:47 -07:00
Brent Vatne
095814230b Release 2.0.0-beta.4 2018-03-22 19:43:47 -07:00
Eric Vicenti
9cf557bba0 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
Eric Vicenti
5e4512f3eb Implement paths on SwitchRouter (#3806)
* Fix paths overriding in SwitchRouter
2018-03-22 22:41:27 -04:00
Brent Vatne
ee1b5972ce Release 2.0.0-beta.3 2018-03-19 16:53:34 -04:00
Brent Vatne
2233d0e1d8 Add switch example 2018-03-19 16:52:12 -04:00
Eric Vicenti
577d99c165 StackRouter to return null on idempotent navigation (#3793)
This new behavior indicates that the action has been handled, but the state has not changed.
2018-03-19 16:46:57 -04:00
Brent Vatne
aa362ea776 Release 2.0.0-beta.2 2018-03-19 13:06:49 -04:00
Brent Vatne
864908a49c Bump version to 2.0.0-beta.1 2018-03-19 01:36:37 -04:00
Brent Vatne
5cab55b8c9 Release 2.0.0-beta.0 2018-03-19 00:13:27 -04:00
Brent Vatne
9b9db86bde Release 2.0.7 2018-03-18 22:22:26 -04:00
Eric Vicenti
4def39c0f7 Improve path matching for SwitchRouter and empty paths (#3784) 2018-03-18 22:10:15 -04:00
Brent Vatne
e6559f5878 Add react-native-tabs as export from react-navigation 2018-03-18 17:50:02 -04:00
Eric Vicenti
a9d8f2e03e Temporarily disable broken test in NavigationPlayground 2018-03-18 12:22:56 -04:00
Brent Vatne
84a070b9d5 Release 2.0.0-alpha.6 2018-03-17 16:27:52 -04:00
Brent Vatne
ee984943c7 Fix push action -- regressed when making navigate "less pushy" 2018-03-17 16:27:19 -04:00
Brent Vatne
9fdfec18f6 Remove yarn link in test script 2018-03-16 20:08:47 -04:00
Eric Vicenti
aee16b91a4 Improve consistency of jest version
Hopefully will fix build on Circle
2018-03-16 16:21:17 -07:00
Jakob Murko
191439f79a Prevent duplicate drawer events (#3763) 2018-03-16 15:36:31 -07:00
Brent Vatne
b1ac152fec Rename 'carefullyGetParent' to 'dangerouslyGetParent'
- It is potentially dangerous because screen components may or may not have the
expected parent, so depending on anything related to the parent may lead to
bugs. You should use carefully because it is dangerous ;)
2018-03-15 16:01:58 -07:00
Brent Vatne
c588ab9f9d Fix TabNavigator related tests 2018-03-15 13:40:29 -07:00
Brent Vatne
ae8cd41396 Deprecate TabNavigator in favor of react-navigation-tabs 2018-03-15 13:31:41 -07:00
Michał Pierzchała
5038ee2360 Fix memory leak in TabView-test.js (#3742) 2018-03-15 12:25:08 -07:00
Brent Vatne
5bf071e3ee Release 2.0.0-alpha.5 2018-03-15 10:57:33 -07:00
Michał Pierzchała
fcbf78e658 feat(context): refactor passing navigation context (#3668)
* feat(context): refactor passing navigation context

* remove commented code in example

* adjust src/views/withNavigationFocus.js

* refactor stuff

* extract scene to variable

* Add test

* Apply CR comments

* remove junk

* bring back screen mode header
2018-03-15 10:55:00 -07:00
KUBO
fd75e9c14c Remove unuseful SafeAreaView (#3721) 2018-03-15 10:35:02 -07:00
Brent Vatne
7d36a3b137 Update snapshots 2018-03-15 10:34:18 -07:00
Brent Vatne
175387b22f Another fix for frustrating tab bar icon layout issue 2018-03-15 10:34:18 -07:00
Brent Vatne
0dd7daecc0 Rename exports for navigators from XNavigator to createXNavigator (#3753) 2018-03-14 23:23:04 -07:00
Brent Vatne
42230634fd Missed a case where we should not have flexGrow 2018-03-14 21:48:48 -07:00
Brent Vatne
a9943e9b2e Update snapshot 2018-03-14 21:42:39 -07:00
Brent Vatne
6475e32dba Apply horizontal icon style whenever we should use horizontal tabs in icon 2018-03-14 21:34:53 -07:00
Brent Vatne
f67872d8f1 Release 2.0.0-alpha.4 2018-03-14 15:22:14 -07:00
Brent Vatne
2c7187b22a Rename exports for navigators from XNavigator to createXNavigator 2018-03-14 15:21:38 -07:00
Brent Vatne
160d44f58e Fix back button on modular header 2018-03-14 15:19:03 -07:00
spaceye
d017ed01b3 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 13:15:11 -07:00
Vojtech Novak
c2e197f8d3 fix contribution docs link (#3707) 2018-03-13 13:14:02 -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
Vojtech Novak
b575200879 reuse styles (#3725) 2018-03-13 13:05:21 -07:00
Brent Vatne
cd5bd8882e Release 2.0.0-alpha.3 2018-03-12 16:19:48 -07:00
Brent Vatne
3f837c895e Add lifecycle polyfill and change away from componentWillMount where possible without too much refactoring 2018-03-12 16:05:43 -07:00
Brent Vatne
bc5d35aba3 Release 2.0.0-alpha.2 2018-03-12 16:01:57 -07:00
Brent Vatne
9a6e0bbd98 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
052d22804c Release 2.0.0-alpha.1 2018-03-12 15:23:38 -07:00
Brent Vatne
7a978b1087 Implement "less pushy navigate" RFC 2018-03-12 15:22:51 -07:00
Brent Vatne
b06fb7e432 Release 2.0.0-alpha.0 2018-03-12 15:06:47 -07:00
Brent Vatne
a92ed83302 Fix tab icon height on horizontal / ipad 2018-03-12 15:06:47 -07:00
Brent Vatne
0c31bc44ea Make push, pop, and popToTop bubble like navigate (#3617) 2018-03-12 15:06:38 -07:00
Brent Vatne
8e5ee4d312 Use arrow function for isFocused 2018-03-12 09:56:39 -07:00
Brandon Smith
4bb8987ab7 Pass initialRouteKey into StackRouter (#3540) (#3702) 2018-03-09 11:32:01 -08:00
Brent Vatne
81a86fa091 Swap addListener out for isFocused prop on ResourceSavingSceneView (#3700) 2018-03-09 10:55:00 -08:00
Brent Vatne
47f357f332 Fix TabRouter-test 2018-03-09 10:46:05 -08:00
Brent Vatne
bdda6fa5be Add SwitchNavigator to 2.x 2018-03-07 17:35:15 -08:00
Ashoat Tevosyan
b097136f74 [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 11:29:25 -08:00
Ben Styles
c9b0219cec 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 14:19:00 -05:00
Eric Vicenti
ac83cf804c Fix issue in drawer actions (#3667)
* Fix issue in drawer actions

* Update DrawerView.js
2018-03-06 14:38:03 -08:00
Sirui Li
cf63521516 Flow type: SafeAreaView doesn't require children (#3670)
`children` prop should be optional.
2018-03-06 14:19:46 -08:00
282 changed files with 18926 additions and 41827 deletions

View File

@@ -1,3 +0,0 @@
{
"presets": ["react-native"]
}

View File

@@ -1,40 +1,11 @@
version: 2
version: 3
jobs:
build:
docker:
- image: reactcommunity/node-ci:8.4.0-0 # custom image -- includes ocaml, libelf1, Yarn
- image: circleci/node:10
parallelism: 2
working_directory: ~/react-navigation
steps:
- checkout
- restore_cache:
# cache by branch + package.json, by branch, and then master
keys:
- v3-react-navigation-{{ .Branch }}-{{ checksum "package.json" }}
- v3-react-navigation-{{ .Branch }}
- v3-react-navigation-master
- run: yarn # install root deps
- run: ./scripts/test.sh # run tests
- setup_remote_docker
- deploy:
command: |
set -x
VER="17.03.0-ce"
curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
mv /tmp/docker/* /usr/bin
yarn global add exp
set +x
exp login -u "$EXPO_USERNAME" -p "$EXPO_PASSWORD"
set -x
cd examples/NavigationPlayground && yarn && exp publish --release-channel "${CIRCLE_SHA1}"
- save_cache:
key: v3-react-navigation-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- ~/.cache/yarn
- ~/react-navigation/examples/NavigationPlayground/node_modules
- ~/react-navigation/examples/ReduxExample/node_modules
notify:
webhooks:
- url: https://react-navigation-ci.now.sh
- run: yarn install --frozen-lockfile
- run: ./scripts/test.sh

View File

@@ -7,18 +7,18 @@
"prettier/react"
],
"parser": "babel-eslint",
"plugins": [
"react",
"prettier"
],
"plugins": ["react", "prettier"],
"env": {
"jasmine": true
},
"rules": {
"prettier/prettier": ["error", {
"trailingComma": "es5",
"singleQuote": true
}],
"prettier/prettier": [
"error",
{
"trailingComma": "es5",
"singleQuote": true
}
],
"no-underscore-dangle": "off",
"no-use-before-define": "off",
@@ -27,24 +27,20 @@
"no-plusplus": "off",
"no-class-assign": "off",
"no-duplicate-imports": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"react/jsx-filename-extension": [
"off", { "extensions": [".js", ".jsx"] }
],
"react/jsx-filename-extension": ["off", { "extensions": [".js", ".jsx"] }],
"react/sort-comp": "off",
"react/prefer-stateless-function": "off",
"react/no-deprecated": "off",
"react/forbid-prop-types": "warn",
"react/prop-types": "off",
"react/require-default-props": "off",
"react/no-unused-prop-types": "off",
},
"settings": {
"react/no-unused-prop-types": "off"
},
"parserOptions": {
"ecmaVersion": 6,

View File

@@ -25,7 +25,7 @@ Bugs with react-navigation must be reproducible *without any external libraries
### How to reproduce
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repoistory as that is outside of the scope of Rect Navigation.
- You must provide a way to reproduce the problem. If you are having an issue with your machine or build tools, the issue belongs on another repository as that is outside of the scope of React Navigation.
- Either re-create the bug on [Snack](https://snack.expo.io) or link to a GitHub repository with code that reproduces the bug.
- Explain how to run the example app and any steps that we need to take to reproduce the issue from the example app.

View File

@@ -1,17 +1,21 @@
Please provide enough information so that others can review your pull request:
## Motivation
Explain the **motivation** for making this change. What existing problem does the pull request solve?
Prefer **small pull requests**. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise split it.
## Test plan
**Test plan (required)**
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
Demonstrate the code is solid. Example: the exact commands you ran and their output, screenshots / videos if the pull request changes UI.
Make sure you test on both platforms if your change affects both platforms.
The code must pass tests.
**Code formatting**
## Code formatting
Look around. Match the style of the rest of the codebase.
Look around. Match the style of the rest of the codebase. Run `yarn format` before committing.
## Changelog
Add an entry under the "Unreleased" heading in [CHANGELOG.md](https://github.com/react-navigation/react-navigation/blob/master/CHANGELOG.md#unreleased) which explains your change.

15
.release-it.json Normal file
View File

@@ -0,0 +1,15 @@
{
"increment": "conventional:angular",
"changelogCommand": "conventional-changelog -p angular | tail -n +3",
"safeBump": false,
"src": {
"commitMessage": "chore: release %s",
"tagName": "v%s"
},
"npm": {
"publish": true
},
"github": {
"release": true
}
}

281
CHANGELOG.md Normal file
View File

@@ -0,0 +1,281 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [3.8.1] - [2019-04-12](https://github.com/react-navigation/react-navigation/releases/tag/3.8.1)
## Changed
- Add missing type for `enableURLHandling` to TypeScript definition (#5803)
- Update Flow types (#5806)
## [3.8.0] - [2019-04-12](https://github.com/react-navigation/react-navigation/releases/tag/3.8.0)
## Fixes
- `onRefresh` on exported lists `FlatList` and `SectionList` works as expected now (no need to add `refreshControl` prop explicitly)
- On Android, the exported `ScrollView` is now same as the React Native ScrollView (but with scroll-to-top behavior added), whereas on iOS we still use react-native-gesture-handler ScrollView. We can change Android back to react-native-gesture-handler ScrollView when https://github.com/kmagiera/react-native-gesture-handler/issues/560 is resolved.
- Look for `scrollResponderScrollTo` function in our ScrollView, in react-native 0.59 the interface appears to have changed for FlatList such that this is needed. (react-navigation-native#20)
## Changed
- Stack header style improvements for web (react-navigation-stack#104)
## [3.7.1] - [2019-04-10](https://github.com/react-navigation/react-navigation/releases/tag/3.7.1)
## Fixes
- Update Flow types (#5800 and #5801)
- More open `navigationOptions` types for bottom tab navigator config (#5796)
- Fix hit slop for bottom tab bar (react-navigation-tabs#110)
## Added
- Add accessibility role and state to bottom bar (react-navigation-tabs#90)
- Hide tab bar when keyboard is shown (react-navigation-tabs#112)
- Specify default values for getAccessibilityX on tabs (react-navigation-tabs##116)
- Add a isFirstRouteInParent method to navigation object (react-navigation-core#51)
## [3.6.1] - [2019-04-02](https://github.com/react-navigation/react-navigation/releases/tag/3.6.1)
## Fixed
- Move event subscriptions to constructor in `withNavigationFocus` to ensure initial `didFocus` event is received.
## [3.6.0] - [2019-03-31](https://github.com/react-navigation/react-navigation/releases/tag/3.6.0)
## Added
- Export TabBarIconProps, TabBarLabelProps, DrawerIconProps, DrawerLabelProps, ScreenProps and InitialLayout.
- Add `disabled` prop to HeaderBackButton
- Add `StackViewTransitionConfigs.NoAnimation`
- Add `drawerContainerStyle` to navigator config for drawer navigator
## [3.5.1] - [2019-03-19](https://github.com/react-navigation/react-navigation/releases/tag/3.5.1)
## Added
- Export StackGestureContext and DrawerGestureContext
- Add missing type for withOrientation
## Fixed
- Fix header HeaderBackButton title TypeScript type
## [3.5.0] - [2019-03-19](https://github.com/react-navigation/react-navigation/releases/tag/3.5.0)
## Fixed
- Fixed types for `BottomTabBar`
- export `NavigationContext` type
## Changed
- Make 'react-native-gesture-handler' a peer dependency rather than a hard dependency
## [3.4.1] - [2019-03-16](https://github.com/react-navigation/react-navigation/releases/tag/3.4.1)
## Fixed
- Fix missing TypeScript definitions file in release package
## [3.4.0] - [2019-03-15](https://github.com/react-navigation/react-navigation/releases/tag/3.4.0)
## Added
- TypeScript type definition now included in the project.
- Better support for react-native-web in core and stack.
## Fixed
- Default key to null in stack reset action (https://github.com/react-navigation/react-navigation-core/commit/59238160d86284a3353d53af10688fcf3f36004f)
- Fix header back button label and title label scaling. Defaults to false. (https://github.com/react-navigation/react-navigation-stack/commit/c1f1dff465e9eebe274a08e274cf10570045fa23)
## Changed
- Remove react-lifecycles-compat from @react-navigation/core
- NavigationPlayground uses TypeScript
## [3.3.2] - [2019-02-25](https://github.com/react-navigation/react-navigation/releases/tag/3.3.2)
## Fixed
- Updated Flow types (https://github.com/react-navigation/react-navigation/commit/d3040e52b39bc8e91ffc1354d9c5f8c096baf597)
## [3.3.1] - [2019-02-25](https://github.com/react-navigation/react-navigation/releases/tag/3.3.1)
## Fixed
- SafeAreaView bottom inset on iPhone XR and XS fixed. (https://github.com/react-navigation/react-navigation/issues/5625)
## [3.3.0] - [2019-02-16](https://github.com/react-navigation/react-navigation/releases/tag/3.3.0)
## Added
- Pass through `drawerOpenProgress` to drawer content component (https://github.com/react-navigation/react-navigation-drawer/pull/40)
## [3.2.3] - [2019-02-09](https://github.com/react-navigation/react-navigation/releases/tag/3.2.3)
## Fixed
- `await` the result of `onTransitionStart` before starting the transition (https://github.com/react-navigation/react-navigation-stack/pull/79)
## [3.2.2]
- Oops, I skipped it. Nothing here.
## [3.2.1] - [2019-02-09](https://github.com/react-navigation/react-navigation/releases/tag/3.2.1)
## Fixed
- Remove accidental console.log
## [3.2.0] - [2019-02-08](https://github.com/react-navigation/react-navigation/releases/tag/3.2.0)
## Added
- Add support for `backBehavior: history'` and `backBehavior: 'order'` to any navigator based on SwitchRouter (eg: tab navigators). (https://github.com/react-navigation/react-navigation-core/pull/31)
## [3.1.5] - [2019-02-06](https://github.com/react-navigation/react-navigation/releases/tag/3.1.5)
## Fixed
- Revert "Transparent header measurement fix (https://github.com/react-navigation/react-navigation-stack/pull/71)"
## [3.1.4] - [2019-02-05](https://github.com/react-navigation/react-navigation/releases/tag/3.1.4)
## Fixed
- Fix references to onGestureFinish in StackViewLayout, should be onGestureEnd
## [3.1.3] - [2019-02-04](https://github.com/react-navigation/react-navigation/releases/tag/3.1.3)
## Fixed
- Stack navigator properly dismisses and restores keyboard when gesture starts and is cancelled
- Transparent header measurement fix (https://github.com/react-navigation/react-navigation-stack/pull/71)
## [3.1.2] - [2019-02-01](https://github.com/react-navigation/react-navigation/releases/tag/3.1.2)
## Fixed
- Update flow definition for `withNavigation` and `withNavigationFocus` to support `defaultProps`
- Prevent onRef callback be called twice on withNavigationFocus components (https://github.com/react-navigation/react-navigation-core/pull/30)
- Bump react-navigation-drawer version to improve performance - if you use Expo, you will need expo@^32.0.3 to update!
## [3.0.9] - [2018-12-19](https://github.com/react-navigation/react-navigation/releases/tag/3.0.9)
## Fixed
- Intermittent flicker when changing tabs while using react-native-screens fixed by not changing opacity (https://github.com/react-navigation/react-navigation-tabs/pull/80)
- Prevent fading the previous screen on push/pop on Android (https://github.com/react-navigation/react-navigation-stack/pull/73)
## [3.0.8] - [2018-12-08](https://github.com/react-navigation/react-navigation/releases/tag/3.0.8)
## Changed
- Lock create-react-context to 0.2.2
## [3.0.7] - [2018-12-08](https://github.com/react-navigation/react-navigation/releases/tag/3.0.7)
## Changed
- Optimize stack gesture to avoid a setState and reduce unnecessary Animated node creation (https://github.com/react-navigation/react-navigation-stack/pull/70)
## [3.0.6] - [2018-12-06](https://github.com/react-navigation/react-navigation/releases/tag/3.0.6)
## Fixes
- Fix drawer accessibility label when drawer label is not a string
## [3.0.5] - [2018-12-03](https://github.com/react-navigation/react-navigation/releases/tag/3.0.5)
## Fixes
- Fix crash in rare case where onNavigationStateChange on container leads to setState and container has screenProps (https://github.com/react-navigation/react-navigation/issues/5301)
- Expose underlaying ScrollView methods to NavigationAwareScrollable (https://github.com/react-navigation/react-navigation-native/pull/8)
## [3.0.4] - [2018-11-30](https://github.com/react-navigation/react-navigation/releases/tag/3.0.4)
## Changed
- Lock dependencies to exact versions
## Fixes
- Fix crash when screenInterpolator is null (https://github.com/react-navigation/react-navigation-stack/issues/64)
- Fix renderPager override (https://github.com/react-navigation/react-navigation-tabs/pull/70)
## Added
- Accessibility labels on drawer items (https://github.com/react-navigation/react-navigation-drawer/pull/30)
## [3.0.3] - [2018-11-30](https://github.com/react-navigation/react-navigation/releases/tag/3.0.3)
## Fixes
- Fix bug where if you navigate immediately when the navigator is first mounted the stack could get in an invalid state.
- Transparent stack card factors in header height now, even though you probably won't want to use this.
- Fix bug where shadow was still rendered on transparent stack
- Fix gestureResponseDistance custom values being ignored for modal stack
## [3.0.2] - [2018-11-27](https://github.com/react-navigation/react-navigation/releases/tag/3.0.2)
## Fixes
- Fix `drawerLockMode` on drawer navigator
- Fix RTL support in drawer navigator
## [3.0.1] - [2018-11-26](https://github.com/react-navigation/react-navigation/releases/tag/3.0.1)
## Fixes
- fix NavigationTestUtils.js deprecated file import.
- Update `getParam` flow typings to check `key` and `fallback` arguments, as well as return the correct type automatically.
- Fix regression in backgroundColor on cardStyle for stack navigator.
## [3.0.0] - [2018-11-17](https://github.com/react-navigation/react-navigation/releases/tag/3.0.0)
- Changes between the latest 2.x release and 3.0.0 are listed on the blog at https://reactnavigation.org/blog/2018/11/17/react-navigation-3.0.html
# [Previous major versions]
- [2.x](https://github.com/react-navigation/react-navigation/blob/2.x/CHANGELOG.md)
[Unreleased]: https://github.com/react-navigation/react-navigation/compare/3.8.1...HEAD
[3.8.1]: https://github.com/react-navigation/react-navigation/compare/3.8.0...3.8.1
[3.8.0]: https://github.com/react-navigation/react-navigation/compare/3.7.1...3.8.0
[3.7.1]: https://github.com/react-navigation/react-navigation/compare/3.6.1...3.7.1
[3.6.1]: https://github.com/react-navigation/react-navigation/compare/3.6.0...3.6.1
[3.6.0]: https://github.com/react-navigation/react-navigation/compare/3.5.1...3.6.0
[3.5.1]: https://github.com/react-navigation/react-navigation/compare/3.5.0...3.5.1
[3.5.0]: https://github.com/react-navigation/react-navigation/compare/3.4.1...3.5.0
[3.4.1]: https://github.com/react-navigation/react-navigation/compare/3.4.0...3.4.1
[3.4.0]: https://github.com/react-navigation/react-navigation/compare/3.3.2...3.4.0
[3.3.2]: https://github.com/react-navigation/react-navigation/compare/3.3.1...3.3.2
[3.3.1]: https://github.com/react-navigation/react-navigation/compare/3.3.0...3.3.1
[3.3.0]: https://github.com/react-navigation/react-navigation/compare/3.2.3...3.3.0
[3.2.3]: https://github.com/react-navigation/react-navigation/compare/3.2.1...3.2.3
[3.2.1]: https://github.com/react-navigation/react-navigation/compare/3.2.0...3.2.1
[3.2.0]: https://github.com/react-navigation/react-navigation/compare/3.1.5...3.2.0
[3.1.5]: https://github.com/react-navigation/react-navigation/compare/3.1.4...3.1.5
[3.1.4]: https://github.com/react-navigation/react-navigation/compare/3.1.3...3.1.4
[3.1.3]: https://github.com/react-navigation/react-navigation/compare/3.1.2...3.1.3
[3.1.2]: https://github.com/react-navigation/react-navigation/compare/3.0.9...3.1.2
[3.0.9]: https://github.com/react-navigation/react-navigation/compare/3.0.8...3.0.9
[3.0.8]: https://github.com/react-navigation/react-navigation/compare/3.0.7...3.0.8
[3.0.7]: https://github.com/react-navigation/react-navigation/compare/3.0.6...3.0.7
[3.0.6]: https://github.com/react-navigation/react-navigation/compare/3.0.5...3.0.6
[3.0.5]: https://github.com/react-navigation/react-navigation/compare/3.0.4...3.0.5
[3.0.4]: https://github.com/react-navigation/react-navigation/compare/3.0.3...3.0.4
[3.0.3]: https://github.com/react-navigation/react-navigation/compare/3.0.2...3.0.3
[3.0.2]: https://github.com/react-navigation/react-navigation/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/react-navigation/react-navigation/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/react-navigation/react-navigation/compare/2.x...3.0.0

7
NavigationTestUtils.js Normal file
View File

@@ -0,0 +1,7 @@
import { _TESTING_ONLY_reset_container_count } from '@react-navigation/native/src/createAppContainer';
export default {
resetInternalState: () => {
_TESTING_ONLY_reset_container_count();
},
};

View File

@@ -1,22 +1,12 @@
# React Navigation
[![npm version](https://badge.fury.io/js/react-navigation.svg)](https://badge.fury.io/js/react-navigation) [![codecov](https://codecov.io/gh/react-community/react-navigation/branch/master/graph/badge.svg)](https://codecov.io/gh/react-community/react-navigation) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactnavigation.org/docs/guides/contributors)
[![npm version](https://badge.fury.io/js/react-navigation.svg)](https://badge.fury.io/js/react-navigation) [![CircleCI badge](https://circleci.com/gh/react-navigation/react-navigation/tree/master.svg?style=shield)](https://circleci.com/gh/react-navigation/react-navigation/tree/master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://reactnavigation.org/docs/contributing.html)
React Navigation is born from the React Native community's need for an extensible yet easy-to-use navigation solution based on Javascript.
## Installation
Since the library is a JS-based solution, to install the latest version of react-navigation you only need to run:
```bash
yarn add react-navigation
```
or
```bash
npm install --save react-navigation
```
See: https://reactnavigation.org/docs/en/getting-started.html
## Documentation
@@ -43,7 +33,7 @@ See our [Contributing Guide](CONTRIBUTING.md)!
#### Is this the only library available for navigation?
Certainly not! There other libraries - which, depending on your needs, can be better or worse suited for your project. Read more in the [alternative libraries](https://reactnavigation.org/docs/alternatives.html) documentation, and read React Navigation's [pitch & anti-pitch](https://reactnavigation.org/docs/pitch.html) to understand the tradeoffs.
Certainly not! There are other libraries - which, depending on your needs, can be better or worse suited for your project. Read more in the [alternative libraries](https://reactnavigation.org/docs/alternatives.html) documentation, and read React Navigation's [pitch & anti-pitch](https://reactnavigation.org/docs/pitch.html) to understand the tradeoffs.
#### Can I use this library for web?
@@ -55,4 +45,4 @@ This library has adopted a Code of Conduct that we expect project participants t
## License
React-navigation is licensed under the [BSD 2-clause "Simplified" License](https://github.com/react-community/react-navigation/blob/master/LICENSE).
React Navigation is licensed under the [BSD 2-clause "Simplified" License](https://github.com/react-community/react-navigation/blob/master/LICENSE).

12
assetsTransformer.js Normal file
View File

@@ -0,0 +1,12 @@
/**
* This file is needed to hijack asset imports so that test files don't attempt
* to import them as JavaScript modules.
* See https://github.com/facebook/jest/issues/2663#issuecomment-317109798
*/
const path = require('path');
module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};

3
babel.config.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};

View File

@@ -1,17 +1,3 @@
{
"presets": [
"babel-preset-expo"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source"
],
},
"production": {
"plugins": [
"transform-remove-console"
]
}
}
"presets": ["module:metro-react-native-babel-preset"]
}

View File

@@ -0,0 +1,6 @@
[android]
target = Google Inc.:Google APIs:23
[maven_repositories]
central = https://repo1.maven.org/maven2

View File

@@ -1,83 +0,0 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js
; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/
; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*
; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js
; Ignore polyfills
.*/Libraries/polyfills/.*
.*/react-navigation/node_modules/.*
; Additional create-react-native-app ignores
; Ignore duplicate module providers
.*/node_modules/fbemitter/lib/*
; Ignore misbehaving dev-dependencies
.*/node_modules/xdl/build/*
.*/node_modules/reqwest/tests/*
; Ignore missing expo-sdk dependencies (temporarily)
; https://github.com/expo/expo/issues/162
.*/node_modules/expo/src/*
; Ignore react-native-fbads dependency of the expo sdk
.*/node_modules/react-native-fbads/*
.*/react-navigation/examples/ReduxExample/.*
.*/react-navigation/website/.*
; This package is required by Expo and causes Flow errors
.*/node_modules/react-native-gesture-handler/.*
.*/node_modules/metro/.*
[include]
[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/react-native/flow-github/
../../flow/
[options]
module.system=haste
emoji=true
experimental.strict_type_args=true
munge_underscores=true
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.native.js
suppress_type=$FlowIgnore
suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_comment=\\(.\\|\n\\)*\\$FlowIgnore\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
unsafe.enable_getters_and_setters=true
[version]
^0.61.0

View File

@@ -0,0 +1 @@
*.pbxproj -text

View File

@@ -1,3 +1,60 @@
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
# Visual Studio Code
#
.vscode/
# node.js
#
node_modules/
.expo/
npm-debug.*
npm-debug.log
yarn-error.log
# BUCK
buck-out/
\.buckd/
*.keystore
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
# Bundle artifact
*.jsbundle

View File

@@ -1 +1 @@
{}
{}

View File

@@ -1,2 +0,0 @@
import App from './js/App';
export default App;

View File

@@ -1,9 +0,0 @@
import React from 'react';
import App from './App';
import renderer from 'react-test-renderer';
it('renders without crashing', () => {
const rendered = renderer.create(<App />).toJSON();
expect(rendered).toBeTruthy();
});

View File

@@ -1,9 +1,14 @@
# Navigation Playground Example
A playground for experimenting with react-navigation in a pure-JS React Native app.
The NavigationPlayground example app includes a variety of patterns and is used as a simple way for contributors to manually integration test changes.
## Usage
Please see the [Contributors Guide](https://reactnavigation.org/docs/guides/contributors#Run-the-Example-App) for instructions on running these example apps.
```bash
yarn # in the react-navigation root directory
cd examples/NavigationPlayground
yarn
yarn start
```
You can view this example application directly on your phone by visiting [our expo demo](https://exp.host/@react-navigation/NavigationPlayground).
You can view this example application directly on Android phones by visiting scanning the QR code on [this site](https://exp.host/@react-navigation/NavigationPlayground) with the [Expo app](https://play.google.com/store/apps/details?id=host.exp.exponent&hl=en).

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>NavigationPlayground</name>
<comment>Project NavigationPlayground created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1

View File

@@ -0,0 +1,65 @@
# To learn about Buck see [Docs](https://buckbuild.com/).
# To run your application with Buck:
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#
lib_deps = []
for jarfile in glob(['libs/*.jar']):
name = 'jars__' + jarfile[jarfile.rindex('/') + 1: jarfile.rindex('.jar')]
lib_deps.append(':' + name)
prebuilt_jar(
name = name,
binary_jar = jarfile,
)
for aarfile in glob(['libs/*.aar']):
name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')]
lib_deps.append(':' + name)
android_prebuilt_aar(
name = name,
aar = aarfile,
)
android_library(
name = "all-libs",
exported_deps = lib_deps,
)
android_library(
name = "app-code",
srcs = glob([
"src/main/java/**/*.java",
]),
deps = [
":all-libs",
":build_config",
":res",
],
)
android_build_config(
name = "build_config",
package = "com.navigationplayground",
)
android_resource(
name = "res",
package = "com.navigationplayground",
res = "src/main/res",
)
android_binary(
name = "app",
keystore = "//android/keystores:debug",
manifest = "src/main/AndroidManifest.xml",
package_type = "debug",
deps = [
":app-code",
],
)

View File

@@ -0,0 +1,153 @@
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.navigationplayground"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-blur')
compile project(':react-native-vector-icons')
compile project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

View File

@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@@ -0,0 +1,26 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.navigationplayground">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>

View File

@@ -0,0 +1,28 @@
package com.navigationplayground;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is
* used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "NavigationPlayground";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}

View File

@@ -0,0 +1,51 @@
package com.navigationplayground;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.cmcewen.blurview.BlurViewPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new BlurViewPackage(),
new VectorIconsPackage(),
new RNGestureHandlerPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">NavigationPlayground</string>
</resources>

View File

@@ -0,0 +1,8 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
</resources>

View File

@@ -0,0 +1,39 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}

View File

@@ -0,0 +1,18 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

172
examples/NavigationPlayground/android/gradlew vendored Executable file
View File

@@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

View File

@@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -0,0 +1,8 @@
keystore(
name = "debug",
properties = "debug.keystore.properties",
store = "debug.keystore",
visibility = [
"PUBLIC",
],
)

View File

@@ -0,0 +1,4 @@
key.store=debug.keystore
key.alias=androiddebugkey
key.store.password=android
key.alias.password=android

View File

@@ -0,0 +1,9 @@
rootProject.name = 'NavigationPlayground'
include ':react-native-blur'
project(':react-native-blur').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-blur/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':app'

View File

@@ -1,26 +1,4 @@
{
"expo": {
"name": "NavigationPlayground",
"description": "Try out react-navigation now with this awesome playground",
"version": "1.0.0",
"slug": "NavigationPlayground",
"privacy": "public",
"orientation": "portrait",
"primaryColor": "#cccccc",
"icon": "./assets/icons/icon.png",
"splash": {
"image": "./assets/icons/splash.png"
},
"sdkVersion": "25.0.0",
"entryPoint": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"packagerOpts": {
"assetExts": [
"ttf",
"mp4"
]
},
"ios": {
"supportsTablet": true
}
}
"name": "NavigationPlayground",
"displayName": "NavigationPlayground"
}

View File

@@ -5,5 +5,5 @@ import renderer from 'react-test-renderer';
it('renders without crashing', () => {
const rendered = renderer.create(<App />).toJSON();
expect(rendered).toBeTruthy();
expect(rendered).toBeDefined();
});

View File

@@ -1,136 +1,165 @@
/* @flow */
import React from 'react';
import { Asset, Constants, ScreenOrientation } from 'expo';
ScreenOrientation.allow(ScreenOrientation.Orientation.ALL);
import {
Animated,
Image,
Platform,
ScrollView,
StyleSheet,
TouchableOpacity,
Text,
StatusBar,
StyleSheet,
Text,
View,
} from 'react-native';
import { SafeAreaView, StackNavigator } from 'react-navigation';
import {
NativeViewGestureHandler,
RectButton,
} from 'react-native-gesture-handler';
import {
createAppContainer,
createStackNavigator,
SafeAreaView,
} from 'react-navigation';
import CustomTabs from './CustomTabs';
import CustomTransitioner from './CustomTransitioner';
import CustomTabUI from './CustomTabUI';
// import CustomTransitioner from './CustomTransitioner';
import Drawer from './Drawer';
import MultipleDrawer from './MultipleDrawer';
import TabsInDrawer from './TabsInDrawer';
import ModalStack from './ModalStack';
import SimpleStack from './SimpleStack';
import SimpleTabs from './SimpleTabs';
import StacksInTabs from './StacksInTabs';
import StacksOverTabs from './StacksOverTabs';
import StacksWithKeys from './StacksWithKeys';
import SimpleStack from './SimpleStack';
import StacksOverTopTabs from './StacksOverTopTabs';
import StacksAndKeys from './StacksAndKeys';
import StackWithCustomHeaderBackImage from './StackWithCustomHeaderBackImage';
import StackWithHeaderPreset from './StackWithHeaderPreset';
import StackWithTranslucentHeader from './StackWithTranslucentHeader';
import SimpleTabs from './SimpleTabs';
import TabAnimations from './TabAnimations';
import TabsWithNavigationFocus from './TabsWithNavigationFocus';
import SwitchWithStacks from './SwitchWithStacks';
import TabsInDrawer from './TabsInDrawer';
const ExampleInfo = {
SimpleStack: {
name: 'Stack Example',
description: 'A card stack',
},
SimpleTabs: {
name: 'Tabs Example',
description: 'Tabs following platform conventions',
},
Drawer: {
name: 'Drawer Example',
description: 'Android-style drawer navigation',
},
StackWithHeaderPreset: {
name: 'UIKit-style Header Transitions',
description: 'Masked back button and sliding header items. iOS only.',
},
StackWithHeaderPreset: {
name: 'UIKit-style Header Transitions',
description: 'Masked back button and sliding header items. iOS only.',
},
StackWithTranslucentHeader: {
name: 'Translucent Header',
description: 'Render arbitrary translucent content in header background.',
},
// MultipleDrawer: {
// name: 'Multiple Drawer Example',
// description: 'Add any drawer you need',
// },
TabsInDrawer: {
name: 'Drawer + Tabs Example',
description: 'A drawer combined with tabs',
const ExampleInfo: any = {
CustomTabUI: {
description: 'Render additional views around a Tab navigator',
name: 'Custom Tabs UI',
},
CustomTabs: {
name: 'Custom Tabs',
description: 'Custom tabs with tab router',
name: 'Custom Tabs',
},
CustomTransitioner: {
name: 'Custom Transitioner',
description: 'Custom transitioner with stack router',
name: 'Custom Transitioner',
},
Drawer: {
description: 'Android-style drawer navigation',
name: 'Drawer Example',
},
InactiveStack: {
description:
'An inactive route in a stack should be given the opportunity to handle actions',
name: 'Navigate idempotently to stacks in inactive routes',
},
KeyboardHandlingExample: {
description:
'Demo automatic handling of keyboard showing/hiding inside StackNavigator',
name: 'Keyboard Handling Example',
},
LinkStack: {
description: 'Deep linking into a route in stack',
name: 'Link in Stack',
},
LinkTabs: {
description: 'Deep linking into a route in tab',
name: 'Link to Settings Tab',
},
ModalStack: {
name:
Platform.OS === 'ios'
? 'Modal Stack Example'
: 'Stack with Dynamic Header',
description:
Platform.OS === 'ios'
? 'Stack navigation with modals'
: 'Dynamically showing and hiding the header',
name:
Platform.OS === 'ios'
? 'Modal Stack Example'
: 'Stack with Dynamic Header',
},
SimpleStack: {
description: 'A card stack',
name: 'Stack Example',
},
SimpleTabs: {
description: 'Tabs following platform conventions',
name: 'Tabs Example',
},
StackWithCustomHeaderBackImage: {
description: 'Stack with custom header back image',
name: 'Custom header back image',
},
StackWithHeaderPreset: {
description: 'Masked back button and sliding header items. iOS only.',
name: 'UIKit-style Header Transitions',
},
StackWithTranslucentHeader: {
description: 'Render arbitrary translucent content in header background.',
name: 'Translucent Header',
},
StacksInTabs: {
name: 'Stacks in Tabs',
description: 'Nested stack navigation in tabs',
name: 'Stacks in Tabs',
},
StacksOverTabs: {
name: 'Stacks over Tabs',
description: 'Nested stack navigation that pushes on top of tabs',
name: 'Stacks over Tabs',
},
StacksWithKeys: {
name: 'Link in Stack with keys',
StacksOverTopTabs: {
description: 'Tab navigator in stack with custom header heights',
name: 'Stacks with non-standard header height',
},
StacksAndKeys: {
description: 'Use keys to link between screens',
name: 'Link in Stack with keys',
},
LinkStack: {
name: 'Link in Stack',
description: 'Deep linking into a route in stack',
SwitchWithStacks: {
description: 'Jump between routes',
name: 'Switch between routes',
},
LinkTabs: {
name: 'Link to Settings Tab',
description: 'Deep linking into a route in tab',
// MultipleDrawer: {
// description: 'Add any drawer you need',
// name: 'Multiple Drawer Example',
// },
TabsInDrawer: {
description: 'A drawer combined with tabs',
name: 'Drawer + Tabs Example',
},
TabAnimations: {
name: 'Animated Tabs Example',
description: 'Tab transitions have custom animations',
TabsWithNavigationEvents: {
description:
'Declarative NavigationEvents component to subscribe to navigation events',
name: 'NavigationEvents',
},
TabsWithNavigationFocus: {
name: 'withNavigationFocus',
description: 'Receive the focus prop to know when a screen is focused',
name: 'withNavigationFocus',
},
};
const ExampleRoutes = {
SimpleStack: SimpleStack,
SimpleTabs: SimpleTabs,
Drawer: Drawer,
// MultipleDrawer: {
// screen: MultipleDrawer,
// },
StackWithHeaderPreset: StackWithHeaderPreset,
StackWithTranslucentHeader: StackWithTranslucentHeader,
TabsInDrawer: TabsInDrawer,
CustomTabs: CustomTabs,
CustomTransitioner: CustomTransitioner,
ModalStack: ModalStack,
StacksWithKeys: StacksWithKeys,
StacksInTabs: StacksInTabs,
StacksOverTabs: StacksOverTabs,
const ExampleRoutes: any = {
CustomTabUI,
CustomTabs,
// CustomTransitioner,
Drawer,
ModalStack,
SimpleStack,
SimpleTabs,
StackWithCustomHeaderBackImage,
StackWithTranslucentHeader,
StacksAndKeys,
StacksOverTabs,
SwitchWithStacks,
StacksOverTopTabs,
StacksInTabs,
...Platform.select({
android: {},
ios: {
StackWithHeaderPreset,
},
}),
TabsInDrawer,
LinkStack: {
screen: SimpleStack,
path: 'people/Jordan',
@@ -139,34 +168,24 @@ const ExampleRoutes = {
screen: SimpleTabs,
path: 'settings',
},
TabAnimations,
TabsWithNavigationFocus,
};
type State = {
scrollY: Animated.Value,
};
interface State {
scrollY: Animated.Value;
}
class MainScreen extends React.Component<any, State> {
state = {
scrollY: new Animated.Value(0),
};
componentWillMount() {
Asset.fromModule(
require('react-navigation/src/views/assets/back-icon-mask.png')
).downloadAsync();
Asset.fromModule(
require('react-navigation/src/views/assets/back-icon.png')
).downloadAsync();
}
render() {
const { navigation } = this.props;
const scale = this.state.scrollY.interpolate({
extrapolate: 'clamp',
inputRange: [-450, 0, 100],
outputRange: [2, 1, 0.8],
extrapolate: 'clamp',
});
const translateY = this.state.scrollY.interpolate({
@@ -175,21 +194,21 @@ class MainScreen extends React.Component<any, State> {
});
const opacity = this.state.scrollY.interpolate({
extrapolate: 'clamp',
inputRange: [0, 50],
outputRange: [1, 0],
extrapolate: 'clamp',
});
const underlayOpacity = this.state.scrollY.interpolate({
extrapolate: 'clamp',
inputRange: [0, 50],
outputRange: [0, 1],
extrapolate: 'clamp',
});
const backgroundScale = this.state.scrollY.interpolate({
extrapolate: 'clamp',
inputRange: [-450, 0],
outputRange: [3, 1],
extrapolate: 'clamp',
});
const backgroundTranslateY = this.state.scrollY.interpolate({
@@ -199,69 +218,72 @@ class MainScreen extends React.Component<any, State> {
return (
<View style={{ flex: 1 }}>
<Animated.ScrollView
style={{ flex: 1 }}
scrollEventThrottle={1}
onScroll={Animated.event(
[
{
nativeEvent: { contentOffset: { y: this.state.scrollY } },
},
],
{ useNativeDriver: true }
)}
>
<Animated.View
style={[
styles.backgroundUnderlay,
{
transform: [
{ scale: backgroundScale },
{ translateY: backgroundTranslateY },
],
},
]}
/>
<Animated.View
style={{ opacity, transform: [{ scale }, { translateY }] }}
<NativeViewGestureHandler>
<Animated.ScrollView
style={{ flex: 1, backgroundColor: '#eee' }}
scrollEventThrottle={1}
onScroll={Animated.event(
[
{
nativeEvent: { contentOffset: { y: this.state.scrollY } },
},
],
{ useNativeDriver: true }
)}
>
<SafeAreaView
style={styles.bannerContainer}
forceInset={{ top: 'always', bottom: 'never' }}
<Animated.View
style={[
styles.backgroundUnderlay,
{
transform: [
{ scale: backgroundScale },
{ translateY: backgroundTranslateY },
],
},
]}
/>
<Animated.View
style={{ opacity, transform: [{ scale }, { translateY }] }}
>
<View style={styles.banner}>
<Image
source={require('./assets/NavLogo.png')}
style={styles.bannerImage}
/>
<Text style={styles.bannerTitle}>
React Navigation Examples
</Text>
</View>
</SafeAreaView>
</Animated.View>
<SafeAreaView
style={styles.bannerContainer}
forceInset={{ top: 'always', bottom: 'never' }}
>
<View style={styles.banner}>
<Image
source={require('./assets/NavLogo.png')}
style={styles.bannerImage}
/>
<Text style={styles.bannerTitle}>
React Navigation Examples
</Text>
</View>
</SafeAreaView>
</Animated.View>
<SafeAreaView forceInset={{ bottom: 'always', horizontal: 'never' }}>
<View style={{ backgroundColor: '#fff' }}>
{Object.keys(ExampleRoutes).map((routeName: string) => (
<TouchableOpacity
key={routeName}
onPress={() => {
let route = ExampleRoutes[routeName];
if (route.screen || route.path || route.params) {
const { path, params, screen } = route;
const { router } = screen;
const action =
path && router.getActionForPathAndParams(path, params);
navigation.navigate(routeName, {}, action);
} else {
navigation.navigate(routeName);
}
}}
>
<SafeAreaView
style={styles.itemContainer}
forceInset={{ veritcal: 'never', bottom: 'never' }}
<SafeAreaView
forceInset={{ top: 'never', bottom: 'always' }}
style={{ backgroundColor: '#eee' }}
>
<View style={{ backgroundColor: '#fff' }}>
{Object.keys(ExampleRoutes).map((routeName: string) => (
<RectButton
key={routeName}
underlayColor="#ccc"
activeOpacity={0.3}
onPress={() => {
const route = ExampleRoutes[routeName];
if (route.screen || route.path || route.params) {
const { path, params, screen } = route;
const { router } = screen;
const action =
path &&
router.getActionForPathAndParams(path, params);
navigation.navigate(routeName, {}, action);
} else {
navigation.navigate(routeName);
}
}}
>
<View style={styles.item}>
<Text style={styles.title}>
@@ -271,12 +293,12 @@ class MainScreen extends React.Component<any, State> {
{ExampleInfo[routeName].description}
</Text>
</View>
</SafeAreaView>
</TouchableOpacity>
))}
</View>
</SafeAreaView>
</Animated.ScrollView>
</RectButton>
))}
</View>
</SafeAreaView>
</Animated.ScrollView>
</NativeViewGestureHandler>
<StatusBar barStyle="light-content" />
<Animated.View
style={[styles.statusBarUnderlay, { opacity: underlayOpacity }]}
@@ -286,91 +308,93 @@ class MainScreen extends React.Component<any, State> {
}
}
const AppNavigator = StackNavigator(
{
...ExampleRoutes,
Index: {
screen: MainScreen,
const AppNavigator = createAppContainer(
createStackNavigator(
{
...ExampleRoutes,
Index: {
screen: MainScreen,
},
},
},
{
initialRouteName: 'Index',
headerMode: 'none',
{
headerMode: 'none',
initialRouteName: 'Index',
/*
* Use modal on iOS because the card mode comes from the right,
* which conflicts with the drawer example gesture
*/
mode: Platform.OS === 'ios' ? 'modal' : 'card',
}
/*
* Use modal on iOS because the card mode comes from the right,
* which conflicts with the drawer example gesture
*/
mode: Platform.OS === 'ios' ? 'modal' : 'card',
}
)
);
// export default () => <AppNavigator />;
export default SimpleStack;
export default class App extends React.Component {
render() {
return <AppNavigator /* persistenceKey="if-you-want-it" */ />;
}
}
const styles = StyleSheet.create({
item: {
paddingHorizontal: 16,
paddingVertical: 12,
},
itemContainer: {
backgroundColor: '#fff',
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#ddd',
},
image: {
width: 120,
height: 120,
alignSelf: 'center',
marginBottom: 20,
resizeMode: 'contain',
},
statusBarUnderlay: {
backgroundColor: '#673ab7',
position: 'absolute',
top: 0,
left: 0,
right: 0,
height: Constants.statusBarHeight,
},
title: {
fontSize: 16,
fontWeight: 'bold',
color: '#444',
},
description: {
fontSize: 13,
color: '#999',
},
backgroundUnderlay: {
backgroundColor: '#673ab7',
position: 'absolute',
top: -100,
height: 300,
left: 0,
position: 'absolute',
right: 0,
top: -100,
},
banner: {
alignItems: 'center',
flexDirection: 'row',
padding: 16,
},
bannerContainer: {
// backgroundColor: '#673ab7',
alignItems: 'center',
},
banner: {
flexDirection: 'row',
alignItems: 'center',
padding: 16,
},
bannerImage: {
width: 36,
height: 36,
margin: 8,
resizeMode: 'contain',
tintColor: '#fff',
margin: 8,
width: 36,
},
bannerTitle: {
color: '#fff',
fontSize: 18,
fontWeight: '200',
color: '#fff',
marginVertical: 8,
marginRight: 5,
marginVertical: 8,
},
description: {
color: '#999',
fontSize: 13,
},
image: {
alignSelf: 'center',
height: 120,
marginBottom: 20,
resizeMode: 'contain',
width: 120,
},
item: {
borderBottomColor: '#ddd',
borderBottomWidth: StyleSheet.hairlineWidth,
paddingHorizontal: 16,
paddingVertical: 12,
},
statusBarUnderlay: {
backgroundColor: '#673ab7',
height: 20,
left: 0,
position: 'absolute',
right: 0,
top: 0,
},
title: {
color: '#444',
fontSize: 16,
fontWeight: 'bold',
},
});

View File

@@ -0,0 +1,171 @@
import React from 'react';
import {
LayoutAnimation,
StatusBar,
StyleSheet,
Text,
View,
} from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
createMaterialTopTabNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
interface Props {
navigation: NavigationScreenProp<NavigationState>;
}
class MyHomeScreen extends React.Component<Props> {
static navigationOptions = {
tabBarLabel: 'Home',
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={focused ? 'ios-home' : 'ios-home'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
};
render() {
const { navigation } = this.props;
return (
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
<Text>Home Screen</Text>
<Button
onPress={() => navigation.navigate('Home')}
title="Go to home tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</SafeAreaView>
);
}
}
class RecommendedScreen extends React.Component<Props> {
static navigationOptions = {
tabBarLabel: 'Recommended',
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={focused ? 'ios-people' : 'ios-people'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
};
render() {
const { navigation } = this.props;
return (
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
<Text>Recommended Screen</Text>
<Button
onPress={() => navigation.navigate('Home')}
title="Go to home tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</SafeAreaView>
);
}
}
class FeaturedScreen extends React.Component<Props> {
static navigationOptions = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
tabBarLabel: 'Featured',
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={focused ? 'ios-star' : 'ios-star'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
});
render() {
const { navigation } = this.props;
return (
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
<Text>Featured Screen</Text>
<Button
onPress={() => navigation.navigate('Home')}
title="Go to home tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</SafeAreaView>
);
}
}
const SimpleTabs = createMaterialTopTabNavigator({
Home: MyHomeScreen,
Recommended: RecommendedScreen,
Featured: FeaturedScreen,
});
class TabNavigator extends React.Component<Props> {
static router = SimpleTabs.router;
componentWillUpdate() {
LayoutAnimation.easeInEaseOut();
}
render() {
const { navigation } = this.props;
const { routes, index } = navigation.state;
const activeRoute = routes[index];
let bottom = null;
if (activeRoute.routeName !== 'Home') {
bottom = (
<View style={{ height: 50, borderTopWidth: StyleSheet.hairlineWidth }}>
<Button
title="Check out"
onPress={() => {
//
}}
/>
</View>
);
}
return (
<View style={{ flex: 1 }}>
<StatusBar barStyle="default" />
<SafeAreaView
style={{ flex: 1 }}
forceInset={{ horizontal: 'always', top: 'always' }}
>
<SimpleTabs navigation={navigation} />
</SafeAreaView>
{bottom}
</View>
);
}
}
export default TabNavigator;

View File

@@ -0,0 +1,132 @@
import React from 'react';
import { ScrollView, StatusBar, StyleSheet, Text } from 'react-native';
import { BorderlessButton } from 'react-native-gesture-handler';
import {
createNavigator,
NavigationState,
SafeAreaView,
TabRouter,
} from 'react-navigation';
import { createAppContainer } from 'react-navigation';
import { NavigationScreenProp } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const MyNavScreen = ({
navigation,
banner,
}: {
navigation: NavigationScreenProp<NavigationState>;
banner: string;
}) => (
<ScrollView>
<SafeAreaView forceInset={{ horizontal: 'always' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => {
navigation.goBack(null);
}}
title="Go back"
/>
</SafeAreaView>
<StatusBar barStyle="default" />
</ScrollView>
);
const MyHomeScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Home Screen" navigation={navigation} />;
const MyNotificationsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
const MySettingsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Settings Screen" navigation={navigation} />;
const CustomTabBar = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => {
const { routes } = navigation.state;
return (
<SafeAreaView style={styles.tabContainer}>
{routes.map(route => (
<BorderlessButton
onPress={() => navigation.navigate(route.routeName)}
style={styles.tab}
key={route.routeName}
>
<Text>{route.routeName}</Text>
</BorderlessButton>
))}
</SafeAreaView>
);
};
// @todo - how does the type definition for a custom navigator work?
class CustomTabView extends React.Component<any> {
render() {
const { navigation, descriptors } = this.props;
const { routes, index } = navigation.state;
const descriptor = descriptors[routes[index].key];
const ActiveScreen = descriptor.getComponent();
return (
<SafeAreaView forceInset={{ top: 'always' }}>
<CustomTabBar navigation={navigation} />
<ActiveScreen navigation={descriptor.navigation} />
</SafeAreaView>
);
}
}
const CustomTabRouter = TabRouter(
{
Home: {
path: '',
screen: MyHomeScreen,
},
Notifications: {
path: 'notifications',
screen: MyNotificationsScreen,
},
Settings: {
path: 'settings',
screen: MySettingsScreen,
},
},
{
// Change this to start on a different tab
initialRouteName: 'Home',
}
);
const CustomTabs = createAppContainer(
createNavigator(CustomTabView, CustomTabRouter, {})
);
const styles = StyleSheet.create({
tab: {
alignItems: 'center',
borderColor: '#ddd',
borderRadius: 4,
borderWidth: 1,
flex: 1,
justifyContent: 'center',
margin: 4,
},
tabContainer: {
flexDirection: 'row',
height: 48,
},
});
export default CustomTabs;

View File

@@ -0,0 +1,116 @@
import React from 'react';
import { ScrollView, StatusBar, StyleProp, TextStyle } from 'react-native';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import {
createDrawerNavigator,
createStackNavigator,
SafeAreaView,
} from 'react-navigation';
import { NavigationScreenProp, NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const MyNavScreen = ({
navigation,
banner,
}: {
navigation: NavigationScreenProp<NavigationState>;
banner: string;
}) => (
<ScrollView>
<SafeAreaView forceInset={{ top: 'always' }}>
<SampleText>{banner}</SampleText>
<Button onPress={() => navigation.openDrawer()} title="Open drawer" />
<Button
onPress={() => navigation.navigate('Email')}
title="Open other screen"
/>
<Button onPress={() => navigation.navigate('Index')} title="Go back" />
</SafeAreaView>
<StatusBar barStyle="default" />
</ScrollView>
);
const InboxScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner={'Inbox Screen'} navigation={navigation} />;
InboxScreen.navigationOptions = {
headerTitle: 'Inbox',
};
const EmailScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner={'Email Screen'} navigation={navigation} />;
const DraftsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner={'Drafts Screen'} navigation={navigation} />;
DraftsScreen.navigationOptions = {
headerTitle: 'Drafts',
};
const InboxStack = createStackNavigator(
{
Email: { screen: EmailScreen },
Inbox: { screen: InboxScreen },
},
{
navigationOptions: {
drawerIcon: ({ tintColor }) => (
<MaterialIcons
name="move-to-inbox"
size={24}
style={{ color: tintColor } as StyleProp<TextStyle>}
/>
),
drawerLabel: 'Inbox',
},
}
);
const DraftsStack = createStackNavigator(
{
Drafts: { screen: DraftsScreen },
Email: { screen: EmailScreen },
},
{
navigationOptions: {
drawerIcon: ({ tintColor }) => (
<MaterialIcons
name="drafts"
size={24}
style={{ color: tintColor } as StyleProp<TextStyle>}
/>
),
drawerLabel: 'Drafts',
},
}
);
const DrawerExample = createDrawerNavigator(
{
Drafts: {
path: '/sent',
screen: DraftsStack,
},
Inbox: {
path: '/',
screen: InboxStack,
},
},
{
contentOptions: {
activeTintColor: '#e91e63',
},
initialRouteName: 'Drafts',
}
);
export default DrawerExample;

View File

@@ -1,13 +1,21 @@
/**
* @flow
*/
import React from 'react';
import { Button, ScrollView, StatusBar, Text } from 'react-native';
import { SafeAreaView, StackNavigator } from 'react-navigation';
import { ScrollView, StatusBar, Text } from 'react-native';
import {
createStackNavigator,
NavigationScreenProp,
SafeAreaView,
} from 'react-navigation';
import { NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const MyNavScreen = ({ navigation, banner }) => (
const MyNavScreen = ({
navigation,
banner,
}: {
navigation: NavigationScreenProp<NavigationState & any>;
banner: string;
}) => (
<ScrollView>
<SafeAreaView
forceInset={{
@@ -31,7 +39,8 @@ const MyNavScreen = ({ navigation, banner }) => (
headerVisible:
!navigation.state.params ||
!navigation.state.params.headerVisible,
})}
})
}
/>
)}
<Button onPress={() => navigation.goBack(null)} title="Go back" />
@@ -40,24 +49,34 @@ const MyNavScreen = ({ navigation, banner }) => (
</ScrollView>
);
const MyHomeScreen = ({ navigation }) => (
<MyNavScreen banner="Home Screen" navigation={navigation} />
);
const MyHomeScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Home Screen" navigation={navigation} />;
MyHomeScreen.navigationOptions = {
title: 'Welcome',
};
const MyProfileScreen = ({ navigation }) => (
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params.name}'s Profile`}
banner={`${navigation.state.params!.name}'s Profile`}
navigation={navigation}
/>
);
MyProfileScreen.navigationOptions = ({ navigation }) => ({
title: `${navigation.state.params.name}'s Profile!`,
MyProfileScreen.navigationOptions = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
title: `${navigation.state.params!.name}'s Profile!`,
});
const ProfileNavigator = StackNavigator(
const ProfileNavigator = createStackNavigator(
{
Home: {
screen: MyHomeScreen,
@@ -68,17 +87,23 @@ const ProfileNavigator = StackNavigator(
},
},
{
navigationOptions: {
defaultNavigationOptions: {
headerLeft: null,
},
mode: 'modal',
}
);
const MyHeaderTestScreen = ({ navigation }) => (
<MyNavScreen banner={`Full screen view`} navigation={navigation} />
);
MyHeaderTestScreen.navigationOptions = ({ navigation }) => {
const MyHeaderTestScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner={`Full screen view`} navigation={navigation} />;
MyHeaderTestScreen.navigationOptions = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => {
const headerVisible =
navigation.state.params && navigation.state.params.headerVisible;
return {
@@ -87,15 +112,15 @@ MyHeaderTestScreen.navigationOptions = ({ navigation }) => {
};
};
const ModalStack = StackNavigator(
const ModalStack = createStackNavigator(
{
HeaderTest: { screen: MyHeaderTestScreen },
ProfileNavigator: {
screen: ProfileNavigator,
},
HeaderTest: { screen: MyHeaderTestScreen },
},
{
navigationOptions: {
defaultNavigationOptions: {
header: null,
},
mode: 'modal',

View File

@@ -1,15 +1,11 @@
/* @flow */
import React from 'react';
import React, { ReactNode } from 'react';
import { StyleSheet, Text } from 'react-native';
/**
* Used across examples as a screen placeholder.
*/
import type { ChildrenArray } from 'react';
const SampleText = ({ children }: { children?: ChildrenArray<*> }) => (
const SampleText = ({ children }: { children?: ReactNode }) => (
<Text style={styles.sampleText}>{children}</Text>
);

View File

@@ -0,0 +1,249 @@
// tslint:disable no-unused-expression
import * as React from 'react';
import { StatusBar } from 'react-native';
import {
createStackNavigator,
NavigationActions,
NavigationEventPayload,
NavigationEventSubscription,
NavigationScreenProp,
NavigationState,
NavigationStateRoute,
SafeAreaView,
StackActions,
withNavigation,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import { HeaderButtons } from './commonComponents/HeaderButtons';
import SampleText from './SampleText';
const DEBUG = false;
interface MyNavScreenProps {
navigation: NavigationScreenProp<NavigationState>;
banner: React.ReactNode;
}
interface BackButtonProps {
navigation: NavigationScreenProp<NavigationStateRoute<any>>;
}
class MyBackButton extends React.Component<BackButtonProps, any> {
render() {
return (
<HeaderButtons>
<HeaderButtons.Item title="Back" onPress={this.navigateBack} />
</HeaderButtons>
);
}
navigateBack = () => {
this.props.navigation.goBack(null);
};
}
const MyBackButtonWithNavigation: any = withNavigation(MyBackButton);
class MyNavScreen extends React.Component<MyNavScreenProps> {
render() {
const { navigation, banner } = this.props;
const { push, replace, popToTop, pop, dismiss } = navigation;
return (
<SafeAreaView forceInset={{ top: 'never' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => push('Profile', { name: 'Jane' })}
title="Push a profile screen"
/>
<Button
onPress={() =>
navigation.dispatch(
StackActions.reset({
actions: [
NavigationActions.navigate({
params: { name: 'Jane' },
routeName: 'Photos',
}),
],
index: 0,
})
)
}
title="Reset photos"
/>
<Button
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
title="Navigate to a photos screen"
/>
<Button
onPress={() => replace('Profile', { name: 'Lucy' })}
title="Replace with profile"
/>
<Button onPress={() => popToTop()} title="Pop to top" />
<Button onPress={() => pop()} title="Pop" />
<Button
onPress={() => {
if (navigation.goBack()) {
console.log('goBack handled');
} else {
console.log('goBack unhandled');
}
}}
title="Go back"
/>
<Button onPress={() => dismiss()} title="Dismiss" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
interface MyHomeScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
static navigationOptions = {
title: 'Welcome',
};
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
}
componentWillUnmount() {
this.s0!.remove();
this.s1!.remove();
this.s2!.remove();
this.s3!.remove();
}
onWF = (a: NavigationEventPayload) => {
DEBUG && console.log('willFocus HomeScreen', a);
};
onDF = (a: NavigationEventPayload) => {
DEBUG && console.log('didFocus HomeScreen', a);
};
onWB = (a: NavigationEventPayload) => {
DEBUG && console.log('willBlur HomeScreen', a);
};
onDB = (a: NavigationEventPayload) => {
DEBUG && console.log('didBlur HomeScreen', a);
};
render() {
const { navigation } = this.props;
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
}
}
interface MyPhotosScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
static navigationOptions = {
headerLeft: <MyBackButtonWithNavigation />,
title: 'Photos',
};
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
}
componentWillUnmount() {
this.s0!.remove();
this.s1!.remove();
this.s2!.remove();
this.s3!.remove();
}
onWF = (a: NavigationEventPayload) => {
DEBUG && console.log('willFocus PhotosScreen', a);
};
onDF = (a: NavigationEventPayload) => {
DEBUG && console.log('didFocus PhotosScreen', a);
};
onWB = (a: NavigationEventPayload) => {
DEBUG && console.log('willBlur PhotosScreen', a);
};
onDB = (a: NavigationEventPayload) => {
DEBUG && console.log('didBlur PhotosScreen', a);
};
render() {
const { navigation } = this.props;
return (
<MyNavScreen
banner={`${navigation.getParam('name')}'s Photos`}
navigation={navigation}
/>
);
}
}
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${
navigation.getParam('mode') === 'edit' ? 'Now Editing ' : ''
}${navigation.getParam('name')}'s Profile`}
navigation={navigation}
/>
);
MyProfileScreen.navigationOptions = (props: MyHomeScreenProps) => {
const { navigation } = props;
const { state, setParams } = navigation;
const { params } = state;
return {
headerBackImage: params!.headerBackImage,
// Render a button on the right side of the header.
// When pressed switches the screen to edit mode.
headerRight: (
<HeaderButtons>
<HeaderButtons.Item
title={params!.mode === 'edit' ? 'Done' : 'Edit'}
onPress={() =>
setParams({ mode: params!.mode === 'edit' ? '' : 'edit' })
}
/>
</HeaderButtons>
),
headerTitle: `${params!.name}'s Profile!`,
};
};
const SimpleStack = createStackNavigator(
{
Home: {
screen: MyHomeScreen,
},
Photos: {
path: 'photos/:name',
screen: MyPhotosScreen,
},
Profile: {
path: 'people/:name',
screen: MyProfileScreen,
},
},
{
// headerLayoutPreset: 'center',
}
);
export default SimpleStack;

View File

@@ -0,0 +1,273 @@
import React from 'react';
import { Animated, Platform, StatusBar, Text, View } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
createBottomTabNavigator,
FlatList,
NavigationEventSubscription,
NavigationScreenProp,
SafeAreaView,
ScrollView,
} from 'react-navigation';
import { NavigationEventPayload, NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const TEXT = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a hendrerit dui, id consectetur nulla. Curabitur mattis sapien nunc, quis dignissim eros venenatis sit amet. Praesent rutrum dapibus diam quis eleifend. Donec vulputate quis purus sed vulputate. Fusce ipsum felis, cursus at congue vel, consectetur tincidunt purus. Pellentesque et fringilla lorem. In at augue malesuada, sollicitudin ex ut, convallis elit. Curabitur metus nibh, consequat vel libero sit amet, iaculis congue nisl. Maecenas eleifend sodales sapien, fringilla sagittis nisi ornare volutpat. Integer tellus enim, volutpat vitae nisl et, dignissim pharetra leo. Sed sit amet efficitur sapien, at tristique sapien. Aenean dignissim semper sagittis. Nullam sit amet volutpat mi.
Curabitur auctor orci et justo molestie iaculis. Integer elementum tortor ac ipsum egestas pharetra. Etiam ultrices elementum pharetra. Maecenas lobortis ultrices risus dignissim luctus. Nunc malesuada cursus posuere. Vestibulum tristique lectus pretium pellentesque pellentesque. Nunc ac nisi lacus. Duis ultrices dui ac viverra ullamcorper. Morbi placerat laoreet lacus sit amet ullamcorper.
Nulla convallis pulvinar hendrerit. Nulla mattis sem et aliquam ultrices. Nam egestas magna leo, nec luctus turpis sollicitudin ac. Sed id leo luctus, lobortis tortor ut, rhoncus ex. Aliquam gravida enim ac dapibus ultricies. Vestibulum at interdum est, et vehicula nibh. Phasellus dignissim iaculis rhoncus. Vestibulum tempus leo lectus, quis euismod metus ullamcorper quis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut id ipsum at enim eleifend porttitor id quis metus. Proin bibendum ornare iaculis. Duis elementum lacus vel cursus efficitur. Nunc eu tortor sed risus lacinia scelerisque.
Praesent lobortis elit sit amet mauris pulvinar, viverra condimentum massa pellentesque. Curabitur massa ex, dignissim eget neque at, fringilla consectetur justo. Cras sollicitudin vel ligula sed cursus. Aliquam porta sem hendrerit diam porta ultricies. Sed eu mi erat. Curabitur id justo vel tortor hendrerit vestibulum id eget est. Morbi eros magna, placerat id diam ut, varius sollicitudin mi. Curabitur pretium finibus accumsan.`;
const MyNavScreen = ({
navigation,
banner,
}: {
navigation: NavigationScreenProp<NavigationState>;
banner: string;
}) => (
<ScrollView style={{ flex: 1 }}>
<SafeAreaView forceInset={{ horizontal: 'always', top: 'always' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => navigation.navigate('Home')}
title="Go to home tab"
/>
<Button
onPress={() => navigation.navigate('Settings')}
title="Go to settings tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
{TEXT.split('\n').map((p, n) => (
<Text key={n} style={{ marginVertical: 10, marginHorizontal: 8 }}>
{p}
</Text>
))}
<StatusBar barStyle="default" />
</SafeAreaView>
</ScrollView>
);
const MyListScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<FlatList
data={TEXT.split('\n')}
style={{ paddingTop: 10 }}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item }) => (
<Text style={{ fontSize: 16, marginVertical: 10, marginHorizontal: 8 }}>
{item}
</Text>
)}
/>
);
const MyHomeScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Home Tab" navigation={navigation} />;
MyHomeScreen.navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={'ios-home'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
tabBarLabel: 'Home',
tabBarTestIDProps: {
accessibilityLabel: 'TEST_ID_HOME_ACLBL',
testID: 'TEST_ID_HOME',
},
};
MyListScreen.navigationOptions = MyHomeScreen.navigationOptions;
interface MyPeopleScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyPeopleScreen extends React.Component<MyPeopleScreenProps> {
static navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={'ios-people'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
tabBarLabel: 'People',
};
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
// this.s0! = this.props.navigation.addListener('willFocus', this.onEvent);
// this.s1! = this.props.navigation.addListener('didFocus', this.onEvent);
// this.s2! = this.props.navigation.addListener('willBlur', this.onEvent);
// this.s3! = this.props.navigation.addListener('didBlur', this.onEvent);
}
componentWillUnmount() {
// this.s0!.remove();
// this.s1!.remove();
// this.s2!.remove();
// this.s3!.remove();
}
onEvent = (a: NavigationEventPayload) => {
console.log('EVENT ON PEOPLE TAB', a.type, a);
};
render() {
const { navigation } = this.props;
return <MyNavScreen banner="People Tab" navigation={navigation} />;
}
}
interface MyChatScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyChatScreen extends React.Component<MyChatScreenProps> {
static navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={'ios-chatboxes'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
tabBarLabel: 'Chat',
};
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
// this.s0! = this.props.navigation.addListener('willFocus', this.onEvent);
// this.s1! = this.props.navigation.addListener('didFocus', this.onEvent);
// this.s2! = this.props.navigation.addListener('willBlur', this.onEvent);
// this.s3! = this.props.navigation.addListener('didBlur', this.onEvent);
}
componentWillUnmount() {
// this.s0!.remove();
// this.s1!.remove();
// this.s2!.remove();
// this.s3!.remove();
}
onEvent = (a: NavigationEventPayload) => {
console.log('EVENT ON CHAT TAB', a.type, a);
};
render() {
const { navigation } = this.props;
return <MyNavScreen banner="Chat Tab" navigation={navigation} />;
}
}
const MySettingsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Settings Tab" navigation={navigation} />;
MySettingsScreen.navigationOptions = {
tabBarIcon: ({
tintColor,
focused,
horizontal,
}: {
tintColor: string;
focused: boolean;
horizontal: boolean;
}) => (
<Ionicons
name={'ios-settings'}
size={horizontal ? 20 : 26}
style={{ color: tintColor }}
/>
),
tabBarLabel: 'Settings',
};
const SimpleTabs = createBottomTabNavigator(
{
Chat: {
path: 'chat',
screen: MyChatScreen,
},
Home: {
path: '',
screen: MyListScreen,
},
People: {
path: 'cart',
screen: MyPeopleScreen,
},
Settings: {
path: 'settings',
screen: MySettingsScreen,
},
},
{
backBehavior: 'history',
tabBarOptions: {
activeTintColor: '#e91e63',
},
}
);
interface SimpleTabsContainerProps {
navigation: NavigationScreenProp<NavigationState>;
}
class SimpleTabsContainer extends React.Component<SimpleTabsContainerProps> {
static router = SimpleTabs.router;
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
// this.s0! = this.props.navigation.addListener('willFocus', this.onAction);
// this.s1! = this.props.navigation.addListener('didFocus', this.onAction);
// this.s2! = this.props.navigation.addListener('willBlur', this.onAction);
// this.s3! = this.props.navigation.addListener('didBlur', this.onAction);
}
componentWillUnmount() {
// this.s0!.remove();
// this.s1!.remove();
// this.s2!.remove();
// this.s3!.remove();
}
onAction = (a: NavigationEventPayload) => {
console.log('TABS EVENT', a.type, a);
};
render() {
return <SimpleTabs navigation={this.props.navigation} />;
}
}
export default SimpleTabsContainer;

View File

@@ -0,0 +1,148 @@
import * as React from 'react';
import { Button, Image, StatusBar, StyleSheet } from 'react-native';
import {
createStackNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import SampleText from './SampleText';
interface MyNavScreenProps {
navigation: NavigationScreenProp<NavigationState>;
banner: React.ReactNode;
}
class MyCustomHeaderBackImage extends React.Component<any, any> {
render() {
const source = require('./assets/back.png');
return (
<Image
source={source}
style={[styles.myCustomHeaderBackImage, this.props.style]}
/>
);
}
}
class MyNavScreen extends React.Component<MyNavScreenProps> {
render() {
const { navigation, banner } = this.props;
return (
<SafeAreaView>
<SampleText>{banner}</SampleText>
<Button
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
title="Navigate to a photos screen"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
interface MyHomeScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
static navigationOptions = {
headerBackTitle: null,
title: 'Welcome',
};
render() {
const { navigation } = this.props;
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
}
}
interface MyPhotosScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
static navigationOptions = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
headerBackTitle: null,
title: `${navigation.state.params!.name}'s photos`,
});
render() {
const { navigation } = this.props;
return (
<SafeAreaView>
<SampleText>{`${navigation.state.params!.name}'s Photos`}</SampleText>
<Button
onPress={() => navigation.navigate('Profile', { name: 'Jane' })}
title="Navigate to a profile screen"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
interface MyProfileScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyProfileScreen extends React.Component<MyProfileScreenProps> {
static navigationOptions = () => ({
headerBackImage: (
<MyCustomHeaderBackImage style={styles.myCustomHeaderBackImageAlt} />
),
title: 'Profile',
});
render() {
const { navigation } = this.props;
return (
<SafeAreaView>
<SampleText>{`${navigation.state.params!.name}'s Profile`}</SampleText>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
const StackWithCustomHeaderBackImage = createStackNavigator(
{
Home: {
screen: MyHomeScreen,
},
Photos: {
path: 'photos/:name',
screen: MyPhotosScreen,
},
Profile: {
path: 'profile/:name',
screen: MyProfileScreen,
},
},
{
defaultNavigationOptions: {
headerBackImage: MyCustomHeaderBackImage as any,
},
}
);
export default StackWithCustomHeaderBackImage;
const styles = StyleSheet.create({
myCustomHeaderBackImage: {
height: 14.5,
marginLeft: 9,
marginRight: 12,
marginVertical: 12,
resizeMode: 'contain',
width: 24,
},
myCustomHeaderBackImageAlt: {
tintColor: '#f00',
},
});

View File

@@ -0,0 +1,118 @@
import * as React from 'react';
import { StatusBar } from 'react-native';
import {
createStackNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
interface NavScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class HomeScreen extends React.Component<NavScreenProps> {
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigation } = this.props;
const { push } = navigation;
return (
<SafeAreaView style={{ paddingTop: 30 }}>
<Button onPress={() => push('Other')} title="Push another screen" />
<Button
onPress={() => push('ScreenWithNoHeader')}
title="Push screen with no header"
/>
<Button onPress={() => navigation.goBack(null)} title="Go Home" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
class OtherScreen extends React.Component<NavScreenProps> {
static navigationOptions = {
title: 'Your title here',
};
render() {
const { navigation } = this.props;
const { push, pop } = navigation;
return (
<SafeAreaView style={{ paddingTop: 30 }}>
<Button
onPress={() => push('ScreenWithLongTitle')}
title="Push another screen"
/>
<Button
onPress={() => push('ScreenWithNoHeader')}
title="Push screen with no header"
/>
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
class ScreenWithLongTitle extends React.Component<NavScreenProps> {
static navigationOptions = {
title: "Another title that's kind of long",
};
render() {
const { navigation } = this.props;
const { pop } = navigation;
return (
<SafeAreaView style={{ paddingTop: 30 }}>
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
class ScreenWithNoHeader extends React.Component<NavScreenProps> {
static navigationOptions = {
header: null,
title: 'No Header',
};
render() {
const { navigation } = this.props;
const { push, pop } = navigation;
return (
<SafeAreaView style={{ paddingTop: 30 }}>
<Button onPress={() => push('Other')} title="Push another screen" />
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</SafeAreaView>
);
}
}
const StackWithHeaderPreset = createStackNavigator(
{
Home: HomeScreen,
Other: OtherScreen,
ScreenWithLongTitle,
ScreenWithNoHeader,
},
{
headerTransitionPreset: 'uikit',
}
);
export default StackWithHeaderPreset;

View File

@@ -0,0 +1,254 @@
import * as React from 'react';
import {
Platform,
ScrollView,
StatusBar,
StyleSheet,
View,
} from 'react-native';
import { BlurView } from 'react-native-blur';
import { isIphoneX } from 'react-native-iphone-x-helper';
import {
createStackNavigator,
Header,
HeaderStyleInterpolator,
NavigationEventPayload,
NavigationEventSubscription,
NavigationScreenProp,
NavigationState,
TransitionConfig,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import { HeaderButtons } from './commonComponents/HeaderButtons';
import SampleText from './SampleText';
interface MyNavScreenProps {
navigation: NavigationScreenProp<NavigationState>;
banner: React.ReactNode;
}
class MyNavScreen extends React.Component<MyNavScreenProps> {
render() {
const { navigation, banner } = this.props;
const { push, replace, popToTop, pop } = navigation;
return (
<ScrollView style={{ flex: 1 }} {...this.getHeaderInset()}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => push('Profile', { name: 'Jane' })}
title="Push a profile screen"
/>
<Button
onPress={() => navigation.navigate('Photos', { name: 'Jane' })}
title="Navigate to a photos screen"
/>
<Button
onPress={() => replace('Profile', { name: 'Lucy' })}
title="Replace with profile"
/>
<Button onPress={() => popToTop()} title="Pop to top" />
<Button onPress={() => pop()} title="Pop" />
<Button onPress={() => navigation.goBack(null)} title="Go back" />
<StatusBar barStyle="default" />
</ScrollView>
);
}
// Inset to compensate for navigation bar being transparent.
// And improved abstraction for this will be built in to react-navigation
// at some point.
getHeaderInset(): any {
const NOTCH_HEIGHT = isIphoneX() ? 25 : 0;
// $FlowIgnore: we will remove the HEIGHT static soon enough
const BASE_HEADER_HEIGHT = Header.HEIGHT;
const HEADER_HEIGHT =
Platform.OS === 'ios'
? BASE_HEADER_HEIGHT + NOTCH_HEIGHT
: BASE_HEADER_HEIGHT + 20;
return Platform.select({
android: {
contentContainerStyle: {
paddingTop: HEADER_HEIGHT,
},
},
ios: {
contentInset: { top: HEADER_HEIGHT },
contentOffset: { y: -HEADER_HEIGHT },
},
});
}
}
interface MyHomeScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyHomeScreen extends React.Component<MyHomeScreenProps> {
static navigationOptions = {
title: 'Welcome',
};
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
}
componentWillUnmount() {
this.s0!.remove();
this.s1!.remove();
this.s2!.remove();
this.s3!.remove();
}
onWF = (a: NavigationEventPayload) => {
console.log('willFocus HomeScreen', a);
};
onDF = (a: NavigationEventPayload) => {
console.log('didFocus HomeScreen', a);
};
onWB = (a: NavigationEventPayload) => {
console.log('willBlur HomeScreen', a);
};
onDB = (a: NavigationEventPayload) => {
console.log('didBlur HomeScreen', a);
};
render() {
const { navigation } = this.props;
return <MyNavScreen banner="Home Screen" navigation={navigation} />;
}
}
interface MyPhotosScreenProps {
navigation: NavigationScreenProp<NavigationState>;
}
class MyPhotosScreen extends React.Component<MyPhotosScreenProps> {
static navigationOptions = {
title: 'Photos',
};
s0: NavigationEventSubscription | null = null;
s1: NavigationEventSubscription | null = null;
s2: NavigationEventSubscription | null = null;
s3: NavigationEventSubscription | null = null;
componentDidMount() {
this.s0 = this.props.navigation.addListener('willFocus', this.onWF);
this.s1 = this.props.navigation.addListener('didFocus', this.onDF);
this.s2 = this.props.navigation.addListener('willBlur', this.onWB);
this.s3 = this.props.navigation.addListener('didBlur', this.onDB);
}
componentWillUnmount() {
this.s0!.remove();
this.s1!.remove();
this.s2!.remove();
this.s3!.remove();
}
onWF = (a: NavigationEventPayload) => {
console.log('willFocus PhotosScreen', a);
};
onDF = (a: NavigationEventPayload) => {
console.log('didFocus PhotosScreen', a);
};
onWB = (a: NavigationEventPayload) => {
console.log('willBlur PhotosScreen', a);
};
onDB = (a: NavigationEventPayload) => {
console.log('didBlur PhotosScreen', a);
};
render() {
const { navigation } = this.props;
return (
<MyNavScreen
banner={`${navigation.state.params!.name}'s Photos`}
navigation={navigation}
/>
);
}
}
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.mode === 'edit' ? 'Now Editing ' : ''}${
navigation.state.params!.name
}'s Profile`}
navigation={navigation}
/>
);
MyProfileScreen.navigationOptions = (props: {
navigation: NavigationScreenProp<NavigationState>;
}) => {
const { navigation } = props;
const { state, setParams } = navigation;
const { params } = state;
return {
headerBackImage: params!.headerBackImage,
// Render a button on the right side of the header.
// When pressed switches the screen to edit mode.
headerRight: (
<HeaderButtons>
<HeaderButtons.Item
title={params!.mode === 'edit' ? 'Done' : 'Edit'}
onPress={() =>
setParams({ mode: params!.mode === 'edit' ? '' : 'edit' })
}
/>
</HeaderButtons>
),
headerTitle: `${params!.name}'s Profile!`,
};
};
const StackWithTranslucentHeader = createStackNavigator(
{
Home: {
screen: MyHomeScreen,
},
Photos: {
path: 'photos/:name',
screen: MyPhotosScreen,
},
Profile: {
path: 'people/:name',
screen: MyProfileScreen,
},
},
{
defaultNavigationOptions: {
headerBackground: Platform.select({
android: (
<View style={{ flex: 1, backgroundColor: 'rgba(255,255,255,0.7)' }} />
),
ios: <BlurView style={{ flex: 1 }} blurType="light" />,
}),
headerStyle: {
borderBottomColor: '#A7A7AA',
borderBottomWidth: StyleSheet.hairlineWidth,
},
headerTransparent: true,
},
headerTransitionPreset: 'uikit',
// You can leave this out if you don't want the card shadow to
// be visible through the header
transitionConfig: () =>
({
headerBackgroundInterpolator:
HeaderStyleInterpolator.forBackgroundWithTranslation,
} as TransitionConfig),
}
);
export default StackWithTranslucentHeader;

View File

@@ -1,8 +1,14 @@
import React from 'react';
import { Button, StatusBar, Text, View } from 'react-native';
import { StackNavigator } from 'react-navigation';
import { StatusBar, Text, View } from 'react-native';
import { createStackNavigator, NavigationScreenProp } from 'react-navigation';
import { NavigationState } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
class HomeScreen extends React.Component<any, any> {
interface Props {
navigation: NavigationScreenProp<NavigationState & any>;
}
class HomeScreen extends React.Component<Props, any> {
render() {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -11,9 +17,9 @@ class HomeScreen extends React.Component<any, any> {
title="Navigate to 'Profile' with key 'A'"
onPress={() =>
this.props.navigation.navigate({
routeName: 'Profile',
key: 'A',
params: { homeKey: this.props.navigation.state.key },
routeName: 'Profile',
})
}
/>
@@ -37,9 +43,9 @@ class ProfileScreen extends React.Component<any, any> {
title="Navigate to 'Settings' with key 'B'"
onPress={() =>
this.props.navigation.navigate({
routeName: 'Settings',
key: 'B',
params: { homeKey },
routeName: 'Settings',
})
}
/>
@@ -54,9 +60,9 @@ class ProfileScreen extends React.Component<any, any> {
}
}
class SettingsScreen extends React.Component<any, any> {
class SettingsScreen extends React.Component<Props, any> {
render() {
const { homeKey } = this.props.navigation.state.params;
const { homeKey } = this.props.navigation.state.params!;
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
@@ -71,8 +77,8 @@ class SettingsScreen extends React.Component<any, any> {
title="Navigate back to 'Profile' with key 'A'"
onPress={() =>
this.props.navigation.navigate({
routeName: 'Profile',
key: 'A',
routeName: 'Profile',
})
}
/>
@@ -81,7 +87,7 @@ class SettingsScreen extends React.Component<any, any> {
}
}
const Stack = StackNavigator(
const Stack = createStackNavigator(
{
Home: {
screen: HomeScreen,

View File

@@ -0,0 +1,163 @@
import React from 'react';
import { StatusBar, Text } from 'react-native';
import {
createBottomTabNavigator,
createStackNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
ScrollView,
} from 'react-navigation';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const TEXT = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a hendrerit dui, id consectetur nulla. Curabitur mattis sapien nunc, quis dignissim eros venenatis sit amet. Praesent rutrum dapibus diam quis eleifend. Donec vulputate quis purus sed vulputate. Fusce ipsum felis, cursus at congue vel, consectetur tincidunt purus. Pellentesque et fringilla lorem. In at augue malesuada, sollicitudin ex ut, convallis elit. Curabitur metus nibh, consequat vel libero sit amet, iaculis congue nisl. Maecenas eleifend sodales sapien, fringilla sagittis nisi ornare volutpat. Integer tellus enim, volutpat vitae nisl et, dignissim pharetra leo. Sed sit amet efficitur sapien, at tristique sapien. Aenean dignissim semper sagittis. Nullam sit amet volutpat mi.
Curabitur auctor orci et justo molestie iaculis. Integer elementum tortor ac ipsum egestas pharetra. Etiam ultrices elementum pharetra. Maecenas lobortis ultrices risus dignissim luctus. Nunc malesuada cursus posuere. Vestibulum tristique lectus pretium pellentesque pellentesque. Nunc ac nisi lacus. Duis ultrices dui ac viverra ullamcorper. Morbi placerat laoreet lacus sit amet ullamcorper.
Nulla convallis pulvinar hendrerit. Nulla mattis sem et aliquam ultrices. Nam egestas magna leo, nec luctus turpis sollicitudin ac. Sed id leo luctus, lobortis tortor ut, rhoncus ex. Aliquam gravida enim ac dapibus ultricies. Vestibulum at interdum est, et vehicula nibh. Phasellus dignissim iaculis rhoncus. Vestibulum tempus leo lectus, quis euismod metus ullamcorper quis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut id ipsum at enim eleifend porttitor id quis metus. Proin bibendum ornare iaculis. Duis elementum lacus vel cursus efficitur. Nunc eu tortor sed risus lacinia scelerisque.
Praesent lobortis elit sit amet mauris pulvinar, viverra condimentum massa pellentesque. Curabitur massa ex, dignissim eget neque at, fringilla consectetur justo. Cras sollicitudin vel ligula sed cursus. Aliquam porta sem hendrerit diam porta ultricies. Sed eu mi erat. Curabitur id justo vel tortor hendrerit vestibulum id eget est. Morbi eros magna, placerat id diam ut, varius sollicitudin mi. Curabitur pretium finibus accumsan.`;
interface Props {
navigation: NavigationScreenProp<NavigationState>;
banner: string;
}
class MyNavScreen extends React.Component<Props> {
render() {
const { navigation } = this.props;
const banner = navigation.getParam('banner');
return (
<ScrollView style={{ flex: 1 }}>
<SafeAreaView forceInset={{ horizontal: 'always' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
title="Open profile screen"
/>
<Button
onPress={() => navigation.navigate('NotifSettings')}
title="Open notifications screen"
/>
<Button
onPress={() => navigation.navigate('SettingsTab')}
title="Go to settings tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
{TEXT.split('\n').map((p, n) => (
<Text key={n} style={{ marginVertical: 10, marginHorizontal: 8 }}>
{p}
</Text>
))}
</SafeAreaView>
<StatusBar barStyle="default" />
</ScrollView>
);
}
}
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.name}s Profile`}
navigation={navigation}
/>
);
const MainTab = createStackNavigator({
Home: {
navigationOptions: {
title: 'Welcome',
},
params: { banner: 'Home Screen' },
path: '/',
screen: MyNavScreen,
},
Profile: {
navigationOptions: ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
title: `${navigation.state.params!.name}'s Profile!`,
}),
path: '/people/:name',
screen: MyProfileScreen,
},
});
const SettingsTab = createStackNavigator({
NotifSettings: {
navigationOptions: {
title: 'Notifications',
},
params: { banner: 'Notifications Screen' },
screen: MyNavScreen,
},
Settings: {
navigationOptions: () => ({
title: 'Settings',
}),
params: { banner: 'Settings Screen' },
path: '/',
screen: MyNavScreen,
},
});
const StacksInTabs = createBottomTabNavigator(
{
MainTab: {
navigationOptions: {
tabBarIcon: ({
tintColor,
focused,
}: {
tintColor: string;
focused: boolean;
}) => (
<Ionicons
name={focused ? 'ios-home' : 'ios-home'}
size={26}
style={{ color: tintColor }}
/>
),
tabBarLabel: 'Home',
},
path: '/',
screen: MainTab,
},
SettingsTab: {
screen: SettingsTab,
path: '/settings',
navigationOptions: {
tabBarLabel: 'Settings',
tabBarIcon: ({
tintColor,
focused,
}: {
tintColor: string;
focused: boolean;
}) => (
<Ionicons
name={focused ? 'ios-settings' : 'ios-settings'}
size={26}
style={{ color: tintColor }}
/>
),
},
},
},
{
tabBarOptions: {
showLabel: false,
},
}
);
export default StacksInTabs;

View File

@@ -0,0 +1,159 @@
import React from 'react';
import { ScrollView, StatusBar } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import {
createBottomTabNavigator,
createStackNavigator,
getActiveChildNavigationOptions,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const MyNavScreen = ({
navigation,
banner,
}: {
navigation: NavigationScreenProp<NavigationState>;
banner: string;
}) => (
<ScrollView>
<SafeAreaView forceInset={{ horizontal: 'always', vertical: 'never' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
title="Open profile screen"
/>
<Button
onPress={() => navigation.navigate('NotifSettings')}
title="Open notifications screen"
/>
<Button
onPress={() => navigation.navigate('SettingsTab')}
title="Go to settings tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</SafeAreaView>
<StatusBar barStyle="default" />
</ScrollView>
);
const MyHomeScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Home Screen" navigation={navigation} />;
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.name}s Profile`}
navigation={navigation}
/>
);
const MyNotificationsSettingsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
const MySettingsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Settings Screen" navigation={navigation} />;
const TabNav = createBottomTabNavigator(
{
MainTab: {
navigationOptions: {
tabBarIcon: ({
tintColor,
focused,
}: {
tintColor: string;
focused: boolean;
}) => (
<Ionicons
name={focused ? 'ios-home' : 'ios-home'}
size={26}
style={{ color: tintColor }}
/>
),
tabBarLabel: 'Home',
title: 'Welcome',
},
path: '/',
screen: MyHomeScreen,
},
SettingsTab: {
navigationOptions: {
tabBarIcon: ({
tintColor,
focused,
}: {
tintColor: string;
focused: boolean;
}) => (
<Ionicons
name={focused ? 'ios-settings' : 'ios-settings'}
size={26}
style={{ color: tintColor }}
/>
),
title: 'Settings',
},
path: '/settings',
screen: MySettingsScreen,
},
},
{
animationEnabled: false,
swipeEnabled: false,
tabBarPosition: 'bottom',
}
);
TabNav.navigationOptions = ({
navigation,
screenProps,
}: {
navigation: NavigationScreenProp<NavigationState>;
screenProps: { [key: string]: any };
}) => {
const childOptions = getActiveChildNavigationOptions(navigation, screenProps);
return {
title: childOptions.title,
};
};
const StacksOverTabs = createStackNavigator({
NotifSettings: {
navigationOptions: {
title: 'Notifications',
},
screen: MyNotificationsSettingsScreen,
},
Profile: {
navigationOptions: ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
title: `${navigation.state.params!.name}'s Profile!`,
}),
path: '/people/:name',
screen: MyProfileScreen,
},
Root: {
screen: TabNav,
},
});
export default StacksOverTabs;

View File

@@ -0,0 +1,176 @@
import React from 'react';
import {
ScrollView,
StatusBar,
StatusBarStyle,
StyleSheet,
View,
} from 'react-native';
import {
createMaterialTopTabNavigator,
createStackNavigator,
NavigationScreenProp,
NavigationState,
SafeAreaView,
} from 'react-navigation';
import { MaterialTopTabBar } from 'react-navigation-tabs';
import { Button } from './commonComponents/ButtonWithMargin';
import SampleText from './SampleText';
const HEADER_HEIGHT = 64;
const MyNavScreen = ({
navigation,
banner,
statusBarStyle,
}: {
navigation: NavigationScreenProp<NavigationState>;
banner: string;
statusBarStyle?: StatusBarStyle;
}) => (
<ScrollView>
<SafeAreaView forceInset={{ horizontal: 'always' }}>
<SampleText>{banner}</SampleText>
<Button
onPress={() => navigation.navigate('Profile', { name: 'Jordan' })}
title="Open profile screen"
/>
<Button
onPress={() => navigation.navigate('NotifSettings')}
title="Open notifications screen"
/>
<Button
onPress={() => navigation.navigate('SettingsTab')}
title="Go to settings tab"
/>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</SafeAreaView>
<StatusBar barStyle={statusBarStyle || 'default'} />
</ScrollView>
);
const MyHomeScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner="Home Screen"
navigation={navigation}
statusBarStyle="light-content"
/>
);
const MyProfileScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner={`${navigation.state.params!.name}s Profile`}
navigation={navigation}
/>
);
const MyNotificationsSettingsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => <MyNavScreen banner="Notifications Screen" navigation={navigation} />;
const MySettingsScreen = ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => (
<MyNavScreen
banner="Settings Screen"
navigation={navigation}
statusBarStyle="light-content"
/>
);
const styles = StyleSheet.create({
stackHeader: {
height: HEADER_HEIGHT,
},
tab: {
height: HEADER_HEIGHT,
},
});
function MaterialTopTabBarWithStatusBar(props: any) {
return (
<View
style={{
paddingTop: 20,
backgroundColor: '#2196f3',
}}
>
<MaterialTopTabBar
{...props}
jumpToIndex={() => {
//
}}
/>
</View>
);
}
const TabNavigator = createMaterialTopTabNavigator(
{
MainTab: {
screen: MyHomeScreen,
navigationOptions: {
title: 'Welcome',
},
},
SettingsTab: {
screen: MySettingsScreen,
navigationOptions: {
title: 'Settings',
},
},
},
{
tabBarComponent: MaterialTopTabBarWithStatusBar,
tabBarOptions: {
tabStyle: styles.tab,
},
}
);
const StackNavigator = createStackNavigator(
{
Root: {
screen: TabNavigator,
navigationOptions: {
header: null,
},
},
NotifSettings: {
screen: MyNotificationsSettingsScreen,
navigationOptions: {
title: 'Notifications',
},
},
Profile: {
screen: MyProfileScreen,
navigationOptions: ({
navigation,
}: {
navigation: NavigationScreenProp<NavigationState>;
}) => ({
title: `${navigation.state.params!.name}'s Profile!`,
}),
},
},
{
defaultNavigationOptions: {
headerStyle: styles.stackHeader,
},
}
);
export default StackNavigator;

View File

@@ -0,0 +1,118 @@
import React from 'react';
import {
ActivityIndicator,
AsyncStorage,
StatusBar,
StyleSheet,
View,
Platform,
} from 'react-native';
import { createStackNavigator, createSwitchNavigator } from 'react-navigation';
import { Button } from './commonComponents/ButtonWithMargin';
class SignInScreen extends React.Component<any, any> {
static navigationOptions = {
title: 'Please sign in',
};
render() {
return (
<View style={styles.container}>
<Button title="Sign in!" onPress={this.signInAsync} />
<Button
title="Go back to other examples"
onPress={() => this.props.navigation.goBack(null)}
/>
<StatusBar barStyle="default" />
</View>
);
}
signInAsync = async () => {
await AsyncStorage.setItem('userToken', 'abc');
this.props.navigation.navigate('Home');
};
}
class HomeScreen extends React.Component<any, any> {
static navigationOptions = {
title: 'Welcome to the app!',
};
render() {
return (
<View style={styles.container}>
<Button title="Show me more of the app" onPress={this.showMoreApp} />
<Button title="Actually, sign me out :)" onPress={this.signOutAsync} />
<StatusBar barStyle="default" />
</View>
);
}
showMoreApp = () => {
this.props.navigation.navigate('Other');
};
signOutAsync = async () => {
Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
this.props.navigation.navigate('Auth');
};
}
class OtherScreen extends React.Component<any, any> {
static navigationOptions = {
title: 'Lots of features here',
};
render() {
return (
<View style={styles.container}>
<Button title="I'm done, sign me out" onPress={this.signOutAsync} />
<StatusBar barStyle="default" />
</View>
);
}
signOutAsync = async () => {
Platform.OS === 'ios' ? await AsyncStorage.getAllKeys().then(AsyncStorage.multiRemove) : await AsyncStorage.clear()
this.props.navigation.navigate('Auth');
};
}
class LoadingScreen extends React.Component<any, any> {
componentDidMount() {
this.bootstrapAsync();
}
bootstrapAsync = async () => {
const userToken = await AsyncStorage.getItem('userToken');
const initialRouteName = userToken ? 'App' : 'Auth';
this.props.navigation.navigate(initialRouteName);
};
render() {
return (
<View style={styles.container}>
<ActivityIndicator />
<StatusBar barStyle="default" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
});
const AppStack = createStackNavigator({ Home: HomeScreen, Other: OtherScreen });
const AuthStack = createStackNavigator({ SignIn: SignInScreen });
export default createSwitchNavigator({
App: AppStack,
Auth: AuthStack,
Loading: LoadingScreen,
});

View File

@@ -0,0 +1,29 @@
import React from 'react';
import { Platform, ScrollView } from 'react-native';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import { createDrawerNavigator } from 'react-navigation';
import SimpleTabs from './SimpleTabs';
import StacksOverTabs from './StacksOverTabs';
const TabsInDrawer = createDrawerNavigator({
SimpleTabs: {
navigationOptions: {
drawerIcon: ({ tintColor }: { tintColor: string }) => (
<MaterialIcons name="filter-1" size={24} style={{ color: tintColor }} />
),
drawerLabel: 'Simple tabs',
},
screen: SimpleTabs,
},
StacksOverTabs: {
navigationOptions: {
drawerIcon: ({ tintColor }: { tintColor: string }) => (
<MaterialIcons name="filter-2" size={24} style={{ color: tintColor }} />
),
drawerLabel: 'Stacks Over Tabs',
},
screen: StacksOverTabs,
},
});
export default TabsInDrawer;

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -0,0 +1,151 @@
import React from 'react';
import { AccessibilityState, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
export interface ButtonProps {
/**
* Text to display inside the button
*/
title: string,
/**
* Handler to be called when the user taps the button
*/
onPress: (event?: any) => void,
/**
* Color of the text (iOS), or background color of the button (Android)
*/
color?: string,
/**
* TV preferred focus (see documentation for the View component).
*/
hasTVPreferredFocus?: boolean,
/**
* Text to display for blindness accessibility features
*/
accessibilityLabel?: string,
/**
* If true, disable all interactions for this component.
*/
disabled?: boolean,
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string,
};
/**
* A basic button component that should render nicely on any platform. Supports
* a minimal level of customization.
*
* <center><img src="img/buttonExample.png"></img></center>
*
* This button is built using TouchableOpacity
*
* Example usage:
*
* ```
* import { Button } from 'react-native';
* ...
*
* <Button
* onPress={onPressLearnMore}
* title="Learn More"
* color="#841584"
* accessibilityLabel="Learn more about this purple button"
* />
* ```
*
*/
export default class Button extends React.Component<ButtonProps> {
render() {
const {
accessibilityLabel,
color,
onPress,
title,
disabled,
testID,
} = this.props;
const buttonStyles: any = [styles.button];
const textStyles: any = [styles.text];
if (color) {
if (Platform.OS === 'ios') {
textStyles.push({ color });
} else {
buttonStyles.push({ backgroundColor: color });
}
}
const accessibilityStates: AccessibilityState[] = [];
if (disabled) {
buttonStyles.push(styles.buttonDisabled);
textStyles.push(styles.textDisabled);
accessibilityStates.push('disabled');
}
const formattedTitle =
Platform.OS === 'android' ? title.toUpperCase() : title;
return (
<TouchableOpacity
accessibilityLabel={accessibilityLabel}
accessibilityRole="button"
accessibilityStates={accessibilityStates}
testID={testID}
disabled={disabled}
onPress={onPress}
>
<View style={buttonStyles}>
<Text style={textStyles}>
{formattedTitle}
</Text>
</View>
</TouchableOpacity>
);
}
}
const styles = StyleSheet.create({
button: Platform.select({
android: {
backgroundColor: '#2196F3',
borderRadius: 2,
elevation: 4,
// Material design blue from https://material.google.com/style/color.html#color-color-palette
},
ios: {},
}),
buttonDisabled: Platform.select({
android: {
backgroundColor: '#dfdfdf',
elevation: 0,
},
ios: {},
}),
text: {
padding: 8,
textAlign: 'center',
...Platform.select({
android: {
color: 'white',
fontWeight: '500',
},
ios: {
// iOS blue from https://developer.apple.com/ios/human-interface-guidelines/visual-design/color/
color: '#007AFF',
fontSize: 18,
},
}),
},
textDisabled: Platform.select({
android: {
color: '#a1a1a1',
},
ios: {
color: '#cdcdcd',
},
}),
});

View File

@@ -0,0 +1,19 @@
import React from 'react';
import { Platform, StyleSheet, View } from 'react-native';
import BaseButton, { ButtonProps } from './Button';
export const Button = (props: ButtonProps) => (
<View style={styles.margin}>
<BaseButton {...props} />
</View>
);
const styles = StyleSheet.create({
margin: {
...Platform.select({
android: {
margin: 10,
},
}),
},
});

View File

@@ -0,0 +1,16 @@
import DefaultHeaderButtons from 'react-navigation-header-buttons';
import * as React from 'react';
import { Platform } from 'react-native';
export class HeaderButtons extends React.PureComponent {
static Item = DefaultHeaderButtons.Item;
render() {
return (
<DefaultHeaderButtons
// color={Platform.OS === 'ios' ? '#037aff' : 'black'}
{...this.props}
/>
);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

View File

@@ -1,32 +0,0 @@
// flow-typed signature: ee7b4028012cfdcd83cc6541a39b2282
// flow-typed version: <<STUB>>/babel-jest_v^21.0.0/flow_v0.61.0
/**
* This is an autogenerated libdef stub for:
*
* 'babel-jest'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'babel-jest' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'babel-jest/build/index' {
declare module.exports: any;
}
// Filename aliases
declare module 'babel-jest/build/index.js' {
declare module.exports: $Exports<'babel-jest/build/index'>;
}

View File

@@ -1,823 +0,0 @@
// flow-typed signature: c1ecfe71fbb86c3602b7da3d7c141df1
// flow-typed version: <<STUB>>/expo_v^24.0.2/flow_v0.61.0
/**
* This is an autogenerated libdef stub for:
*
* 'expo'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'expo' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'expo/AppEntry' {
declare module.exports: any;
}
declare module 'expo/flow/metro-bundler' {
declare module.exports: any;
}
declare module 'expo/flow/react-native-gesture-handler' {
declare module.exports: any;
}
declare module 'expo/src/__mocks__/Constants-development' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Amplitude-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/AuthSession-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Constants-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/ErrorRecovery-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Expo-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Facebook-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Font-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Location-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Notifications-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/SecureStore-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/Segment-test' {
declare module.exports: any;
}
declare module 'expo/src/__tests__/WebBrowser-test' {
declare module.exports: any;
}
declare module 'expo/src/admob/RNAdMobBanner' {
declare module.exports: any;
}
declare module 'expo/src/admob/RNAdMobInterstitial' {
declare module.exports: any;
}
declare module 'expo/src/admob/RNAdMobRewarded' {
declare module.exports: any;
}
declare module 'expo/src/admob/RNPublisherBanner' {
declare module.exports: any;
}
declare module 'expo/src/Amplitude' {
declare module.exports: any;
}
declare module 'expo/src/apisAreAvailable' {
declare module.exports: any;
}
declare module 'expo/src/Asset' {
declare module.exports: any;
}
declare module 'expo/src/AuthSession' {
declare module.exports: any;
}
declare module 'expo/src/av/Audio' {
declare module.exports: any;
}
declare module 'expo/src/av/Audio/Recording' {
declare module.exports: any;
}
declare module 'expo/src/av/Audio/Sound' {
declare module.exports: any;
}
declare module 'expo/src/av/AV' {
declare module.exports: any;
}
declare module 'expo/src/av/Video' {
declare module.exports: any;
}
declare module 'expo/src/BarCodeScanner.android' {
declare module.exports: any;
}
declare module 'expo/src/BarCodeScanner.ios' {
declare module.exports: any;
}
declare module 'expo/src/Brightness' {
declare module.exports: any;
}
declare module 'expo/src/Camera' {
declare module.exports: any;
}
declare module 'expo/src/CameraBasedBarCodeScanner' {
declare module.exports: any;
}
declare module 'expo/src/Constants' {
declare module.exports: any;
}
declare module 'expo/src/Contacts' {
declare module.exports: any;
}
declare module 'expo/src/DangerZone' {
declare module.exports: any;
}
declare module 'expo/src/DocumentPicker' {
declare module.exports: any;
}
declare module 'expo/src/effects/BlurView.android' {
declare module.exports: any;
}
declare module 'expo/src/effects/BlurView.ios' {
declare module.exports: any;
}
declare module 'expo/src/effects/LinearGradient.android' {
declare module.exports: any;
}
declare module 'expo/src/effects/LinearGradient.ios' {
declare module.exports: any;
}
declare module 'expo/src/environment/__tests__/validate-test' {
declare module.exports: any;
}
declare module 'expo/src/environment/logging' {
declare module.exports: any;
}
declare module 'expo/src/environment/validate' {
declare module.exports: any;
}
declare module 'expo/src/ErrorRecovery' {
declare module.exports: any;
}
declare module 'expo/src/Expo' {
declare module.exports: any;
}
declare module 'expo/src/facebook-ads/AdSettings' {
declare module.exports: any;
}
declare module 'expo/src/facebook-ads/BannerViewManager' {
declare module.exports: any;
}
declare module 'expo/src/facebook-ads/index' {
declare module.exports: any;
}
declare module 'expo/src/facebook-ads/InterstitialAdManager' {
declare module.exports: any;
}
declare module 'expo/src/facebook-ads/NativeAdsManager' {
declare module.exports: any;
}
declare module 'expo/src/facebook-ads/withNativeAd' {
declare module.exports: any;
}
declare module 'expo/src/Facebook' {
declare module.exports: any;
}
declare module 'expo/src/FaceDetector' {
declare module.exports: any;
}
declare module 'expo/src/FileSystem' {
declare module.exports: any;
}
declare module 'expo/src/Fingerprint' {
declare module.exports: any;
}
declare module 'expo/src/Font' {
declare module.exports: any;
}
declare module 'expo/src/GLView' {
declare module.exports: any;
}
declare module 'expo/src/Google' {
declare module.exports: any;
}
declare module 'expo/src/Icon' {
declare module.exports: any;
}
declare module 'expo/src/ImageManipulator' {
declare module.exports: any;
}
declare module 'expo/src/ImagePicker' {
declare module.exports: any;
}
declare module 'expo/src/IntentLauncherAndroid' {
declare module.exports: any;
}
declare module 'expo/src/KeepAwake' {
declare module.exports: any;
}
declare module 'expo/src/launch/AppLoading' {
declare module.exports: any;
}
declare module 'expo/src/launch/AppLoadingNativeWrapper.android' {
declare module.exports: any;
}
declare module 'expo/src/launch/AppLoadingNativeWrapper.ios' {
declare module.exports: any;
}
declare module 'expo/src/launch/registerRootComponent' {
declare module.exports: any;
}
declare module 'expo/src/launch/RootErrorBoundary' {
declare module.exports: any;
}
declare module 'expo/src/lib/Queue' {
declare module.exports: any;
}
declare module 'expo/src/Location' {
declare module.exports: any;
}
declare module 'expo/src/logs/__tests__/Logs-test' {
declare module.exports: any;
}
declare module 'expo/src/logs/__tests__/LogSerialization-test' {
declare module.exports: any;
}
declare module 'expo/src/logs/__tests__/RemoteConsole-test' {
declare module.exports: any;
}
declare module 'expo/src/logs/__tests__/RemoteLogging-test' {
declare module.exports: any;
}
declare module 'expo/src/logs/__tests__/RemoteLogs-test' {
declare module.exports: any;
}
declare module 'expo/src/logs/Logs' {
declare module.exports: any;
}
declare module 'expo/src/logs/LogSerialization' {
declare module.exports: any;
}
declare module 'expo/src/logs/RemoteConsole' {
declare module.exports: any;
}
declare module 'expo/src/logs/RemoteLogging' {
declare module.exports: any;
}
declare module 'expo/src/modal/Modal' {
declare module.exports: any;
}
declare module 'expo/src/modal/ModalHost' {
declare module.exports: any;
}
declare module 'expo/src/modal/ModalImplementation' {
declare module.exports: any;
}
declare module 'expo/src/modal/PureContainer' {
declare module.exports: any;
}
declare module 'expo/src/Notifications' {
declare module.exports: any;
}
declare module 'expo/src/OldBarCodeScanner' {
declare module.exports: any;
}
declare module 'expo/src/Payments' {
declare module.exports: any;
}
declare module 'expo/src/Pedometer' {
declare module.exports: any;
}
declare module 'expo/src/Permissions' {
declare module.exports: any;
}
declare module 'expo/src/ScreenOrientation' {
declare module.exports: any;
}
declare module 'expo/src/SecureStore' {
declare module.exports: any;
}
declare module 'expo/src/Segment' {
declare module.exports: any;
}
declare module 'expo/src/sensor/__tests__/Accelerometer-test' {
declare module.exports: any;
}
declare module 'expo/src/sensor/__tests__/DeviceMotion-test' {
declare module.exports: any;
}
declare module 'expo/src/sensor/__tests__/DeviceSensor-test' {
declare module.exports: any;
}
declare module 'expo/src/sensor/__tests__/Gyroscope-test' {
declare module.exports: any;
}
declare module 'expo/src/sensor/__tests__/Magnetometer-test' {
declare module.exports: any;
}
declare module 'expo/src/sensor/Accelerometer' {
declare module.exports: any;
}
declare module 'expo/src/sensor/DeviceMotion' {
declare module.exports: any;
}
declare module 'expo/src/sensor/DeviceSensor' {
declare module.exports: any;
}
declare module 'expo/src/sensor/Gyroscope' {
declare module.exports: any;
}
declare module 'expo/src/sensor/Magnetometer' {
declare module.exports: any;
}
declare module 'expo/src/sensor/MagnetometerUncalibrated' {
declare module.exports: any;
}
declare module 'expo/src/sensor/ThreeAxisSensor' {
declare module.exports: any;
}
declare module 'expo/src/Speech' {
declare module.exports: any;
}
declare module 'expo/src/SQLite' {
declare module.exports: any;
}
declare module 'expo/src/Svg' {
declare module.exports: any;
}
declare module 'expo/src/takeSnapshotAsync' {
declare module.exports: any;
}
declare module 'expo/src/timer/polyfillNextTick' {
declare module.exports: any;
}
declare module 'expo/src/Util' {
declare module.exports: any;
}
declare module 'expo/src/WebBrowser' {
declare module.exports: any;
}
declare module 'expo/tools/hashAssetFiles' {
declare module.exports: any;
}
declare module 'expo/tools/LogReporter' {
declare module.exports: any;
}
// Filename aliases
declare module 'expo/AppEntry.js' {
declare module.exports: $Exports<'expo/AppEntry'>;
}
declare module 'expo/flow/metro-bundler.js' {
declare module.exports: $Exports<'expo/flow/metro-bundler'>;
}
declare module 'expo/flow/react-native-gesture-handler.js' {
declare module.exports: $Exports<'expo/flow/react-native-gesture-handler'>;
}
declare module 'expo/src/__mocks__/Constants-development.js' {
declare module.exports: $Exports<'expo/src/__mocks__/Constants-development'>;
}
declare module 'expo/src/__tests__/Amplitude-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Amplitude-test'>;
}
declare module 'expo/src/__tests__/AuthSession-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/AuthSession-test'>;
}
declare module 'expo/src/__tests__/Constants-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Constants-test'>;
}
declare module 'expo/src/__tests__/ErrorRecovery-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/ErrorRecovery-test'>;
}
declare module 'expo/src/__tests__/Expo-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Expo-test'>;
}
declare module 'expo/src/__tests__/Facebook-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Facebook-test'>;
}
declare module 'expo/src/__tests__/Font-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Font-test'>;
}
declare module 'expo/src/__tests__/Location-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Location-test'>;
}
declare module 'expo/src/__tests__/Notifications-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Notifications-test'>;
}
declare module 'expo/src/__tests__/SecureStore-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/SecureStore-test'>;
}
declare module 'expo/src/__tests__/Segment-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/Segment-test'>;
}
declare module 'expo/src/__tests__/WebBrowser-test.js' {
declare module.exports: $Exports<'expo/src/__tests__/WebBrowser-test'>;
}
declare module 'expo/src/admob/RNAdMobBanner.js' {
declare module.exports: $Exports<'expo/src/admob/RNAdMobBanner'>;
}
declare module 'expo/src/admob/RNAdMobInterstitial.js' {
declare module.exports: $Exports<'expo/src/admob/RNAdMobInterstitial'>;
}
declare module 'expo/src/admob/RNAdMobRewarded.js' {
declare module.exports: $Exports<'expo/src/admob/RNAdMobRewarded'>;
}
declare module 'expo/src/admob/RNPublisherBanner.js' {
declare module.exports: $Exports<'expo/src/admob/RNPublisherBanner'>;
}
declare module 'expo/src/Amplitude.js' {
declare module.exports: $Exports<'expo/src/Amplitude'>;
}
declare module 'expo/src/apisAreAvailable.js' {
declare module.exports: $Exports<'expo/src/apisAreAvailable'>;
}
declare module 'expo/src/Asset.js' {
declare module.exports: $Exports<'expo/src/Asset'>;
}
declare module 'expo/src/AuthSession.js' {
declare module.exports: $Exports<'expo/src/AuthSession'>;
}
declare module 'expo/src/av/Audio.js' {
declare module.exports: $Exports<'expo/src/av/Audio'>;
}
declare module 'expo/src/av/Audio/Recording.js' {
declare module.exports: $Exports<'expo/src/av/Audio/Recording'>;
}
declare module 'expo/src/av/Audio/Sound.js' {
declare module.exports: $Exports<'expo/src/av/Audio/Sound'>;
}
declare module 'expo/src/av/AV.js' {
declare module.exports: $Exports<'expo/src/av/AV'>;
}
declare module 'expo/src/av/Video.js' {
declare module.exports: $Exports<'expo/src/av/Video'>;
}
declare module 'expo/src/BarCodeScanner.android.js' {
declare module.exports: $Exports<'expo/src/BarCodeScanner.android'>;
}
declare module 'expo/src/BarCodeScanner.ios.js' {
declare module.exports: $Exports<'expo/src/BarCodeScanner.ios'>;
}
declare module 'expo/src/Brightness.js' {
declare module.exports: $Exports<'expo/src/Brightness'>;
}
declare module 'expo/src/Camera.js' {
declare module.exports: $Exports<'expo/src/Camera'>;
}
declare module 'expo/src/CameraBasedBarCodeScanner.js' {
declare module.exports: $Exports<'expo/src/CameraBasedBarCodeScanner'>;
}
declare module 'expo/src/Constants.js' {
declare module.exports: $Exports<'expo/src/Constants'>;
}
declare module 'expo/src/Contacts.js' {
declare module.exports: $Exports<'expo/src/Contacts'>;
}
declare module 'expo/src/DangerZone.js' {
declare module.exports: $Exports<'expo/src/DangerZone'>;
}
declare module 'expo/src/DocumentPicker.js' {
declare module.exports: $Exports<'expo/src/DocumentPicker'>;
}
declare module 'expo/src/effects/BlurView.android.js' {
declare module.exports: $Exports<'expo/src/effects/BlurView.android'>;
}
declare module 'expo/src/effects/BlurView.ios.js' {
declare module.exports: $Exports<'expo/src/effects/BlurView.ios'>;
}
declare module 'expo/src/effects/LinearGradient.android.js' {
declare module.exports: $Exports<'expo/src/effects/LinearGradient.android'>;
}
declare module 'expo/src/effects/LinearGradient.ios.js' {
declare module.exports: $Exports<'expo/src/effects/LinearGradient.ios'>;
}
declare module 'expo/src/environment/__tests__/validate-test.js' {
declare module.exports: $Exports<'expo/src/environment/__tests__/validate-test'>;
}
declare module 'expo/src/environment/logging.js' {
declare module.exports: $Exports<'expo/src/environment/logging'>;
}
declare module 'expo/src/environment/validate.js' {
declare module.exports: $Exports<'expo/src/environment/validate'>;
}
declare module 'expo/src/ErrorRecovery.js' {
declare module.exports: $Exports<'expo/src/ErrorRecovery'>;
}
declare module 'expo/src/Expo.js' {
declare module.exports: $Exports<'expo/src/Expo'>;
}
declare module 'expo/src/facebook-ads/AdSettings.js' {
declare module.exports: $Exports<'expo/src/facebook-ads/AdSettings'>;
}
declare module 'expo/src/facebook-ads/BannerViewManager.js' {
declare module.exports: $Exports<'expo/src/facebook-ads/BannerViewManager'>;
}
declare module 'expo/src/facebook-ads/index.js' {
declare module.exports: $Exports<'expo/src/facebook-ads/index'>;
}
declare module 'expo/src/facebook-ads/InterstitialAdManager.js' {
declare module.exports: $Exports<'expo/src/facebook-ads/InterstitialAdManager'>;
}
declare module 'expo/src/facebook-ads/NativeAdsManager.js' {
declare module.exports: $Exports<'expo/src/facebook-ads/NativeAdsManager'>;
}
declare module 'expo/src/facebook-ads/withNativeAd.js' {
declare module.exports: $Exports<'expo/src/facebook-ads/withNativeAd'>;
}
declare module 'expo/src/Facebook.js' {
declare module.exports: $Exports<'expo/src/Facebook'>;
}
declare module 'expo/src/FaceDetector.js' {
declare module.exports: $Exports<'expo/src/FaceDetector'>;
}
declare module 'expo/src/FileSystem.js' {
declare module.exports: $Exports<'expo/src/FileSystem'>;
}
declare module 'expo/src/Fingerprint.js' {
declare module.exports: $Exports<'expo/src/Fingerprint'>;
}
declare module 'expo/src/Font.js' {
declare module.exports: $Exports<'expo/src/Font'>;
}
declare module 'expo/src/GLView.js' {
declare module.exports: $Exports<'expo/src/GLView'>;
}
declare module 'expo/src/Google.js' {
declare module.exports: $Exports<'expo/src/Google'>;
}
declare module 'expo/src/Icon.js' {
declare module.exports: $Exports<'expo/src/Icon'>;
}
declare module 'expo/src/ImageManipulator.js' {
declare module.exports: $Exports<'expo/src/ImageManipulator'>;
}
declare module 'expo/src/ImagePicker.js' {
declare module.exports: $Exports<'expo/src/ImagePicker'>;
}
declare module 'expo/src/IntentLauncherAndroid.js' {
declare module.exports: $Exports<'expo/src/IntentLauncherAndroid'>;
}
declare module 'expo/src/KeepAwake.js' {
declare module.exports: $Exports<'expo/src/KeepAwake'>;
}
declare module 'expo/src/launch/AppLoading.js' {
declare module.exports: $Exports<'expo/src/launch/AppLoading'>;
}
declare module 'expo/src/launch/AppLoadingNativeWrapper.android.js' {
declare module.exports: $Exports<'expo/src/launch/AppLoadingNativeWrapper.android'>;
}
declare module 'expo/src/launch/AppLoadingNativeWrapper.ios.js' {
declare module.exports: $Exports<'expo/src/launch/AppLoadingNativeWrapper.ios'>;
}
declare module 'expo/src/launch/registerRootComponent.js' {
declare module.exports: $Exports<'expo/src/launch/registerRootComponent'>;
}
declare module 'expo/src/launch/RootErrorBoundary.js' {
declare module.exports: $Exports<'expo/src/launch/RootErrorBoundary'>;
}
declare module 'expo/src/lib/Queue.js' {
declare module.exports: $Exports<'expo/src/lib/Queue'>;
}
declare module 'expo/src/Location.js' {
declare module.exports: $Exports<'expo/src/Location'>;
}
declare module 'expo/src/logs/__tests__/Logs-test.js' {
declare module.exports: $Exports<'expo/src/logs/__tests__/Logs-test'>;
}
declare module 'expo/src/logs/__tests__/LogSerialization-test.js' {
declare module.exports: $Exports<'expo/src/logs/__tests__/LogSerialization-test'>;
}
declare module 'expo/src/logs/__tests__/RemoteConsole-test.js' {
declare module.exports: $Exports<'expo/src/logs/__tests__/RemoteConsole-test'>;
}
declare module 'expo/src/logs/__tests__/RemoteLogging-test.js' {
declare module.exports: $Exports<'expo/src/logs/__tests__/RemoteLogging-test'>;
}
declare module 'expo/src/logs/__tests__/RemoteLogs-test.js' {
declare module.exports: $Exports<'expo/src/logs/__tests__/RemoteLogs-test'>;
}
declare module 'expo/src/logs/Logs.js' {
declare module.exports: $Exports<'expo/src/logs/Logs'>;
}
declare module 'expo/src/logs/LogSerialization.js' {
declare module.exports: $Exports<'expo/src/logs/LogSerialization'>;
}
declare module 'expo/src/logs/RemoteConsole.js' {
declare module.exports: $Exports<'expo/src/logs/RemoteConsole'>;
}
declare module 'expo/src/logs/RemoteLogging.js' {
declare module.exports: $Exports<'expo/src/logs/RemoteLogging'>;
}
declare module 'expo/src/modal/Modal.js' {
declare module.exports: $Exports<'expo/src/modal/Modal'>;
}
declare module 'expo/src/modal/ModalHost.js' {
declare module.exports: $Exports<'expo/src/modal/ModalHost'>;
}
declare module 'expo/src/modal/ModalImplementation.js' {
declare module.exports: $Exports<'expo/src/modal/ModalImplementation'>;
}
declare module 'expo/src/modal/PureContainer.js' {
declare module.exports: $Exports<'expo/src/modal/PureContainer'>;
}
declare module 'expo/src/Notifications.js' {
declare module.exports: $Exports<'expo/src/Notifications'>;
}
declare module 'expo/src/OldBarCodeScanner.js' {
declare module.exports: $Exports<'expo/src/OldBarCodeScanner'>;
}
declare module 'expo/src/Payments.js' {
declare module.exports: $Exports<'expo/src/Payments'>;
}
declare module 'expo/src/Pedometer.js' {
declare module.exports: $Exports<'expo/src/Pedometer'>;
}
declare module 'expo/src/Permissions.js' {
declare module.exports: $Exports<'expo/src/Permissions'>;
}
declare module 'expo/src/ScreenOrientation.js' {
declare module.exports: $Exports<'expo/src/ScreenOrientation'>;
}
declare module 'expo/src/SecureStore.js' {
declare module.exports: $Exports<'expo/src/SecureStore'>;
}
declare module 'expo/src/Segment.js' {
declare module.exports: $Exports<'expo/src/Segment'>;
}
declare module 'expo/src/sensor/__tests__/Accelerometer-test.js' {
declare module.exports: $Exports<'expo/src/sensor/__tests__/Accelerometer-test'>;
}
declare module 'expo/src/sensor/__tests__/DeviceMotion-test.js' {
declare module.exports: $Exports<'expo/src/sensor/__tests__/DeviceMotion-test'>;
}
declare module 'expo/src/sensor/__tests__/DeviceSensor-test.js' {
declare module.exports: $Exports<'expo/src/sensor/__tests__/DeviceSensor-test'>;
}
declare module 'expo/src/sensor/__tests__/Gyroscope-test.js' {
declare module.exports: $Exports<'expo/src/sensor/__tests__/Gyroscope-test'>;
}
declare module 'expo/src/sensor/__tests__/Magnetometer-test.js' {
declare module.exports: $Exports<'expo/src/sensor/__tests__/Magnetometer-test'>;
}
declare module 'expo/src/sensor/Accelerometer.js' {
declare module.exports: $Exports<'expo/src/sensor/Accelerometer'>;
}
declare module 'expo/src/sensor/DeviceMotion.js' {
declare module.exports: $Exports<'expo/src/sensor/DeviceMotion'>;
}
declare module 'expo/src/sensor/DeviceSensor.js' {
declare module.exports: $Exports<'expo/src/sensor/DeviceSensor'>;
}
declare module 'expo/src/sensor/Gyroscope.js' {
declare module.exports: $Exports<'expo/src/sensor/Gyroscope'>;
}
declare module 'expo/src/sensor/Magnetometer.js' {
declare module.exports: $Exports<'expo/src/sensor/Magnetometer'>;
}
declare module 'expo/src/sensor/MagnetometerUncalibrated.js' {
declare module.exports: $Exports<'expo/src/sensor/MagnetometerUncalibrated'>;
}
declare module 'expo/src/sensor/ThreeAxisSensor.js' {
declare module.exports: $Exports<'expo/src/sensor/ThreeAxisSensor'>;
}
declare module 'expo/src/Speech.js' {
declare module.exports: $Exports<'expo/src/Speech'>;
}
declare module 'expo/src/SQLite.js' {
declare module.exports: $Exports<'expo/src/SQLite'>;
}
declare module 'expo/src/Svg.js' {
declare module.exports: $Exports<'expo/src/Svg'>;
}
declare module 'expo/src/takeSnapshotAsync.js' {
declare module.exports: $Exports<'expo/src/takeSnapshotAsync'>;
}
declare module 'expo/src/timer/polyfillNextTick.js' {
declare module.exports: $Exports<'expo/src/timer/polyfillNextTick'>;
}
declare module 'expo/src/Util.js' {
declare module.exports: $Exports<'expo/src/Util'>;
}
declare module 'expo/src/WebBrowser.js' {
declare module.exports: $Exports<'expo/src/WebBrowser'>;
}
declare module 'expo/tools/hashAssetFiles.js' {
declare module.exports: $Exports<'expo/tools/hashAssetFiles'>;
}
declare module 'expo/tools/LogReporter.js' {
declare module.exports: $Exports<'expo/tools/LogReporter'>;
}

View File

@@ -1,6 +0,0 @@
// flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583
// flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x
declare module "flow-bin" {
declare module.exports: string;
}

View File

@@ -1,46 +0,0 @@
// flow-typed signature: b1e3826a494aecf4ff482336321b54bd
// flow-typed version: <<STUB>>/jest-expo_v^24.0.0/flow_v0.61.0
/**
* This is an autogenerated libdef stub for:
*
* 'jest-expo'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'jest-expo' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'jest-expo/src/createMockConstants' {
declare module.exports: any;
}
declare module 'jest-expo/src/expoModules' {
declare module.exports: any;
}
declare module 'jest-expo/src/setup' {
declare module.exports: any;
}
// Filename aliases
declare module 'jest-expo/src/createMockConstants.js' {
declare module.exports: $Exports<'jest-expo/src/createMockConstants'>;
}
declare module 'jest-expo/src/expoModules.js' {
declare module.exports: $Exports<'jest-expo/src/expoModules'>;
}
declare module 'jest-expo/src/setup.js' {
declare module.exports: $Exports<'jest-expo/src/setup'>;
}

View File

@@ -1,584 +0,0 @@
// flow-typed signature: 107cf7068b8835594e97f938e8848244
// flow-typed version: 8b4dd96654/jest_v21.x.x/flow_>=v0.39.x
type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
*/
mock: {
/**
* An array that represents all calls that have been made into this mock
* function. Each call is represented by an array of arguments that were
* passed during the call.
*/
calls: Array<TArguments>,
/**
* An array that contains all the object instances that have been
* instantiated from this mock function.
*/
instances: Array<TReturn>
},
/**
* Resets all information stored in the mockFn.mock.calls and
* mockFn.mock.instances arrays. Often this is useful when you want to clean
* up a mock's usage data between two assertions.
*/
mockClear(): void,
/**
* Resets all information stored in the mock. This is useful when you want to
* completely restore a mock back to its initial state.
*/
mockReset(): void,
/**
* Removes the mock and restores the initial implementation. This is useful
* when you want to mock functions in certain test cases and restore the
* original implementation in others. Beware that mockFn.mockRestore only
* works when mock was created with jest.spyOn. Thus you have to take care of
* restoration yourself when manually assigning jest.fn().
*/
mockRestore(): void,
/**
* Accepts a function that should be used as the implementation of the mock.
* The mock itself will still record all calls that go into and instances
* that come from itself -- the only difference is that the implementation
* will also be executed when the mock is called.
*/
mockImplementation(
fn: (...args: TArguments) => TReturn
): JestMockFn<TArguments, TReturn>,
/**
* Accepts a function that will be used as an implementation of the mock for
* one call to the mocked function. Can be chained so that multiple function
* calls produce different results.
*/
mockImplementationOnce(
fn: (...args: TArguments) => TReturn
): JestMockFn<TArguments, TReturn>,
/**
* Just a simple sugar function for returning `this`
*/
mockReturnThis(): void,
/**
* Deprecated: use jest.fn(() => value) instead
*/
mockReturnValue(value: TReturn): JestMockFn<TArguments, TReturn>,
/**
* Sugar for only returning a value once inside your mock
*/
mockReturnValueOnce(value: TReturn): JestMockFn<TArguments, TReturn>
};
type JestAsymmetricEqualityType = {
/**
* A custom Jasmine equality tester
*/
asymmetricMatch(value: mixed): boolean
};
type JestCallsType = {
allArgs(): mixed,
all(): mixed,
any(): boolean,
count(): number,
first(): mixed,
mostRecent(): mixed,
reset(): void
};
type JestClockType = {
install(): void,
mockDate(date: Date): void,
tick(milliseconds?: number): void,
uninstall(): void
};
type JestMatcherResult = {
message?: string | (() => string),
pass: boolean
};
type JestMatcher = (actual: any, expected: any) => JestMatcherResult;
type JestPromiseType = {
/**
* Use rejects to unwrap the reason of a rejected promise so any other
* matcher can be chained. If the promise is fulfilled the assertion fails.
*/
rejects: JestExpectType,
/**
* Use resolves to unwrap the value of a fulfilled promise so any other
* matcher can be chained. If the promise is rejected the assertion fails.
*/
resolves: JestExpectType
};
/**
* Plugin: jest-enzyme
*/
type EnzymeMatchersType = {
toBeChecked(): void,
toBeDisabled(): void,
toBeEmpty(): void,
toBePresent(): void,
toContainReact(element: React$Element<any>): void,
toHaveClassName(className: string): void,
toHaveHTML(html: string): void,
toHaveProp(propKey: string, propValue?: any): void,
toHaveRef(refName: string): void,
toHaveState(stateKey: string, stateValue?: any): void,
toHaveStyle(styleKey: string, styleValue?: any): void,
toHaveTagName(tagName: string): void,
toHaveText(text: string): void,
toIncludeText(text: string): void,
toHaveValue(value: any): void,
toMatchElement(element: React$Element<any>): void,
toMatchSelector(selector: string): void
};
type JestExpectType = {
not: JestExpectType & EnzymeMatchersType,
/**
* If you have a mock function, you can use .lastCalledWith to test what
* arguments it was last called with.
*/
lastCalledWith(...args: Array<any>): void,
/**
* toBe just checks that a value is what you expect. It uses === to check
* strict equality.
*/
toBe(value: any): void,
/**
* Use .toHaveBeenCalled to ensure that a mock function got called.
*/
toBeCalled(): void,
/**
* Use .toBeCalledWith to ensure that a mock function was called with
* specific arguments.
*/
toBeCalledWith(...args: Array<any>): void,
/**
* Using exact equality with floating point numbers is a bad idea. Rounding
* means that intuitive things fail.
*/
toBeCloseTo(num: number, delta: any): void,
/**
* Use .toBeDefined to check that a variable is not undefined.
*/
toBeDefined(): void,
/**
* Use .toBeFalsy when you don't care what a value is, you just want to
* ensure a value is false in a boolean context.
*/
toBeFalsy(): void,
/**
* To compare floating point numbers, you can use toBeGreaterThan.
*/
toBeGreaterThan(number: number): void,
/**
* To compare floating point numbers, you can use toBeGreaterThanOrEqual.
*/
toBeGreaterThanOrEqual(number: number): void,
/**
* To compare floating point numbers, you can use toBeLessThan.
*/
toBeLessThan(number: number): void,
/**
* To compare floating point numbers, you can use toBeLessThanOrEqual.
*/
toBeLessThanOrEqual(number: number): void,
/**
* Use .toBeInstanceOf(Class) to check that an object is an instance of a
* class.
*/
toBeInstanceOf(cls: Class<*>): void,
/**
* .toBeNull() is the same as .toBe(null) but the error messages are a bit
* nicer.
*/
toBeNull(): void,
/**
* Use .toBeTruthy when you don't care what a value is, you just want to
* ensure a value is true in a boolean context.
*/
toBeTruthy(): void,
/**
* Use .toBeUndefined to check that a variable is undefined.
*/
toBeUndefined(): void,
/**
* Use .toContain when you want to check that an item is in a list. For
* testing the items in the list, this uses ===, a strict equality check.
*/
toContain(item: any): void,
/**
* Use .toContainEqual when you want to check that an item is in a list. For
* testing the items in the list, this matcher recursively checks the
* equality of all fields, rather than checking for object identity.
*/
toContainEqual(item: any): void,
/**
* Use .toEqual when you want to check that two objects have the same value.
* This matcher recursively checks the equality of all fields, rather than
* checking for object identity.
*/
toEqual(value: any): void,
/**
* Use .toHaveBeenCalled to ensure that a mock function got called.
*/
toHaveBeenCalled(): void,
/**
* Use .toHaveBeenCalledTimes to ensure that a mock function got called exact
* number of times.
*/
toHaveBeenCalledTimes(number: number): void,
/**
* Use .toHaveBeenCalledWith to ensure that a mock function was called with
* specific arguments.
*/
toHaveBeenCalledWith(...args: Array<any>): void,
/**
* Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
* with specific arguments.
*/
toHaveBeenLastCalledWith(...args: Array<any>): void,
/**
* Check that an object has a .length property and it is set to a certain
* numeric value.
*/
toHaveLength(number: number): void,
/**
*
*/
toHaveProperty(propPath: string, value?: any): void,
/**
* Use .toMatch to check that a string matches a regular expression or string.
*/
toMatch(regexpOrString: RegExp | string): void,
/**
* Use .toMatchObject to check that a javascript object matches a subset of the properties of an object.
*/
toMatchObject(object: Object | Array<Object>): void,
/**
* This ensures that a React component matches the most recent snapshot.
*/
toMatchSnapshot(name?: string): void,
/**
* Use .toThrow to test that a function throws when it is called.
* If you want to test that a specific error gets thrown, you can provide an
* argument to toThrow. The argument can be a string for the error message,
* a class for the error, or a regex that should match the error.
*
* Alias: .toThrowError
*/
toThrow(message?: string | Error | Class<Error> | RegExp): void,
toThrowError(message?: string | Error | Class<Error> | RegExp): void,
/**
* Use .toThrowErrorMatchingSnapshot to test that a function throws a error
* matching the most recent snapshot when it is called.
*/
toThrowErrorMatchingSnapshot(): void
};
type JestObjectType = {
/**
* Disables automatic mocking in the module loader.
*
* After this method is called, all `require()`s will return the real
* versions of each module (rather than a mocked version).
*/
disableAutomock(): JestObjectType,
/**
* An un-hoisted version of disableAutomock
*/
autoMockOff(): JestObjectType,
/**
* Enables automatic mocking in the module loader.
*/
enableAutomock(): JestObjectType,
/**
* An un-hoisted version of enableAutomock
*/
autoMockOn(): JestObjectType,
/**
* Clears the mock.calls and mock.instances properties of all mocks.
* Equivalent to calling .mockClear() on every mocked function.
*/
clearAllMocks(): JestObjectType,
/**
* Resets the state of all mocks. Equivalent to calling .mockReset() on every
* mocked function.
*/
resetAllMocks(): JestObjectType,
/**
* Removes any pending timers from the timer system.
*/
clearAllTimers(): void,
/**
* The same as `mock` but not moved to the top of the expectation by
* babel-jest.
*/
doMock(moduleName: string, moduleFactory?: any): JestObjectType,
/**
* The same as `unmock` but not moved to the top of the expectation by
* babel-jest.
*/
dontMock(moduleName: string): JestObjectType,
/**
* Returns a new, unused mock function. Optionally takes a mock
* implementation.
*/
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
implementation?: (...args: TArguments) => TReturn
): JestMockFn<TArguments, TReturn>,
/**
* Determines if the given function is a mocked function.
*/
isMockFunction(fn: Function): boolean,
/**
* Given the name of a module, use the automatic mocking system to generate a
* mocked version of the module for you.
*/
genMockFromModule(moduleName: string): any,
/**
* Mocks a module with an auto-mocked version when it is being required.
*
* The second argument can be used to specify an explicit module factory that
* is being run instead of using Jest's automocking feature.
*
* The third argument can be used to create virtual mocks -- mocks of modules
* that don't exist anywhere in the system.
*/
mock(
moduleName: string,
moduleFactory?: any,
options?: Object
): JestObjectType,
/**
* Returns the actual module instead of a mock, bypassing all checks on
* whether the module should receive a mock implementation or not.
*/
requireActual(moduleName: string): any,
/**
* Returns a mock module instead of the actual module, bypassing all checks
* on whether the module should be required normally or not.
*/
requireMock(moduleName: string): any,
/**
* Resets the module registry - the cache of all required modules. This is
* useful to isolate modules where local state might conflict between tests.
*/
resetModules(): JestObjectType,
/**
* Exhausts the micro-task queue (usually interfaced in node via
* process.nextTick).
*/
runAllTicks(): void,
/**
* Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(),
* setInterval(), and setImmediate()).
*/
runAllTimers(): void,
/**
* Exhausts all tasks queued by setImmediate().
*/
runAllImmediates(): void,
/**
* Executes only the macro task queue (i.e. all tasks queued by setTimeout()
* or setInterval() and setImmediate()).
*/
runTimersToTime(msToRun: number): void,
/**
* Executes only the macro-tasks that are currently pending (i.e., only the
* tasks that have been queued by setTimeout() or setInterval() up to this
* point)
*/
runOnlyPendingTimers(): void,
/**
* Explicitly supplies the mock object that the module system should return
* for the specified module. Note: It is recommended to use jest.mock()
* instead.
*/
setMock(moduleName: string, moduleExports: any): JestObjectType,
/**
* Indicates that the module system should never return a mocked version of
* the specified module from require() (e.g. that it should always return the
* real module).
*/
unmock(moduleName: string): JestObjectType,
/**
* Instructs Jest to use fake versions of the standard timer functions
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
* setImmediate and clearImmediate).
*/
useFakeTimers(): JestObjectType,
/**
* Instructs Jest to use the real versions of the standard timer functions.
*/
useRealTimers(): JestObjectType,
/**
* Creates a mock function similar to jest.fn but also tracks calls to
* object[methodName].
*/
spyOn(object: Object, methodName: string): JestMockFn<any, any>,
/**
* Set the default timeout interval for tests and before/after hooks in milliseconds.
* Note: The default timeout interval is 5 seconds if this method is not called.
*/
setTimeout(timeout: number): JestObjectType
};
type JestSpyType = {
calls: JestCallsType
};
/** Runs this function after every test inside this context */
declare function afterEach(
fn: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void;
/** Runs this function before every test inside this context */
declare function beforeEach(
fn: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void;
/** Runs this function after all tests have finished inside this context */
declare function afterAll(
fn: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void;
/** Runs this function before any tests have started inside this context */
declare function beforeAll(
fn: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void;
/** A context for grouping tests together */
declare var describe: {
/**
* Creates a block that groups together several related tests in one "test suite"
*/
(name: string, fn: () => void): void,
/**
* Only run this describe block
*/
only(name: string, fn: () => void): void,
/**
* Skip running this describe block
*/
skip(name: string, fn: () => void): void
};
/** An individual test unit */
declare var it: {
/**
* An individual test unit
*
* @param {string} Name of Test
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
(
name: string,
fn?: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void,
/**
* Only run this test
*
* @param {string} Name of Test
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
only(
name: string,
fn?: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void,
/**
* Skip running this test
*
* @param {string} Name of Test
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
skip(
name: string,
fn?: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void,
/**
* Run the test concurrently
*
* @param {string} Name of Test
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
concurrent(
name: string,
fn?: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void
};
declare function fit(
name: string,
fn: (done: () => void) => ?Promise<mixed>,
timeout?: number
): void;
/** An individual test unit */
declare var test: typeof it;
/** A disabled group of tests */
declare var xdescribe: typeof describe;
/** A focused group of tests */
declare var fdescribe: typeof describe;
/** A disabled individual test */
declare var xit: typeof it;
/** A disabled individual test */
declare var xtest: typeof it;
/** The expect function is used every time you want to test a value */
declare var expect: {
/** The object that you want to make assertions against */
(value: any): JestExpectType & JestPromiseType & EnzymeMatchersType,
/** Add additional Jasmine matchers to Jest's roster */
extend(matchers: { [name: string]: JestMatcher }): void,
/** Add a module that formats application-specific data structures. */
addSnapshotSerializer(serializer: (input: Object) => string): void,
assertions(expectedAssertions: number): void,
hasAssertions(): void,
any(value: mixed): JestAsymmetricEqualityType,
anything(): void,
arrayContaining(value: Array<mixed>): void,
objectContaining(value: Object): void,
/** Matches any received string that contains the exact expected string. */
stringContaining(value: string): void,
stringMatching(value: string | RegExp): void
};
// TODO handle return type
// http://jasmine.github.io/2.4/introduction.html#section-Spies
declare function spyOn(value: mixed, method: string): Object;
/** Holds all functions related to manipulating test runner */
declare var jest: JestObjectType;
/**
* The global Jasmine object, this is generally not exposed as the public API,
* using features inside here could break in later versions of Jest.
*/
declare var jasmine: {
DEFAULT_TIMEOUT_INTERVAL: number,
any(value: mixed): JestAsymmetricEqualityType,
anything(): void,
arrayContaining(value: Array<mixed>): void,
clock(): JestClockType,
createSpy(name: string): JestSpyType,
createSpyObj(
baseName: string,
methodNames: Array<string>
): { [methodName: string]: JestSpyType },
objectContaining(value: Object): void,
stringMatching(value: string): void
};

View File

@@ -1,39 +0,0 @@
// flow-typed signature: 3ba80f288ae054d394dca2d025d14dd9
// flow-typed version: <<STUB>>/jest_v^21.0.1/flow_v0.53.0
/**
* This is an autogenerated libdef stub for:
*
* 'jest'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/
declare module 'jest' {
declare module.exports: any;
}
/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'jest/bin/jest' {
declare module.exports: any;
}
declare module 'jest/build/jest' {
declare module.exports: any;
}
// Filename aliases
declare module 'jest/bin/jest.js' {
declare module.exports: $Exports<'jest/bin/jest'>;
}
declare module 'jest/build/jest.js' {
declare module.exports: $Exports<'jest/build/jest'>;
}

Some files were not shown because too many files have changed in this diff Show More