Browse Source

New documentation site (#6098)

* Completely rewritten the docs from scratch
* More coherent separation between guides and API documentation
* Switched to Docusaurus 2 since Docsify is deprecated
* More code samples
* Images and animated gifs were added where appropriate improve clarity (more will be added in the future)
Guy Carmeli 4 years ago
parent
commit
d1c2329b0b
No account linked to committer's email address
100 changed files with 4781 additions and 3610 deletions
  1. 4
    0
      .gitignore
  2. 1
    0
      .npmignore
  3. 1
    1
      README.md
  4. 0
    0
      docs/.nojekyll
  5. 0
    21
      docs/_sidebar.md
  6. 0
    115
      docs/api/Commands.md
  7. 0
    19
      docs/api/CommandsObserver.md
  8. 0
    67
      docs/api/ComponentEventsObserver.md
  9. 0
    11
      docs/api/ComponentRegistry.md
  10. 0
    19
      docs/api/ComponentWrapper.md
  11. 0
    32
      docs/api/Constants.md
  12. 0
    32
      docs/api/Element.md
  13. 0
    11
      docs/api/EventSubscription.md
  14. 0
    83
      docs/api/EventsRegistry.md
  15. 0
    65
      docs/api/LayoutTreeCrawler.md
  16. 0
    75
      docs/api/LayoutTreeParser.md
  17. 0
    12
      docs/api/LayoutType.md
  18. 0
    115
      docs/api/NativeCommandsSender.md
  19. 0
    67
      docs/api/NativeEventsReceiver.md
  20. 0
    196
      docs/api/Navigation.md
  21. 0
    10
      docs/api/OptionsModalPresentationStyle.md
  22. 0
    22
      docs/api/OptionsProcessor.md
  23. 0
    20
      docs/api/README.md
  24. 0
    43
      docs/api/Store.md
  25. 0
    65
      docs/api/TouchablePreview.md
  26. 0
    11
      docs/api/UniqueIdProvider.md
  27. 0
    20
      docs/api/_sidebar.md
  28. 0
    106
      docs/docs/Usage.md
  29. 0
    88
      docs/docs/WorkingLocally.md
  30. 0
    178
      docs/docs/animations.md
  31. 0
    28
      docs/docs/app-launch.md
  32. 0
    21
      docs/docs/constants.md
  33. 0
    428
      docs/docs/layout-types.md
  34. 0
    278
      docs/docs/screen-api.md
  35. 0
    429
      docs/docs/styling.md
  36. 0
    101
      docs/docs/third-party.md
  37. 0
    184
      docs/docs/top-level-api-migration.md
  38. 0
    105
      docs/docs/top-level-api.md
  39. 0
    177
      docs/docs/topBar-buttons.md
  40. 0
    65
      docs/index.html
  41. 0
    83
      docs/sw.js
  42. 3
    2
      package.json
  43. 124
    101
      website/docs/Installing.mdx
  44. 23
    0
      website/docs/Layout.mdx
  45. 1
    1
      website/docs/README.mdx
  46. 50
    0
      website/docs/SplitView.mdx
  47. 295
    0
      website/docs/advanced-navigation.mdx
  48. 304
    0
      website/docs/animations.mdx
  49. 57
    0
      website/docs/api-component.mdx
  50. 77
    102
      website/docs/api-events.mdx
  51. 59
    0
      website/docs/api-modal.mdx
  52. 47
    0
      website/docs/api-options.mdx
  53. 37
    0
      website/docs/api-overlay.mdx
  54. 103
    0
      website/docs/api-root.mdx
  55. 33
    0
      website/docs/api-sideMenu.mdx
  56. 37
    0
      website/docs/app-launch.mdx
  57. 351
    0
      website/docs/basic-navigation.mdx
  58. 12
    0
      website/docs/before-you-start.mdx
  59. 140
    0
      website/docs/docs-bottomTabs.mdx
  60. 28
    0
      website/docs/docs-constants.mdx
  61. 100
    0
      website/docs/docs-externalComponent.mdx
  62. 126
    0
      website/docs/docs-modal.mdx
  63. 152
    0
      website/docs/docs-overlay.mdx
  64. 147
    0
      website/docs/docs-root.mdx
  65. 258
    0
      website/docs/docs-stack.mdx
  66. 50
    0
      website/docs/layout-BottomTabs.mdx
  67. 55
    0
      website/docs/layout-component.mdx
  68. 57
    0
      website/docs/layout-options.mdx
  69. 91
    0
      website/docs/meta-contributing.mdx
  70. 50
    0
      website/docs/options-backButton.mdx
  71. 58
    0
      website/docs/options-background.mdx
  72. 133
    0
      website/docs/options-bottomTab.mdx
  73. 101
    0
      website/docs/options-bottomTabs.mdx
  74. 76
    0
      website/docs/options-button.mdx
  75. 37
    0
      website/docs/options-iconInsets.mdx
  76. 55
    0
      website/docs/options-largeTitle.mdx
  77. 0
    0
      website/docs/options-migration.mdx
  78. 29
    0
      website/docs/options-overlay.mdx
  79. 164
    0
      website/docs/options-root.mdx
  80. 39
    0
      website/docs/options-sideMenu.mdx
  81. 48
    0
      website/docs/options-sideMenuSide.mdx
  82. 37
    0
      website/docs/options-splitView.mdx
  83. 86
    0
      website/docs/orientation.mdx
  84. 62
    0
      website/docs/passing-data-to-components.mdx
  85. 17
    0
      website/docs/playground-app.mdx
  86. 49
    0
      website/docs/screen-lifecycle.mdx
  87. 5
    1
      website/docs/showcases.mdx
  88. 65
    0
      website/docs/sideMenu-disable.mdx
  89. 105
    0
      website/docs/sideMenu-docs.mdx
  90. 44
    0
      website/docs/sideMenu-layout.mdx
  91. 177
    0
      website/docs/stack-api.mdx
  92. 40
    0
      website/docs/stack-backButton.mdx
  93. 10
    0
      website/docs/stack-backNavigation.mdx
  94. 101
    0
      website/docs/stack-buttons.mdx
  95. 39
    0
      website/docs/stack-layout.mdx
  96. 184
    0
      website/docs/stack-options.mdx
  97. 56
    0
      website/docs/stack-programmatically.mdx
  98. 43
    0
      website/docs/statusBar-options.mdx
  99. 48
    0
      website/docs/statusbar-docs.mdx
  100. 0
    0
      website/docs/styling-fonts.mdx

+ 4
- 0
.gitignore View File

@@ -3,6 +3,10 @@ dist
3 3
 package-lock.json
4 4
 .history/
5 5
 
6
+# Docusaurus
7
+.docusaurus
8
+.cache-loader
9
+
6 10
 ############
7 11
 # Node
8 12
 ############

+ 1
- 0
.npmignore View File

@@ -4,6 +4,7 @@ e2e/
4 4
 integration/
5 5
 playground/
6 6
 scripts/
7
+website/
7 8
 .travis.yml
8 9
 wallaby.js
9 10
 package-lock.json

+ 1
- 1
README.md View File

@@ -6,7 +6,7 @@
6 6
 [![StackExchange](https://img.shields.io/stackexchange/stackoverflow/t/react-native-navigation.svg)](https://stackoverflow.com/questions/tagged/wix-react-native-navigation)
7 7
 
8 8
 <h1 align="center">
9
-  <img src=".logo.png"/><br>
9
+  <img src=".logo.png"/><br/>
10 10
   React Native Navigation
11 11
 </h1>
12 12
 

+ 0
- 0
docs/.nojekyll View File


+ 0
- 21
docs/_sidebar.md View File

@@ -1,21 +0,0 @@
1
-- [Home](/)
2
-- Getting Started
3
-  - [Installing](/docs/Installing)
4
-  - [Working Locally](/docs/WorkingLocally)
5
-  - [Usage](/docs/Usage)
6
-  - [Showcases](/docs/showcases)
7
-- Guide
8
-  - [Launching the App](/docs/app-launch)
9
-  - [Top Level](/docs/top-level-api)
10
-  - [Screen](/docs/screen-api)
11
-  - [Events](/docs/events)
12
-  - [Layouts](/docs/layout-types)
13
-  - [Styling](/docs/styling)
14
-  - [TopBar Buttons](/docs/topBar-buttons) 
15
-  - [Animations](/docs/animations)
16
-  - [Constants](/docs/constants)
17
-  - [Third Party Libraries Support](/docs/third-party)
18
-- Migration from v1
19
-  - [Top Level](/docs/top-level-api-migration)
20
-  - [Options](/docs/options-migration)
21
-- [API](/api/README)

+ 0
- 115
docs/api/Commands.md View File

@@ -1,115 +0,0 @@
1
-# Commands
2
-
3
-## setRoot
4
-
5
-`setRoot(simpleApi: any): any`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L15)
8
-
9
----
10
-
11
-## setDefaultOptions
12
-
13
-`setDefaultOptions(options: any): void`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L38)
16
-
17
----
18
-
19
-## mergeOptions
20
-
21
-`mergeOptions(componentId: any, options: any): void`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L46)
24
-
25
----
26
-
27
-## showModal
28
-
29
-`showModal(simpleApi: any): any`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L54)
32
-
33
----
34
-
35
-## dismissModal
36
-
37
-`dismissModal(componentId: any): any`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L65)
40
-
41
----
42
-
43
-## dismissAllModals
44
-
45
-`dismissAllModals(): any`
46
-
47
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L72)
48
-
49
----
50
-
51
-## push
52
-
53
-`push(componentId: any, simpleApi: any): any`
54
-
55
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L79)
56
-
57
----
58
-
59
-## pop
60
-
61
-`pop(componentId: any, options: any): any`
62
-
63
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L91)
64
-
65
----
66
-
67
-## popTo
68
-
69
-`popTo(componentId: any): any`
70
-
71
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L98)
72
-
73
----
74
-
75
-## popToRoot
76
-
77
-`popToRoot(componentId: any): any`
78
-
79
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L105)
80
-
81
----
82
-
83
-## setStackRoot
84
-
85
-`setStackRoot(componentId: any, simpleApi: any): any`
86
-
87
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L112)
88
-
89
----
90
-
91
-## showOverlay
92
-
93
-`showOverlay(simpleApi: any): any`
94
-
95
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L124)
96
-
97
----
98
-
99
-## dismissOverlay
100
-
101
-`dismissOverlay(componentId: any): any`
102
-
103
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L136)
104
-
105
----
106
-
107
-## getLaunchArgs
108
-
109
-`getLaunchArgs(): any`
110
-
111
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/Commands.ts#L143)
112
-
113
----
114
-
115
-

+ 0
- 19
docs/api/CommandsObserver.md View File

@@ -1,19 +0,0 @@
1
-# CommandsObserver
2
-
3
-## register
4
-
5
-`register(listener: CommandsListener): EventSubscription`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/CommandsObserver.ts#L9)
8
-
9
----
10
-
11
-## notify
12
-
13
-`notify(commandName: string, params: __type): void`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/CommandsObserver.ts#L17)
16
-
17
----
18
-
19
-

+ 0
- 67
docs/api/ComponentEventsObserver.md View File

@@ -1,67 +0,0 @@
1
-# ComponentEventsObserver
2
-
3
-## registerOnceForAllComponentEvents
4
-
5
-`registerOnceForAllComponentEvents(): void`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L25)
8
-
9
----
10
-
11
-## bindComponent
12
-
13
-`bindComponent(component: Component<any>): EventSubscription`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L35)
16
-
17
----
18
-
19
-## unmounted
20
-
21
-`unmounted(componentId: string): void`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L49)
24
-
25
----
26
-
27
-## notifyComponentDidAppear
28
-
29
-`notifyComponentDidAppear(event: ComponentDidAppearEvent): void`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L53)
32
-
33
----
34
-
35
-## notifyComponentDidDisappear
36
-
37
-`notifyComponentDidDisappear(event: ComponentDidDisappearEvent): void`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L57)
40
-
41
----
42
-
43
-## notifyNavigationButtonPressed
44
-
45
-`notifyNavigationButtonPressed(event: NavigationButtonPressedEvent): void`
46
-
47
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L61)
48
-
49
----
50
-
51
-## notifySearchBarUpdated
52
-
53
-`notifySearchBarUpdated(event: SearchBarUpdatedEvent): void`
54
-
55
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L65)
56
-
57
----
58
-
59
-## notifySearchBarCancelPressed
60
-
61
-`notifySearchBarCancelPressed(event: SearchBarCancelPressedEvent): void`
62
-
63
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/ComponentEventsObserver.ts#L69)
64
-
65
----
66
-
67
-

+ 0
- 11
docs/api/ComponentRegistry.md View File

@@ -1,11 +0,0 @@
1
-# ComponentRegistry
2
-
3
-## registerComponent
4
-
5
-`registerComponent(componentName: string, getComponentClassFunc: ComponentProvider, ReduxProvider: any, userStore: any): ComponentType<any>`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/ComponentRegistry.ts#L10)
8
-
9
----
10
-
11
-

+ 0
- 19
docs/api/ComponentWrapper.md View File

@@ -1,19 +0,0 @@
1
-# ComponentWrapper
2
-
3
-## wrap
4
-
5
-`wrap(componentName: string, OriginalComponentClass: React.ComponentType<any>, store: any, componentEventsObserver: any, ReduxProvider: any, reduxStore: any): React.ComponentType<any>`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/ComponentWrapper.tsx#L7)
8
-
9
----
10
-
11
-## wrapWithRedux
12
-
13
-`wrapWithRedux(WrappedComponent: any, ReduxProvider: any, reduxStore: any): React.ComponentType<any>`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/ComponentWrapper.tsx#L64)
16
-
17
----
18
-
19
-

+ 0
- 32
docs/api/Constants.md View File

@@ -1,32 +0,0 @@
1
-# Constants
2
-
3
-## backButtonId
4
-
5
-`backButtonId (string)`
6
-
7
----
8
-## bottomTabsHeight
9
-
10
-`bottomTabsHeight (number)`
11
-
12
----
13
-## statusBarHeight
14
-
15
-`statusBarHeight (number)`
16
-
17
----
18
-## topBarHeight
19
-
20
-`topBarHeight (number)`
21
-
22
----
23
-
24
-## get
25
-
26
-`get(): Promise<any>`
27
-
28
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/Constants.ts#L4)
29
-
30
----
31
-
32
-

+ 0
- 32
docs/api/Element.md View File

@@ -1,32 +0,0 @@
1
-# Element
2
-
3
-## context
4
-
5
-`context (any)`
6
-
7
----
8
-## props
9
-
10
-`props (Readonly<object> & Readonly<object>)`
11
-
12
----
13
-## refs
14
-
15
-`refs (object)`
16
-
17
----
18
-## state
19
-
20
-`state (Readonly<any>)`
21
-
22
----
23
-
24
-## render
25
-
26
-`render(): Element`
27
-
28
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/Element.tsx#L18)
29
-
30
----
31
-
32
-

+ 0
- 11
docs/api/EventSubscription.md View File

@@ -1,11 +0,0 @@
1
-# EventSubscription
2
-
3
-## remove
4
-
5
-`remove(): any`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/interfaces/EventSubscription.ts#L2)
8
-
9
----
10
-
11
-

+ 0
- 83
docs/api/EventsRegistry.md View File

@@ -1,83 +0,0 @@
1
-# EventsRegistry
2
-
3
-## registerAppLaunchedListener
4
-
5
-`registerAppLaunchedListener(callback: function): EventSubscription`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L17)
8
-
9
----
10
-
11
-## registerComponentDidAppearListener
12
-
13
-`registerComponentDidAppearListener(callback: function): EventSubscription`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L21)
16
-
17
----
18
-
19
-## registerComponentDidDisappearListener
20
-
21
-`registerComponentDidDisappearListener(callback: function): EventSubscription`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L25)
24
-
25
----
26
-
27
-## registerCommandCompletedListener
28
-
29
-`registerCommandCompletedListener(callback: function): EventSubscription`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L29)
32
-
33
----
34
-
35
-## registerBottomTabSelectedListener
36
-
37
-`registerBottomTabSelectedListener(callback: function): EventSubscription`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L33)
40
-
41
----
42
-
43
-## registerNavigationButtonPressedListener
44
-
45
-`registerNavigationButtonPressedListener(callback: function): EventSubscription`
46
-
47
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L37)
48
-
49
----
50
-
51
-## registerSearchBarUpdatedListener
52
-
53
-`registerSearchBarUpdatedListener(callback: function): EventSubscription`
54
-
55
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L41)
56
-
57
----
58
-
59
-## registerSearchBarCancelPressedListener
60
-
61
-`registerSearchBarCancelPressedListener(callback: function): EventSubscription`
62
-
63
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L45)
64
-
65
----
66
-
67
-## registerCommandListener
68
-
69
-`registerCommandListener(callback: function): EventSubscription`
70
-
71
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L49)
72
-
73
----
74
-
75
-## bindComponent
76
-
77
-`bindComponent(component: Component<any>): EventSubscription`
78
-
79
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/events/EventsRegistry.ts#L53)
80
-
81
----
82
-
83
-

+ 0
- 65
docs/api/LayoutTreeCrawler.md View File

@@ -1,65 +0,0 @@
1
-# LayoutTreeCrawler
2
-
3
-## store
4
-
5
-`store (any)`
6
-
7
----
8
-
9
-## crawl
10
-
11
-`crawl(node: LayoutNode): void`
12
-
13
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L27)
14
-
15
----
16
-
17
-## processOptions
18
-
19
-`processOptions(options: any): void`
20
-
21
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L39)
22
-
23
----
24
-
25
-## _handleComponent
26
-
27
-`_handleComponent(node: any): void`
28
-
29
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L43)
30
-
31
----
32
-
33
-## _savePropsToStore
34
-
35
-`_savePropsToStore(node: any): void`
36
-
37
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L49)
38
-
39
----
40
-
41
-## _applyStaticOptions
42
-
43
-`_applyStaticOptions(node: any): void`
44
-
45
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L53)
46
-
47
----
48
-
49
-## _assertKnownLayoutType
50
-
51
-`_assertKnownLayoutType(type: any): void`
52
-
53
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L60)
54
-
55
----
56
-
57
-## _assertComponentDataName
58
-
59
-`_assertComponentDataName(component: any): void`
60
-
61
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeCrawler.ts#L66)
62
-
63
----
64
-
65
-

+ 0
- 75
docs/api/LayoutTreeParser.md View File

@@ -1,75 +0,0 @@
1
-# LayoutTreeParser
2
-
3
-## parse
4
-
5
-`parse(api: any): LayoutNode`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L10)
8
-
9
----
10
-
11
-## _topTabs
12
-
13
-`_topTabs(api: any): LayoutNode`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L29)
16
-
17
----
18
-
19
-## _sideMenu
20
-
21
-`_sideMenu(api: any): LayoutNode`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L38)
24
-
25
----
26
-
27
-## _sideMenuChildren
28
-
29
-`_sideMenuChildren(api: any): LayoutNode[]`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L47)
32
-
33
----
34
-
35
-## _bottomTabs
36
-
37
-`_bottomTabs(api: any): LayoutNode`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L77)
40
-
41
----
42
-
43
-## _stack
44
-
45
-`_stack(api: any): LayoutNode`
46
-
47
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L86)
48
-
49
----
50
-
51
-## _component
52
-
53
-`_component(api: any): LayoutNode`
54
-
55
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L95)
56
-
57
----
58
-
59
-## _externalComponent
60
-
61
-`_externalComponent(api: any): LayoutNode`
62
-
63
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L104)
64
-
65
----
66
-
67
-## _splitView
68
-
69
-`_splitView(api: any): LayoutNode`
70
-
71
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/LayoutTreeParser.ts#L113)
72
-
73
----
74
-
75
-

+ 0
- 12
docs/api/LayoutType.md View File

@@ -1,12 +0,0 @@
1
-# LayoutType
2
-
3
-- BottomTabs
4
-- Component
5
-- ExternalComponent
6
-- SideMenuCenter
7
-- SideMenuLeft
8
-- SideMenuRight
9
-- SideMenuRoot
10
-- SplitView
11
-- Stack
12
-- TopTabs

+ 0
- 115
docs/api/NativeCommandsSender.md View File

@@ -1,115 +0,0 @@
1
-# NativeCommandsSender
2
-
3
-## setRoot
4
-
5
-`setRoot(commandId: string, layout: object): any`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L9)
8
-
9
----
10
-
11
-## setDefaultOptions
12
-
13
-`setDefaultOptions(options: object): any`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L13)
16
-
17
----
18
-
19
-## mergeOptions
20
-
21
-`mergeOptions(componentId: string, options: object): any`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L17)
24
-
25
----
26
-
27
-## push
28
-
29
-`push(commandId: string, onComponentId: string, layout: object): any`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L21)
32
-
33
----
34
-
35
-## pop
36
-
37
-`pop(commandId: string, componentId: string, options: object): any`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L25)
40
-
41
----
42
-
43
-## popTo
44
-
45
-`popTo(commandId: string, componentId: string): any`
46
-
47
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L29)
48
-
49
----
50
-
51
-## popToRoot
52
-
53
-`popToRoot(commandId: string, componentId: string): any`
54
-
55
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L33)
56
-
57
----
58
-
59
-## setStackRoot
60
-
61
-`setStackRoot(commandId: string, onComponentId: string, layout: object): any`
62
-
63
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L37)
64
-
65
----
66
-
67
-## showModal
68
-
69
-`showModal(commandId: string, layout: object): any`
70
-
71
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L41)
72
-
73
----
74
-
75
-## dismissModal
76
-
77
-`dismissModal(commandId: string, componentId: string): any`
78
-
79
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L45)
80
-
81
----
82
-
83
-## dismissAllModals
84
-
85
-`dismissAllModals(commandId: string): any`
86
-
87
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L49)
88
-
89
----
90
-
91
-## showOverlay
92
-
93
-`showOverlay(commandId: string, layout: object): any`
94
-
95
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L53)
96
-
97
----
98
-
99
-## dismissOverlay
100
-
101
-`dismissOverlay(commandId: string, componentId: string): any`
102
-
103
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L57)
104
-
105
----
106
-
107
-## getLaunchArgs
108
-
109
-`getLaunchArgs(commandId: string): any`
110
-
111
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeCommandsSender.ts#L61)
112
-
113
----
114
-
115
-

+ 0
- 67
docs/api/NativeEventsReceiver.md View File

@@ -1,67 +0,0 @@
1
-# NativeEventsReceiver
2
-
3
-## registerAppLaunchedListener
4
-
5
-`registerAppLaunchedListener(callback: function): EventSubscription`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L28)
8
-
9
----
10
-
11
-## registerComponentDidAppearListener
12
-
13
-`registerComponentDidAppearListener(callback: function): EventSubscription`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L32)
16
-
17
----
18
-
19
-## registerComponentDidDisappearListener
20
-
21
-`registerComponentDidDisappearListener(callback: function): EventSubscription`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L36)
24
-
25
----
26
-
27
-## registerNavigationButtonPressedListener
28
-
29
-`registerNavigationButtonPressedListener(callback: function): EventSubscription`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L40)
32
-
33
----
34
-
35
-## registerSearchBarUpdatedListener
36
-
37
-`registerSearchBarUpdatedListener(callback: function): EventSubscription`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L44)
40
-
41
----
42
-
43
-## registerSearchBarCancelPressedListener
44
-
45
-`registerSearchBarCancelPressedListener(callback: function): EventSubscription`
46
-
47
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L48)
48
-
49
----
50
-
51
-## registerCommandCompletedListener
52
-
53
-`registerCommandCompletedListener(callback: function): EventSubscription`
54
-
55
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L52)
56
-
57
----
58
-
59
-## registerBottomTabSelectedListener
60
-
61
-`registerBottomTabSelectedListener(callback: function): EventSubscription`
62
-
63
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/NativeEventsReceiver.ts#L56)
64
-
65
----
66
-
67
-

+ 0
- 196
docs/api/Navigation.md View File

@@ -1,196 +0,0 @@
1
-# Navigation
2
-
3
-## Element
4
-
5
-`Element (React.ComponentType<object>)`
6
-
7
----
8
-## store
9
-
10
-`store (Store)`
11
-
12
----
13
-
14
-## registerComponent
15
-
16
-`registerComponent(componentName: string, getComponentClassFunc: ComponentProvider): ComponentType<any>`
17
-
18
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L52)
19
-
20
-Every navigation component in your app must be registered with a unique name.
21
-The component itself is a traditional React component extending React.Component.
22
-
23
----
24
-
25
-## registerComponentWithRedux
26
-
27
-`registerComponentWithRedux(componentName: string, getComponentClassFunc: ComponentProvider, ReduxProvider: any, reduxStore: any): ComponentType<any>`
28
-
29
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L60)
30
-
31
-Utility helper function like registerComponent,
32
-wraps the provided component with a react-redux Provider with the passed redux store
33
-
34
----
35
-
36
-## setRoot
37
-
38
-`setRoot(layout: any): Promise<any>`
39
-
40
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L67)
41
-
42
-Reset the app to a new layout
43
-
44
----
45
-
46
-## setDefaultOptions
47
-
48
-`setDefaultOptions(options: any): void`
49
-
50
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L74)
51
-
52
-Set default options to all screens. Useful for declaring a consistent style across the app.
53
-
54
----
55
-
56
-## mergeOptions
57
-
58
-`mergeOptions(componentId: string, options: any): void`
59
-
60
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L81)
61
-
62
-Change a component's navigation options
63
-
64
----
65
-
66
-## showModal
67
-
68
-`showModal(layout: any): Promise<any>`
69
-
70
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L88)
71
-
72
-Show a screen as a modal.
73
-
74
----
75
-
76
-## dismissModal
77
-
78
-`dismissModal(componentId: string): Promise<any>`
79
-
80
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L95)
81
-
82
-Dismiss a modal by componentId. The dismissed modal can be anywhere in the stack.
83
-
84
----
85
-
86
-## dismissAllModals
87
-
88
-`dismissAllModals(): Promise<any>`
89
-
90
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L102)
91
-
92
-Dismiss all Modals
93
-
94
----
95
-
96
-## push
97
-
98
-`push(componentId: string, layout: any): Promise<any>`
99
-
100
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L109)
101
-
102
-Push a new layout into this screen's navigation stack.
103
-
104
----
105
-
106
-## pop
107
-
108
-`pop(componentId: string, params: any): Promise<any>`
109
-
110
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L116)
111
-
112
-Pop a component from the stack, regardless of it's position.
113
-
114
----
115
-
116
-## popTo
117
-
118
-`popTo(componentId: string): Promise<any>`
119
-
120
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L123)
121
-
122
-Pop the stack to a given component
123
-
124
----
125
-
126
-## popToRoot
127
-
128
-`popToRoot(componentId: string): Promise<any>`
129
-
130
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L130)
131
-
132
-Pop the component's stack to root.
133
-
134
----
135
-
136
-## setStackRoot
137
-
138
-`setStackRoot(componentId: string, layout: any): Promise<any>`
139
-
140
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L137)
141
-
142
-Sets new root component to stack.
143
-
144
----
145
-
146
-## showOverlay
147
-
148
-`showOverlay(layout: any): Promise<any>`
149
-
150
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L144)
151
-
152
-Show overlay on top of the entire app
153
-
154
----
155
-
156
-## dismissOverlay
157
-
158
-`dismissOverlay(componentId: string): Promise<any>`
159
-
160
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L151)
161
-
162
-dismiss overlay by componentId
163
-
164
----
165
-
166
-## getLaunchArgs
167
-
168
-`getLaunchArgs(): Promise<any>`
169
-
170
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L158)
171
-
172
-Resolves arguments passed on launch
173
-
174
----
175
-
176
-## events
177
-
178
-`events(): EventsRegistry`
179
-
180
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L165)
181
-
182
-Obtain the events registry instance
183
-
184
----
185
-
186
-## constants
187
-
188
-`constants(): Promise<any>`
189
-
190
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/Navigation.ts#L172)
191
-
192
-Constants coming from native
193
-
194
----
195
-
196
-

+ 0
- 10
docs/api/OptionsModalPresentationStyle.md View File

@@ -1,10 +0,0 @@
1
-# OptionsModalPresentationStyle
2
-
3
-- currentContext
4
-- formSheet
5
-- fullScreen
6
-- none
7
-- overCurrentContext
8
-- overFullScreen
9
-- pageSheet
10
-- popover

+ 0
- 22
docs/api/OptionsProcessor.md View File

@@ -1,22 +0,0 @@
1
-# OptionsProcessor
2
-
3
-## store
4
-
5
-`store (any)`
6
-
7
----
8
-## uniqueIdProvider
9
-
10
-`uniqueIdProvider (any)`
11
-
12
----
13
-
14
-## processOptions
15
-
16
-`processOptions(options: any): void`
17
-
18
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/OptionsProcessor.ts#L8)
19
-
20
----
21
-
22
-

+ 0
- 20
docs/api/README.md View File

@@ -1,20 +0,0 @@
1
-- [Home](/)
2
-- [Navigation](/api/Navigation)
3
-- [Constants](/api/Constants)
4
-- [Element](/api/Element)
5
-- [NativeCommandsSender](/api/NativeCommandsSender)
6
-- [NativeEventsReceiver](/api/NativeEventsReceiver)
7
-- [UniqueIdProvider](/api/UniqueIdProvider)
8
-- [Commands](/api/Commands)
9
-- [LayoutTreeCrawler](/api/LayoutTreeCrawler)
10
-- [LayoutTreeParser](/api/LayoutTreeParser)
11
-- [OptionsProcessor](/api/OptionsProcessor)
12
-- [ComponentRegistry](/api/ComponentRegistry)
13
-- [ComponentWrapper](/api/ComponentWrapper)
14
-- [Store](/api/Store)
15
-- [CommandsObserver](/api/CommandsObserver)
16
-- [ComponentEventsObserver](/api/ComponentEventsObserver)
17
-- [EventsRegistry](/api/EventsRegistry)
18
-- [EventSubscription](/api/EventSubscription)
19
-- [LayoutType](/api/LayoutType)
20
-- [OptionsModalPresentationStyle](/api/OptionsModalPresentationStyle)

+ 0
- 43
docs/api/Store.md View File

@@ -1,43 +0,0 @@
1
-# Store
2
-
3
-## setPropsForId
4
-
5
-`setPropsForId(componentId: string, props: any): void`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L7)
8
-
9
----
10
-
11
-## getPropsForId
12
-
13
-`getPropsForId(componentId: string): any`
14
-
15
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L11)
16
-
17
----
18
-
19
-## setComponentClassForName
20
-
21
-`setComponentClassForName(componentName: string, ComponentClass: any): void`
22
-
23
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L15)
24
-
25
----
26
-
27
-## getComponentClassForName
28
-
29
-`getComponentClassForName(componentName: string): any`
30
-
31
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L19)
32
-
33
----
34
-
35
-## clearComponent
36
-
37
-`clearComponent(id: string): void`
38
-
39
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/components/Store.ts#L23)
40
-
41
----
42
-
43
-

+ 0
- 65
docs/api/TouchablePreview.md View File

@@ -1,65 +0,0 @@
1
-# TouchablePreview
2
-
3
-## peeking
4
-
5
-`peeking (boolean)`
6
-
7
----
8
-
9
-## onRef
10
-
11
-`onRef(ref: Component<any>): void`
12
-
13
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L54)
14
-
15
----
16
-
17
-## onPress
18
-
19
-`onPress(): void`
20
-
21
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L58)
22
-
23
----
24
-
25
-## onPressIn
26
-
27
-`onPressIn(): void`
28
-
29
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L68)
30
-
31
----
32
-
33
-## onTouchStart
34
-
35
-`onTouchStart(event: GestureResponderEvent): void`
36
-
37
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L85)
38
-
39
----
40
-
41
-## onTouchMove
42
-
43
-`onTouchMove(event: GestureResponderEventWithForce): void`
44
-
45
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L90)
46
-
47
----
48
-
49
-## onTouchEnd
50
-
51
-`onTouchEnd(): void`
52
-
53
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L106)
54
-
55
----
56
-
57
-## render
58
-
59
-`render(): Element`
60
-
61
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/TouchablePreview.tsx#L115)
62
-
63
----
64
-
65
-

+ 0
- 11
docs/api/UniqueIdProvider.md View File

@@ -1,11 +0,0 @@
1
-# UniqueIdProvider
2
-
3
-## generate
4
-
5
-`generate(prefix: string): string`
6
-
7
-[source](https://github.com/wix/react-native-navigation/blob/v2/lib/src/adapters/UniqueIdProvider.ts#L4)
8
-
9
----
10
-
11
-

+ 0
- 20
docs/api/_sidebar.md View File

@@ -1,20 +0,0 @@
1
-- [Home](/)
2
-- [Navigation](/api/Navigation)
3
-- [Constants](/api/Constants)
4
-- [Element](/api/Element)
5
-- [NativeCommandsSender](/api/NativeCommandsSender)
6
-- [NativeEventsReceiver](/api/NativeEventsReceiver)
7
-- [UniqueIdProvider](/api/UniqueIdProvider)
8
-- [Commands](/api/Commands)
9
-- [LayoutTreeCrawler](/api/LayoutTreeCrawler)
10
-- [LayoutTreeParser](/api/LayoutTreeParser)
11
-- [OptionsProcessor](/api/OptionsProcessor)
12
-- [ComponentRegistry](/api/ComponentRegistry)
13
-- [ComponentWrapper](/api/ComponentWrapper)
14
-- [Store](/api/Store)
15
-- [CommandsObserver](/api/CommandsObserver)
16
-- [ComponentEventsObserver](/api/ComponentEventsObserver)
17
-- [EventsRegistry](/api/EventsRegistry)
18
-- [EventSubscription](/api/EventSubscription)
19
-- [LayoutType](/api/LayoutType)
20
-- [OptionsModalPresentationStyle](/api/OptionsModalPresentationStyle)

+ 0
- 106
docs/docs/Usage.md View File

@@ -1,106 +0,0 @@
1
-# Usage
2
-
3
-- If you don't like reading, just jump into the fully working [playground](https://github.com/wix/react-native-navigation/tree/v2/playground) project. All features are implemented there, and it's the basis for the e2e tests.
4
-- We fully support Redux, MobX and other state management libraries. See the integration tests [here](https://github.com/wix/react-native-navigation/tree/v2/integration).
5
-- Navigation is written with `TypeScript` and shipped with the type definitions alongside the transpiled JS code. To enjoy API autocompletion, use an IDE that supports it, like VSCode or Webstorm.
6
-- Take a look at this excellent showcase app [JuneDomingo/movieapp](https://github.com/JuneDomingo/movieapp). (using v1 of React Native Navigation with redux).
7
-
8
-## The Basics
9
-
10
-### Navigation
11
-```js
12
-import { Navigation } from 'react-native-navigation';
13
-```
14
-
15
-### registerComponent(screenID, generator)
16
-Every screen component in your app must be registered with a unique name. The component itself is a traditional React component extending `React.Component` or `React.PureComponent`. It can also be a HOC to provide context (or a Redux store). Analgous to ReactNative's `AppRegistry.registerComponent`.
17
-
18
-```js
19
-Navigation.registerComponent(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
20
-```
21
-
22
-
23
-### registerAppLaunchedListener(callback)
24
-This event is called once the app is launched. It's where you will initialize the app with the layout you want, via the SetRoot command. This creates the native layout hierarchy, loading React components into the `component` by name. 
25
-
26
-Afterwards, the app is ready for user interaction. (Common gotcha: Be sure not to run setRoot before registerAppLaunchedListener() has fired!)
27
-
28
-```js
29
-Navigation.events().registerAppLaunchedListener(() => {
30
-  Navigation.setRoot({
31
-    root: {
32
-      component: {
33
-        name: 'navigation.playground.WelcomeScreen'
34
-      }
35
-    }
36
-  });
37
-});
38
-```
39
-
40
-As specified in the [LayoutTypes](docs/layout-types) part of the documentation, we use the layout type `component` here, which renders a React component but does not allow you to navigate to others.
41
-
42
-If you want to navigate, use a `stack` layout type:
43
-```js
44
-Navigation.events().registerAppLaunchedListener(() => {
45
-  Navigation.setRoot({
46
-    root: {
47
-      stack: {
48
-        children: [{
49
-          component: {
50
-            name: "navigation.playground.WelcomeScreen"
51
-          }
52
-        }]
53
-      }
54
-    }
55
-  });
56
-});
57
-```
58
-
59
-## Screen Lifecycle
60
-
61
-The `componentDidAppear` and `componentDidDisappear` functions are special React Native Navigation lifecycle callbacks that are called on the component when it appears and disappears (after it was bounded using `Navigation.events().bindComponent(this)`). 
62
-
63
-Similar to React's `componentDidMount` and `componentWillUnmount`, what's different is that they represent whether the user can actually see the component in question -- and not just whether it's been mounted or not. Because of the way React Native Navigation optimizes performance, a component is actually `mounted` as soon as it's part of a layout -- but it is not always `visible` (for example, when another screen is `pushed` on top of it).
64
-
65
-There are lots of use cases for these. For example: starting and stopping an animation while the component is shown on-screen.
66
-
67
-> They are implemented by iOS's viewDidAppear/viewDidDisappear and Android's ViewTreeObserver visibility detection
68
-
69
-To use them, simply implement them in your component like any other React lifecycle function, and bind the screen to the Navigation events module which will call all functions automatically:
70
-
71
-```js
72
-class LifecycleScreenExample extends Component {
73
-  constructor(props) {
74
-    super(props);
75
-    Navigation.events().bindComponent(this);
76
-    this.state = {
77
-      text: 'nothing yet'
78
-    };
79
-  }
80
-
81
-  componentDidAppear() {
82
-    this.setState({ text: 'componentDidAppear' });
83
-  }
84
-
85
-  componentDidDisappear() {
86
-    alert('componentDidDisappear');
87
-  }
88
-
89
-  navigationButtonPressed({buttonId}) {
90
-    // a navigation-based button (for example in the topBar) was clicked. See section on buttons.
91
-  }
92
-
93
-  componentWillUnmount() {
94
-    alert('componentWillUnmount');
95
-  }
96
-
97
-  render() {
98
-    return (
99
-      <View style={styles.root}>
100
-        <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
101
-        <Text style={styles.h1}>{this.state.text}</Text>
102
-      </View>
103
-    );
104
-  }
105
-}
106
-```

+ 0
- 88
docs/docs/WorkingLocally.md View File

@@ -1,88 +0,0 @@
1
-# Working Locally
2
-
3
-> Thanks for your interest in helping out! We'd love your contributions, and there's plenty of work to be done regardless of your skill level
4
-
5
-## Environment Requirements
6
-
7
-* Mac OSX
8
-* [Latest stable Xcode](https://developer.apple.com/xcode/)
9
-* [Android SDK](https://developer.android.com/studio/index.html)
10
-* [Node 8+](https://nodejs.org/en/)
11
-* [AppleSimulatorUtils](https://github.com/wix/AppleSimulatorUtils)
12
-
13
-## Running The Project
14
-
15
-Got your environment set up? Go ahead and clone the repo. (Fork it first so you can open a PR when you're ready.)
16
-
17
-Then:
18
-
19
-1. Install dependencies `npm install`
20
-2. Run the playground project in Android and iOS so that you can get a feel for the project.
21
-    - `npm run start` to get the packager running in a terminal, leave it open
22
-    - **iOS**: `npm run xcode` & run the project from Xcode
23
-    - **Android**: `npm run install-android`, or open the app in Android Studio and click `Run`
24
-3. Run the tests (using the scripts below). Before you start changing things, make sure everything works.
25
-	- To easily run all tests in parallel `npm run test-all`
26
-
27
-
28
-## Workflow
29
-This project is driven by tests. Before implementing any feature or fixing any bug, a failing test (e2e or unit or both) should be added, depending on the environment of where the fix should be implemented. For example, for an API change, a failing e2e should be written. For a small bug fix in Android, for example, a unit test in Android should be added.
30
-
31
-This will ensure good quality throughout the life of the project and will avoid unexpected breakages.
32
-
33
-No PR will be accepted without adequate test coverage.
34
-
35
-## Folder Structure
36
-
37
-| Folder | Description |
38
-| ------ | ----------- |
39
-| `lib` | The project itself composed of: |
40
-| `lib/android` | android sources and unit tests |
41
-| `lib/ios` | iOS sources and unit tests |
42
-| `lib/src` | TypeScript sources and unit tests |
43
-| `lib/dist` | compiled javascript sources and unit tests |
44
-| `lib/dist/index.js` | the entry point for `import Navigation from 'react-native-navigation'` |
45
-| `e2e` | [detox](https://github.com/wix/detox) e2e tests on both Android and iOS |
46
-| `playground` | The end-user project all e2e tests run against. Contains its own `src`, `android` and `ios`. Does not have its own package.json, depends on the local `<root>/lib` for faster local development (no need to `npm install` locally). |
47
-| `integration` | misc javascript integration tests, proving integration with other libraries like redux |
48
-| `scripts` | all scripts |
49
-
50
-## Scripts
51
-
52
-| Command | Description |
53
-| ------- | ----------- |
54
-| `npm install` | installs dependencies |
55
-| `npm run build` | compiles TypeScript sources `./lib/src` into javascript `./lib/dist` |
56
-| `npm run clean` | cleans all build directories, stops packager, fixes flakiness by removing watchman cache, etc. |
57
-| `npm run start` | starts the react-native packager for local debugging |
58
-| `npm run start-windows` | starts the react-native packager for local debugging [Windows only] |
59
-| `npm run xcode` | for convenience, opens xcode in this project |
60
-| `npm run install-android`  |  builds playground debug/release version and installs on running android devices/emulators. <br> **Options:** `-- --release` |
61
-| `npm run uninstall-android` | uninstalls playground from running android devices/simulators |
62
-| `npm run test-js` | runs javascript tests and coverage report |
63
-| `npm run test-unit-ios` | runs ios unit tests in debug/release <br> **Options:** `-- --release` |
64
-| `npm run test-unit-android` | runs android unit tests in debug/release <br> **Options:** `-- --release` |
65
-| `npm run test-e2e-ios` | runs the ios e2e tests using [detox](https://github.com/wix/detox) in debug/release <br> **Options:** `-- --release`|
66
-| `npm run test-e2e-android` | runs the android e2e tests using [detox](https://github.com/wix/detox) in debug/release <br> **Options:** `-- --release` |
67
-| `npm run test-all` | runs all tests in parallel |
68
-| `npm run gen-docs` | generates api docs |
69
-| `npm run local-docs` | serve the docs locally for `http://localhost:3000/` |
70
-
71
-## Common Problems
72
-
73
-* If the tests fail with an error like `Ineligible destinations for the "ReactNativeNavigation" scheme`, double check that you have the latest XCode installed.
74
-* If the tests fail because an Android emulator isn't available (something like `com.android.builder.testing.api.DeviceException: No connected devices!`), start the Android project from Android Studio and leave the emulator running, then try again.
75
-* If the tests fail with an error such as:
76
-		
77
-	```js
78
-	 beforeEach(async () => {
79
-	                   ^
80
-	SyntaxError: Unexpected token (
81
-	```
82
-		
83
-	You probably have an old node version which doesn't support async functions. Update your nodejs to 8+.
84
-* If the bundling fails with an error like `bundling failed: ambiguous resolution`, reset the `rn-packager` cache manually.
85
-	```
86
-	node ./node_modules/react-native/local-cli/cli.js start --reset-cache
87
-	```
88
-

+ 0
- 178
docs/docs/animations.md View File

@@ -1,178 +0,0 @@
1
-# Animations
2
-
3
-## Shared element transition
4
-
5
-Shared element transitions allows us to provide visual continuity when navigating between destinations. It also
6
-focuses the user's attention on a significant element which gives the user better context when transitioning to
7
-another destination.
8
-
9
-!> At the moment, the transition is available on iOS for push and pop while on Android it's available only for push commands.
10
-We will soon add parity and expand the supported commands to show/dismiss modal and changing BottomTabs.
11
-
12
-### Example
13
-In the sections below we will use the following example from the playground app:
14
-* [Source screen](https://github.com/wix/react-native-navigation/blob/master/playground/src/screens/sharedElementTransition/CocktailsList.js)
15
-* [Destination screen](https://github.com/wix/react-native-navigation/blob/master/playground/src/screens/sharedElementTransition/CocktailDetailsScreen.js)
16
-
17
-<img src="https://github.com/wix/react-native-navigation/blob/master/docs/_images/sharedElement.gif?raw=true"/>
18
-
19
-
20
-
21
-
22
-#### Transition breakdown
23
-Four elements are animated in this example.
24
-
25
-* **image** - the item's image is animated to the next screen.
26
-  * Image scale (resizeMode)
27
-  * position on screen
28
-
29
-* **image background** - each item has a "shadow" view which transitions to the next screen and turns into a colorful header.
30
-  * scale
31
-  * position on screen
32
-
33
-* **title** - the item's title is animated to the next screen.
34
-  * font size
35
-  * font color
36
-  * position on screen
37
-
38
-* **Description** - the item's description in the destination screen.
39
-  * fade-in
40
-  * translation y
41
-
42
-
43
-### API
44
-#### Step 1 - set a nativeID prop to elements in the source screen
45
-In order for RNN to be able to detect the corresponding native views of the elements,
46
-each element must include a unique `nativeID` prop.
47
-
48
-```jsx
49
-<Image
50
-  source={item.image}
51
-  nativeID={`image${item.id}`}
52
-  style={styles.image}
53
-  resizeMode={'contain'} />
54
-```
55
-
56
-#### Step 2 - set a nativeID prop to elements in the destination screen
57
-
58
-```jsx
59
-<Image
60
-  source={this.props.image}
61
-  nativeID={`image${this.props.id}Dest`}
62
-  style={styles.image} />
63
-```
64
-
65
-#### Step 3 - Declare the shared element animation when pushing the screen
66
-
67
-```jsx
68
-Navigation.push(this.props.componentId, {
69
-  component: {
70
-    name: Screens.CocktailDetailsScreen,
71
-    passProps: { ...item },
72
-    options: {
73
-      animations: {
74
-        push: {
75
-          sharedElementTransitions: [
76
-            {
77
-              fromId: `image${item.id}`,
78
-              toId: `image${item.id}Dest`
79
-            }
80
-          ]
81
-        }
82
-      }
83
-    }
84
-  }
85
-});
86
-```
87
-
88
-## Element Transitions
89
-Element transitions allow you to animate elements during shared element transitions.
90
-
91
-### Example
92
-In the sections below we will use the following example from the playground app:
93
-* [Source screen](https://github.com/wix/react-native-navigation/blob/master/playground/src/screens/sharedElementTransition/CocktailsList.js)
94
-* [Destination screen](https://github.com/wix/react-native-navigation/blob/master/playground/src/screens/sharedElementTransition/CocktailDetailsScreen.js)
95
-
96
-### API
97
-#### Step 1 - set a nativeID prop to elements either source or destination screens
98
-
99
-```jsx
100
-<Text
101
-  nativeID='description'
102
-  style={styles.description}>
103
-  {this.props.description}
104
-</Text>
105
-```
106
-
107
-#### Step 2 - Declare the element animation when pushing the screen
108
-
109
-```jsx
110
-Navigation.push(this.props.componentId, {
111
-  component: {
112
-    name: Screens.CocktailDetailsScreen,
113
-    passProps: { ...item },
114
-    options: {
115
-      animations: {
116
-        push: {
117
-          elementTransitions: [
118
-            {
119
-              id: 'description',
120
-              alpha: {
121
-                from: 0, // We don't declare 'to' value as that is the element's current alpha value, here we're essentially animating from 0 to 1
122
-                duration: SHORT_DURATION
123
-              },
124
-              translationY: {
125
-                from: 16, // Animate translationY from 16dp to 0dp
126
-                duration: SHORT_DURATION
127
-              }
128
-            }
129
-          ]
130
-        }
131
-      }
132
-    }
133
-  }
134
-});
135
-```
136
-
137
-## Peek and Pop (iOS 11.4+) (Preview API)
138
-
139
-react-native-navigation supports the [Peek and pop](
140
-https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/#//apple_ref/doc/uid/TP40016543-CH1-SW3) feature in iOS 11.4 and newer.
141
-
142
-This works by passing a ref a componentent you would want to transform into a peek view. We have included a handly component to handle all the touches and ref for you.
143
-
144
-```jsx
145
-const handlePress ({ reactTag }) => {
146
-  Navigation.push(this.props.componentId, {
147
-    component {
148
-      name: 'previewed.screen',
149
-      options: {
150
-        preview: {
151
-          reactTag,
152
-          height: 300,
153
-          width: 300,
154
-          commit: true,
155
-          actions: [{
156
-            title: "Displayed Name",
157
-            id: "actionId",
158
-            style: 'default', /* or 'selected', 'destructive'*/
159
-            actions: [/*define a submenu of actions with the same options*/]
160
-          }]
161
-        },
162
-      },
163
-    },
164
-  });
165
-};
166
-
167
-const Button = (
168
-  <Navigation.TouchablePreview
169
-    touchableComponent={TouchableHighlight}
170
-    onPress={handlePress}
171
-    onPressIn={handlePress}
172
-  >
173
-    <Text>My button</Text>
174
-  </Navigation.TouchablePreview>
175
-);
176
-```
177
-
178
-All options except for reactTag are optional. Actions trigger the same event as [navigation button presses](https://wix.github.io/react-native-navigation/#/docs/topBar-buttons?id=handling-button-press-events). To react when a preview is committed, listen to the [previewCompleted](https://wix.github.io/react-native-navigation/#/docs/events?id=previewcompleted-ios-114-only) event.

+ 0
- 28
docs/docs/app-launch.md View File

@@ -1,28 +0,0 @@
1
-# App Launch
2
-When your app is launched for the first time, the bundle is parsed and executed. At this point you need to show your UI. To do so, Listen to the `appLaunched` event and call `Navigation.setRoot` when the event is received.
3
-
4
-```js
5
-Navigation.events().registerAppLaunchedListener(() => {
6
-  // Each time the event is received we should call Navigation.setRoot
7
-});
8
-```
9
-
10
-!> Register the listener with `registerAppLaunchedListener` as soon as possible - it should be one of the first lines in your `index.js` file.
11
-If you're observing a "white screen" or a hanging splash screen after relaunching your app, it probably means `Navigation.setRoot` isn't called once the app has launched. Perhaps the listener was registered too late.
12
-
13
-## The difference between the platforms
14
-When your app is launched, RN makes sure Js context is running. Js context is what enables you to execute JavaScript code.
15
-There are a few differences between iOS and Android in this regard
16
-
17
-### iOS
18
-Whenever the app is put into the background, the app process could potentially be destroyed by the system. If this destruction of the app takes place, the Js context will be destroyed along with the app process.
19
-
20
-### Android
21
-An Android application is typically bound to two contexts:
22
-1. Application context - bound to the app process
23
-2. Activity context - bound to app UI
24
-
25
-React's Js Context is executed on and bound to the Application context. This means that even when the Activity context (and thus the UI) is destroyed, React's Js Context remains active until the Application (and your process) are destroyed by the system.
26
-
27
-!>*Important!* Because of this, when your app returns to foreground, Js Context might still exist on Android, even when the Activity and UI context has been destroyed - meaning you might not need to initialise all of your app logic; instead you'll only need to call `Navigation.setRoot` to repopulate the UI context. This circumstance can easily be determined by setting a flag on your app's first `appLaunched` event, and checking the value of that flag on subsequent `appLaunched` events -- if the flag is true in your `appLaunched` callback, you need to call `Navigation.setRoot` to repopulate the UI.
28
-

+ 0
- 21
docs/docs/constants.md View File

@@ -1,21 +0,0 @@
1
-# Constants
2
-
3
-!> Note! iOS resolves the values from the currently displayed root. If the current root doesn't contain BottomTabs - it will return 0 as the BottomTabs height while Android will always return a static value.
4
-
5
-## statusBarHeight
6
-```js
7
-const constants = await Navigation.constants();
8
-const statusBarHeight = constants.statusBarHeight;
9
-```
10
-
11
-## topBarHeight
12
-```js
13
-const constants = await Navigation.constants();
14
-const topBarHeight = constants.topBarHeight;
15
-```
16
-
17
-## bottomTabsHeight
18
-```js
19
-const constants = await Navigation.constants();
20
-const bottomTabsHeight = constants.bottomTabsHeight;
21
-```

+ 0
- 428
docs/docs/layout-types.md View File

@@ -1,428 +0,0 @@
1
-# Layouts
2
-
3
-The possibilities of the RNN layout API are wide open in terms of what you can construct with it: stacks, tabs and drawers in many combinations.
4
-
5
-You can compose arbitrary native layout hierarchies (although some weird edge cases may not be possible or produce errors). In such cases, open an issue so that we either fix it or warn in dev time.
6
-
7
-## component
8
-
9
-Component layout holds a single react component.
10
-
11
-```js
12
-const component = {
13
-  id: 'component1', // Optional, Auto generated if empty
14
-  name: 'Your registered component name',
15
-  options: {},
16
-  passProps: {
17
-    text: 'This text will be available in your component.props'
18
-  }
19
-}
20
-```
21
-
22
-## stack
23
-
24
-Support children layouts of any kind.
25
-A stack can be initialised with more than one screen, in which case the last screen will be presented at the top of the stack.
26
-
27
-```js
28
-const stack = {
29
-  children: [
30
-    {
31
-      component: {}
32
-    },
33
-    {
34
-      component: {}
35
-    }
36
-  ],
37
-  options: {}
38
-}
39
-```
40
-
41
-### api
42
-### TopBar buttons
43
-#### Android:
44
-* LeftButtons just support one button 
45
-* RightButtons support three visable buttons, more getting replaced with a menu button 
46
-```js
47
-options: {
48
-  topBar: {
49
-    visible: true,
50
-    leftButtons: [
51
-      {
52
-        id: 'back',
53
-        icon: {
54
-          uri: 'back',
55
-        },
56
-      },
57
-    ],
58
-    rightButtons: [
59
-      {
60
-        id: 'search',
61
-        icon: {
62
-          uri: 'search',
63
-        },
64
-      },
65
-    ],
66
-  },
67
-},
68
-```
69
-### Customizations
70
-#### Custom TopBar Title
71
-It's possible to set a custom topBar title to implement a searchbar for example.
72
-```js
73
-options: {
74
-  topBar: {
75
-    visible: true,
76
-    title: {
77
-      component: {
78
-        id: 'app.Search.SearchInput',
79
-        name: 'app.Search.SearchInput', // required
80
-        alignment: 'center', // 'center' or 'fill'
81
-        passProps: {
82
-
83
-        },
84
-      },
85
-    },
86
-  },
87
-},
88
-```
89
-
90
-### Back button
91
-Push a ModalStack which requires a back button on the first screen.
92
-```js
93
-options: {
94
-  topBar: {
95
-    visible: true,
96
-    leftButtons: [
97
-      {
98
-        id: 'back',
99
-        icon: {
100
-          uri: 'back',
101
-        },
102
-      },
103
-    ],
104
-  },
105
-},
106
-```
107
-Catch the button press event inside the ModalScreen.
108
-
109
-```js
110
-navigationButtonPressed = ({ buttonId }) => {
111
-  const { componentId } = this.props;
112
-  if (buttonId === 'back') {
113
-    Navigation.dismissModal(componentId);
114
-  }
115
-}
116
-```
117
-
118
-
119
-## bottomTabs
120
-
121
-```js
122
-const bottomTabs = {
123
-  children: [
124
-    {
125
-      stack: {
126
-        children: [],
127
-        options: {
128
-          bottomTab: {
129
-            text: 'Tab 1',
130
-            icon: require('../images/one.png')
131
-          }
132
-        }
133
-      }
134
-    },
135
-    {
136
-      component: {
137
-        name: 'secondTabScreen',
138
-        options: {
139
-          bottomTab: {
140
-            text: 'Tab 2',
141
-            icon: require('../images/two.png')
142
-          }
143
-        }
144
-      }
145
-    }
146
-  ],
147
-  options: {}
148
-}
149
-```
150
-
151
-!> Note! On Android an `icon` is required when using `bottomTabs`.
152
-
153
-### Selecting tabs programmatically
154
-
155
-The selected index is a style property which can be updated using the `mergeOptions` command. In order to update the BottomTabs options, Pass the BottomTabs `componentId` or the `componentId` of one of its children.
156
-
157
-?>We'll use the following BottomTabs layout to demonstrate programmatic tab selection.
158
-
159
-```js
160
-const bottomTabs = {
161
-  id: 'BottomTabsId',
162
-  children: [
163
-    {
164
-      component: {
165
-        name: 'FirstScreen',
166
-        options: { ... }
167
-      }
168
-    },
169
-    {
170
-      component: {
171
-        id: 'SecondScreenId',
172
-        name: 'SecondScreen',
173
-        options: { ... }
174
-      }
175
-    }
176
-  ]
177
-}
178
-```
179
-
180
-#### selecting a tab by index
181
-
182
-The following `mergeOptions` command will select the second tab. We're passing the id of our BottomTabs, but we could also use the id of any of the child components, for example `SecondScreenId`.
183
-
184
-```js
185
-Navigation.mergeOptions('BottomTabsId', {
186
-  bottomTabs: {
187
-    currentTabIndex: 1
188
-  }
189
-});
190
-```
191
-
192
-#### selecting a tab by componentId
193
-
194
-Tabs can also be selected by componentId. This is particularly useful in cases where you don't know in which tab a screen is contained.
195
-
196
-For example, if invoked from one of the child components;`SecondScreen` or `FirstScreen`, the following merge command will select the tab containing the child.
197
-
198
-```js
199
-Navigation.mergeOptions(this.props.componentId, {
200
-  bottomTabs: {
201
-    currentTabId: this.props.componentId
202
-  }
203
-});
204
-```
205
-
206
-### Changing BottomTabs visibility
207
-
208
-The `visible` property can be used to control the BottomTab visibility.
209
-
210
-On **Android**, Visibility can be toggled dynamically using the `mergeOptions` command. When hiding BottomTabs, `drawBehind: true` should be specified in order for the screen to render behind the area which was previously allocated to the BottomTabs.
211
-
212
-```js
213
-Navigation.mergeOptions(componentId, {
214
-  bottomTabs: {
215
-    visible: false,
216
-    ...Platform.select({ android: { drawBehind: true } })
217
-  },
218
-});
219
-```
220
-
221
-On **both** platforms visibility can be changed when pushing screens into a stack which is a direct child of a `BottomTabs` layout:
222
-
223
-```js
224
-Navigation.push(componentId, {
225
-  component: {
226
-    name: 'pushedScreen',
227
-    options: {
228
-      bottomTabs: {
229
-        visible: false
230
-      }
231
-    }
232
-  }
233
-});
234
-```
235
-
236
-### Updating options for a specific tab
237
-
238
-Updating (merging) tab specific options is done using the `mergeOptions` command. `mergeOptions` expects a `componentId` as first argument, therefore in order to update a specific tab we'll need to pass a `componentId` of a child of that specific tab.
239
-For example, Using the layout specified above, To update the `badge` property of the second tab we'll call `mergeOptions` with `SecondScreenId`.
240
-
241
-```js
242
-Navigation.mergeOptions('SecondScreenId', {
243
-  bottomTab: {
244
-    badge: 'New'
245
-  }
246
-});
247
-```
248
-
249
-## sideMenu
250
-
251
-This layout allows to implement sidemenus, which can be opened by swiping from one side towards the other side.
252
-`left` and `right` are optional and contain the components, which gets rendered for the sidemenus. `center` is **required** and contains the main application, which **requires** to have a topBar aka `stack`.
253
-
254
-```js
255
-const sideMenu = {
256
-  left: {
257
-    component: {}
258
-  },
259
-  center: {
260
-    stack: {
261
-      options: {},
262
-      children: [{
263
-        component: {}
264
-      }]
265
-    }
266
-  },
267
-  right: {
268
-    component: {}
269
-  }
270
-}
271
-```
272
-
273
-### Opening the menu programmatically
274
-The  most common usecase is to open the sidemenus by pressing a [burger button in the topBar](https://wix.github.io/react-native-navigation/#/docs/layout-types?id=adding-a-hamburger-button). To achive this listen on the press event of the burger button and open the sidemenu by calling `Navigation.mergeOptions()` with `visible: true` for the sidemenu.
275
-```js
276
-navigationButtonPressed = ({ buttonId }) => {
277
-  const { componentId } = this.props;
278
-
279
-  if (buttonId === 'sideMenu') {
280
-    Navigation.mergeOptions(componentId, {
281
-      sideMenu: {
282
-        left: {
283
-          visible: true,
284
-        },
285
-      },
286
-    });
287
-  }
288
-}
289
-```
290
-
291
-### Adding a hamburger button
292
-For more information on how to add icons read [this article about react-native-vector-icons](https://wix.github.io/react-native-navigation/#/docs/third-party?id=react-native-vector-icons) or [this article about custom tab icons](https://wix.github.io/react-native-navigation/#/docs/styling?id=custom-tab-icons).
293
-
294
-```js
295
-leftButtons: [
296
-  {
297
-    id: 'sideMenu',
298
-    icon: {
299
-      uri: 'menu',
300
-    },
301
-  },
302
-],
303
-```
304
-
305
-## splitView (iOS only)
306
-
307
-Master and Detail based layout.
308
-
309
-You can change the it's options with `Navigation.mergeOptions('splitView1', { maxWidth: 400 })`.
310
-
311
-```js
312
-const splitView = {
313
-  id: 'splitView1', // Required to update options
314
-  master: {
315
-    // All layout types accepted supported by device, eg. `stack`
316
-  },
317
-  detail: {
318
-    // All layout types accepted supported by device, eg. `stack`
319
-  },
320
-  options: {
321
-    splitView: {
322
-      displayMode: 'auto', // Master view display mode: `auto`, `visible`, `hidden` and `overlay`
323
-      primaryEdge: 'leading', // Master view side: `leading` or `trailing`
324
-      minWidth: 150, // Minimum width of master view
325
-      maxWidth: 300, // Maximum width of master view
326
-    },
327
-  },
328
-}
329
-```
330
-
331
-## Layout Examples
332
-
333
-### Single page app with two side menus:
334
-
335
-```js
336
-Navigation.setRoot({
337
-  root: {
338
-    sideMenu: {
339
-      left: {
340
-        component: {
341
-          name: 'navigation.playground.TextScreen',
342
-          passProps: {
343
-            text: 'This is a left side menu screen'
344
-          }
345
-        }
346
-      },
347
-      center: {
348
-        component: {
349
-          name: 'navigation.playground.WelcomeScreen'
350
-        },
351
-      },
352
-      right: {
353
-        component: {
354
-          name: 'navigation.playground.TextScreen',
355
-          passProps: {
356
-            text: 'This is a right side menu screen'
357
-          }
358
-        }
359
-      }
360
-    }
361
-  }
362
-});
363
-```
364
-
365
-### Tab based app (with passProps example):
366
-
367
-```js
368
-Navigation.setRoot({
369
-  root: {
370
-    bottomTabs: {
371
-      children: [
372
-        {
373
-          component: {
374
-            name: 'navigation.playground.TextScreen',
375
-            passProps: {
376
-              text: 'This is tab 1',
377
-              myFunction: () => 'Hello from a function!',
378
-            },
379
-          },
380
-        },
381
-        {
382
-          component: {
383
-            name: 'navigation.playground.TextScreen',
384
-            passProps: {
385
-              text: 'This is tab 2',
386
-            },
387
-          },
388
-        },
389
-      ],
390
-    },
391
-  }
392
-});
393
-```
394
-
395
-### Stack based app (with options example, initialised with 2 screens):
396
-
397
-```js
398
-Navigation.setRoot({
399
-  root: {
400
-    stack: {
401
-      options: {
402
-        topBar: {
403
-          visible: false
404
-        }
405
-      },
406
-      children: [
407
-        {
408
-          component: {
409
-            name: 'navigation.playground.TextScreen',
410
-            passProps: {
411
-              text: 'This is tab 1',
412
-              myFunction: () => 'Hello from a function!',
413
-            }
414
-          }
415
-        },
416
-        {
417
-          component: {
418
-            name: 'navigation.playground.TextScreen',
419
-            passProps: {
420
-              text: 'This is tab 2',
421
-            }
422
-          }
423
-        }
424
-      ]
425
-    }
426
-  }
427
-});
428
-```

+ 0
- 278
docs/docs/screen-api.md View File

@@ -1,278 +0,0 @@
1
-# Screen API
2
-
3
-This API is relevant when in a screen component context - it allows a screen to push other screens, pop screens, change its navigator style, etc. Access to this API is available through the `Navigation` module and expect to receive the current presented component id from screen `props.componentId`.
4
-Component must initialize in a stack in order to push another component.
5
-
6
-## push(componentId, layout)
7
-
8
-Push a new screen into this screen's navigation stack.
9
-
10
-```js
11
-Navigation.push(this.props.componentId, {
12
-  component: {
13
-    name: 'example.PushedScreen',
14
-    passProps: {
15
-      text: 'Pushed screen'
16
-    },
17
-    options: {
18
-      topBar: {
19
-        title: {
20
-          text: 'Pushed screen title'
21
-        }
22
-      }
23
-    }
24
-  }
25
-});
26
-```
27
-
28
-## pop(componentId, mergeOptions?)
29
-
30
-Pop the top screen from this screen's navigation stack.
31
-
32
-```js
33
-Navigation.pop(this.props.componentId);
34
-```
35
-
36
-## popToRoot(componentId, mergeOptions?)
37
-
38
-Pop all the screens until the root from this screen's navigation stack.
39
-
40
-```js
41
-Navigation.popToRoot(this.props.componentId);
42
-```
43
-## popTo(componentId, mergeOptions?)
44
-
45
-Pop the stack to a given component.
46
-
47
-```js
48
-Navigation.popTo(componentId);
49
-```
50
-
51
-## setStackRoot(componentId, params)
52
-
53
-Reset the current navigation stack to a new screen component (the stack root is changed, accepts multiple children).
54
-
55
-```js
56
-Navigation.setStackRoot(this.props.componentId, [
57
-    {
58
-    component: {
59
-          name: 'example.NewRootScreen',
60
-          passProps: {
61
-            text: 'Root screen'
62
-          },
63
-          options: {
64
-            animations: {
65
-              setStackRoot: {
66
-                enabled: true
67
-              }
68
-            }
69
-          }
70
-        }
71
-  }
72
-]);
73
-```
74
-
75
-## showModal(layout = {})
76
-
77
-Show a screen as a modal.
78
-
79
-```js
80
-Navigation.showModal({
81
-  stack: {
82
-    children: [{
83
-      component: {
84
-        name: 'example.ModalScreen',
85
-        passProps: {
86
-          text: 'stack with one child'
87
-        },
88
-        options: {
89
-          topBar: {
90
-            title: {
91
-              text: 'Modal'
92
-            }
93
-          }
94
-        }
95
-      }
96
-    }]
97
-  }
98
-});
99
-```
100
-
101
-## dismissModal(componentId, mergeOptions?)
102
-
103
-Dismiss the current modal.
104
-
105
-```js
106
-Navigation.dismissModal(this.props.componentId);
107
-```
108
-
109
-## dismissAllModals(mergeOptions?)
110
-
111
-Dismiss all the current modals at the same time.
112
-
113
-```js
114
-Navigation.dismissAllModals();
115
-```
116
-
117
-<!-- ## handleDeepLink(params = {})
118
-
119
-Trigger a deep link within the app. See [deep links](https://wix.github.io/react-native-navigation/#/deep-links) for more details about how screens can listen for deep link events.
120
-
121
-```js
122
-this.props.navigator.handleDeepLink({
123
-  link: "chats/2349823023" // the link string (required)
124
-});
125
-```
126
-
127
-> `handleDeepLink` can also be called statically:
128
-```js
129
-  import {Navigation} from 'react-native-navigation';
130
-  Navigation.handleDeepLink(...);
131
-``` -->
132
-
133
-## mergeOptions(componentId, options = {})
134
-
135
-Set options dynamically for component.
136
-
137
-WARNING! this is called after the component has been rendered at least once.
138
-If you want the options to apply as soon as the screen is created, use `static options(passProps){...}` or pass the options as part of the push/modal etc command.
139
-
140
-```js
141
-Navigation.mergeOptions(this.props.componentId, {
142
-  topBar: {
143
-    visible: true,
144
-    title: {
145
-      text: 'Title'
146
-    }
147
-  },
148
-  bottomTabs: {
149
-
150
-  },
151
-  bottomTab: {
152
-
153
-  },
154
-  sideMenu: {
155
-
156
-  },
157
-  overlay: {
158
-
159
-  }
160
-});
161
-```
162
-
163
-<!-- ## toggleDrawer(params = {})
164
-
165
-Toggle the side menu drawer assuming you have one in your app.
166
-
167
-```js
168
-this.props.navigator.toggleDrawer({
169
-  side: 'left', // the side of the drawer since you can have two, 'left' / 'right'
170
-  animated: true, // does the toggle have transition animation or does it happen immediately (optional)
171
-  to: 'open' // optional, 'open' = open the drawer, 'closed' = close it, missing = the opposite of current state
172
-});
173
-``` -->
174
-
175
-
176
-<!-- ## setOnNavigatorEvent(callback)
177
-
178
-Set a handler for navigator events (like nav button press). This would normally go in your component constructor.
179
-Can not be used in conjuction with `addOnNavigatorEvent`.
180
-
181
-```js
182
-// this.onNavigatorEvent will be our handler
183
-this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
184
-```
185
-
186
-## addOnNavigatorEvent(callback)
187
-
188
-Add a handler for navigator events (like nav button press). This would normally go in your component constructor.
189
-If you choose to use `addOnNavigatorEvent` instead of `setOnNavigatorEvent` you will be able to add multiple handlers.
190
-Bear in mind that you can't use both `addOnNavigatorEvent` and `setOnNavigatorEvent`.
191
-`addOnNavigatorEvent` returns a function, that once called will remove the registered handler. -->
192
-
193
-<!-- # Screen Visibility
194
-
195
-`const isVisible = await this.props.navigator.screenIsCurrentlyVisible()`
196
-
197
-## Listen visibility events in onNavigatorEvent handler
198
-
199
-```js
200
-export default class ExampleScreen extends Component {
201
-  constructor(props) {
202
-    super(props);
203
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
204
-  }
205
-  onNavigatorEvent(event) {
206
-    switch(event.id) {
207
-      case 'willAppear':
208
-       break;
209
-      case 'didAppear':
210
-        break;
211
-      case 'willDisappear':
212
-        break;
213
-      case 'didDisappear':
214
-        break;
215
-      case 'willCommitPreview':
216
-        break;
217
-    }
218
-  }
219
-}
220
-```
221
-
222
-## Listen to visibility events globally
223
-
224
-```js
225
-import {ScreenVisibilityListener as RNNScreenVisibilityListener} from 'react-native-navigation';
226
-
227
-export class ScreenVisibilityListener {
228
-
229
-  constructor() {
230
-    this.listener = new RNNScreenVisibilityListener({
231
-      didAppear: ({screen, startTime, endTime, commandType}) => {
232
-        console.log('screenVisibility', `Screen ${screen} displayed in ${endTime - startTime} millis after [${commandType}]`);
233
-      }
234
-    });
235
-  }
236
-
237
-  register() {
238
-    this.listener.register();
239
-  }
240
-
241
-  unregister() {
242
-    if (this.listener) {
243
-      this.listener.unregister();
244
-      this.listener = null;
245
-    }
246
-  }
247
-}
248
-```
249
-
250
-# Listening to tab selected events
251
-In order to listen to `bottomTabSelected` event, set an `onNavigatorEventListener` on screens that are pushed to BottomTab. The event is dispatched to the top most screen pushed to the selected tab's stack.
252
-
253
-```js
254
-export default class ExampleScreen extends Component {
255
-  constructor(props) {
256
-    super(props);
257
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
258
-  }
259
-
260
-  onNavigatorEvent(event) {
261
-	if (event.id === 'bottomTabSelected') {
262
-	  console.log('Tab selected!');
263
-	}
264
-	if (event.id === 'bottomTabReselected') {
265
-	  console.log('Tab reselected!');
266
-	}
267
-  }
268
-}
269
-```
270
-
271
-# Peek and pop (3D touch)
272
-
273
-react-native-navigation supports the [Peek and pop](
274
-https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/#//apple_ref/doc/uid/TP40016543-CH1-SW3) feature by setting a react view reference as a `previewView` parameter when doing a push, more options are available in the `push` section.
275
-
276
-You can define actions and listen for interactions on the pushed screen with the `PreviewActionPress` event.
277
-
278
-Previewed screens will have the prop `isPreview` that can be used to render different things when the screen is in the "Peek" state and will then recieve a navigator event of `willCommitPreview` when in the "Pop" state. -->

+ 0
- 429
docs/docs/styling.md View File

@@ -1,429 +0,0 @@
1
-# Styling Options
2
-
3
-You can style the navigator appearance and behavior by passing an `options` object. This object can be passed when the screen is originally created; can be defined per-screen by setting `static options(passProps)` on the screen component; and can be overridden when a screen is pushed, dynamically (after the screen was already rendered at least once) using `mergeOptions()`.
4
-
5
-The easiest way to style your screen is by adding `static options(passProps)` to your screen React component definition. `passProps` is the same passProps you can specify as part of the push/modal or other command operation.
6
-
7
-```js
8
-export default class StyledScreen extends Component {
9
-  static options(passProps) {
10
-    return {
11
-      topBar: {
12
-        title: {
13
-          text: 'My Screen'
14
-        },
15
-        drawBehind: true,
16
-        visible: false,
17
-        animate: false
18
-      }
19
-    };
20
-  }
21
-
22
-  constructor(props) {
23
-    super(props);
24
-  }
25
-  render() {
26
-    return (
27
-      <View style={{flex: 1}}>...</View>
28
-     );
29
-  }
30
-```
31
-
32
-## Enabling persistent styling properties
33
-In v2 we added `setDefaultOptions` API for styles that should be applied on all components.
34
-
35
-> `setDefaultOptions` Does not update options of existing component, therefore it should be called before `setRoot`
36
-
37
-```js
38
-Navigation.setDefaultOptions({
39
-  topBar: {
40
-    visible: false
41
-  }
42
-});
43
-```
44
-
45
-## Setting styles dynamically
46
-Use the `mergeOptions` method to change a screen's style dynamically. WARNING! these options will be applied on an already rendered screen, after it has been rendered at least once.
47
-
48
-```js
49
-Navigation.mergeOptions(this.props.componentId, {
50
-  topBar: {
51
-    visible: true
52
-  }
53
-});
54
-```
55
-
56
-## Options object format
57
-
58
-### Common options
59
-
60
-```js
61
-{
62
-  statusBar: {
63
-    visible: false,
64
-    style: 'light' | 'dark'
65
-  },
66
-  layout: {
67
-    direction: 'ltr', // Supported directions are: 'rtl', 'ltr'
68
-    backgroundColor: 'white',
69
-    orientation: ['portrait', 'landscape'] // An array of supported orientations
70
-  },
71
-  modalPresentationStyle: 'overCurrentContext', // Supported styles are: 'default', 'formSheet', 'pageSheet', 'overFullScreen', 'overCurrentContext', 'currentContext', 'popover', 'fullScreen' and 'none'. On Android, only overCurrentContext and none are supported.
72
-  topBar: {
73
-    visible: true,
74
-    animate: false, // Controls whether TopBar visibility changes should be animated
75
-    hideOnScroll: true,
76
-    leftButtonColor: 'black',
77
-    rightButtonColor: 'black',
78
-    drawBehind: false,
79
-    testID: 'topBar',
80
-    title: {
81
-      text: 'Title',
82
-      fontSize: 14,
83
-      color: 'red',
84
-      fontFamily: 'Helvetica',
85
-      fontWeight: 'regular', // Available on iOS only, will ignore fontFamily style and use the iOS system fonts instead. Supported weights are: 'regular', 'bold', 'thin', 'ultraLight', 'light', 'medium', 'semibold', 'heavy' and 'black'.
86
-      component: {
87
-        name: 'example.CustomTopBarTitle',
88
-        alignment: 'center'
89
-      }
90
-    },
91
-    subtitle: {
92
-      text: 'Title',
93
-      fontSize: 14,
94
-      color: 'red',
95
-      fontFamily: 'Helvetica',
96
-      fontWeight: 'regular', // Available on iOS only, will ignore fontFamily style and use the iOS system fonts instead. Supported weights are: 'regular', 'bold', 'thin', 'ultraLight', 'light', 'medium', 'semibold', 'heavy' and 'black'.
97
-      alignment: 'center'
98
-    },
99
-    backButton: {
100
-      icon: require('icon.png'),
101
-      visible: true
102
-    },
103
-    background: {
104
-      color: '#00ff00',
105
-      component: {
106
-        name: 'example.CustomTopBarBackground'
107
-      }
108
-    }
109
-  },
110
-  bottomTabs: {
111
-    visible: true,
112
-    animate: false, // Controls whether BottomTabs visibility changes should be animated
113
-    currentTabIndex: 0,
114
-    currentTabId: 'currentTabId',
115
-    testID: 'bottomTabsTestID',
116
-    drawBehind: false,
117
-    backgroundColor: 'white'
118
-  },
119
-  bottomTab: {
120
-    text: 'Tab 1',
121
-    badge: '2',
122
-    badgeColor: 'red',
123
-    dotIndicator: {
124
-      color: 'green', // default red
125
-      size: 8, // default 6
126
-      visible: true // default false
127
-    }
128
-    testID: 'bottomTabTestID',
129
-    icon: require('tab.png'),
130
-    iconColor: 'red',
131
-    selectedIconColor: 'blue',
132
-    textColor: 'red',
133
-    selectedTextColor: 'blue',
134
-    fontFamily: 'Helvetica',
135
-    fontWeight: 'regular', // Available on iOS only, will ignore fontFamily style and use the iOS system fonts instead. Supported weights are: 'regular', 'bold', 'thin', 'ultraLight', 'light', 'medium', 'semibold', 'heavy' and 'black'.
136
-    fontSize: 10
137
-  },
138
-  sideMenu: {
139
-    left: {
140
-      width: 260,
141
-      height: 270,
142
-      visible: false,
143
-      enabled: true
144
-    },
145
-    right: {
146
-      width: 260,
147
-      height: 270,
148
-      visible: false,
149
-      enabled: true
150
-    }
151
-  },
152
-  overlay: {
153
-    interceptTouchOutside: true,
154
-    handleKeyboardEvents: true
155
-  },
156
-  modal: {
157
-    swipeToDismiss: true
158
-  }
159
-  preview: {
160
-    reactTag: 0, // result from findNodeHandle(ref)
161
-    width: 100,
162
-    height: 100,
163
-    commit: false,
164
-    actions: [{
165
-      id: 'ActionId1',
166
-      title: 'Action title',
167
-      style: 'selected', // default, selected, destructive,
168
-      actions: [/* ... */]
169
-    }]
170
-  }  
171
-}
172
-```
173
-
174
-### iOS specific options
175
-```js
176
-{
177
-  statusBar: {
178
-    hideWithTopBar: false,
179
-    blur: true
180
-  },
181
-  popGesture: true,
182
-  backgroundImage: require('background.png'),
183
-  rootBackgroundImage: require('rootBackground.png'),
184
-  topBar: {
185
-    barStyle: 'default' | 'black',
186
-    background: {
187
-      color: 'white',
188
-      translucent: true,
189
-      blur: false
190
-    }
191
-    noBorder: false,
192
-    backButton: {
193
-      title: 'Back',
194
-      showTitle: false
195
-    },
196
-    searchBar: true, // iOS 11+ native UISearchBar inside topBar
197
-    searchBarHiddenWhenScrolling: true,
198
-    searchBarPlaceholder: 'Search', // iOS 11+ SearchBar placeholder
199
-    largeTitle: {
200
-      visible: true,
201
-      fontSize: 30,
202
-      color: 'red',
203
-      fontFamily: 'Helvetica',
204
-      fontWeight: 'regular' // Available on iOS only, will ignore fontFamily style and use the iOS system fonts instead. Supported weights are: 'regular', 'bold', 'thin', 'ultraLight', 'light', 'medium', 'semibold', 'heavy' and 'black'.
205
-    },
206
-  },
207
-  sideMenu: {
208
-    left: {
209
-      shouldStretchDrawer: false, // defaults to true, when false sideMenu contents not stretched when opened past the width
210
-      animationVelocity: 2500 // defaults to 840, high number is a faster sideMenu open/close animation
211
-    },
212
-    right: {
213
-      shouldStretchDrawer: false, // defaults to true, when false sideMenu contents not stretched when opened past the width
214
-      animationVelocity: 2500 // defaults to 840, high number is a faster sideMenu open/close animation
215
-    },
216
-    animationType: 'parallax', // defaults to none if not provided, options are 'parallax', 'door', 'slide', or 'slide-and-scale'    
217
-    openGestureMode: 'entireScreen' | 'bezel'
218
-  }
219
-  bottomTabs: {
220
-    barStyle: 'default' | 'black',
221
-    translucent: true,
222
-    hideShadow: false
223
-  },
224
-  bottomTab: {
225
-    iconInsets: { top: 0, left: 0, bottom: 0, right: 0 },
226
-    selectedIcon: require('selectedTab.png'),
227
-    disableIconTint: true, //set true if you want to disable the icon tinting
228
-    disableSelectedIconTint: true
229
-  }
230
-}
231
-```
232
-
233
-### Android specific options
234
-
235
-```js
236
-{
237
-  statusBar: {
238
-    backgroundColor: 'red',
239
-    drawBehind: true,
240
-    visible: false
241
-  },
242
-  navigationBar: {
243
-    backgroundColor: 'red',
244
-  },
245
-  layout: {
246
-    topMargin: (await Navigation.constants()).statusBarHeight, // Set the layout's top margin
247
-    orientation: ['portrait', 'landscape'] | ['sensorLandscape'], // An array of supported orientations
248
-    componentBackgroundColor: 'red' // Set background color only for components, helps reduce overdraw if background color is set in default options.
249
-  },
250
-  topBar: {
251
-    height: 70, // TopBar height in dp
252
-    backButton: {
253
-      color: 'red'
254
-    },
255
-    borderColor: 'red',
256
-    borderHeight: 1.3,
257
-    elevation: 1.5, // TopBar elevation in dp
258
-    topMargin: 24, // top margin in dp
259
-    title: {
260
-      height: 70, // TitleBar height in dp
261
-      alignment: 'center', // Center title
262
-    }
263
-  },
264
-  bottomTabs: {
265
-    elevation: 8, // BottomTabs elevation in dp
266
-    titleDisplayMode: 'alwaysShow' | 'showWhenActive' | 'alwaysHide' | 'showWhenActiveForce' // Sets the title state for each tab. (showWhenActiveForce to be used when showWhenActive doesn't work, e.g. with three bottom tabs)
267
-  },
268
-  bottomTab: {
269
-    selectedFontSize: 19 // Selected tab font size in sp
270
-  },
271
-  fab: {
272
-    id: 'fab',  // required
273
-    backgroundColor: 'green',
274
-    clickColor: 'blue',
275
-    rippleColor: 'yellow',
276
-    visible: true,
277
-    icon: require('add.png'),
278
-    iconColor: 'white',
279
-    alignHorizontally: 'left', // one of 'left', 'right'
280
-    hideOnScroll: false,
281
-    size: 24,
282
-    actions: [{
283
-      id: 'fab-1',  // required
284
-      backgroundColor: 'green',
285
-      clickColor: 'blue',
286
-      rippleColor: 'yellow',
287
-      visible: true,
288
-      icon: require('add.png'),
289
-      iconColor: 'white',
290
-      size: 24,
291
-    }]
292
-  },
293
-}
294
-```
295
-
296
-### RTL layout usage
297
-In order to set layout direction to RTL use following options:
298
-```javascript
299
-{
300
-  layout: {
301
-    direction: rtl
302
-  },
303
-  ...
304
-}
305
-```
306
-
307
-also __Android__ requires to set `supportsRTL` in _AndroidManifest.xml_
308
-```xml
309
-<application
310
-      android:name=".MainApplication"
311
-+     android:supportsRtl="true"
312
-      ...
313
-      android:theme="@style/AppTheme">
314
-```
315
-
316
-## Styling the StatusBar
317
-If you set any styles related to the Status Bar, make sure that in Xcode > project > Info.plist, the property `View controller-based status bar appearance` is set to `YES`.
318
-
319
-## Custom fonts
320
-If you'd like to use a custom font, you'll first have to edit your project.
321
-
322
-* Android - add the `.ttf` or `.otf` files to `src/main/assets/fonts/`
323
-
324
-* iOS - follow this [guide](https://medium.com/@dabit3/adding-custom-fonts-to-react-native-b266b41bff7f)
325
-
326
-## Custom tab icons
327
-
328
-* Android - add corresponding resolution icons into folders in `android/app/src/main/res`.
329
-For example, `icon_name.png` in each drawable-x folder.
330
-* iOS - drag and drop to `Images.xcassets` in Xcode.
331
-For example, image set `icon_name` in `Images.xcassets` with x1, x2, x3.
332
-
333
-Then, the tab icon can be defined with the following syntax:
334
-
335
-```js
336
-bottomTab: {
337
-  icon: {
338
-    uri: 'icon_name',
339
-    ...
340
-  },
341
-  ...
342
-}
343
-```
344
-
345
-## Customizing screen animations
346
-Animation used for navigation commands that modify the layout hierarchy can be controlled in options. Animations can be modified per command and it's also possible to change the default animation for each command.
347
-
348
-## Animation properties
349
-
350
-The following properties can be animated:
351
-* x
352
-* y
353
-* alpha
354
-* scaleX
355
-* scaleY
356
-* rotationX
357
-* rotationY
358
-* rotation
359
-
360
-```js
361
-{
362
-  from: 0, // Mandatory, initial value
363
-  to: 1, // Mandatory, end value
364
-  duration: 400, // Default value is 300 ms
365
-  startDelay: 100, // Default value is 0
366
-  interpolation: 'accelerate' | 'decelerate' // Optional
367
-}
368
-```
369
-
370
-For example, changing the animation used when the app is first launched (Supported only on Android):
371
-```js
372
-Navigation.setDefaultOptions({
373
-  animations: {
374
-    setRoot: {
375
-      enabled: 'true' | 'false', // Optional, used to enable/disable the animation
376
-      alpha: {
377
-        from: 0,
378
-        to: 1,
379
-        duration: 400,
380
-        startDelay: 100,
381
-        interpolation: 'accelerate'
382
-      }
383
-    }
384
-  }
385
-});
386
-```
387
-
388
-## Customizing navigation commands animation
389
-
390
-Animations for the following set of commands can be customized
391
-* setRoot
392
-* push
393
-* pop
394
-* showModal
395
-* dismissModal
396
-
397
-## Customizing stack command animation
398
-
399
-When *pushing* and *popping* screens to and from a stack, you can control the TopBar, BottomTabs and actual content animations as separately.
400
-
401
-```js
402
-animations: {
403
-  push: {
404
-    enabled: 'true' | 'false', // Optional, used to enable/disable the animation
405
-    topBar: {
406
-      id: 'TEST', // Optional, id of the TopBar we'd like to animate.
407
-      alpha: {
408
-        from: 0,
409
-        to: 1
410
-      }
411
-    },
412
-    bottomTabs: {
413
-      alpha: {
414
-        from: 0,
415
-        to: 1
416
-      }
417
-    },
418
-    content: {
419
-      alpha: {
420
-        from: 0,
421
-        to: 1
422
-      }
423
-    }
424
-  },
425
-  pop: {
426
-    ...
427
-  }
428
-}
429
-```

+ 0
- 101
docs/docs/third-party.md View File

@@ -1,101 +0,0 @@
1
-# Third Party Libraries Support
2
-
3
-## Redux
4
-
5
-Create a HOC which provides the redux store.
6
-```js
7
-import { Provider } from 'react-redux';
8
-
9
-let store;
10
-function ReduxProvider(Component) {
11
-    store = store || createStore({});
12
-
13
-    return (props) => (
14
-        <Provider store={store}>
15
-            <Component {...props} />
16
-        </Provider>
17
-    );
18
-}
19
-```
20
-Wrap all Screens, which need the redux store, with the HOC.
21
-```js
22
-import { Navigation } from 'react-native-navigation';
23
-
24
-export default () => {
25
-    Navigation.registerComponent('TestScreen', () => ReduxProvider(TestScreen), () => TestScreen);
26
-}
27
-```
28
-
29
-For more information about how to set up redux read the [react-redux docs](https://react-redux.js.org/)
30
-
31
-## react-native-vector-icons
32
-
33
-This library can be used to set icons as the following example does.
34
-For available icons read the [react-native-vector-icons docs](https://github.com/oblador/react-native-vector-icons).
35
-
36
-```js
37
-import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
38
-import { Navigation } from 'react-native-navigation';
39
-
40
-export default function startApp() {
41
-  Promise.all([
42
-    MaterialIcons.getImageSource('home', 25),
43
-    MaterialIcons.getImageSource('menu', 25),
44
-    MaterialIcons.getImageSource('search', 25),
45
-    MaterialIcons.getImageSource('add', 25),
46
-  ]).then(([homeIcon, menuIcon, searchIcon, addIcon]) => {
47
-    Navigation.setRoot({
48
-      root: {
49
-        sideMenu: {
50
-          id: 'main',
51
-          left: {
52
-            component: {
53
-              name: 'App.FirstBottomTab.HomeScreen',
54
-            },
55
-          },
56
-          center: {
57
-            bottomTabs: {
58
-              id: 'BottomTabs',
59
-              children: [{
60
-                stack: {
61
-                  id: 'FirstBottomTab',
62
-                  children: [{
63
-                    component: {
64
-                      name: 'App.FirstBottomTab.HomeScreen',
65
-                    },
66
-                  }],
67
-                  options: {
68
-                    topBar: {
69
-                      title: {
70
-                        text: 'Home',
71
-                      },
72
-                      leftButtons: [{
73
-                        id: 'sideMenu',
74
-                        icon: menuIcon,
75
-                      }],
76
-                      rightButtons: [{
77
-                        id: 'search',
78
-                        icon: searchIcon,
79
-                      }],
80
-                    },
81
-                    bottomTab: {
82
-                      text: 'FirstBottomTab',
83
-                      icon: homeIcon,
84
-                    },
85
-                    fab: {
86
-                      id: 'addRecipe',
87
-                      icon: addIcon,
88
-                    },
89
-                  },
90
-                },
91
-              }],
92
-            },
93
-          },
94
-        },
95
-      },
96
-    });
97
-  });
98
-}
99
-```
100
-
101
-Its also possible to to define custom icons without react-native-vector-icons within the iOS and Android project as described [here](https://wix.github.io/react-native-navigation/#/docs/styling?id=custom-tab-icons).

+ 0
- 184
docs/docs/top-level-api-migration.md View File

@@ -1,184 +0,0 @@
1
-# Top Level API Migration
2
-
3
-In order to make our API homogenous as much as possible, we provide setRoot function that will receive layout of any kind.
4
-
5
-## registerComponent
6
-Registering screens without redux or any wrapping providers is the same as in v1.
7
-```js
8
-Navigation.registerComponent('example.FirstTabScreen', () => FirstTabScreen);
9
-```
10
-
11
-### Registering screens with wrapping provider component
12
-```js
13
-Navigation.registerComponent('navigation.playground.ReduxScreen', () => (props) => (
14
-  <Provider store={reduxStore}>
15
-    <ReduxScreen {...props} />
16
-  </Provider>
17
-), () => ReduxScreen);
18
-```
19
-!>Note that `Navigation.registerComponentWithRedux` is deprecated
20
-
21
-
22
-## startTabBasedApp(params) -> setRoot({bottomTabs})
23
-
24
-```js
25
-Navigation.setRoot({
26
-  root: {
27
-    bottomTabs: {
28
-      children: [{
29
-        stack: {
30
-          children: [{
31
-            component: {
32
-              name: 'example.FirstTabScreen',
33
-              passProps: {
34
-                text: 'This is tab 1'
35
-              }
36
-            }
37
-          }],
38
-          options: {
39
-            bottomTab: {
40
-              text: 'Tab 1',
41
-              icon: require('../images/one.png'),
42
-              testID: 'FIRST_TAB_BAR_BUTTON'
43
-            }
44
-          }
45
-        }
46
-      },
47
-      {
48
-        component: {
49
-          name: 'navigation.playground.TextScreen',
50
-          passProps: {
51
-            text: 'This is tab 2'
52
-          },
53
-          options: {
54
-            bottomTab: {
55
-              text: 'Tab 2',
56
-              icon: require('../images/two.png'),
57
-              testID: 'SECOND_TAB_BAR_BUTTON'
58
-            }
59
-          }
60
-        }
61
-      }]
62
-    }
63
-  }
64
-});
65
-```
66
-
67
-## startSingleScreenApp(params) -> setRoot({stack})
68
-
69
-Change your app root into an app based on a single screen (like the iOS Calendar or Settings app). The screen will receive its own navigation stack with a native nav bar
70
-
71
-```js
72
-Navigation.setRoot({
73
-  root: {
74
-    stack: {
75
-      children: [{
76
-        component: {
77
-          name: 'example.WelcomeScreen',
78
-          passProps: {
79
-            text: 'stack with one child'
80
-          }
81
-        }
82
-      }],
83
-      options: {
84
-        topBar: {
85
-          title: {
86
-            text: 'Welcome screen'
87
-          }
88
-        }
89
-      }
90
-    }
91
-  }
92
-});
93
-```
94
-
95
-## showModal(params = {}) -> showModal(layout = {})
96
-
97
-Show a screen as a modal.
98
-
99
-```js
100
-Navigation.showModal({
101
-  stack: {
102
-    children: [{
103
-      component: {
104
-        name: 'example.ModalScreen',
105
-        passProps: {
106
-          text: 'stack with one child'
107
-        },
108
-        options: {
109
-          topBar: {
110
-            title: {
111
-              text: 'Modal with stack'
112
-            }
113
-          }
114
-        }
115
-      }
116
-    }]
117
-  }
118
-});
119
-```
120
-
121
-## dismissModal(params = {}) -> dismissModal(componentId)
122
-
123
-Dismiss the current modal.
124
-
125
-```js
126
-Navigation.dismissModal(this.props.componentId);
127
-```
128
-
129
-## dismissAllModals(params = {}) -> dismissAllModals()
130
-
131
-Dismiss all the current modals at the same time.
132
-
133
-```js
134
-Navigation.dismissAllModals();
135
-```
136
-
137
-<!-- ## showLightBox(params = {}) - Use showOverlay
138
-
139
-Show a screen as a lightbox.
140
-
141
-```js
142
-Navigation.showLightBox({
143
-  screen: 'example.LightBoxScreen', // unique ID registered with Navigation.registerScreen
144
-  passProps: {}, // simple serializable object that will pass as props to the lightbox (optional)
145
-  style: {
146
-    backgroundBlur: 'dark', // 'dark' / 'light' / 'xlight' / 'none' - the type of blur on the background
147
-    backgroundColor: '#ff000080', // tint color for the background, you can specify alpha here (optional)
148
-    tapBackgroundToDismiss: true // dismisses LightBox on background taps (optional)
149
-  }
150
-});
151
-``` -->
152
-
153
-<!-- ## dismissLightBox(params = {})
154
-
155
-Dismiss the current lightbox.
156
-
157
-```js
158
-Navigation.dismissLightBox();
159
-``` -->
160
-
161
-<!-- ## handleDeepLink(params = {})
162
-
163
-Trigger a deep link within the app. See [deep links](https://wix.github.io/react-native-navigation/#/deep-links) for more details about how screens can listen for deep link events.
164
-
165
-```js
166
-Navigation.handleDeepLink({
167
-  link: 'link/in/any/format',
168
-  payload: '' // (optional) Extra payload with deep link
169
-});
170
-``` -->
171
-
172
-<!-- ## registerScreen(screenID, generator)
173
-
174
-This is an internal function you probably don't want to use directly. If your screen components extend `Screen` directly (`import { Screen } from 'react-native-navigation'`), you can register them directly with `registerScreen` instead of with `registerComponent`. The main benefit of using `registerComponent` is that it wraps your regular screen component with a `Screen` automatically.
175
-
176
-```js
177
-Navigation.registerScreen('example.AdvancedScreen', () => AdvancedScreen);
178
-```
179
-
180
-## getCurrentlyVisibleScreenId()
181
-
182
-In some cases you might need the id of the currently visible screen. This method returns the unique id of the currently visible screen:
183
-`const visibleScreenInstanceId = await Navigation.getCurrentlyVisibleScreenId()`
184
-In order to have any use of this method, you'd need to map instanceId to screens your self. -->

+ 0
- 105
docs/docs/top-level-api.md View File

@@ -1,105 +0,0 @@
1
-# Top Level API
2
-
3
-So as to make the navigation API as consistent and homogenous as possible, we begin with a single, unifying function -- setRoot. SetRoot receives properties for any kind of layout, whether tabs or stacks, or a combination of both (as seen in this example.)
4
-
5
-See [Layout types](docs/layout-types)
6
-
7
-
8
-## setRoot(layout)
9
-
10
-```js
11
-Navigation.setRoot({
12
-  root: {
13
-    bottomTabs: {
14
-      children: [{
15
-        stack: {
16
-          children: [{
17
-            component: {
18
-              name: 'example.FirstTabScreen',
19
-              passProps: {
20
-                text: 'This is tab 1'
21
-              }
22
-            }
23
-          }],
24
-          options: {
25
-            bottomTab: {
26
-              text: 'Tab 1',
27
-              icon: require('../images/one.png'),
28
-              testID: 'FIRST_TAB_BAR_BUTTON'
29
-            }
30
-          }
31
-        }
32
-      },
33
-      {
34
-        component: {
35
-          name: 'navigation.playground.TextScreen',
36
-          passProps: {
37
-            text: 'This is tab 2'
38
-          },
39
-          options: {
40
-            bottomTab: {
41
-              text: 'Tab 2',
42
-              icon: require('../images/two.png'),
43
-              testID: 'SECOND_TAB_BAR_BUTTON'
44
-            }
45
-          }
46
-        }
47
-      }]
48
-    }
49
-  }
50
-});
51
-```
52
-
53
-## showOverlay(layout = {})
54
-
55
-Shows a component as an overlay.
56
-
57
-```js
58
-Navigation.showOverlay({
59
-  component: {
60
-    name: 'example.Overlay',
61
-    options: {
62
-      overlay: {
63
-        interceptTouchOutside: true
64
-      },
65
-      layout: {
66
-        componentBackgroundColor: 'transparent', // Use this if you want your background to be transparent.
67
-      },
68
-    }
69
-  }
70
-});
71
-```
72
-
73
-## dismissOverlay(componentId)
74
-
75
-Dismisses an overlay matching the given overlay componentId.
76
-
77
-```js
78
-Navigation.dismissOverlay(this.props.componentId);
79
-```
80
-
81
-
82
-<!-- ## handleDeepLink(params = {})
83
-
84
-Triggers a deep link within the app. See [deep links](https://wix.github.io/react-native-navigation/#/deep-links) for more details about how screens can listen for deep link events.
85
-
86
-```js
87
-Navigation.handleDeepLink({
88
-  link: 'link/in/any/format',
89
-  payload: '' // (optional) Extra payload with deep link
90
-});
91
-``` -->
92
-
93
-<!-- ## registerScreen(screenID, generator)
94
-
95
-This is an internal function you probably don't want to use directly. If your screen components extend `Screen` directly (`import { Screen } from 'react-native-navigation'`), you can register them directly with `registerScreen` instead of with `registerComponent`. The main benefit of using `registerComponent` is that it wraps your regular screen component with a `Screen` automatically.
96
-
97
-```js
98
-Navigation.registerScreen('example.AdvancedScreen', () => AdvancedScreen);
99
-```
100
-
101
-## getCurrentlyVisibleScreenId()
102
-
103
-In some cases you might need the id of the currently visible screen. This method returns the unique id of the currently visible screen:
104
-`const visibleScreenInstanceId = await Navigation.getCurrentlyVisibleScreenId()`
105
-In order to have any use of this method, you'd need to map instanceId to screens yourself. -->

+ 0
- 177
docs/docs/topBar-buttons.md View File

@@ -1,177 +0,0 @@
1
-# Button options
2
-
3
-The following options can be used to customise buttons.
4
-
5
-```js
6
-{
7
-  id: 'buttonOne',
8
-  icon: require('icon.png'),
9
-  component: {
10
-    name: 'example.CustomButtonComponent'
11
-  },
12
-  text: 'Button one',
13
-  enabled: true,
14
-  disableIconTint: false,
15
-  color: 'red',
16
-  disabledColor: 'black',
17
-  testID: 'buttonOneTestID',
18
-  fontFamily: 'Helvetica',
19
-  fontSize: 10
20
-  fontWeight: 'regular', // Available on iOS only, will ignore fontFamily style and use the iOS system fonts instead. Supported weights are: 'regular', 'bold', 'thin', 'ultraLight', 'light', 'medium', 'semibold', 'heavy' and 'black'.
21
-  // Android only
22
-  showAsAction: 'ifRoom', // See below for details.
23
-  // iOS only
24
-  systemItem: 'done', // Sets a system bar button item as the icon. Matches UIBarButtonSystemItem naming. See below for details.
25
-}
26
-```
27
-
28
-## iOS System Items
29
-On iOS, UIKit supplies some common bar button glyphs for developers to use. The following values can be supplied as values to to `systemItem` to use them as an icon for your button.
30
-
31
-* `done`
32
-* `cancel`
33
-* `edit`
34
-* `save`
35
-* `add`
36
-* `flexibleSpace`
37
-* `fixedSpace`
38
-* `compose`
39
-* `reply`
40
-* `action`
41
-* `organize`
42
-* `bookmarks`
43
-* `search`
44
-* `refresh`
45
-* `stop`
46
-* `camera`
47
-* `trash`
48
-* `play`
49
-* `pause`
50
-* `rewind`
51
-* `fastForward`
52
-* `undo`
53
-* `redo`
54
-
55
-More information about these glyphs can be found in [Apple's Human Interface Guidelines](https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/system-icons/).
56
-
57
-
58
-## Android showAsAction
59
-
60
-The keyword `showAsAction` configures when and how an item should appear as an action item in the app bar. 
61
-A menu item can appear as an action item only when the activity includes an app bar.
62
-
63
-* `always`
64
-* `ifRoom`
65
-* `never`
66
-* `withText`
67
-
68
-[More info about `showAsAction` values](https://developer.android.com/guide/topics/resources/menu-resource)
69
-
70
-# Declaring Buttons statically
71
-
72
-Buttons can be defined in a screen's options:
73
-
74
-```js
75
-class MyScreen extends Component {
76
-  static options(passProps) {
77
-    return {
78
-      topBar: {
79
-        leftButtons: [
80
-          {
81
-            id: 'buttonOne',
82
-            icon: require('icon.png')
83
-          }
84
-        ],
85
-        rightButtons: [],
86
-      }
87
-    };
88
-  }
89
-  
90
-}
91
-```
92
-
93
-# Declaring buttons dynamically
94
-
95
-TopBar buttons can be declared dynamically as well when adding a screen to the layout hierarchy.
96
-
97
-```js
98
-Navigation.push(this.props.componentId, {
99
-  component: {
100
-    name: 'navigation.playground.PushedScreen',
101
-    options: {
102
-      topBar: {
103
-        rightButtons: [
104
-          {
105
-            id: 'buttonOne',
106
-            icon: require('icon.png')
107
-          }
108
-        ]
109
-      }
110
-    }
111
-  }
112
-}
113
-```
114
-
115
-# Handling button press events
116
-
117
-Navigation sends events on button clicks, to which you can subscribe from anywhere using `Navigation.events().registerNavigationButtonPressedListener((event) => {})`.
118
-Additionally the component can listen to the button clicks just for its own buttons (via componentId) by using `events().bindComponent(this)`.
119
-This has to be called if you want the component to handle navigation events, such as navigationButtonPressed.
120
-Example:
121
-
122
-```js
123
-class MyScreen extends Component {
124
-  static options(passProps) {
125
-    return {
126
-      topBar: {
127
-        rightButtons: {
128
-          id: 'buttonOne',
129
-          icon: require('icon.png')
130
-        }
131
-      }
132
-    };
133
-  }
134
-
135
-  constructor(props) {
136
-    super(props);
137
-    Navigation.events().bindComponent(this); // <== Will be automatically unregistered when unmounted
138
-  }
139
-
140
-  navigationButtonPressed({ buttonId }) {
141
-    // will be called when "buttonOne" is clicked
142
-  }
143
-}
144
-```
145
-
146
-# Modifying buttons at runtime
147
-
148
-As buttons are part of a screen's options, they can be modified like any other styling option using the `mergeOptions` command.
149
-
150
-## Setting buttons
151
-
152
-The following command will set the screen's right buttons. If the screen already has Right Buttons declared - they will be overridden.
153
-
154
-```js
155
-Navigation.mergeOptions(this.props.componentId, {
156
-  topBar: {
157
-    rightButtons: [
158
-      {
159
-        id: 'myDynamicButton',
160
-        text: 'My Button'
161
-      }
162
-    ]
163
-  }
164
-});
165
-```
166
-
167
-## Removing buttons
168
-
169
-Buttons can be removed by setting zero buttons, as shown in the snippet below.
170
-
171
-```js
172
-Navigation.mergeOptions(this.props.componentId, {
173
-  topBar: {
174
-    rightButtons: []
175
-  }
176
-});
177
-```

+ 0
- 65
docs/index.html View File

@@ -1,65 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en">
3
-
4
-<head>
5
-  <meta charset="UTF-8">
6
-  <title>React Native Navigation - truly native navigation for iOS and Android</title>
7
-  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
8
-  <meta name="description" content="React Native Navigation - truly native navigation for iOS and Android">
9
-  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
10
-  <link rel="shortcut icon" href="_images/favicon.ico" type="image/x-icon">
11
-  <link rel="icon" href="_images/favicon.ico" type="image/x-icon">
12
-  <link rel="stylesheet" href="https://unpkg.com/docsify@4.7.1/themes/vue.css">
13
-
14
-  <style>
15
-    /* diff syntax highlighting */
16
-    .token.inserted {
17
-      color: #42b983;
18
-      background-color: #f0fff4;
19
-      border-bottom: none;
20
-    }
21
-
22
-    .token.deleted {
23
-      color: #f66;
24
-      background-color: #ffeef0;
25
-      text-decoration: none;
26
-    }
27
-  </style>
28
-</head>
29
-
30
-<body>
31
-  <div id="app">Please wait...</div>
32
-  <script src="https://unpkg.com/docsify-copy-code@2"></script>
33
-  <script>
34
-    window.$docsify = {
35
-      name: 'React Native Navigation',
36
-      repo: 'wix/react-native-navigation',
37
-      themeColor: '#21B8F0',
38
-      search: 'auto',
39
-      loadSidebar: true,
40
-      alias: {
41
-        '/api/_sidebar.md': '/api/_sidebar.md',
42
-        '/.*/_sidebar.md': '/_sidebar.md'
43
-      },
44
-      subMaxLevel: 2,
45
-      auto2top: true,
46
-    }
47
-  </script>
48
-  <script src="https://unpkg.com/docsify@4.7.1/lib/docsify.min.js"></script>
49
-  <script src="https://unpkg.com/docsify@4.7.1/lib/plugins/search.min.js"></script>
50
-  <script src="https://unpkg.com/prismjs/components/prism-typescript.min.js"></script>
51
-  <script src="https://unpkg.com/prismjs/components/prism-jsx.min.js"></script>
52
-  <script src="https://unpkg.com/prismjs/components/prism-java.min.js"></script>
53
-  <script src="https://unpkg.com/prismjs/components/prism-c.min.js"></script>
54
-  <script src="https://unpkg.com/prismjs/components/prism-objectivec.min.js"></script>
55
-  <script src="https://unpkg.com/prismjs/components/prism-diff.min.js"></script>
56
-
57
-  <!-- this allows us to re-run docs even when offline -->
58
-  <script>
59
-    if (typeof navigator.serviceWorker !== 'undefined') {
60
-      navigator.serviceWorker.register('sw.js')
61
-    }
62
-  </script>
63
-</body>
64
-
65
-</html>

+ 0
- 83
docs/sw.js View File

@@ -1,83 +0,0 @@
1
-/* ===========================================================
2
- * docsify sw.js
3
- * ===========================================================
4
- * Copyright 2016 @huxpro
5
- * Licensed under Apache 2.0
6
- * Register service worker.
7
- * ========================================================== */
8
-
9
-const RUNTIME = 'docsify'
10
-const HOSTNAME_WHITELIST = [
11
-  self.location.hostname,
12
-  'fonts.gstatic.com',
13
-  'fonts.googleapis.com',
14
-  'unpkg.com'
15
-]
16
-
17
-// The Util Function to hack URLs of intercepted requests
18
-const getFixedUrl = (req) => {
19
-  var now = Date.now()
20
-  var url = new URL(req.url)
21
-
22
-  // 1. fixed http URL
23
-  // Just keep syncing with location.protocol
24
-  // fetch(httpURL) belongs to active mixed content.
25
-  // And fetch(httpRequest) is not supported yet.
26
-  url.protocol = self.location.protocol
27
-
28
-  // 2. add query for caching-busting.
29
-  // Github Pages served with Cache-Control: max-age=600
30
-  // max-age on mutable content is error-prone, with SW life of bugs can even extend.
31
-  // Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
32
-  // Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
33
-  if (url.hostname === self.location.hostname) {
34
-    url.search += (url.search ? '&' : '?') + 'cache-bust=' + now
35
-  }
36
-  return url.href
37
-}
38
-
39
-/**
40
- *  @Lifecycle Activate
41
- *  New one activated when old isnt being used.
42
- *
43
- *  waitUntil(): activating ====> activated
44
- */
45
-self.addEventListener('activate', event => {
46
-  event.waitUntil(self.clients.claim())
47
-})
48
-
49
-/**
50
- *  @Functional Fetch
51
- *  All network requests are being intercepted here.
52
- *
53
- *  void respondWith(Promise<Response> r)
54
- */
55
-self.addEventListener('fetch', event => {
56
-  // Skip some of cross-origin requests, like those for Google Analytics.
57
-  if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
58
-    // Stale-while-revalidate
59
-    // similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
60
-    // Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
61
-    const cached = caches.match(event.request)
62
-    const fixedUrl = getFixedUrl(event.request)
63
-    const fetched = fetch(fixedUrl, { cache: 'no-store' })
64
-    const fetchedCopy = fetched.then(resp => resp.clone())
65
-
66
-    // Call respondWith() with whatever we get first.
67
-    // If the fetch fails (e.g disconnected), wait for the cache.
68
-    // If there’s nothing in cache, wait for the fetch.
69
-    // If neither yields a response, return offline pages.
70
-    event.respondWith(
71
-      Promise.race([fetched.catch(_ => cached), cached])
72
-        .then(resp => resp || fetched)
73
-        .catch(_ => { /* eat any errors */ })
74
-    )
75
-
76
-    // Update the cache with the version we fetched (only for ok status)
77
-    event.waitUntil(
78
-      Promise.all([fetchedCopy, caches.open(RUNTIME)])
79
-        .then(([response, cache]) => response.ok && cache.put(event.request, response))
80
-        .catch(_ => { /* eat any errors */ })
81
-    )
82
-  }
83
-})

+ 3
- 2
package.json View File

@@ -44,7 +44,8 @@
44 44
     "prerelease": "npm run build",
45 45
     "release": "node ./scripts/release",
46 46
     "local-docs": "node ./scripts/local-docs",
47
-    "gen-docs": "ts-node ./scripts/gen-docs/Main"
47
+    "gen-docs": "ts-node ./scripts/gen-docs/Main",
48
+    "docusaurus": "npm start --prefix website"
48 49
   },
49 50
   "peerDependencies": {
50 51
     "react": "*",
@@ -160,4 +161,4 @@
160 161
       }
161 162
     }
162 163
   }
163
-}
164
+}

docs/docs/Installing.md → website/docs/Installing.mdx View File

@@ -1,4 +1,8 @@
1
-# Installing
1
+---
2
+id: installing
3
+title: Installation
4
+sidebar_label: Installation
5
+---
2 6
 
3 7
 ## Requirements
4 8
 * node >= 8
@@ -7,79 +11,55 @@
7 11
 ## npm
8 12
 * `npm install --save react-native-navigation`
9 13
 
10
-## Installing with react-native link
11
-If you're using RN 0.60 or higher, you can link RNN automatically with react-native link. Otherwise, follow the manual installation steps. Unlike most other libraries, react-native-navigation requires you to make a few changes to native files. To make all the necessary changes, run `react-native link react-native-navigation` in your project's root folder. Make sure to commit the changes introduced by the link script.
14
+## Installing with `react-native link`
15
+If you're using RN 0.60 or higher, you can link RNN automatically with react-native link.
12 16
 
13
-If the link script completed successfully, you're good to go! If one of the steps failed, you'll need to complete the relevant step in the manual installation steps below.
17
+Unlike most other libraries, react-native-navigation requires you to make a few changes to native files. To make all the necessary changes, run 
14 18
 
15
-## Manual Installation
16
-If installation with react-native link did not work, follow the manual installation steps.
17
-
18
-### iOS
19
-
20
-> Make sure your Xcode is updated. We recommend editing `.h` and `.m` files in Xcode as the IDE will usually point out common errors.
21
-
22
-#### Native Installation
23
-
24
-1. In Xcode, in Project Navigator (left pane), right-click on the `Libraries` > `Add files to [project name]`. Add `node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.xcodeproj` ([screenshots](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking)).
19
+```react-native link react-native-navigation```
25 20
 
26
-2. In Xcode, in Project Navigator (left pane), click on your project (top), then click on your *target* row (on the "project and targets list", which is on the left column of the right pane) and select the `Build Phases` tab (right pane). In the `Link Binary With Libraries` section add `libReactNativeNavigation.a` ([screenshots](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-2)).
27
-
28
-	a. If you're seeing an error message in Xcode such as:
29
-	```
30
-	'ReactNativeNavigation/ReactNativeNavigation.h' file not found.
31
-	```
32
-	You may also need to add a Header Search Path: ([screenshots](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-3)).
33
-	```objectivec
34
-	$(SRCROOT)/../node_modules/react-native-navigation/lib/ios
35
-	```
21
+in your project's root folder. Make sure to commit the changes introduced by the link script.
36 22
 
37
-3. In Xcode, you will need to edit this file: `AppDelegate.m`. This function is the main entry point for your app:
23
+If the link script completed successfully, you're good to go! If one of the steps failed, you'll need to complete the relevant step in the manual installation steps bellow.
38 24
 
39
-	```objectivec
40
-	 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... }
25
+## Displaying the app root
41 26
 
42
-	```
27
+### Update index.js file
28
+`index.js` is typically used as an entry point into the app. It's first parsed and executed by the JS engine, therefore we'll want to show our UI from there.
43 29
 
44
-	Its content should look like this:
45
-	```objectivec
46
-	#import "AppDelegate.h"
30
+The following diff demonstrates changes needed to be made to `index.js`, initialized by `react-native init`.
47 31
 
48
-	#import <React/RCTBundleURLProvider.h>
49
-	#import <React/RCTRootView.h>
50
-	#import <ReactNativeNavigation/ReactNativeNavigation.h>
32
+```diff
33
++import { Navigation } from "react-native-navigation";
34
+-import {AppRegistry} from 'react-native';
35
+import App from "./App";
36
+-import {name as appName} from './app.json';
51 37
 
52
-	@implementation AppDelegate
38
+-AppRegistry.registerComponent(appName, () => App);
39
++Navigation.registerComponent('com.myApp.WelcomeScreen', () => App);
53 40
 
54
-	- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
55
-	{
56
-		NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
57
-		[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
41
++Navigation.events().registerAppLaunchedListener(() => {
42
++   Navigation.setRoot({
43
++     root: {
44
++       stack: {
45
++         component: {
46
++           name: 'com.myApp.WelcomeScreen'
47
++         }
48
++       }
49
++     }
50
++  });
51
++});
52
+```
58 53
 
59
-		return YES;
60
-	}
54
+⚠️ we use the layout type `component` here, which renders a React component but does not allow you to navigate to others. See [Usage](docs/Usage.md) and [LayoutTypes](docs/layout-types.md) for more options.
55
+___
61 56
 
62
-	@end
63
-	```
57
+## Manual Installation
58
+If installation with react-native link did not work, follow the manual installation steps below.
64 59
 
65
-    a. If, in Xcode, you see the following error message in `AppDelegate.m` next to `#import "RCTBundleURLProvider.h"`: 
66
-  	```
67
-  	! 'RCTBundleURLProvider.h' file not found
68
-  	```
69
-  	This is because the `React` scheme is missing from your project. You can verify this by opening the `Product` menu and the `Scheme` submenu. 
70
-  	To make the `React` scheme available to your project, run `npm install -g react-native-git-upgrade` followed by `react-native-git-upgrade`. Once this is done, you can click back to the menu in Xcode: `Product -> Scheme -> Manage Schemes`, then click '+' to add a new scheme. From the `Target` menu, select "React", and click the checkbox to make the scheme `shared`. This should make the error disappear.
60
+### iOS
71 61
 
72
-    b. If, in Xcode, you see the following warning message in `AppDelegate.m` next to `#import "@implementation AppDelegate"`:
73
-  	```
74
-  	Class 'AppDelegate' does not conform to protocol 'RCTBridgeDelegate'
75
-  	```
76
-  	You can remove `RCTBridgeDelegate` from this file: `AppDelegate.h`:
77
-  	```diff
78
-  	- #import <React/RCTBridgeDelegate.h>
79
-  	- @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
80
-  	+ @interface AppDelegate : UIResponder <UIApplicationDelegate>
81
-  		...
82
-  	```
62
+> Make sure your Xcode is updated. We recommend editing `.h` and `.m` files in Xcode as the IDE will usually point out common errors.
83 63
 
84 64
 #### Installation with CocoaPods
85 65
 
@@ -127,9 +107,73 @@ end
127 107
 
128 108
 2. `cd ios && pod install`
129 109
 
110
+#### Native Installation
111
+
112
+If all else fails, we can always try and install the hardcore way:
113
+
114
+1. In Xcode, in Project Navigator (left pane), right-click on the `Libraries` > `Add files to [project name]`. Add `node_modules/react-native-navigation/lib/ios/ReactNativeNavigation.xcodeproj` ([screenshots](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking)).
115
+
116
+2. In Xcode, in Project Navigator (left pane), click on your project (top), then click on your *target* row (on the "project and targets list", which is on the left column of the right pane) and select the `Build Phases` tab (right pane). In the `Link Binary With Libraries` section add `libReactNativeNavigation.a` ([screenshots](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-2)).
117
+
118
+  a. If you're seeing an error message in Xcode such as:
119
+  ```
120
+  'ReactNativeNavigation/ReactNativeNavigation.h' file not found.
121
+  ```
122
+  You may also need to add a Header Search Path: ([screenshots](https://facebook.github.io/react-native/docs/linking-libraries-ios.html#step-3)).
123
+  ```objectivec
124
+  $(SRCROOT)/../node_modules/react-native-navigation/lib/ios
125
+  ```
126
+
127
+3. In Xcode, you will need to edit this file: `AppDelegate.m`. This function is the main entry point for your app:
128
+
129
+  ```objectivec
130
+   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... }
131
+
132
+  ```
133
+
134
+  Its content should look like this:
135
+  ```objectivec
136
+  #import "AppDelegate.h"
137
+
138
+  #import <React/RCTBundleURLProvider.h>
139
+  #import <React/RCTRootView.h>
140
+  #import <ReactNativeNavigation/ReactNativeNavigation.h>
141
+
142
+  @implementation AppDelegate
143
+
144
+  -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
145
+  {
146
+    NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
147
+    [ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];
148
+
149
+    return YES;
150
+  }
151
+
152
+  @end
153
+  ```
154
+
155
+    a. If, in Xcode, you see the following error message in `AppDelegate.m` next to `#import "RCTBundleURLProvider.h"`: 
156
+    ```
157
+    ! 'RCTBundleURLProvider.h' file not found
158
+    ```
159
+    This is because the `React` scheme is missing from your project. You can verify this by opening the `Product` menu and the `Scheme` submenu. 
160
+    To make the `React` scheme available to your project, run `npm install -g react-native-git-upgrade` followed by `react-native-git-upgrade`. Once this is done, you can click back to the menu in Xcode: `Product -> Scheme -> Manage Schemes`, then click '+' to add a new scheme. From the `Target` menu, select "React", and click the checkbox to make the scheme `shared`. This should make the error disappear.
161
+
162
+    b. If, in Xcode, you see the following warning message in `AppDelegate.m` next to `#import "@implementation AppDelegate"`:
163
+    ```
164
+    Class 'AppDelegate' does not conform to protocol 'RCTBridgeDelegate'
165
+    ```
166
+    You can remove `RCTBridgeDelegate` from this file: `AppDelegate.h`:
167
+    ```diff
168
+    - #import <React/RCTBridgeDelegate.h>
169
+    - @interface AppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
170
+    + @interface AppDelegate : UIResponder <UIApplicationDelegate>
171
+      ...
172
+    ```
173
+
130 174
 ### Android
131 175
 
132
-> Make sure your Android Studio installation is updated. We recommend editing `gradle` and `java` files in Android Studio as the IDE will suggest fixes and point out errors, this way you avoid most common pitfalls.
176
+> Make sure your Android Studio installation is up to date. We recommend editing `gradle` and `java` files in Android Studio as the IDE will suggest fixes and point out errors, this way you avoid most common pitfalls.
133 177
 
134 178
 #### 1 Update `android/build.gradle`:
135 179
 
@@ -144,34 +188,34 @@ buildscript {
144 188
 +   RNNKotlinVersion = "1.3.61" // Or any version above 1.3.x
145 189
 +   RNNKotlinStdlib = "kotlin-stdlib-jdk8"
146 190
   }
147
-	repositories {
191
+  repositories {
148 192
         google()
149 193
         jcenter()
150 194
 +        mavenLocal()
151 195
 +        mavenCentral()
152
-	}
153
-	dependencies {
196
+  }
197
+  dependencies {
154 198
 +        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61" // Or whatever Kotlin version you've specified above
155
-+        classpath 'com.android.tools.build:gradle:3.4.2' // Or higher
199
++        classpath 'com.android.tools.build:gradle:3.5.3' // Or higher
156 200
 -        classpath 'com.android.tools.build:gradle:2.2.3'
157
-	}
201
+  }
158 202
 }
159 203
 
160 204
 allprojects {
161
-	repositories {
162
-+		google()
163
-		mavenLocal()
164
-		jcenter()
165
-		maven {
166
-			// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
167
-			url "$rootDir/../node_modules/react-native/android"
168
-		}
205
+  repositories {
206
++   google()
207
+    mavenLocal()
208
+    jcenter()
209
+    maven {
210
+      // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
211
+      url "$rootDir/../node_modules/react-native/android"
212
+    }
169 213
 -        maven {
170 214
 -            url 'https://maven.google.com/'
171 215
 -            name 'Google'
172 216
 -        }
173
-+		maven { url 'https://jitpack.io' }
174
-	}
217
++   maven { url 'https://jitpack.io' }
218
+  }
175 219
 }
176 220
 ```
177 221
 #### 2 Update `MainActivity.java`
@@ -252,30 +296,9 @@ private final ReactNativeHost mReactNativeHost =
252 296
 }
253 297
 ```
254 298
 
255
-## You can use react-native-navigation \o/
299
+### App root
256 300
 
257
-Update `index.js` file
258
-```diff
259
-+import { Navigation } from "react-native-navigation";
260
--import {AppRegistry} from 'react-native';
261
-import App from "./App";
262
--import {name as appName} from './app.json';
263
-
264
--AppRegistry.registerComponent(appName, () => App);
265
-+Navigation.registerComponent(`navigation.playground.WelcomeScreen`, () => App);
266
-
267
-+Navigation.events().registerAppLaunchedListener(() => {
268
-+  Navigation.setRoot({
269
-+    root: {
270
-+      component: {
271
-+        name: "navigation.playground.WelcomeScreen"
272
-+      }
273
-+    }
274
-+  });
275
-+});
276
-```
277
-
278
-⚠️ we use the layout type `component` here, which renders a React component but does not allow you to navigate to others. See [Usage](docs/Usage.md) and [LayoutTypes](docs/layout-types.md) for more options.
301
+Now that you're done, don't forget to update the `index.js` file, as [shown above](#update-indexjs-file).
279 302
 
280 303
 ## Troubleshooting
281 304
 ### Build app with gradle command
@@ -312,7 +335,7 @@ To do so edit `android/build.gradle` and add:
312 335
 +}
313 336
 ```
314 337
 
315
-**Note**: As more build variants come available in the future, you will need to adjust the list (`names.contains("reactNative51") || names.contains("reactNative55")`). This is why we recommend the first solution.
338
+**Note**: As more build variants become available in the future, you will need to adjust the list (`names.contains("reactNative51") || names.contains("reactNative55")`). This is why we recommend the first solution.
316 339
 
317 340
 ### Force the same support library version across all dependencies
318 341
 Some of your dependencies might require a different version of one of Google's support library packages. This results in compilation errors similar to this:
@@ -347,4 +370,4 @@ dependencies {
347 370
     implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
348 371
 }
349 372
 
350
-```
373
+```

+ 23
- 0
website/docs/Layout.mdx View File

@@ -0,0 +1,23 @@
1
+---
2
+id: layout
3
+title: Layout
4
+sidebar_label: Layout
5
+---
6
+
7
+## `id`
8
+
9
+| Type   | Required | Description                                                                                                                                                    |
10
+| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+| string | No       | Unique id used to interact with the view via the Navigation API, usually `Navigation.mergeOptions` which accepts the componentId as it's first argument. |
12
+
13
+## `options`
14
+
15
+| Type                    | Required | Description                    |
16
+| ----------------------- | -------- | ------------------------------ |
17
+| [Options](options-root.mdx) | No       | dynamic options for the layout |
18
+
19
+## `children`
20
+
21
+| Type               | Required | Description                   |
22
+| ------------------ | -------- | ----------------------------- |
23
+| [Layout[]](Layout.mdx) | YES      | Child layouts of any kind. |

docs/README.md → website/docs/README.mdx View File

@@ -1,5 +1,5 @@
1 1
 <h1 align="center">
2
-  <img src="https://raw.githubusercontent.com/wix/react-native-navigation/master/.logo.png"/><br>
2
+  <img src="https://raw.githubusercontent.com/wix/react-native-navigation/master/.logo.png"/><br/>
3 3
   React Native Navigation
4 4
 </h1>
5 5
 

+ 50
- 0
website/docs/SplitView.mdx View File

@@ -0,0 +1,50 @@
1
+---
2
+id: splitView
3
+title: SplitView
4
+sidebar_label: SplitView
5
+---
6
+
7
+A container view controller implementing a master-detail interface. See [UISplitViewController docs](https://developer.apple.com/documentation/uikit/uisplitviewcontroller).
8
+Currently implemented only in iOS.
9
+
10
+```js
11
+{
12
+  id: 'PROFILE_TAB',
13
+  master: {
14
+    component: {
15
+      id: 'MASTER_SCREEN',
16
+      name: 'MasterScreen'
17
+    }
18
+  },
19
+  detail: {
20
+    component: {
21
+      id: 'DETAIL_SCREEN',
22
+      name: 'DetailScreen'
23
+    }
24
+  }
25
+}
26
+```
27
+
28
+## `id`
29
+
30
+| Type   | Required | Description                                                                                                                                                    |
31
+| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
32
+| string | No       | Unique id used to interact with the view via the Navigation api, usually `Navigation.mergeOptions` which accepts the componentId as it's first argument. |
33
+
34
+## `master`
35
+
36
+| Type               | Required | Description                                     |
37
+| ------------------ | -------- | ----------------------------------------------- |
38
+| [Layout](Layout.mdx) | YES      | Set master layout (the smaller screen, sidebar) |
39
+
40
+## `detail`
41
+
42
+| Type               | Required | Description                                   |
43
+| ------------------ | -------- | --------------------------------------------- |
44
+| [Layout](Layout.mdx) | YES      | Set detail layout (the larger screen, flexes) |
45
+
46
+## `options`
47
+
48
+| Type                    | Required | Description                                     |
49
+| ----------------------- | -------- | ----------------------------------------------- |
50
+| [Options](options-root.mdx) | No       | dynamic options which will apply to all screens |

+ 295
- 0
website/docs/advanced-navigation.mdx View File

@@ -0,0 +1,295 @@
1
+---
2
+id: advanced-navigation
3
+title: Advanced navigation
4
+sidebar_label: Advanced navigation
5
+---
6
+
7
+import useBaseUrl from '@docusaurus/useBaseUrl';
8
+
9
+## Tab navigation
10
+
11
+As mobile applications become bigger and more complex, they usually end up containing multiple primary high-level destinations, which are logically independent from one another. The `BottomTabs` layout is often used when an app contains three to five top-level destinations which should be accessible from anywhere in the app.
12
+
13
+Lets return to the example code from the previous section ([Basic navigation](basic-navigation.mdx)) and see how we can convert it to a tab-based application. We'll use the BottomTabs layout to display tabs at the bottom of the screen. Similarly to `Stack` layout, The BottomTabs layout also contains a `children` property where each child will be displayed in a tab.
14
+
15
+Lets change our code to the following and reload the app.
16
+
17
+```jsx
18
+const Navigation = require('./services/Navigation');
19
+const React = require('react');
20
+const { View, Text, Button, StyleSheet } = require('react-native');
21
+
22
+const HomeScreen = (props) => {
23
+  return (
24
+    <View style={styles.root}>
25
+      <Text>Hello React Native Navigation 👋</Text>
26
+
27
+      <Button
28
+        title='Push Settings Screen'
29
+        color='#710ce3'
30
+        onPress={() => Navigation.push(props.componentId, {
31
+          component: {
32
+            name: 'Settings'
33
+          }
34
+        })} />
35
+    </View>
36
+  );
37
+};
38
+HomeScreen.options = {
39
+  topBar: {
40
+    title: {
41
+      text: 'Home'
42
+    }
43
+  },
44
+  bottomTab: {
45
+    text: 'Home'
46
+  }
47
+};
48
+
49
+const SettingsScreen = () => {
50
+  return (
51
+    <View style={styles.root}>
52
+      <Text>Settings Screen</Text>
53
+    </View>
54
+  );
55
+}
56
+SettingsScreen.options = {
57
+  topBar: {
58
+    title: {
59
+      text: 'Settings'
60
+    }
61
+  },
62
+  bottomTab: {
63
+    text: 'Settings'
64
+  }
65
+}
66
+
67
+Navigation.registerComponent('Home', () => HomeScreen);
68
+Navigation.registerComponent('Settings', () => SettingsScreen);
69
+
70
+Navigation.setDefaultOptions({
71
+  statusBar: {
72
+    backgroundColor: '#4d089a'
73
+  },
74
+  topBar: {
75
+    title: {
76
+      color: 'white'
77
+    },
78
+    backButton: {
79
+      color: 'white'
80
+    },
81
+    background: {
82
+      color: '#4d089a'
83
+    }
84
+  },
85
+  bottomTab: {
86
+    fontSize: 14,
87
+    selectedFontSize: 14
88
+  }
89
+});
90
+
91
+Navigation.events().registerAppLaunchedListener(async () => {
92
+  Navigation.setRoot({
93
+    root: {
94
+      bottomTabs: {
95
+        children: [
96
+          {
97
+            stack: {
98
+              children: [
99
+                {
100
+                  component: {
101
+                    name: 'Home'
102
+                  }
103
+                },
104
+              ]
105
+            }
106
+          },
107
+          {
108
+            stack: {
109
+              children: [
110
+                {
111
+                  component: {
112
+                    name: 'Settings'
113
+                  }
114
+                }
115
+              ]
116
+            }
117
+          }
118
+        ]
119
+      }
120
+    }
121
+  });
122
+});
123
+
124
+const styles = StyleSheet.create({
125
+  root: {
126
+    flex: 1,
127
+    alignItems: 'center',
128
+    justifyContent: 'center',
129
+    backgroundColor: 'whitesmoke'
130
+  }
131
+});
132
+```
133
+
134
+Now our app has two tabs at the bottom of the screen and our users can easily navigate between them.
135
+
136
+<img width="40%" src={useBaseUrl('img/stack4.png')} />
137
+
138
+## Replacing the root
139
+
140
+Up until now, we've discussed how to navigate within the same layout structure. We'll now learn how to replace the entire layout structure to display a new Root. A real life example for this use case would be, for instance, if you need to switch from a login screen to the app's main root. Replacing the root fits this use case since we'd like to discard the previous root (login root) entirely when switching to the main root.
141
+
142
+To demonstrate this, we'll make the following changes to our code:
143
+
144
+1. Add a login screen with a login button.
145
+2. When the button is clicked, we will switch to the main root.
146
+3. Replace our current root with the login screen. We'll also extract both roots to variables to improve code readability.
147
+
148
+```jsx
149
+const LoginScreen = () => {
150
+  return (
151
+    <View style={styles.root}>
152
+      <Button
153
+        title='Login'
154
+        color='#710ce3'
155
+        onPress={() => Navigation.setRoot(mainRoot)}
156
+      />
157
+    </View>
158
+  );
159
+};
160
+
161
+const HomeScreen = (props) => {
162
+  return (
163
+    <View style={styles.root}>
164
+      <Text>Hello React Native Navigation 👋</Text>
165
+
166
+      <Button
167
+        title='Push Settings Screen'
168
+        color='#710ce3'
169
+        onPress={() => Navigation.push(props.componentId, {
170
+          component: {
171
+            name: 'Settings'
172
+          }
173
+        })} />
174
+    </View>
175
+  );
176
+};
177
+HomeScreen.options = {
178
+  topBar: {
179
+    title: {
180
+      text: 'Home'
181
+    }
182
+  },
183
+  bottomTab: {
184
+    text: 'Home'
185
+  }
186
+};
187
+
188
+const SettingsScreen = () => {
189
+  return (
190
+    <View style={styles.root}>
191
+      <Text>Settings Screen</Text>
192
+    </View>
193
+  );
194
+}
195
+SettingsScreen.options = {
196
+  topBar: {
197
+    title: {
198
+      text: 'Settings'
199
+    }
200
+  },
201
+  bottomTab: {
202
+    text: 'Settings'
203
+  }
204
+}
205
+
206
+Navigation.registerComponent('Login', () => LoginScreen);
207
+Navigation.registerComponent('Home', () => HomeScreen);
208
+Navigation.registerComponent('Settings', () => SettingsScreen);
209
+
210
+const mainRoot = {
211
+  root: {
212
+    bottomTabs: {
213
+      children: [
214
+        {
215
+          stack: {
216
+            children: [
217
+              {
218
+                component: {
219
+                  name: 'Home'
220
+                }
221
+              },
222
+            ]
223
+          }
224
+        },
225
+        {
226
+          stack: {
227
+            children: [
228
+              {
229
+                component: {
230
+                  name: 'Settings'
231
+                }
232
+              }
233
+            ]
234
+          }
235
+        }
236
+      ]
237
+    }
238
+  }
239
+};
240
+const loginRoot = {
241
+  root: {
242
+    component: {
243
+      name: 'Login'
244
+    }
245
+  }
246
+};
247
+
248
+
249
+Navigation.setDefaultOptions({
250
+  statusBar: {
251
+    backgroundColor: '#4d089a'
252
+  },
253
+  topBar: {
254
+    title: {
255
+      color: 'white'
256
+    },
257
+    backButton: {
258
+      color: 'white'
259
+    },
260
+    background: {
261
+      color: '#4d089a'
262
+    }
263
+  },
264
+  bottomTab: {
265
+    fontSize: 14,
266
+    selectedFontSize: 14
267
+  }
268
+});
269
+Navigation.events().registerAppLaunchedListener(async () => {
270
+  Navigation.setRoot(loginRoot);
271
+});
272
+
273
+const styles = StyleSheet.create({
274
+  root: {
275
+    flex: 1,
276
+    alignItems: 'center',
277
+    justifyContent: 'center',
278
+    backgroundColor: 'whitesmoke'
279
+  }
280
+});
281
+```
282
+
283
+## Conditional roots
284
+
285
+Now that our initial root is the Login root, we're facing a new problem - how do we show the Login root only to users that are not logged in? Since our initial root is determined in the `registerAppLaunchedListener` callback, we'll check if a user is logged in there and set the appropriate root accordingly.
286
+
287
+```jsx
288
+Navigation.events().registerAppLaunchedListener(async () => {
289
+  Navigation.setRoot(isLoggedIn() ? mainRoot : loginRoot);
290
+});
291
+
292
+function isLoggedIn() {
293
+  // TODO: your business logic goes here
294
+}
295
+```

+ 304
- 0
website/docs/animations.mdx View File

@@ -0,0 +1,304 @@
1
+---
2
+id: docs-animations
3
+title: Animations
4
+sidebar_label: Animations
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+import useBaseUrl from '@docusaurus/useBaseUrl';
10
+
11
+Various UI elements can be animated by declaring animation options.
12
+You can change the default animations for various commands, like push and pop, and even animate elements in
13
+your screens during screen transitions.
14
+
15
+#### Animation properties
16
+The following properties can be animated with our animation framework:
17
+
18
+* **x** - Translate the view to a coordinate along the x axis.
19
+* **y** - Translate the view to a coordinate along the y axis.
20
+* **translationX** - Translate the view along the x axis relative to its current x position.
21
+* **translationY** - Translate the view along the y axis relative to its current y position.
22
+* **alpha** - Apply alpha animation to the view. A value of 0 means the view is not visible, 1 means it's visible.
23
+* **scaleX** - Scale the view on the x axis. A value of 1 means that no scaling is applied.
24
+* **scaleY** - Scale the view on the y axis. A value of 1 means that no scaling is applied.
25
+* **rotationX** - Applies rotation around the x axis (in degrees, passed as a float).
26
+* **rotationY** - Applies rotation around the y axis (in degrees, passed as a float).
27
+* **rotation** - Rotates the view on all axis. Positive values result in clockwise rotation.
28
+
29
+## Layout animations
30
+
31
+### Stack animations
32
+When animating screens in and out of a stack, there are three elements you can work with: 
33
+
34
+1. **content** - screen being pushed or popped
35
+2. **topBar** - stack's TopBar
36
+3. **bottomTabs** - if stack is a child of a bottomTabs layout, we can control the `hide` and `show` animations of the bottomTabs.
37
+
38
+The following example demonstrates how to replace the default push and pop animations with slide animations.
39
+
40
+<Tabs
41
+  defaultValue="push"
42
+  values={[
43
+    { label: 'Push', value: 'push', },
44
+    { label: 'Pop', value: 'pop', },
45
+  ]
46
+}>
47
+<TabItem value="push">
48
+
49
+```js
50
+options: {
51
+  animations: {
52
+    push: {
53
+      content: {
54
+        translationX: {
55
+          from: require('react-native').Dimensions.get('window').width,
56
+          to: 0,
57
+          duration: 300
58
+        }
59
+      }
60
+    }
61
+  }
62
+}
63
+```
64
+
65
+</TabItem>
66
+<TabItem value="pop">
67
+
68
+```js
69
+options: {
70
+  animations: {
71
+    pop: {
72
+      content: {
73
+        translationX: {
74
+          from: 0,
75
+          to: -require('react-native').Dimensions.get('window').width,
76
+          duration: 300
77
+        }
78
+      }
79
+    }
80
+  }
81
+}
82
+```
83
+
84
+</TabItem>
85
+</Tabs>
86
+
87
+### Modal animations
88
+Modal animations are declared similarly to stack animations, only this time we animate the entire view and not only part of the UI (content).
89
+
90
+<Tabs
91
+  defaultValue="show"
92
+  values={[
93
+    { label: 'Show', value: 'show', },
94
+    { label: 'Dismiss', value: 'dismiss', },
95
+  ]
96
+}>
97
+<TabItem value="show">
98
+
99
+The following example demonstrates how to show a modal with a fade-in animation.
100
+
101
+```js
102
+options: {
103
+  showModal: {
104
+    alpha: {
105
+      from: 0,
106
+      to: 1,
107
+      duration: 300
108
+    }
109
+  }
110
+}
111
+```
112
+
113
+</TabItem>
114
+<TabItem value="dismiss">
115
+
116
+The following example demonstrates how to dismiss a modal with a fade-out animation.
117
+
118
+```js
119
+options: {
120
+  dismissModal: {
121
+    alpha: {
122
+      from: 1,
123
+      to: 0,
124
+      duration: 300
125
+    }
126
+  }
127
+}
128
+```
129
+
130
+</TabItem>
131
+</Tabs>
132
+
133
+## Shared element transitions
134
+
135
+Shared element transitions allow us to provide visual continuity when navigating between destinations. This also focuses user attention on a particular significant element, which then also gives such user better context when transitioning to some other destination.
136
+
137
+:::caution
138
+At the moment, the transition is available on iOS for push and pop while on Android it's available only for push commands. We are working on adding parity and expanding supported commands to show/dismiss modal and change BottomTabs.
139
+:::
140
+
141
+### Transition breakdown
142
+
143
+Let's take a more in-depth look at the following example, which you can find in the playground app:
144
+
145
+> [Source screen](https://github.com/wix/react-native-navigation/blob/master/playground/src/screens/sharedElementTransition/CocktailsList.js) and the [Destination screen](https://github.com/wix/react-native-navigation/blob/master/playground/src/screens/sharedElementTransition/CocktailDetailsScreen.js)
146
+
147
+
148
+<p align="center">
149
+  <img alt="Shared Element Transition" src={useBaseUrl('img/sharedElement.gif')} />
150
+</p>
151
+
152
+Four elements are animated in this example. Let's list the elements involved in the transition and note which properties are being animated.
153
+
154
+* **image** - the item image is animated to the next screen.
155
+  * image scale (resizeMode)
156
+  * position on screen
157
+
158
+* **image background** - each item has a "shadow" view which transitions to the next screen and turns into a colorful header.
159
+  * scale
160
+  * position on screen
161
+  * color
162
+
163
+* **title** - the title of the item is animated to the next screen.
164
+  * font size
165
+  * font color
166
+  * position on screen
167
+
168
+* **Description** - the description of the item in the destination screen.
169
+  * fade-in
170
+  * translation y
171
+
172
+### Implementing shared element transitions
173
+
174
+#### Step 1 - set a nativeID prop to elements in the source screen
175
+In order for RNN to be able to detect the corresponding native views of the elements,
176
+each element must include a unique `nativeID` prop.
177
+
178
+```jsx
179
+<Image
180
+  source={item.image}
181
+  nativeID={`image${item.id}`}
182
+  style={styles.image}
183
+  resizeMode={'contain'} />
184
+```
185
+
186
+#### Step 2 - set a nativeID prop to elements in the destination screen
187
+
188
+```jsx
189
+<Image
190
+  source={this.props.image}
191
+  nativeID={`image${this.props.id}Dest`}
192
+  style={styles.image} />
193
+```
194
+
195
+#### Step 3 - Declare the shared element animation when pushing the screen
196
+
197
+```jsx
198
+Navigation.push(this.props.componentId, {
199
+  component: {
200
+    name: Screens.CocktailDetailsScreen,
201
+    passProps: { ...item },
202
+    options: {
203
+      animations: {
204
+        push: {
205
+          sharedElementTransitions: [
206
+            {
207
+              fromId: `image${item.id}`,
208
+              toId: `image${item.id}Dest`
209
+            }
210
+          ]
211
+        }
212
+      }
213
+    }
214
+  }
215
+});
216
+```
217
+
218
+## Element Transitions
219
+Element transitions also allow you to animate elements during shared element transitions.
220
+
221
+### Recreating
222
+#### Step 1 - Set a nativeID prop to the element you'd like to animate
223
+An element can either be in the source or destination screen.
224
+
225
+```jsx
226
+<Text
227
+  nativeID='description'
228
+  style={styles.description}>
229
+  {this.props.description}
230
+</Text>
231
+```
232
+
233
+#### Step 2 - Declare the element animation when pushing the screen
234
+
235
+```jsx
236
+Navigation.push(this.props.componentId, {
237
+  component: {
238
+    name: Screens.CocktailDetailsScreen,
239
+    passProps: { ...item },
240
+    options: {
241
+      animations: {
242
+        push: {
243
+          elementTransitions: [
244
+            {
245
+              id: 'description',
246
+              alpha: {
247
+                from: 0, // We don't declare 'to' value as that is the element's current alpha value, here we're essentially animating from 0 to 1
248
+                duration: SHORT_DURATION
249
+              },
250
+              translationY: {
251
+                from: 16, // Animate translationY from 16dp to 0dp
252
+                duration: SHORT_DURATION
253
+              }
254
+            }
255
+          ]
256
+        }
257
+      }
258
+    }
259
+  }
260
+});
261
+```
262
+
263
+## Peek and Pop (iOS 11.4+)
264
+
265
+react-native-navigation supports [Peek and pop](
266
+https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/#//apple_ref/doc/uid/TP40016543-CH1-SW3) feature in iOS 11.4 and newer.
267
+
268
+This works by passing a ref to a component you want to transform into peek view. We have included a handy component to handle all the touches and ref for you:
269
+
270
+```jsx
271
+const handlePress ({ reactTag }) => {
272
+  Navigation.push(this.props.componentId, {
273
+    component {
274
+      name: 'previewed.screen',
275
+      options: {
276
+        preview: {
277
+          reactTag,
278
+          height: 300,
279
+          width: 300,
280
+          commit: true,
281
+          actions: [{
282
+            title: "Displayed Name",
283
+            id: "actionId",
284
+            style: 'default', /* or 'selected', 'destructive'*/
285
+            actions: [/*define a submenu of actions with the same options*/]
286
+          }]
287
+        },
288
+      },
289
+    },
290
+  });
291
+};
292
+
293
+const Button = (
294
+  <Navigation.TouchablePreview
295
+    touchableComponent={TouchableHighlight}
296
+    onPress={handlePress}
297
+    onPressIn={handlePress}
298
+  >
299
+    <Text>My button</Text>
300
+  </Navigation.TouchablePreview>
301
+);
302
+```
303
+
304
+All options except for reactTag are optional. Actions trigger the same event as [navigation button presses](https://wix.github.io/react-native-navigation/#/docs/topBar-buttons?id=handling-button-press-events). To react when a preview is committed, listen to the [previewCompleted](https://wix.github.io/react-native-navigation/#/docs/events?id=previewcompleted-ios-114-only) event.

+ 57
- 0
website/docs/api-component.mdx View File

@@ -0,0 +1,57 @@
1
+---
2
+id: component-api
3
+title: Component
4
+sidebar_label: Component
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+
10
+## `registerComponent`
11
+Every screen component in your app must be registered with a unique name. The component itself is a traditional React component extending `React.Component` or `React.PureComponent`. It can also be a HOC to provide context (or a Redux store) or a functional component. Similar to React Native's `AppRegistry.registerComponent`.
12
+
13
+#### Parameters
14
+| Name   | Required | Type                | Description                                                                                                            |
15
+| ------ | -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
16
+| componentName | Yes      | string | Unique component name - not to be confused with **componentId** |
17
+| componentProvider | Yes      | Function | Anonymous function that returns the React component to register, **OR** the component wrapped with Providers|
18
+| concreteComponentProvider | No      | Function | Anonymous function that returns the concrete React component. If your component is wrapped with Providers, this must be an instance of the concrete component.|
19
+
20
+#### Examples
21
+##### Registering a component
22
+```js
23
+Navigation.registerComponent(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
24
+```
25
+
26
+##### Registering a component wrapped with Providers
27
+```js
28
+import { Provider } from 'react-redux';
29
+const store = createStore();
30
+
31
+Navigation.registerComponent(`navigation.playground.MyScreen`, () => (props) =>
32
+  <Provider store={store}>
33
+    <MyScreen {...props} />
34
+  </Provider>,
35
+  () => MyScreen)
36
+);
37
+```
38
+
39
+## `updateProps`
40
+Update props of a component registered with [registerComponent](#registercomponent). Updating props triggers the component lifecycle methods related to [updating](https://reactjs.org/docs/react-component.html#updating).
41
+
42
+#### Parameters
43
+| Name   | Required | Type                | Description                                                                                                            |
44
+| ------ | -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
45
+| componentId | Yes      | string | Unique component id |
46
+| options | Yes      | object | props object to pass to the component |
47
+
48
+#### Example
49
+```js
50
+Navigation.updateProps('MY_COMPONENT', {
51
+  // props to pass to the component
52
+};
53
+```
54
+
55
+:::important
56
+`updateProps` is called with a componentId. This is the same unique id components have in props. Don't confuse it with the `componentName` we use when registering components with [Navigation.registerComponent](#registerComponent).
57
+:::

docs/docs/events.md → website/docs/api-events.mdx View File

@@ -1,29 +1,33 @@
1
-# Events
1
+---
2
+id: events-api
3
+title: Events
4
+sidebar_label: Events
5
+---
2 6
 
3 7
 ## onAppLaunched
4 8
 
5
-Called once the app is launched. This event is used to set the Application's initial layout - after which the app is ready for user interaction.
9
+Called once the app is launched. Used to set the initial layout of the Application - after that the app is ready for user interaction.
6 10
 
7 11
 ```js
8
-const appLaunchedListener = Navigation.events().registerAppLaunchedListener(() => {
9
-
10
-});
12
+const appLaunchedListener = Navigation.events().registerAppLaunchedListener(
13
+  () => {}
14
+);
11 15
 ```
12 16
 
13 17
 RNN automatically unsubscribes components when they unmount, therefore unsubscribing isn't actually mandatory if you subscribed in `componentDidMount`.
14 18
 
15
-But you can use the following method to unsubscribe manually.
19
+But you can use the following method to unsubscribe manually:
16 20
 
17 21
 ```js
18 22
 appLaunchedListener.remove();
19 23
 ```
20 24
 
21 25
 ## componentDidAppear
22
-Called each time this component appears on screen (attached to the view hierarchy)
26
+
27
+Called each time this component appears on the screen (attached to the view hierarchy).
23 28
 
24 29
 ```js
25 30
 class MyComponent extends Component {
26
-
27 31
   componentDidMount() {
28 32
     this.navigationEventListener = Navigation.events().bindComponent(this);
29 33
   }
@@ -35,9 +39,7 @@ class MyComponent extends Component {
35 39
     }
36 40
   }
37 41
 
38
-  componentDidAppear() {
39
-
40
-  }
42
+  componentDidAppear() {}
41 43
 }
42 44
 ```
43 45
 
@@ -52,18 +54,19 @@ const screenEventListener = Navigation.events().registerComponentDidAppearListen
52 54
 // Unsubscribe
53 55
 screenEventListener.remove();
54 56
 ```
55
-|       Parameter         | Description |
56
-|:--------------------:|:-----|
57
-|**componentId**| Id of the appearing component|
58
-|**componentName**|Registered name used when registering the component with `Navigation.registerComponent()`|
59
-|**passProps**| props passed to the component|
57
+
58
+|     Parameter     | Description                                                                               |
59
+| :---------------: | :---------------------------------------------------------------------------------------- |
60
+|  **componentId**  | Id of the appearing component                                                             |
61
+| **componentName** | Registered name used when registering the component with `Navigation.registerComponent()` |
62
+|   **passProps**   | props passed to the component                                                             |
60 63
 
61 64
 ## componentDidDisappear
62
-Called each time this component disappears from screen (detached from the view hierarchy)
65
+
66
+Called each time this component disappears from the screen (detached from the view hierarchy).
63 67
 
64 68
 ```js
65 69
 class MyComponent extends Component {
66
-
67 70
   componentDidMount() {
68 71
     this.navigationEventListener = Navigation.events().bindComponent(this);
69 72
   }
@@ -75,9 +78,7 @@ class MyComponent extends Component {
75 78
     }
76 79
   }
77 80
 
78
-  componentDidDisappear() {
79
-
80
-  }
81
+  componentDidDisappear() {}
81 82
 }
82 83
 ```
83 84
 
@@ -92,13 +93,15 @@ const screenEventListener = Navigation.events().registerComponentDidDisappearLis
92 93
 // Unsubscribe
93 94
 screenEventListener.remove();
94 95
 ```
95
-|       Parameter         | Description |
96
-|:--------------------:|:-----|
97
-|**componentId**| Id of the disappearing component|
98
-|**componentName**|Registered name used when registering the component with `Navigation.registerComponent()`|
96
+
97
+|     Parameter     | Description                                                                               |
98
+| :---------------: | :---------------------------------------------------------------------------------------- |
99
+|  **componentId**  | Id of the disappearing component                                                          |
100
+| **componentName** | Registered name used when registering the component with `Navigation.registerComponent()` |
99 101
 
100 102
 ## registerCommandListener
101
-The `commandListener` is called whenever a *Navigation command* (i.e push, pop, showModal etc) is invoked.
103
+
104
+The `commandListener` is called whenever a _Navigation command_ (i.e push, pop, showModal etc) is invoked.
102 105
 
103 106
 ```js
104 107
 // Subscribe
@@ -109,12 +112,14 @@ const commandListener = Navigation.events().registerCommandListener((name, param
109 112
 // Unsubscribe
110 113
 commandListener.remove();
111 114
 ```
112
-|       Parameter         | Description |
113
-|:--------------------:|:-----|
114
-|**name** | The name of the command that was invoked. For example `push`|
115
-|**params**|`commandId`: Each command is assigned a unique Id<br>`componentId`: Optional, the componentId passed to the command<br>`layout`: Optional, If the command invoked created a screen. Slim representation of the component and its options |
115
+
116
+| Parameter  | Description                                                                                                                                                                                                                                  |
117
+| :--------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
118
+|  **name**  | The name of the command that was invoked. For example `push`                                                                                                                                                                                 |
119
+| **params** | `commandId`: Each command is assigned a unique Id<br />`componentId`: Optional, the componentId passed to the command<br />`layout`: Optional, if the command invoked created a screen. Slim representation of the component and its options |
116 120
 
117 121
 ## registerCommandCompletedListener
122
+
118 123
 Invoked when a command finishes executing in native. If the command contains animations, for example pushed screen animation, the listener is invoked after the animation ends.
119 124
 
120 125
 ```js
@@ -127,54 +132,28 @@ const commandCompletedListener = Navigation.events().registerCommandCompletedLis
127 132
 commandCompletedListener.remove();
128 133
 ```
129 134
 
130
-|       Parameter         | Description |
131
-|:--------------------:|:-----|
132
-|**commandId** | Id of the completed command|
133
-|**completionTime**|Timestamp when the command, and consecutive animations, completed.|
135
+|     Parameter      | Description                                                        |
136
+| :----------------: | :----------------------------------------------------------------- |
137
+|   **commandId**    | Id of the completed command                                        |
138
+| **completionTime** | Timestamp when the command, and consecutive animations, completed. |
134 139
 
135 140
 ## registerModalDismissedListener
136 141
 
137
-Invoked when modal dismissed.
138
-
139
-```js
140
-class MyComponent extends Component {
141
-
142
-  componentDidMount() {
143
-    this.navigationEventListener = Navigation.events().bindComponent(this);
144
-  }
145
-
146
-  componentWillUnmount() {
147
-    // Not mandatory
148
-    if (this.navigationEventListener) {
149
-      this.navigationEventListener.remove();
150
-    }
151
-  }
152
-
153
-  modalDismissed({ componentId, componentName, modalsDismissed }) {
154
-
155
-  }
156
-}
157
-```
158
-
159
-This event can be observed globally as well:
142
+Invoked when a modal is dismissed.
160 143
 
161 144
 ```js
162 145
 // Subscribe
163
-const modalDismissedListener = Navigation.events().registerModalDismissedListener(({ componentId, componentName, modalsDismissed }) => {
146
+const modalDismissedListener = Navigation.events().registerModalDismissedListener(({ componentId, modalsDismissed }) => {
164 147
 
165 148
 });
166 149
 ...
167 150
 // Unsubscribe
168 151
 modalDismissedListener.remove();
169 152
 ```
170
-|       Parameter         | Description |
171
-|:--------------------:|:-----|
172
-|**componentId**| Id of the dismissing modal|
173
-|**componentName**|Registered name used when registering the component with `Navigation.registerComponent()`|
174
-|**modalsDismissed**|Number of modals dismissed.|
175 153
 
176 154
 ## registerModalAttemptedToDismissListener(iOS 13+ only)
177
-Invoked only on iOS pageSheet modal when swipeToDismiss flag is set to true and modal swiped down to dismiss.
155
+
156
+Invoked only on iOS pageSheet modal when `swipeToDismiss` flag is set to true and modal was swiped down to dismiss.
178 157
 
179 158
 ```js
180 159
 // Subscribe
@@ -185,12 +164,14 @@ const modalAttemptedToDismissListener = Navigation.events().registerModalAttempt
185 164
 // Unsubscribe
186 165
 modalDismissedListener.remove();
187 166
 ```
188
-|       Parameter         | Description |
189
-|:--------------------:|:-----|
190
-|**componentId** | Id of the modal tried to dismiss|
167
+
168
+|    Parameter    | Description                      |
169
+| :-------------: | :------------------------------- |
170
+| **componentId** | Id of the modal a user is attempting to dismiss |
191 171
 
192 172
 ## registerScreenPoppedListener
193
-Invoked when screen is popped.
173
+
174
+Invoked when the screen is popped.
194 175
 
195 176
 ```js
196 177
 // Subscribe
@@ -202,13 +183,14 @@ const screenPoppedListener = Navigation.events().registerScreenPoppedListener(({
202 183
 screenPoppedListener.remove();
203 184
 ```
204 185
 
205
-|       Parameter         | Description |
206
-|:--------------------:|:-----|
207
-|**componentId** | Id of the modal|
208
-|**modalsDismissed**| Number of modal which were dismissed|
186
+|      Parameter      | Description                          |
187
+| :-----------------: | :----------------------------------- |
188
+|   **componentId**   | Id of the modal                      |
189
+| **modalsDismissed** | Number of modals that were dismissed |
209 190
 
210 191
 ## registerBottomTabSelectedListener
211
-Invoked when a BottomTab is selected by the user.
192
+
193
+Invoked when BottomTab is selected by a user.
212 194
 
213 195
 ```js
214 196
 // Subscribe
@@ -221,7 +203,8 @@ bottomTabEventListener.remove();
221 203
 ```
222 204
 
223 205
 ## registerBottomTabLongPressedListener
224
-Invoked when a BottomTab is long pressed by the user.
206
+
207
+Invoked when BottomTab is long pressed by a user.
225 208
 
226 209
 ```js
227 210
 // Subscribe
@@ -233,31 +216,29 @@ const bottomTabEventListener = Navigation.events().registerBottomTabLongPressedL
233 216
 bottomTabEventListener.remove();
234 217
 ```
235 218
 
236
-|       Parameter         | Description |
237
-|:--------------------:|:-----|
238
-|**selectedTabIndex** | The index of the newly selected tab|
239
-|**unselectedTabIndex**|The index of the previously selected tab|
219
+|       Parameter        | Description                          |
220
+| :--------------------: | :------------------------------------|
221
+|  **selectedTabIndex**  | Index of the newly selected tab      |
222
+| **unselectedTabIndex** | Index of the previously selected tab |
240 223
 
241 224
 ## navigationButtonPressed event
242
-This event is emitted whenever a TopBar button is pressed by the user.
225
+
226
+This event is emitted whenever a TopBar button is pressed by a user.
243 227
 
244 228
 ```js
245 229
 class MyComponent extends Component {
246
-
247 230
   componentDidMount() {
248 231
     this.navigationEventListener = Navigation.events().bindComponent(this);
249 232
   }
250 233
 
251 234
   componentWillUnmount() {
252
-    // Not mandatory
235
+    // Unregistering listeners bound to components isn't mandatory since RNN handles the unregistration for you
253 236
     if (this.navigationEventListener) {
254 237
       this.navigationEventListener.remove();
255 238
     }
256 239
   }
257
-  
258
-  navigationButtonPressed({ buttonId }) {
259 240
 
260
-  }
241
+  navigationButtonPressed({ buttonId }) {}
261 242
 }
262 243
 ```
263 244
 
@@ -273,16 +254,16 @@ const navigationButtonEventListener = Navigation.events().registerNavigationButt
273 254
 navigationButtonEventListener.remove();
274 255
 ```
275 256
 
276
-|Parameter|Description|
277
-|:-:|:--|
278
-|**buttonId**|`buttonId`: `id` of the pressed button|
257
+|  Parameter   | Description                            |
258
+| :----------: | :------------------------------------- |
259
+| **buttonId** | `buttonId`: `id` of the pressed button |
279 260
 
280 261
 ## searchBarUpdated (iOS 11+ only)
281
-Called when a SearchBar from NavigationBar gets updated.
262
+
263
+Called whenever the SearchBar of NavigationBar is updated.
282 264
 
283 265
 ```js
284 266
 class MyComponent extends Component {
285
-
286 267
   componentDidMount() {
287 268
     this.navigationEventListener = Navigation.events().bindComponent(this);
288 269
   }
@@ -294,18 +275,16 @@ class MyComponent extends Component {
294 275
     }
295 276
   }
296 277
 
297
-  searchBarUpdated({ text, isFocused }) {
298
-
299
-  }
278
+  searchBarUpdated({ text, isFocused }) {}
300 279
 }
301 280
 ```
302 281
 
303 282
 ## searchBarCancelPressed (iOS 11+ only)
304
-Called when the cancel button on the SearchBar from NavigationBar gets pressed.
283
+
284
+Called when the cancel button of the SearchBar from NavigationBar is pressed.
305 285
 
306 286
 ```js
307 287
 class MyComponent extends Component {
308
-
309 288
   componentDidMount() {
310 289
     this.navigationEventListener = Navigation.events().bindComponent(this);
311 290
   }
@@ -317,18 +296,16 @@ class MyComponent extends Component {
317 296
     }
318 297
   }
319 298
 
320
-  searchBarCancelPressed() {
321
-
322
-  }
299
+  searchBarCancelPressed() {}
323 300
 }
324 301
 ```
325 302
 
326 303
 ## previewCompleted (iOS 11.4+ only)
327
-Called when preview peek is completed
304
+
305
+Called when preview peek is completed.
328 306
 
329 307
 ```js
330 308
 class MyComponent extends Component {
331
-
332 309
   componentDidMount() {
333 310
     this.navigationEventListener = Navigation.events().bindComponent(this);
334 311
   }
@@ -340,8 +317,6 @@ class MyComponent extends Component {
340 317
     }
341 318
   }
342 319
 
343
-  previewCompleted({ previewComponentId }) {
344
-
345
-  }
320
+  previewCompleted({ previewComponentId }) {}
346 321
 }
347 322
 ```

+ 59
- 0
website/docs/api-modal.mdx View File

@@ -0,0 +1,59 @@
1
+---
2
+id: modal-api
3
+title: Modal
4
+sidebar_label: Modal
5
+---
6
+## `showModal()`
7
+Show a screen as a modal.
8
+
9
+#### Parameters
10
+| Name   | Required | Type                | Description                                                                                                            |
11
+| ------ | -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
12
+| layout | Yes      | [Layout](Layout.mdx) | Any type of layout. [BottomTabs](layout-BottomTabs.mdx), [Stack](stack-layout.mdx), [SideMenu](sideMenu-layout.mdx), [Component](layout-component.mdx) |
13
+
14
+```js
15
+Navigation.showModal({
16
+  stack: {
17
+    children: [{
18
+      component: {
19
+        name: 'example.ModalScreen',
20
+        passProps: {
21
+          text: 'stack with one child'
22
+        },
23
+        options: {
24
+          topBar: {
25
+            title: {
26
+              text: 'Modal'
27
+            }
28
+          }
29
+        }
30
+      }
31
+    }]
32
+  }
33
+});
34
+```
35
+
36
+## `dismissModal()`
37
+Dismiss the current modal.
38
+
39
+#### Parameters
40
+| Name         | Required | Type    | Description                                                |
41
+| ------------ | -------- | ------- | ---------------------------------------------------------- |
42
+| componentId  | Yes      | string  | Any component id presented in the modal                    |
43
+| mergeOptions | No       | Options | Options to be merged before dismissing the Modal. |
44
+
45
+```js
46
+Navigation.dismissModal(this.props.componentId);
47
+```
48
+
49
+## `dismissAllModals()`
50
+Dismiss all current modals at the same time.
51
+
52
+#### Parameters
53
+| Name         | Required | Type    | Description                                                |
54
+| ------------ | -------- | ------- | ---------------------------------------------------------- |
55
+| mergeOptions | No       | Options | Options to be merged before dismissing all modals. |
56
+
57
+```js
58
+Navigation.dismissAllModals();
59
+```

+ 47
- 0
website/docs/api-options.mdx View File

@@ -0,0 +1,47 @@
1
+---
2
+id: options-api
3
+title: Options Commands
4
+sidebar_label: Options commands
5
+---
6
+
7
+## `setDefaultOptions`
8
+
9
+Set default options for all screens. Useful for declaring a consistent style across the app.
10
+
11
+#### Parameters
12
+
13
+| Name    | Type                    | Required | Description  |
14
+| ------- | ----------------------- | -------- | ------------ |
15
+| options | [Options](options-root.mdx) | Yes      | Options root |
16
+
17
+#### Example
18
+
19
+```js
20
+Navigation.setDefaultOptions({
21
+  bottomTab: {
22
+    textColor: "black",
23
+    selectedTextColor: "blue"
24
+  }
25
+});
26
+```
27
+
28
+## `mergeOptions`
29
+
30
+Change navigation options of a component.
31
+
32
+#### Parameters
33
+
34
+| Name        | Type                    | Required | Description      |
35
+| ----------- | ----------------------- | -------- | ---------------- |
36
+| componentId | string                  | Yes      | The component id |
37
+| options     | [Options](options-root.mdx) | Yes      | Options root     |
38
+
39
+#### Example
40
+
41
+```js
42
+Navigation.mergeOptions('componentId', {
43
+  bottomTabs: {
44
+    visible: false
45
+  }
46
+});
47
+```

+ 37
- 0
website/docs/api-overlay.mdx View File

@@ -0,0 +1,37 @@
1
+---
2
+id: overlay-api
3
+title: Overlay
4
+sidebar_label: Overlay
5
+---
6
+
7
+## `showOverlay()`
8
+Shows a component as an overlay.
9
+
10
+| Name   | Required | Type                | Description                                                                                                                                                                                                         |
11
+| ------ | -------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12
+| layout | Yes      | [Layout](Layout.mdx) | Any type of layout. Typically, Component layout is used in Overlays but it's possible to load any other layout ([BottomTabs](layout-BottomTabs.mdx), [Stack](stack-layout.mdx), [SideMenu](sideMenu-layout.mdx), [Component](layout-component.mdx)) |
13
+
14
+```js
15
+Navigation.showOverlay({
16
+  component: {
17
+    name: 'example.Overlay',
18
+    options: {
19
+      overlay: {
20
+        interceptTouchOutside: true
21
+      }
22
+    }
23
+  }
24
+});
25
+```
26
+
27
+## `dismissOverlay()`
28
+Dismisses an overlay matching the given overlay componentId.
29
+
30
+#### Parameters
31
+| Name        | Required | Type   | Description                           |
32
+| ----------- | -------- | ------ | ------------------------------------- |
33
+| componentId | Yes      | string | The component id presented in Overlay |
34
+
35
+```js
36
+Navigation.dismissOverlay(this.props.componentId);
37
+```

+ 103
- 0
website/docs/api-root.mdx View File

@@ -0,0 +1,103 @@
1
+---
2
+id: root-api
3
+title: Root
4
+sidebar_label: Root
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+
10
+## `setRoot()`
11
+Used to set the UI of the application. Read more about the root hierarchy level in the [docs section](docs-root.mdx).
12
+
13
+#### Parameters
14
+| Name   | Required | Type                | Description                                                                                                            |
15
+| ------ | -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
16
+| layout | Yes      | [Layout](Layout.mdx) | Any type of layout. [BottomTabs](layout-BottomTabs.mdx), [Stack](stack-layout.mdx), [SideMenu](sideMenu-layout.mdx), [Component](layout-component.mdx) |
17
+
18
+#### Example
19
+
20
+<Tabs
21
+  defaultValue='stack'
22
+  values={[
23
+    { label: 'With Stack layout', value: 'stack' },
24
+    { label: 'With BottomTabs layout', value: 'bottomTabs' }
25
+  ]
26
+}>
27
+
28
+<TabItem value='stack'>
29
+
30
+```js
31
+Navigation.setRoot({
32
+  root: {
33
+    stack: {
34
+      children: [{
35
+        component: {
36
+          name: 'example.FirstTabScreen',
37
+          passProps: {
38
+            text: 'This is tab 1'
39
+          }
40
+        }
41
+      }],
42
+      options: {
43
+        bottomTab: {
44
+          text: 'Tab 1',
45
+          icon: require('../images/one.png'),
46
+          testID: 'FIRST_TAB_BAR_BUTTON'
47
+        }
48
+      }
49
+    }
50
+  }
51
+});
52
+```
53
+
54
+</TabItem>
55
+
56
+<TabItem value='bottomTabs'>
57
+
58
+```js
59
+Navigation.setRoot({
60
+  root: {
61
+    bottomTabs: {
62
+      children: [{
63
+        stack: {
64
+          children: [{
65
+            component: {
66
+              name: 'example.FirstTabScreen',
67
+              passProps: {
68
+                text: 'This is tab 1'
69
+              }
70
+            }
71
+          }],
72
+          options: {
73
+            bottomTab: {
74
+              text: 'Tab 1',
75
+              icon: require('../images/one.png'),
76
+              testID: 'FIRST_TAB_BAR_BUTTON'
77
+            }
78
+          }
79
+        }
80
+      },
81
+      {
82
+        component: {
83
+          name: 'navigation.playground.TextScreen',
84
+          passProps: {
85
+            text: 'This is tab 2'
86
+          },
87
+          options: {
88
+            bottomTab: {
89
+              text: 'Tab 2',
90
+              icon: require('../images/two.png'),
91
+              testID: 'SECOND_TAB_BAR_BUTTON'
92
+            }
93
+          }
94
+        }
95
+      }]
96
+    }
97
+  }
98
+});
99
+```
100
+
101
+</TabItem>
102
+
103
+</Tabs>

+ 33
- 0
website/docs/api-sideMenu.mdx View File

@@ -0,0 +1,33 @@
1
+---
2
+id: sideMenu-api
3
+title: Side Menu
4
+sidebar_label: Side Menu
5
+---
6
+
7
+This layout allows to implement sidemenus, which can be opened by swiping from one side towards the other side.
8
+
9
+```js
10
+{
11
+  left: {
12
+    component: {}
13
+  },
14
+  center: {
15
+    stack: {
16
+      options: {},
17
+      children: [{
18
+        component: {}
19
+      }]
20
+    }
21
+  },
22
+  right: {
23
+    component: {}
24
+  }
25
+}
26
+```
27
+
28
+## `center: Layout`
29
+Center component, contains the main application.
30
+## `left?: Layout`
31
+Contain the left component layout.
32
+## `right?: Layout`
33
+Contain the right component layout.

+ 37
- 0
website/docs/app-launch.mdx View File

@@ -0,0 +1,37 @@
1
+---
2
+id: app-launch
3
+title: Launching the app
4
+sidebar_label: Launching the app
5
+---
6
+
7
+When your app is launched for the first time, the bundle is parsed and executed. At this point you need to display your UI. To do so, listen to the `appLaunched` event and call `Navigation.setRoot` when that event is received.
8
+
9
+```js
10
+Navigation.events().registerAppLaunchedListener(() => {
11
+  // Each time the event is received you should call Navigation.setRoot
12
+});
13
+```
14
+
15
+:::important
16
+Register the app launched listener as soon as possible - this should be one of the first lines in your `index.js` file.
17
+:::
18
+
19
+If you're observing a "white screen" or a hanging splash screen after relaunching your app, it probably means `Navigation.setRoot` isn't called as soon as the app is launched. Perhaps the listener was registered too late.
20
+
21
+## Difference between the platforms
22
+When your app is launched, RN makes sure JS context (which is what enables you to execute JavaScript code) is running. There are quite a few differences between iOS and Android in this regard.
23
+
24
+### iOS
25
+Whenever an app is put into the background, the app process can potentially be destroyed by the system. If this destruction takes place, the JS context will be destroyed alongside with the app process.
26
+
27
+### Android
28
+An Android application is typically bound to two contexts:
29
+
30
+1. Application context - bound to the app process
31
+1. Activity context - bound to app UI
32
+
33
+React's JS Context is executed on and bound to the Application context. This means that even when the Activity context (and thus the UI) is destroyed, React's JS Context remains active until the Application (and your process) are destroyed by the system.
34
+
35
+:::caution
36
+Because of this, when your app returns to foreground, JS Context might still exist on Android, even when the Activity and UI contexts have been destroyed - meaning you might not need to initialise all of your app logic; instead, you'll only need to call `Navigation.setRoot` to repopulate the UI context. This circumstance can easily be determined by setting a flag on your app's first `appLaunched` event, and checking the value of that flag on subsequent `appLaunched` events -- if the flag is true in your `appLaunched` callback, you need to call `Navigation.setRoot` to repopulate the UI.
37
+:::

+ 351
- 0
website/docs/basic-navigation.mdx View File

@@ -0,0 +1,351 @@
1
+---
2
+id: basic-navigation
3
+title: Basic navigation
4
+sidebar_label: Basic navigation
5
+---
6
+
7
+import useBaseUrl from '@docusaurus/useBaseUrl';
8
+
9
+Generally, any mobile app consists of various destinations which display some content to the user. And in vast majority of cases using an app means navigating between these destinations. React-native-navigation provides ways for you to layout your content on user screen in a logical and performant manner.
10
+
11
+React Native Navigation's stack layout lets you push screens, and also navigate back to previous screens. Screens pushed into the stack hide the previous screen in the stack, making the user focus on a single screen at a time. Let's look at a stack layout that provides basic navigation for an app.
12
+
13
+## Creating a stack
14
+
15
+```jsx
16
+// In index.js of a new project
17
+const { Navigation } = require('react-native-navigation');
18
+const React = require('react');
19
+const { View, Text, StyleSheet } = require('react-native');
20
+
21
+const HomeScreen = (props) => {
22
+  return (
23
+    <View style={styles.home}>
24
+      <Text>Home Screen</Text>
25
+    </View>
26
+  );
27
+};
28
+Navigation.registerComponent('Home', () => HomeScreen);
29
+
30
+Navigation.events().registerAppLaunchedListener(async () => {
31
+  Navigation.setRoot({
32
+    root: {
33
+      stack: {
34
+        children: [
35
+          {
36
+            component: {
37
+              name: 'Home'
38
+            }
39
+          }
40
+        ]
41
+      }
42
+    }
43
+  });
44
+});
45
+
46
+const styles = StyleSheet.create({
47
+  root: {
48
+    flex: 1,
49
+    alignItems: 'center',
50
+    justifyContent: 'center',
51
+    backgroundColor: 'whitesmoke'
52
+  }
53
+});
54
+```
55
+
56
+Running this code will render a screen with an empty TopBar and your HomeScreen component (shown below). The TopBar is part of the stack layout, we'll work on configuring it later.
57
+
58
+<img width="40%" src={useBaseUrl('img/stack1.png')} />
59
+
60
+## Specifying options
61
+
62
+You can specify options of each layout (Stack, component pushed into a stack, etc.) to configure various parameters like the TopBar title or color. Lets spice things up by changing the TopBar color and while we're at it, also move the title to the TopBar.
63
+
64
+Lets change the Home screen declaration to the following and reload the app to see the changes.
65
+```jsx
66
+const HomeScreen = (props) => {
67
+  return (
68
+    <View style={styles.home}>
69
+      <Text>Hello React Native Navigation 👋</Text>
70
+    </View>
71
+  );
72
+};
73
+HomeScreen.options = {
74
+  topBar: {
75
+    title: {
76
+      text: 'Home',
77
+      color: 'white'
78
+    },
79
+    background: {
80
+      color: '#4d089a'
81
+    }
82
+  }
83
+}
84
+```
85
+
86
+Our app should now look like this:
87
+<img width="40%" src={useBaseUrl('img/stackOptions.png')} />
88
+
89
+## Navigating in a stack
90
+
91
+In the previous section we created a stack and initialized it with a single child. We'll now learn how to add another child to the stack. From now on, we'll call the action of adding children to the stack 'push', and removing children - 'pop'.
92
+
93
+In order to push another screen to the stack, we will add a button to the home screen and call `Navigation.push`. The 'push' command accepts two parameters, the first is the id used to indicate into which stack to push the screen and the second is the screen we're pushing. After pushing a screen, a back button is added automatically to the TopBar so the users can navigate easily back to the previous screen.
94
+
95
+You can read more about the stack layout [here](stack-doc.mdx) or dive right into the API [here](stack-api.mdx).
96
+
97
+:::info componentId
98
+Each React component registered with `Navigation.registerComponent` is assigned a unique `componentId` by Navigation. This unique id is used with Navigation commands (like the push command) to indicate into which stack we'd like to push. In this case, by using the componentId of the Home screen, we are telling Navigation to push into the stack containing the Home screen.
99
+:::
100
+
101
+```js
102
+Navigation.push(props.componentId, {
103
+  component: {
104
+    name: 'Settings', // Push the screen registered with the 'Settings' key
105
+    options: { // Optional options object to configure the screen
106
+      topBar: {
107
+        title: {
108
+          text: 'Settings' // Set the TopBar title of the new Screen
109
+        }
110
+      }
111
+    }
112
+  }
113
+});
114
+```
115
+
116
+Lets change our code to the following snippet below and reload the app. Now our Home should contain a button which when pressed, pushes a new screen into the stack. We've successfully navigated to a new screen! 👏
117
+
118
+```jsx
119
+// In index.js of a new project
120
+const { Navigation } = require('react-native-navigation');
121
+const React = require('react');
122
+const { View, Text, Button, StyleSheet } = require('react-native');
123
+
124
+
125
+// Settings screen declaration - this is the screen we'll be pushing into the stack
126
+const SettingsScreen = () => {
127
+  return (
128
+    <View style={[styles.root, styles.settings]}>
129
+      <Text>Settings Screen</Text>
130
+    </View>
131
+  );
132
+};
133
+
134
+// Home screen declaration
135
+const HomeScreen = (props) => {
136
+  return (
137
+    <View style={styles.root}>
138
+      <Text>Hello React Native Navigation 👋</Text>
139
+      <Button
140
+        title='Push Settings Screen'
141
+        color='#710ce3'
142
+        onPress={() => Navigation.push(props.componentId, {
143
+          component: {
144
+            name: 'Settings',
145
+            options: {
146
+              topBar: {
147
+                title: {
148
+                  text: 'Settings'
149
+                }
150
+              }
151
+            }
152
+          }
153
+        })}/>
154
+    </View>
155
+  );
156
+};
157
+HomeScreen.options = {
158
+  topBar: {
159
+    title: {
160
+      text: 'Home',
161
+      color: 'white'
162
+    },
163
+    background: {
164
+      color: '#4d089a'
165
+    }
166
+  }
167
+};
168
+
169
+const SettingsScreen = () => {
170
+  return (
171
+    <View style={styles.root}>
172
+      <Text>Settings Screen</Text>
173
+    </View>
174
+  );
175
+}
176
+
177
+Navigation.registerComponent('Home', () => HomeScreen);
178
+Navigation.registerComponent('Settings', () => SettingsScreen);
179
+
180
+Navigation.events().registerAppLaunchedListener(async () => {
181
+  Navigation.setRoot({
182
+    root: {
183
+      stack: {
184
+        children: [
185
+          {
186
+            component: {
187
+              name: 'Home'
188
+            }
189
+          }
190
+        ]
191
+      }
192
+    }
193
+  });
194
+});
195
+
196
+const styles = StyleSheet.create({
197
+  root: {
198
+    flex: 1,
199
+    alignItems: 'center',
200
+    justifyContent: 'center',
201
+    backgroundColor: 'whitesmoke'
202
+  }
203
+});
204
+```
205
+
206
+<img width="40%" src={useBaseUrl('img/stack2.gif')} />
207
+
208
+## App theme
209
+
210
+Our app is growing and already contains two screens. This introduces a new problem - while the home screen has a nice purple TopBar, our settings screen seems pretty dull as it still uses the default system look and feel.
211
+
212
+Currently, our style declaration applies only to the Home screen, so lets apply it to all of our screens by using `Navigation.setDefaultOptions`.
213
+
214
+```js
215
+Navigation.setDefaultOptions({
216
+  statusBar: {
217
+    backgroundColor: '#4d089a'
218
+  },
219
+  topBar: {
220
+    title: {
221
+      color: 'white'
222
+    },
223
+    backButton: {
224
+      color: 'white'
225
+    },
226
+    background: {
227
+      color: '#4d089a'
228
+    }
229
+  }
230
+});
231
+```
232
+
233
+We need to add this snippet before registering the `registerAppLaunchedListener`. This way we ensure our theme is applied when our root is set. Our code should now look like this:
234
+
235
+```jsx
236
+// In index.js of a new project
237
+const { Navigation } = require('react-native-navigation');
238
+const React = require('react');
239
+const { View, Text, Button, StyleSheet } = require('react-native');
240
+
241
+
242
+// Settings screen declaration - this is the screen we'll be pushing into the stack
243
+const SettingsScreen = () => {
244
+  return (
245
+    <View style={[styles.root, styles.settings]}>
246
+      <Text>Settings Screen</Text>
247
+    </View>
248
+  );
249
+};
250
+
251
+// Home screen declaration
252
+const HomeScreen = (props) => {
253
+  return (
254
+    <View style={styles.root}>
255
+      <Text>Hello React Native Navigation 👋</Text>
256
+      <Button
257
+        title='Push Settings Screen'
258
+        color='#710ce3'
259
+        onPress={() => Navigation.push(props.componentId, {
260
+          component: {
261
+            name: 'Settings',
262
+            options: {
263
+              topBar: {
264
+                title: {
265
+                  text: 'Settings'
266
+                }
267
+              }
268
+            }
269
+          }
270
+        })}/>
271
+    </View>
272
+  );
273
+};
274
+HomeScreen.options = {
275
+  topBar: {
276
+    title: {
277
+      text: 'Home',
278
+    }
279
+  }
280
+};
281
+
282
+const SettingsScreen = () => {
283
+  return (
284
+    <View style={styles.root}>
285
+      <Text>Settings Screen</Text>
286
+    </View>
287
+  );
288
+}
289
+
290
+Navigation.registerComponent('Home', () => HomeScreen);
291
+Navigation.registerComponent('Settings', () => SettingsScreen);
292
+
293
+
294
+Navigation.setDefaultOptions({
295
+  statusBar: {
296
+    backgroundColor: '#4d089a'
297
+  },
298
+  topBar: {
299
+    title: {
300
+      color: 'white'
301
+    },
302
+    backButton: {
303
+      color: 'white'
304
+    },
305
+    background: {
306
+      color: '#4d089a'
307
+    }
308
+  }
309
+});
310
+Navigation.events().registerAppLaunchedListener(async () => {
311
+  Navigation.setRoot({
312
+    root: {
313
+      stack: {
314
+        children: [
315
+          {
316
+            component: {
317
+              name: 'Home'
318
+            }
319
+          }
320
+        ]
321
+      }
322
+    }
323
+  });
324
+});
325
+
326
+const styles = StyleSheet.create({
327
+  root: {
328
+    flex: 1,
329
+    alignItems: 'center',
330
+    justifyContent: 'center',
331
+    backgroundColor: 'whitesmoke'
332
+  }
333
+});
334
+```
335
+
336
+Lets run our code again - now our design is consistent across both screens.
337
+
338
+<img width="40%" src={useBaseUrl('img/stack3.gif')} />
339
+
340
+## Summary
341
+
342
+We've learned the basics of navigation with React Native Navigation by implementing a stack and pushing screens into it.
343
+We've also learned a few methods of applying styles to our screens and layouts with the Options mechanism.
344
+
345
+* Navigation.setRoot() sets the root layout of our app. The initial root has to be set from an `AppLaunchedEvent` callback.
346
+* Options can be applied directly to components.
347
+* Screens can be added to a stack with the `Navigation.push()` command.
348
+* Components registered with `Navigation.registerComponent()` are injected with a `componentId` which is used when navigating.
349
+* Themes are applied via the `Navigation.setDefaultOptions()` command.
350
+
351
+In the next section we'll explore a more advance navigation patters using BottomTabs layout and also see how, and why, multiple roots are set.

+ 12
- 0
website/docs/before-you-start.mdx View File

@@ -0,0 +1,12 @@
1
+---
2
+id: before-you-start
3
+title: Before you start
4
+sidebar_label: Before you start
5
+---
6
+
7
+React Native Navigation is a module, dependent on and intended to be used alongside [React Native](https://github.com/facebook/react-native), so some experience with it and knowledge of core concepts is required. If you feel the need, you can start with their [getting started](https://reactnative.dev/docs/getting-started) tutorial, and then come back here when you're ready.
8
+
9
+We also assume you are working on a Mac with XCode and Android Studio installed and setup. You can also make it work in a Linux distribution, of course, but in that case bare in mind that some sections of the docs that deal with iOS might not be relevant to you.
10
+
11
+If you want to dig right into it, start with [installing](Installing.mdx) the library. If you're just looking around, we suggest checking out [basic navigation](basic-navigation.mdx) first.
12
+

+ 140
- 0
website/docs/docs-bottomTabs.mdx View File

@@ -0,0 +1,140 @@
1
+---
2
+id: docs-bottomTabs
3
+title: Bottom tabs
4
+sidebar_label: Bottom tabs
5
+---
6
+import useBaseUrl from '@docusaurus/useBaseUrl';
7
+
8
+Bottom tabs refers to a row of links, displayed at the bottom of the screen, and is referred to as "Tab Bar" in iOS and as "Bottom Navigation Bar" on Android. Usually these are intended to be used to switch between top-level content views with a single tap.
9
+
10
+## Creating bottom tabs
11
+
12
+BottomTabs provide flat navigation and access to up to five equally important top-level root destinations. While any type of layout can be displayed in a tab, typically, [Stacks]() are used, since they allow for vertical navigation within a tab.
13
+
14
+### Example
15
+Lets see how to create a simple BottomTabs layout. There are a few things to notice here:
16
+1. Each child represents a tab on the screen.
17
+2. The root layout for each tab is a stack to allow for vertical navigation within the tab.
18
+3. Each stack declares `bottomTab` options which are used to configure the tab's text, icon, color etc.
19
+
20
+```js
21
+bottomTabs: {
22
+  id: 'BOTTOM_TABS_LAYOUT',
23
+  children: [
24
+    {
25
+      stack: {
26
+        id: 'HOME_TAB',
27
+        children: [
28
+          {
29
+            component: {
30
+              id: 'HOME_SCREEN'
31
+              name: 'HomeScreen'
32
+            }
33
+          }
34
+        ],
35
+        options: {
36
+          bottomTab: {
37
+            icon: require('./home.png')
38
+          }
39
+        }
40
+      }
41
+    },
42
+    stack: {
43
+      id: 'PROFILE_TAB',
44
+      children: [
45
+        {
46
+          component: {
47
+            id: 'PROFILE_SCREEN',
48
+            name: 'ProfileScreen'
49
+          }
50
+        }
51
+      ],
52
+      options: {
53
+        bottomTab: {
54
+          icon: require('./profile.png')
55
+        }
56
+      }
57
+    }
58
+  ]
59
+}
60
+```
61
+
62
+Once we run this code, our BottomTabs should look like this:
63
+<img width="40%" src={useBaseUrl('img/bottomTabs.png')} />
64
+
65
+## Selecting Tabs Programmatically
66
+Tabs can be selected programmatically by updating the `currentTabIndex` or `currentTabId` options.
67
+
68
+We'll use the BottomTabs layout showcased [above](bottomTabs-docs#example) to demonstrate programmatic tab selection.
69
+
70
+### Selecting a tab by index
71
+The following mergeOptions command will select the second tab. We're passing the id of our BottomTabs layout, but we could also use the id of any of the child components, for example `PROFILE_TAB` or `PROFILE_SCREEN`.
72
+
73
+```js
74
+Navigation.mergeOptions('BOTTOM_TABS_LAYOUT', {
75
+  bottomTabs: {
76
+    currentTabIndex: 1
77
+  }
78
+});
79
+```
80
+
81
+### Selecting a tab by id
82
+Tabs can also be selected by id (`componentId`). This is particularly useful in cases where you don't know in which tab a screen is contained.
83
+For example, if invoked from one of the child components, `HOME_SCREEN` or `SETTINGS_SCREEN`, the following merge command will select the tab containing the child.
84
+
85
+```js
86
+Navigation.mergeOptions(this.props.componentId, {
87
+  bottomTabs: {
88
+    currentTabId: this.props.componentId
89
+  }
90
+});
91
+```
92
+
93
+## Changing BottomTabs visibility
94
+
95
+The `visible` property is used to control the BottomTab visibility. Visibility can be toggled dynamically using the `mergeOptions` command.
96
+```js
97
+Navigation.mergeOptions(componentId, {
98
+  bottomTabs: {
99
+    visible: false
100
+  },
101
+});
102
+```
103
+
104
+Visibility can also be changed when pushing screens.
105
+```js
106
+Navigation.push(componentId, {
107
+  component: {
108
+    name: 'pushedScreen',
109
+    options: {
110
+      bottomTabs: {
111
+        visible: false
112
+      }
113
+    }
114
+  }
115
+});
116
+```
117
+
118
+## Updating tab options dynamically
119
+
120
+To update a tab option, like an icon, text or color, simply call `mergeOptions` with new options using the id of a component or layout contained in the tab you wish to update.
121
+
122
+For instance, in the example below we update the color of a specific tab:
123
+```js
124
+Navigation.mergeOptions(componentId, {
125
+  bottomTab: {
126
+    iconColor: 'red',
127
+    textColor: 'red'
128
+  },
129
+});
130
+```
131
+
132
+## Controlling tab loading
133
+
134
+By default, all tabs are mounted at the same time. This can have a negative impact on performance since screens which are not visible to the user are mounted.
135
+
136
+The order in which tabs are mounted can be configured with the `tabsAttachMode` option:
137
+
138
+* `together` - all tabs are mounted at the same time, this is the default behavior.
139
+* `afterInitialTab` - after initial tab is mounted, other tabs are mounted.
140
+* `onSwitchToTab` - initial tab is mounted, other tabs are mounted when the user navigates to them for the first time.

+ 28
- 0
website/docs/docs-constants.mdx View File

@@ -0,0 +1,28 @@
1
+---
2
+id: constants-docs
3
+title: Constants
4
+sidebar_label: Constants
5
+---
6
+
7
+React Native Navigation exposes a set of constants which can be used to get the dimensions of various navigation elements on the screen: StatusBar, TopBar and BottomTabs.
8
+
9
+## When are constants evaluated
10
+Some of the values exposed through the constants API are actually evaluated only after the UI is created (`setRoot` has been called) and therefore are not accessible through static getters.
11
+
12
+For example, if you need to get the height of the BottomTabs, you'll first need to have BottomTabs visible on the screen and only then retrieve their height via the constants API.
13
+
14
+:::important
15
+We recommend you don't cache the actual constants object returned by `await Navigation.constants()` as it might not be accurate later on when, for example, a new root is set or orientation changes.
16
+:::
17
+
18
+## API
19
+As explained above, constants are evaluated in native each time the API is invoked. That's why `Navigation.constants()` returns a promise and the use is as follows:
20
+
21
+```js
22
+const { Navigation } = require('react-native-navigation');
23
+const {
24
+  statusBarHeight,
25
+  TopBarHeight,
26
+  BottomTabsHeight
27
+} = await Navigation.constants();
28
+```

+ 100
- 0
website/docs/docs-externalComponent.mdx View File

@@ -0,0 +1,100 @@
1
+---
2
+id: docs-externalComponent
3
+title: External Component
4
+sidebar_label: External Component
5
+---
6
+
7
+The ExternalComponent layout allows you to display any native view as a screen. To use the External Component we'll need to register it with a string name. This name is then used when declaring layouts in JS.
8
+
9
+## Android
10
+### Implementing the native component
11
+When it comes to implementing an external component on Android, you have two choices. We recommend you use a base class extending `View`. If you're required to use Fragments, you'll find an basic example below.
12
+
13
+#### ViewGroup
14
+```java
15
+public class ViewGroupComponent implements ExternalComponent {
16
+    private final FrameLayout content;
17
+
18
+    ViewGroupComponent(FragmentActivity activity, JSONObject props) {
19
+        content = new FrameLayout(activity);
20
+    }
21
+
22
+    @Override
23
+    public View asView() {
24
+        return content;
25
+    }
26
+}
27
+```
28
+
29
+#### Fragment
30
+
31
+Using a Fragment as an external component is done by attaching the Fragment to a FrameLayout, and returning the FrameLayout from the `asView()` method of the ExternalComponent.
32
+
33
+```java
34
+public class FragmentComponent implements ExternalComponent {
35
+    private final FrameLayout content;
36
+
37
+    FragmentComponent(FragmentActivity activity, JSONObject props) {
38
+        // Create the FrameLayout to which we'll attach our Fragment to
39
+        content = new FrameLayout(activity);
40
+        content.setId(R.id.fragment_screen_content);
41
+        // Attach the Fragment to the FrameLayout
42
+        activity.getSupportFragmentManager()
43
+                .beginTransaction()
44
+                .add(R.id.fragment_screen_content, createFragment(props))
45
+                .commitAllowingStateLoss();
46
+    }
47
+
48
+    private FragmentScreen createFragment(JSONObject props) {
49
+        FragmentScreen fragment = new FragmentScreen();
50
+        // Pass the props sent from Js in a bundle
51
+        Bundle args = new Bundle();
52
+        args.putString("text", props.optString("text", ""));
53
+        fragment.setArguments(args);
54
+        return fragment;
55
+    }
56
+
57
+    @Override
58
+    public View asView() {
59
+        return content;
60
+    }
61
+}
62
+```
63
+
64
+### Registering the component
65
+```java
66
+public class MainApplication extends NavigationApplication {
67
+  @Override
68
+    public void onCreate() {
69
+        super.onCreate();
70
+        registerExternalComponent("MyExternalComponent", new FragmentCreator());
71
+    }
72
+}
73
+```
74
+
75
+## iOS
76
+### ViewController registration
77
+
78
+```objectivec
79
+[ReactNativeNavigation registerExternalComponent:@"MyExternalComponent" callback:^UIViewController *(NSDictionary *props, RCTBridge *bridge) {
80
+	return [[ExternalViewController alloc] initWithProps:props];
81
+}];
82
+
83
+```
84
+## Using the component from JS
85
+Once you've registered the external component in native, you can use it in your layout declarations.
86
+For example, to show an external component modally:
87
+```js
88
+Navigation.showModal({
89
+  externalComponent: {
90
+    name: 'MyExternalComponent',
91
+    passProps: {
92
+      text: "Text from JS"
93
+    }
94
+  }
95
+});
96
+```
97
+
98
+:::caution
99
+props passed to external components are sent over the bridge and therefore must be serializable.
100
+:::

+ 126
- 0
website/docs/docs-modal.mdx View File

@@ -0,0 +1,126 @@
1
+---
2
+id: docs-modal
3
+title: Modal
4
+sidebar_label: Modal
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+import useBaseUrl from '@docusaurus/useBaseUrl';
10
+
11
+In human-centered design, when we speak about a modal (or modality), we often refer to a set of techniques, aimed at bringing user attention to a specific event / screen / action / etc. Those often require user input. A pop-up on a website, a file deletion confirmation dialogue on your computer, or an alert asking you to enable location service on your phone - these can all be considered modals.
12
+
13
+A modal is a term used in native iOS world ([full description here](https://developer.apple.com/design/human-interface-guidelines/ios/app-architecture/modality/)), while on Android, [dialogs](https://developer.android.com/guide/topics/ui/dialogs) are often used to create similar or identical behavior, alongside other techniques.
14
+
15
+## Presenting modals
16
+Modal can be displayed by invoking the `Navigation.showModal()` command, as shown in the example below:
17
+
18
+```js
19
+Navigation.showModal({
20
+  stack: {
21
+    children: [
22
+      {
23
+        component: {
24
+          name: 'MODAL_SCREEN',
25
+          options: {
26
+            topBar: {
27
+              title: {
28
+                text: 'Modal'
29
+              }
30
+            }
31
+          }
32
+        }
33
+      }
34
+    ]
35
+  }
36
+});
37
+```
38
+
39
+Here's how the Modal looks on both platforms.
40
+
41
+<Tabs
42
+  defaultValue="ios"
43
+  values={[
44
+    { label: 'iOS', value: 'ios', },
45
+    { label: 'Android', value: 'android', }
46
+  ]}>
47
+  <TabItem value="ios">
48
+    <img width="40%"  src={useBaseUrl('img/modal_ios.gif')} />
49
+  </TabItem>
50
+  <TabItem value="android">
51
+    <img width="40%" src={useBaseUrl('img/modal_android.gif')} />
52
+  </TabItem>
53
+</Tabs>
54
+
55
+## Adding a dismiss button
56
+Modals should always have a dismiss button, on left-to-right devices it's typically placed as a left button in the TopBar.
57
+
58
+After we've added our dismiss button, we need to dismiss the modal when the button is pressed.
59
+
60
+:::note
61
+For the LeftButton to be visible, the screen must be displayed in a Stack.
62
+:::
63
+
64
+```js
65
+class ModalScreen extends React.Component {
66
+  // Set a dismiss button in static options
67
+  static options() {
68
+    return {
69
+      topBar: {
70
+        leftButtons: {
71
+          id: 'dismiss',
72
+          icon: require('./dismiss.png')
73
+        }
74
+      }
75
+    };
76
+  }
77
+
78
+  constructor(props) {
79
+    super(props);
80
+    // Register to events
81
+    Navigation.events().bindComponent(this);
82
+  }
83
+
84
+  // Handle the button press event and dismiss the modal if needed
85
+  navigationButtonPressed({ buttonId }) {
86
+    if (buttonId === 'dismiss') {
87
+      Navigation.dismissModal(this.props.componentId);
88
+    }
89
+  }
90
+}
91
+```
92
+
93
+## Transparent modals
94
+Showing transparent modals is a nice technique to increase immersiveness while keeping the user in the same context.
95
+When a modal is displayed the content behind it (either root or modal) is removed from hierarchy. While this behavior improves performance, it's undesired when
96
+showing transparent modals as we need to see the content behind it.
97
+
98
+To configure this behaviour, we'll need to change the `modalPresentationStyle` option to `overCurrentContext` and change the layout background color to `'transparent'`.
99
+
100
+```js
101
+{
102
+  modalPresentationStyle: 'overCurrentContext',
103
+  layout: {
104
+    backgroundColor: 'transparent'
105
+  }
106
+}
107
+```
108
+
109
+## Preventing a Modal from being dismissed
110
+Preventing a modal from being dismissed is done differently for each platform. While preventing the user from dismissing the modal is possible,
111
+the modal could still be dismissed programmatically by calling `Navigation.dismissModal()`
112
+
113
+If the modal has a dismiss button, of course you'll need to handle it your self and avoid calling `Navigation.dismissModal()`
114
+when the button is pressed.
115
+
116
+### Android
117
+On Android, modals can be dismissed with the hardware back button. You can handle the back press your self by
118
+adding a [BackHandler](https://facebook.github.io/react-native/docs/backhandler)
119
+
120
+### iOS
121
+While iOS devices don't have a hardware back button, PageSheet modals can be dismissed by swipe gesture
122
+from the top of the screen. To disable it, set [swipeToDismiss]() option to false.
123
+
124
+## Presentation Style
125
+
126
+The [presentation style](options-root#modalpresentationstyle) determines the look and feel of a screen displayed as modal.

+ 152
- 0
website/docs/docs-overlay.mdx View File

@@ -0,0 +1,152 @@
1
+---
2
+id: docs-overlay
3
+title: Overlay
4
+sidebar_label: Overlay
5
+---
6
+import Tabs from '@theme/Tabs';
7
+import TabItem from '@theme/TabItem';
8
+import useBaseUrl from '@docusaurus/useBaseUrl';
9
+
10
+Overlays are used to layout content on top of all other layout hierarchies, while fitting the screen bounds.
11
+The contents displayed in an Overlay can either be non-obtrusive, like Toasts and Snackbars, or an Alert that blocks all interactions with any content behind it. The view contained within it should be aligned either with absolute position, flex, or with margins, all according to your needs.
12
+
13
+## Handling touch events outside the view
14
+When showing views like Alert or Toast in an Overlay, you would want to configure if you want to allow users to interact with content behind the alert. This is done via the [interceptTouchOutside]() option.
15
+
16
+## Overlay examples
17
+
18
+<Tabs
19
+  defaultValue="alert"
20
+  values={[
21
+    { label: 'Alert', value: 'alert', },
22
+    { label: 'Toast', value: 'toast', }
23
+  ]
24
+}>
25
+<TabItem value='alert'>
26
+
27
+The example below demonstrates how to create a simple alert dialog using an Overlay. Touch events outside the alert will be blocked and won't pass through to the content behind the alert since we're specifying `interceptTouchOutside: true` in the static options of the Alert.
28
+
29
+[screenshot](/img/alert_android.png)
30
+
31
+```jsx
32
+const React = require('react');
33
+const { Text, Button, View } = require('react-native');
34
+const { Navigation } = require('react-native-navigation');
35
+
36
+function Alert({ componentId, title, message }) {
37
+  const dismiss = () => Navigation.dismissOverlay(componentId);
38
+
39
+  return (
40
+    <View style={styles.root}>
41
+      <View style={styles.alert}>
42
+        <Text style={styles.title}>{title}</Text>
43
+        <Text style={styles.message}>{message}</Text>
44
+        <Button title='OK' onPress={dismiss} />
45
+      </View>
46
+    </View>
47
+  );
48
+}
49
+
50
+const styles = {
51
+  root: {
52
+    flex: 1,
53
+    justifyContent: 'center',
54
+    alignItems: 'center',
55
+    backgroundColor: '#00000050'
56
+  },
57
+  alert: {
58
+    alignItems: 'center',
59
+    backgroundColor: 'whitesmoke',
60
+    width: 250,
61
+    elevation: 4,
62
+    padding: 16
63
+  },
64
+  title: {
65
+    fontSize: 18
66
+  },
67
+  message: {
68
+    marginVertical: 8
69
+  }
70
+};
71
+
72
+Alert.options = (props) => {
73
+  return ({
74
+    overlay: {
75
+      interceptTouchOutside: true
76
+    }
77
+  });
78
+}
79
+
80
+module.exports = Alert;
81
+
82
+```
83
+
84
+</TabItem>
85
+<TabItem value='toast'>
86
+
87
+The example below demonstrates how to show a Toast using an Overlay. A user can interact with the content behind the toast since we've declared `interceptTouchOutside: false` in the static options of the Alert.
88
+
89
+[screenshot](/img/toast_android.png)
90
+
91
+```jsx
92
+const React = require('react');
93
+const { View, Text, StyleSheet, TouchableOpacity } = require('react-native');
94
+const Colors = require('../commons/Colors');
95
+const Navigation = require('../services/Navigation');
96
+
97
+const Toast = function ({componentId}) {
98
+  return (
99
+    <View style={styles.root}>
100
+      <View style={styles.toast}>
101
+        <Text style={styles.text}>This a very important message!</Text>
102
+        <TouchableOpacity style={styles.button} onPress={() => Navigation.dismissOverlay(componentId)}>
103
+          <Text style={styles.buttonText}>OK</Text>
104
+        </TouchableOpacity>
105
+      </View>
106
+    </View>
107
+  )
108
+}
109
+
110
+const styles = StyleSheet.create({
111
+  root: {
112
+    flex: 1,
113
+    flexDirection: 'column-reverse',
114
+  },
115
+  toast: {
116
+    elevation: 2,
117
+    flexDirection: 'row',
118
+    height: 40,
119
+    margin: 16,
120
+    borderRadius: 20,
121
+    backgroundColor: Colors.accent,
122
+    alignItems: 'center',
123
+    justifyContent: 'space-between'
124
+  },
125
+  text: {
126
+    color: 'white',
127
+    fontSize: 16,
128
+    marginLeft: 16
129
+  },
130
+  button: {
131
+    marginRight: 16
132
+  },
133
+  buttonText: {
134
+    color: 'white',
135
+    fontSize: 16,
136
+    fontWeight: 'bold'
137
+  }
138
+});
139
+
140
+Toast.options = {
141
+  layout: {
142
+    componentBackgroundColor: 'transparent'
143
+  },
144
+  overlay: {
145
+    interceptTouchOutside: false
146
+  }
147
+}
148
+
149
+module.exports = Toast;
150
+```
151
+</TabItem>
152
+</Tabs>

+ 147
- 0
website/docs/docs-root.mdx View File

@@ -0,0 +1,147 @@
1
+---
2
+id: docs-root
3
+title: Root
4
+sidebar_label: Root
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+
10
+The root is where the application layout structure is defined. It is typically the first UI element a user interacts with. The root can be changed multiple times during the lifespan of the application. For example, if an app requires users to login, it's common to use a stack-based root and transition to either tabs- or SideMenu-based root if login is successful.
11
+
12
+## Setting root on app launch
13
+RNN exposes an appLaunched listener which is invoked whenever root needs to be set.
14
+
15
+On iOS, the app launched event is usually emitted once in the lifespan of the application - when the app is opened for the first time. On Android things become a little bit more complicated. Like on iOS, the event is emitted when an app is opened for the first time. Since the system can destroy the Activity when the app is in the background to free resources, the event is emitted when the app returns to foreground after the activity has been destroyed.
16
+
17
+```js
18
+Navigation.events().registerAppLaunchedListener(() => {
19
+  Navigation.setRoot({
20
+    root: {
21
+
22
+    }
23
+  });
24
+});
25
+```
26
+
27
+:::important
28
+registerAppLaunchedListener() must be called as soon as the bundle is executed. Otherwise the event, which is emitted from native to JS, won't be handled at the correct moment in time.
29
+::::
30
+
31
+## Conditional initial root
32
+A common use case is to set the initial root according to a condition of some sort. For example:
33
+
34
+> If a user is logged in, show the application main root; otherwise show a login screen.
35
+
36
+To do this, simply set the appropriate root according to your needs.
37
+```js
38
+Navigation.events().registerAppLaunchedListener(() => {
39
+  if (isUserLoggedIn()) {
40
+    setMainRoot();
41
+  } else {
42
+    setLoginRoot();
43
+  }
44
+});
45
+```
46
+
47
+## Common root structures
48
+
49
+<Tabs
50
+  defaultValue='stack'
51
+  values={[
52
+    { label: 'Stack root', value: 'stack' },
53
+    { label: 'BottomTabs root', value: 'bottomTabs' },
54
+    { label: 'SideMenu root', value: 'sideMenu' }
55
+  ]
56
+}>
57
+
58
+<TabItem value='stack'>
59
+Stacks are usually used as root for small scale apps or for short-lived flows within one big app. For example, here's a login flow:
60
+
61
+```js
62
+Navigation.setRoot({
63
+  root: {
64
+    stack: {
65
+      children: [
66
+        {
67
+          component: {
68
+            name: 'LOGIN_SCREEN'
69
+          }
70
+        }
71
+      ]
72
+    }
73
+  }
74
+});
75
+```
76
+
77
+</TabItem>
78
+
79
+<TabItem value='bottomTabs'>
80
+Typically, stacks are used as direct children of BottomTabs and each child is an independent root. This lets users seamlessly switch between tabs as each tab has its own navigation hierarchy.
81
+
82
+```js
83
+Navigation.setRoot({
84
+  root: {
85
+    bottomTabs: {
86
+      children: [
87
+        stack: {
88
+          children: [
89
+            {
90
+              component: {
91
+                name: 'FEED_SCREEN'
92
+              }
93
+            }
94
+          ]
95
+        },
96
+        stack: {
97
+          children: [
98
+            {
99
+              component: {
100
+                name: 'CHAT_LIST'
101
+              }
102
+            }
103
+          ]
104
+        },
105
+        stack: {
106
+          children: [
107
+            {
108
+              component: {
109
+                name: 'PROFILE_SCREEN'
110
+              }
111
+            }
112
+          ]
113
+        }
114
+      ]
115
+    }
116
+  }
117
+});
118
+```
119
+
120
+</TabItem>
121
+
122
+<TabItem value='sideMenu'>
123
+When a SideMenu layout is used as root, the center screen would typically be a stack. The center stack should be treated as a root - you can push child screens into it, or replace it alltogether by calling `setStackRoot`.
124
+
125
+```js
126
+Navigation.setRoot({
127
+  root: {
128
+    sideMenu: {
129
+      center: {
130
+        stack: {
131
+          children: [
132
+            name: 'HOME_SCREEN'
133
+          ]
134
+        }
135
+      },
136
+      left: {
137
+        component: {
138
+          name: 'MENU_SCREEN'
139
+        }
140
+      }
141
+    }
142
+  }
143
+});
144
+```
145
+
146
+</TabItem>
147
+</Tabs>

+ 258
- 0
website/docs/docs-stack.mdx View File

@@ -0,0 +1,258 @@
1
+---
2
+id: docs-stack
3
+title: Stack
4
+sidebar_label: Stack
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+
10
+A stack is a container layout promoting a hierarchical navigation. It is used for navigating between screens at consecutive levels of hierarchy, steps in a flow or across an app.
11
+
12
+The first child in the stack (represented by the `children` array) is the root and is displayed at the bottom of the stack. The last child in the children array is the child currently being displayed.
13
+
14
+In this layout, only a single child screen is visible at any given time and consecutive screen can be added to the top of the stack using the `Navigation.push` command. Tapping the back button will pop the stack and remove the top most screen.
15
+
16
+The stack manages the TopBar at the top of the stack. The TopBar displays the current screens' title and buttons. It can be hidden with the `topBar: { visible: false }` option. By default, screens are rendered below the TopBar. This behavior can be changed by setting `topBar: { drawBehind: true }` in the current screens' options.
17
+
18
+# Layout Examples
19
+<Tabs
20
+  defaultValue="single"
21
+  values={[
22
+    { label: 'Single child', value: 'single', },
23
+    { label: 'Multiple Children', value: 'multiple', }
24
+  ]
25
+}>
26
+<TabItem value="single">
27
+
28
+A stack declared with a single child.
29
+
30
+```js
31
+const stack = {
32
+  children: [
33
+    {
34
+      component: {
35
+        name: 'MyComponent'
36
+      }
37
+    }
38
+  ]
39
+}
40
+```
41
+
42
+</TabItem>
43
+<TabItem value="multiple">
44
+
45
+A stack can be initialized with more than one child, in which case the last child will be the currently displayed child and the first child will be hidden. In this case the back button will be visible automatically, clicking it will go back in the stack revealing the first (previous) child.
46
+Once the root child becomes visible, the back button is hidden.
47
+
48
+```js
49
+const stack = {
50
+  children: [
51
+    {
52
+      component: {
53
+        name: 'RootComponent'
54
+      }
55
+    },
56
+    {
57
+      component: {
58
+        name: 'SecondComponent'
59
+      }
60
+    }
61
+  ]
62
+}
63
+```
64
+
65
+</TabItem>
66
+</Tabs>
67
+
68
+## TopBar Buttons
69
+Buttons can be added to the [right](#rightButtons) and [left](#leftButtons) areas of the TopBar. Buttons can have either an icon or a text. They are declared in the the options object and, as with any other option, can be updated dynamically with the `Navigation.mergeOptions` command.
70
+
71
+:::tip Always assign titles to buttons!
72
+When using an icon button on **Android**, you should always pass a title as well. The title is used when the button is collapsed to the overflow menu and as a tooltip when the button is long pressed.
73
+:::
74
+
75
+### Overflow menu
76
+It's common practice to group less important actions in a menu or an action sheet.
77
+
78
+To do so on iOS, include a button with a menu icon and open an [ActionSheet](https://facebook.github.io/react-native/docs/actionsheetios) with the relevant actions when the button is clicked.
79
+
80
+On Android, use the [showAsAction](#showasaction) options to control when the button should appear in the menu.
81
+
82
+### Left button
83
+Left buttons behave like right buttons with two caveats on Android:
84
+* Only a single left button is allowed
85
+* Textual left button isn't supported
86
+
87
+### Using a react component in a button
88
+:::caution
89
+At the moment, custom buttons in `rightButtons` are supported only on iOS.
90
+:::
91
+
92
+Sometimes we require more from our buttons. In order to support every product need React Components can be used as custom views of buttons.
93
+To do so, you'll first need to register the view with Navigation, just like you register your components used as screens:
94
+
95
+```js
96
+Navigation.registerComponent('ButtonComponent', () => require('./ButtonComponent'));
97
+```
98
+
99
+Now you can create buttons which use the component registered with `'ButtonComponent'` as their custom view:
100
+
101
+```js
102
+topBar: {
103
+  rightButtons: [
104
+    {
105
+      component: 'ButtonComponent',
106
+      passProps: {
107
+        // Pass initial props to the button here
108
+      }
109
+    }
110
+  ]
111
+}
112
+```
113
+
114
+### Updating props of custom buttons
115
+To update props of a mounted component used as a button, you'll first need to assign it a unique id, then call the `Navigation.updateProps()` command with the id.
116
+
117
+Calling the updateProps command will trigger Reacts component lifecycle methods related to [props update](https://reactjs.org/docs/react-component.html#updating)
118
+```js
119
+// Declare the button and assign it a unique id
120
+topBar: {
121
+  rightButtons: [
122
+    {
123
+      id: 'SomeUniqueId',
124
+      component: 'ButtonComponent',
125
+      passProps: {
126
+        count: 0
127
+      }
128
+    }
129
+  ]
130
+}
131
+
132
+// Update props
133
+Navigation.updateProps('SomeUniqueId', {
134
+  count: 1
135
+});
136
+```
137
+
138
+### Changing buttons dynamically
139
+As buttons are part of a screen's options, they can be modified like any other styling option using the [mergeOptions]() command.
140
+
141
+#### Setting buttons
142
+The following command will set the screen's right buttons. If the screen already has Right Buttons declared - they will be overridden.
143
+
144
+```js
145
+Navigation.mergeOptions(this.props.componentId, {
146
+  topBar: {
147
+    rightButtons: [
148
+      {
149
+        id: 'myDynamicButton',
150
+        text: 'My Button'
151
+      }
152
+    ]
153
+  }
154
+});
155
+```
156
+
157
+#### Removing buttons
158
+Buttons can be removed by setting zero buttons, as shown in the snippet below.
159
+
160
+```js
161
+Navigation.mergeOptions(this.props.componentId, {
162
+  topBar: {
163
+    rightButtons: []
164
+  }
165
+});
166
+```
167
+
168
+## Back Button
169
+The back button is added automatically when two or more screens are pushed into the stack.
170
+
171
+### Styling the back button
172
+The back button's style can be customized by declaring a backButton options object. This configuration can be part of a screen's static options, or default options.
173
+
174
+```js
175
+backButton: {
176
+  color: 'red',
177
+  icon: require('../../img/customChevron.png')
178
+}
179
+```
180
+
181
+### Controlling visibility
182
+The back buttons visibility can be controlled with the visible property.
183
+
184
+```js
185
+backButton: {
186
+  visible: false
187
+}
188
+```
189
+
190
+### Changing visibility programmatically
191
+Back button visibility can be changed dynamically using the mergeOptions command. When using a screen's componentId, the change will affect only that specific screen. But when using the stack's id, the change will affect all screens pushed into the stack.
192
+
193
+```js
194
+Navigation.mergeOptions(this.props.componentId, {
195
+  backButton: {
196
+    visible: false
197
+  }
198
+});
199
+```
200
+
201
+### Handling the back button
202
+Handling the back button is not possible. However, you can set a left button with a chevron and handle it like you'd handle any other button and calling `Navigation.pop` when desired.
203
+
204
+## Interacting programmatically
205
+The Navigation object provides ways to programmatically manipulate the stack.
206
+
207
+### Interact with the Stack by componentId
208
+Each layout pushed into the stack has an id. When in the context of a component, The component's `componentId` can be used to interact with a parent stack.
209
+When using a component's componentId, the native implementation knows to perform the command on the parent Stack of this component.
210
+
211
+In this example, we push a screen onto the component's parent stack.
212
+
213
+```jsx
214
+const React = require('react');
215
+const Navigation = require('react-native-navigation');
216
+
217
+class MyComponent extends React.Component {
218
+  onButtonClick = () => {
219
+    Navigation.push(this.props.componentId, {
220
+      component: {
221
+        name: 'PUSHED_SCREEN'
222
+      }
223
+    });
224
+  }
225
+}
226
+```
227
+
228
+### Interact with the Stack by a predefined id
229
+Sometimes we're required to interact with a specific stack not from the context of a component pushed into it. To do so, assign the stack a predefined `id` and use it when invoking any stack command.
230
+
231
+```js
232
+Navigation.setRoot({
233
+  root: {
234
+    stack: {
235
+      id: 'MyStack', // This is the id we're going to use when interacting with the stack
236
+      children: [
237
+        {
238
+          component: {
239
+            name: 'SomeComponent'
240
+          }
241
+        }
242
+      ]
243
+    }
244
+  }
245
+});
246
+
247
+function push() {
248
+  Navigation.push('MyStack', {
249
+    component: {
250
+      name: 'PushedScreen'
251
+    }
252
+  });
253
+}
254
+```
255
+
256
+## Disabling back navigation
257
+
258
+## Handling back navigation

+ 50
- 0
website/docs/layout-BottomTabs.mdx View File

@@ -0,0 +1,50 @@
1
+---
2
+id: bottomTabs-layout
3
+title: Bottom Tabs
4
+sidebar_label: Bottom Tabs
5
+---
6
+
7
+A container view for managing a radio-style selection interface, where a selection determines which child view controller to display.
8
+
9
+```js
10
+{
11
+  id: 'BOTTOM_TABS_LAYOUT',
12
+  children: [
13
+    {
14
+      component: {
15
+        id: 'HOME_SCREEN'
16
+        name: 'HomeScreen'
17
+      }
18
+    },
19
+    stack: {
20
+      id: 'PROFILE_TAB',
21
+      children: [
22
+        {
23
+          component: {
24
+            id: 'PROFILE_SCREEN',
25
+            name: 'ProfileScreen'
26
+          }
27
+        }
28
+      ]
29
+    }
30
+  ]
31
+}
32
+```
33
+
34
+## `id`
35
+
36
+| Type   | Required | Description                                                                                                                                                    |
37
+| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
38
+| string | No       | Unique id used to interact with the view via the Navigation api, usually `Navigation.mergeOptions` which accepts the componentId as it's first argument. |
39
+
40
+## `children`
41
+
42
+| Type               | Required | Description                   |
43
+| ------------------ | -------- | ----------------------------- |
44
+| [Layout[]](Layout.mdx) | YES      | Child layouts of any kind. |
45
+
46
+## `options`
47
+
48
+| Type                    | Required | Description                                                   |
49
+| ----------------------- | -------- | ------------------------------------------------------------- |
50
+| [Options](options-root.mdx) | No       | dynamic options which will apply to all screens in bottomTabs |

+ 55
- 0
website/docs/layout-component.mdx View File

@@ -0,0 +1,55 @@
1
+---
2
+id: component-layout
3
+title: Component
4
+sidebar_label: Component
5
+---
6
+
7
+```js
8
+{
9
+  name: "MyRegisteredComponent";
10
+}
11
+```
12
+
13
+## `name`
14
+
15
+| Type   | Required | Description                                                                      |
16
+| ------ | -------- | -------------------------------------------------------------------------------- |
17
+| string | Yes      | Key used when registering the component with `Navigation.registerComponent`. |
18
+
19
+## `id`
20
+
21
+| Type   | Required | Description                                                                                                                                                    |
22
+| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+| string | No       | Unique id used to interact with the view via the Navigation api, usually `Navigation.mergeOptions` which accepts the componentId as it's first argument. |
24
+
25
+## `options`
26
+
27
+| Type                    | Required | Description                       |
28
+| ----------------------- | -------- | --------------------------------- |
29
+| [Options](options-root.mdx) | No       | dynamic options for the component |
30
+
31
+## `alignment`
32
+
33
+| Type                   | Required | Description                                                                                                                                                                                                                                                                         |
34
+| ---------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35
+| enum('center', 'fill') | No       | This option is relevant only to title components. `fill` will make the component stretch and consume all available space in the TopBar while `center` will center it in the middle of the TopBar. `center` is the default option in iOS while `fill` is the default for Android. |
36
+
37
+## `waitForRender`
38
+
39
+| Type    | Required | Description                                                        |
40
+| ------- | -------- | ------------------------------------------------------------------ |
41
+| boolean | No       | Wait for this component to fully render before showing the screen. |
42
+
43
+This option is useful for ensuring that both a child screen pushed into the stack and all of the TopBar components (title, background and buttons) are displayed to the user at the same time.
44
+
45
+To enable this option, `waitForRender` in the relevant screen animation option needs to be enabled as well.
46
+
47
+:::caution
48
+This option might introduce delays when pushing screens and should be used with caution.
49
+:::
50
+
51
+## `passProps`
52
+
53
+| Type   | Required | Description                                                                        |
54
+| ------ | -------- | ---------------------------------------------------------------------------------- |
55
+| object | No       | A JavaScript object with props accessible inside the component using `this.props`. |

+ 57
- 0
website/docs/layout-options.mdx View File

@@ -0,0 +1,57 @@
1
+---
2
+id: layout-options
3
+title: Layout Options
4
+sidebar_label: Layout
5
+---
6
+
7
+```js
8
+const options = {
9
+  layout: {}
10
+};
11
+```
12
+
13
+### `fitSystemWindows`
14
+
15
+| Type    | Required | Platform |
16
+| ------- | -------- | -------- |
17
+| boolean | No       | Both     |
18
+
19
+### `backgroundColor`
20
+
21
+Set the screen background color.
22
+
23
+| Type  | Required | Platform |
24
+| ----- | -------- | -------- |
25
+| Color | No       | Both     |
26
+
27
+### `componentBackgroundColor`
28
+
29
+Set background color only for components, helps reduce overdraw if background color is set in default options.
30
+
31
+| Type  | Required | Platform |
32
+| ----- | -------- | -------- |
33
+| Color | No       | Android  |
34
+
35
+### `orientation`
36
+
37
+Set the allowed orientations.
38
+
39
+| Type                      | Required | Platform |
40
+| ------------------------- | -------- | -------- |
41
+| ['portrait', 'landscape'] | No       | Both     |
42
+
43
+### `topMargin`
44
+
45
+Set the layout top margin.
46
+
47
+| Type   | Required | Platform |
48
+| ------ | -------- | -------- |
49
+| number | No       | Android  |
50
+
51
+### `direction`
52
+
53
+Set language direction, only works with DefaultOptions.
54
+
55
+| Type               | Required | Platform |
56
+| ------------------ | -------- | -------- |
57
+| enum('rtl', 'ltr') | No       | Both     |

+ 91
- 0
website/docs/meta-contributing.mdx View File

@@ -0,0 +1,91 @@
1
+---
2
+id: meta-contributing
3
+title: Contributing
4
+sidebar_label: Contributing
5
+---
6
+
7
+Thank you for showing interest in contributing to React-Native-Navigation! This project is developed and maintained by Wix in collaboration with the community.
8
+
9
+There are various ways in which you can contribute to this library, not all require knowledge or expertise in native development. Listed below is all you need to get started with your first contribution.
10
+
11
+## Stack Overflow
12
+
13
+Stack Overflow is used by developers to find answers and troubleshoot code. Users are encouraged to post questions on SO and tag them with the [wix-react-native-navigation](https://stackoverflow.com/questions/tagged/wix-react-native-navigation) tag. Answering issues on SO is very helpful and beneficial to the community, only this time, there's a personal angle - you can boost your SO ranking and rack up points quickly.
14
+
15
+## Discord
16
+
17
+Another popular communication channel is our [Discord channel](https://discord.gg/DhkZjq2) where users post questions and consult with each other. You're welcome to join the discussions and answer questions. This is also a great place to meet other community members and project maintainers.
18
+
19
+## GitHub Issues
20
+
21
+### Open an issue
22
+Found a bug? Missing a feature? Go ahead and open an issue! Make sure to add all details mentioned in the issue template. If you're interested in suggesting a big change, please speak to one of the admins on [Discord](#discord) to coordinate your effort.
23
+
24
+### Respond to issues
25
+Although the issue tracker is used solely for bug reports, issues are frequently opened for questions or to request assistance. As the project grows in popularity, more issues remain unanswered for long periods of time.
26
+
27
+Some issues can be trivial and easy to pinpoint - a missing import statement or apostrophe, wrong layout structure, etc. If you're an experienced user, helping out newcomers can be quite satisfying and allows maintainers to focus on features and bug fixes.
28
+
29
+Some issues are tagged as ["looking for contributors"](https://github.com/wix/react-native-navigation/labels/user%3A%20looking%20for%20contributors). These issues have been recognized by the team, but aren't prioritized by Wix developers due to lack of time or for some other reason. We leave these issues to our community and you're more than welcome to take a crack at them. If you'd like to submit a PR, see [these instructions](#running-the-project) on how to run the project locally.
30
+
31
+### Provide reproductions
32
+Reproducing bugs takes time. Lots of time. Usually that's because an issue is lacking important information, which then causes lots of back and forth communication between maintainers and users. Help us address more bugs and issues by providing reproductions.
33
+
34
+Providing reproductions improves the chances of an issue being prioritized by maintainers!
35
+
36
+If an issue is reproduced with a specific combination of options, posting these options will usually suffice. If a specific layout structure is involved or specific actions need to be performed in a certain order - then we ask that you fork the project and push a branch with a reproduction to the Playground app.
37
+
38
+Check out the [list of issues requiring reproductions](https://github.com/wix/react-native-navigation/labels/user%3A%20requires%20reproduction).
39
+
40
+## Submitting PRs
41
+So you've fixed a bug or added a feature and you're ready to submit a pull request 🎉🎊 Make sure the title is clear and describes the reason for the PR. Please include any information you can which will help us understand the reasons for the PR, what it fixes and what it changes. Please include before/after pictures/gifs when appropriate.
42
+
43
+## Workflow
44
+This project is driven by tests. Before implementing any feature or fixing any bug, a failing test (e2e or unit or both) should be added, depending on the environment of where the fix should be implemented. For example, for an API change, a failing e2e should be written. For a small bug fix in Android, for example, a unit test in Android should be added.
45
+
46
+This will ensure good quality throughout the life of the project and will help avoid unexpected breakages.
47
+
48
+No PR will be accepted without adequate test coverage.
49
+
50
+If you need help running the project, have a look at the [Playground app](playground-app) section. You can run the tests using the scripts below. 
51
+
52
+
53
+### Tests and the Playground app
54
+Besides an overview of basic React Native Navigation functionality, the [Playground app](playground-app) can (and rather should) be used for e2e tests and reproductions. If your change requires an e2e, add it to the playground app, to the appropriate screen. Again, quick setup instructions available in [Playground app](playground-app) section of these docs.
55
+
56
+:::tip
57
+If a screen contains too many buttons, e2e tests might fail if the button is positioned out of screen bounds because Detox matchers detect it's invisible.
58
+:::
59
+
60
+### Playground app Folder Structure
61
+
62
+| Folder | Description |
63
+| ------ | ----------- |
64
+| `lib` | The project itself composed of: |
65
+| `lib/android` | android sources and unit tests |
66
+| `lib/ios` | iOS sources and unit tests |
67
+| `lib/src` | TypeScript sources and unit tests |
68
+| `lib/dist` | compiled javascript sources and unit tests |
69
+| `lib/dist/index.js` | the entry point for `import Navigation from 'react-native-navigation'` |
70
+| `e2e` | [detox](https://github.com/wix/detox) e2e tests on both Android and iOS |
71
+| `playground` | The end-user project all e2e tests run against. Contains its own `src`, `android` and `ios`. Does not have its own package.json, depends on the local `<root>/lib` for faster local development (no need to `npm install` locally). |
72
+| `integration` | misc javascript integration tests, proving integration with other libraries like redux |
73
+| `scripts` | all scripts |
74
+
75
+### Scripts
76
+
77
+| Command | Description |
78
+| ------- | ----------- |
79
+| `npm install` | installs dependencies |
80
+| `npm run build` | compiles TypeScript sources `./lib/src` into javascript `./lib/dist` |
81
+| `npm run clean` | cleans all build directories, stops packager, fixes flakiness by removing watchman cache, etc. |
82
+| `npm run start` | starts the react-native packager for local debugging |
83
+| `npm run xcode` | for convenience, opens xcode in this project |
84
+| `npm run install-android`  |  builds playground debug/release version and installs on running android devices/emulators. <br></br> **Options:** `-- --release` |
85
+| `npm run uninstall-android` | uninstalls playground from running android devices/simulators |
86
+| `npm run test-js` | runs javascript tests and coverage report |
87
+| `npm run test-unit-ios` | runs ios unit tests in debug/release <br></br> **Options:** `-- --release` |
88
+| `npm run test-unit-android` | runs android unit tests in debug/release <br></br> **Options:** `-- --release` |
89
+| `npm run test-e2e-ios` | runs the ios e2e tests using [detox](https://github.com/wix/detox) in debug/release <br></br> **Options:** `-- --release`|
90
+| `npm run test-e2e-android` | runs the android e2e tests using [detox](https://github.com/wix/detox) in debug/release <br></br> **Options:** `-- --release` |
91
+| `npm run test-all` | runs all tests in parallel |

+ 50
- 0
website/docs/options-backButton.mdx View File

@@ -0,0 +1,50 @@
1
+---
2
+id: backButton-options
3
+title: Back Button Options
4
+sidebar_label: Back Button
5
+---
6
+
7
+Controls the back button styling.
8
+
9
+```js
10
+const options = {
11
+  topBar: {
12
+    backButton: {}
13
+  }
14
+}
15
+```
16
+
17
+### `color`
18
+Change the back button color. This will change the text color as well.
19
+
20
+| Type  | Required | Platform |
21
+| ----- | -------- | -------- |
22
+| color | No       | Both     |
23
+
24
+### `icon`
25
+Change the default back button icon.
26
+
27
+| Type   | Required | Platform |
28
+| ------ | -------- | -------- |
29
+| number | No       | Both     |
30
+
31
+### `showTitle`
32
+Show or hide the text displayed next to the back button.
33
+
34
+| Type   | Required | Platform |
35
+| ------ | -------- | -------- |
36
+| number | No       | iOS      |
37
+
38
+### `title`
39
+Change the text displayed next to the title. Usually the back button shows the title of the previous screen.
40
+
41
+| Type   | Required | Platform |
42
+| ------ | -------- | -------- |
43
+| string | No       | iOS      |
44
+
45
+### `visible`
46
+Hide or show the back button.
47
+
48
+| Type    | Required | Platform |
49
+| ------- | -------- | -------- |
50
+| boolean | No       | Both     |

+ 58
- 0
website/docs/options-background.mdx View File

@@ -0,0 +1,58 @@
1
+---
2
+id: background-options
3
+title: Background Options
4
+sidebar_label: Background
5
+---
6
+
7
+Controls the top bar background styling.
8
+
9
+```js
10
+const options = {
11
+  topBar: {
12
+    background: {}
13
+  }
14
+};
15
+```
16
+
17
+### `color`
18
+
19
+Set the background color. Ignored if a component is specified.
20
+
21
+| Type  | Required | Platform |
22
+| ----- | -------- | -------- |
23
+| Color | No       | Both     |
24
+
25
+### `component`
26
+
27
+Set a react [component](layout-component.mdx) as the background. Useful when you need to show a gradient as background, for instance.
28
+
29
+
30
+On Android, setting an `id` to the Component will prevent the component from being recreated each time it's used by a screen. The component will be created once and whenever possible it will be reused.
31
+
32
+| Type                   | Required | Platform |
33
+| ---------------------- | -------- | -------- |
34
+| [Component](layout-component.mdx) | No       | Both     |
35
+
36
+### `clipToBounds`
37
+
38
+Clip the top bar background to bounds if set to true.
39
+
40
+| Type    | Required | Platform |
41
+| ------- | -------- | -------- |
42
+| boolean | No       | iOS      |
43
+
44
+### `translucent`
45
+
46
+Allows the NavBar to be translucent (blurred).
47
+
48
+| Type    | Required | Platform |
49
+| ------- | -------- | -------- |
50
+| boolean | No       | iOS      |
51
+
52
+### `blur`
53
+
54
+Enable background blur.
55
+
56
+| Type    | Required | Platform |
57
+| ------- | -------- | -------- |
58
+| boolean | No       | iOS      |

+ 133
- 0
website/docs/options-bottomTab.mdx View File

@@ -0,0 +1,133 @@
1
+---
2
+id: bottomTab-options
3
+title: Bottom Tab Options
4
+sidebar_label: Bottom Tab
5
+---
6
+
7
+```js
8
+const options = {
9
+  bottomTab: {
10
+
11
+  }
12
+}
13
+```
14
+
15
+## `badge`
16
+
17
+| Type   | Required | Platform |
18
+| ------ | -------- | -------- |
19
+| string | No       | Both     |
20
+
21
+## `badgeColor`
22
+
23
+| Type  | Required | Platform |
24
+| ----- | -------- | -------- |
25
+| color | No       | Both     |
26
+
27
+## `disableIconTint`
28
+
29
+| Type    | Required | Platform |
30
+| ------- | -------- | -------- |
31
+| boolean | No       | Both     |
32
+
33
+## `dotIndicator`
34
+
35
+| Type         | Required | Platform |
36
+| ------------ | -------- | -------- |
37
+| DotIndicator | No       | Both     |
38
+
39
+## `fontFamily`
40
+
41
+| Type   | Required | Platform |
42
+| ------ | -------- | -------- |
43
+| string | No       | Both     |
44
+
45
+## `fontSize`
46
+
47
+| Type   | Required | Platform |
48
+| ------ | -------- | -------- |
49
+| number | No       | Both     |
50
+
51
+## `icon`
52
+
53
+| Type   | Required | Platform |
54
+| ------ | -------- | -------- |
55
+| number | No       | Both     |
56
+
57
+## `iconColor`
58
+
59
+| Type  | Required | Platform |
60
+| ----- | -------- | -------- |
61
+| color | No       | Both     |
62
+
63
+## `selectedFontSize`
64
+
65
+| Type   | Required | Platform |
66
+| ------ | -------- | -------- |
67
+| number | No       | Both     |
68
+
69
+## `selectedIcon`
70
+
71
+| Type   | Required | Platform |
72
+| ------ | -------- | -------- |
73
+| number | No       | Both     |
74
+
75
+## `selectedIconColor`
76
+
77
+| Type  | Required | Platform |
78
+| ----- | -------- | -------- |
79
+| color | No       | Both     |
80
+
81
+## `iconInsets`
82
+
83
+| Type       | Required | Platform |
84
+| ---------- | -------- | -------- |
85
+| IconInsets | No       | Both     |
86
+
87
+## `disableSelectedIconTint`
88
+
89
+| Type    | Required | Platform |
90
+| ------- | -------- | -------- |
91
+| boolean | No       | Android  |
92
+
93
+## `disableIconTint`
94
+
95
+| Type    | Required | Platform |
96
+| ------- | -------- | -------- |
97
+| boolean | No       | Android  |
98
+
99
+## `selectedTextColor`
100
+
101
+| Type  | Required | Platform |
102
+| ----- | -------- | -------- |
103
+| color | No       | Both     |
104
+
105
+## `testID`
106
+
107
+| Type   | Required | Platform |
108
+| ------ | -------- | -------- |
109
+| string | No       | Both     |
110
+
111
+## `text`
112
+
113
+| Type   | Required | Platform |
114
+| ------ | -------- | -------- |
115
+| string | No       | Both     |
116
+
117
+## `textColor`
118
+
119
+| Type  | Required | Platform |
120
+| ----- | -------- | -------- |
121
+| color | No       | Both     |
122
+
123
+## DotIndicator
124
+##### color?: color
125
+##### size?: number
126
+##### visible?: boolean
127
+##### animate?: boolean
128
+
129
+## IconInsets
130
+##### top?: number
131
+##### left?: number
132
+##### right?: number
133
+##### bottom?: number

+ 101
- 0
website/docs/options-bottomTabs.mdx View File

@@ -0,0 +1,101 @@
1
+---
2
+id: bottomTabs-options
3
+title: Bottom Tabs Options
4
+sidebar_label: Bottom Tabs
5
+---
6
+
7
+```js
8
+const options = {
9
+  bottomTabs: {
10
+
11
+  }
12
+}
13
+```
14
+
15
+## `animate`
16
+Controls whether toggling visibility states will be animated.
17
+
18
+| Type    | Required | Platform |
19
+| ------- | -------- | -------- |
20
+| boolean | No       | Both     |
21
+
22
+## `backgroundColor`
23
+Change the background color.
24
+
25
+| Type  | Required | Platform |
26
+| ----- | -------- | -------- |
27
+| color | No       | Both     |
28
+
29
+## `barStyle`
30
+Controls whether the BottomTabs use dark (black) or light (default) visual style. Requires `translucent: true`.
31
+
32
+| Type                    | Required | Platform |
33
+| ----------------------- | -------- | -------- |
34
+| enum('default','black') | No       | Both     |
35
+
36
+## `currentTabId`
37
+Select a tab by the id (componentId) of a child contained in it. See [Selecting tabs programmatically](#selectingtabsprogrammatically) for a detailed explanation.
38
+
39
+| Type   | Required | Platform |
40
+| ------ | -------- | -------- |
41
+| number | No       | Both     |
42
+
43
+## `currentTabIndex`
44
+
45
+| Type   | Required | Platform |
46
+| ------ | -------- | -------- |
47
+| number | No       | Both     |
48
+
49
+## `drawBehind`
50
+
51
+| Type    | Required | Platform |
52
+| ------- | -------- | -------- |
53
+| boolean | No       | Both     |
54
+
55
+## `elevation`
56
+
57
+| Type   | Required | Platform |
58
+| ------ | -------- | -------- |
59
+| number | No       | Android  |
60
+
61
+## `hideShadow`
62
+
63
+| Type    | Required | Platform |
64
+| ------- | -------- | -------- |
65
+| boolean | No       | iOS      |
66
+
67
+## `preferLargeIcons`
68
+
69
+| Type    | Required | Platform |
70
+| ------- | -------- | -------- |
71
+| boolean | No       | Android  |
72
+
73
+## `tabsAttachMode`
74
+
75
+| Type                                               | Required | Platform |
76
+| -------------------------------------------------- | -------- | -------- |
77
+| enum('together','afterInitialTab','onSwitchToTab') | No       | Both     |
78
+
79
+## `testID`
80
+
81
+| Type   | Required | Platform |
82
+| ------ | -------- | -------- |
83
+| string | No       | Both     |
84
+
85
+## `titleDisplayMode`
86
+
87
+| Type                                             | Required | Android |
88
+| ------------------------------------------------ | -------- | ------- |
89
+| enum('alwaysShow','showWhenActive','alwaysHide') | No       | Both    |
90
+
91
+## `translucent`
92
+
93
+| Type    | Required | Platform |
94
+| ------- | -------- | -------- |
95
+| boolean | No       | iOS      |
96
+
97
+## `visible`
98
+
99
+| Type    | Required | Platform |
100
+| ------- | -------- | -------- |
101
+| boolean | No       | Both     |

+ 76
- 0
website/docs/options-button.mdx View File

@@ -0,0 +1,76 @@
1
+---
2
+id: button-options
3
+title: Button Options
4
+sidebar_label: Button
5
+---
6
+
7
+```js
8
+const options = {
9
+  topBar: {
10
+    leftButtons: [
11
+      {
12
+        id: "id",
13
+        text: "Button"
14
+      }
15
+    ]
16
+  }
17
+};
18
+```
19
+
20
+### `id`
21
+
22
+Buttons are identified by their id property. When a button is clicked, a buttonPress event is emitted to js, containing the id of the clicked button.
23
+
24
+| Type   | Required | Platform |
25
+| ------ | -------- | -------- |
26
+| string | Yes      | Both     |
27
+
28
+### `icon`
29
+
30
+Button icon. If the button is pushed to the overflow menu, the button [text](#text) is used instead.
31
+
32
+| Type   | Required | Platform |
33
+| ------ | -------- | -------- |
34
+| number | No       | Both     |
35
+
36
+### `text`
37
+
38
+Button text. Ignored if an icon is specified, unless the button is displayed in the overflow menu.
39
+
40
+| Type   | Required | Platform |
41
+| ------ | -------- | -------- |
42
+| string | No       | Both     |
43
+
44
+### `showAsAction`
45
+
46
+| Type                                          | Required | Platform |
47
+| --------------------------------------------- | -------- | -------- |
48
+| enum('always', 'never', 'withText', 'ifRoom') | No       | Android  |
49
+
50
+- **ifRooom** - Only add button to the TopBar if there is room for it, otherwise add it to the overflow menu.
51
+- **never** - Never place this button in the TopBar. Instead, list the button in the overflow menu.
52
+- **always** - Always place this button in the app bar.
53
+
54
+### `component`
55
+
56
+Set a react [component](layout-component.mdx) as this button's view which will be displayed instead of the regular view.
57
+
58
+| Type                   | Required | Platform |
59
+| ---------------------- | -------- | -------- |
60
+| [Component](layout-component.mdx) | No       | Both     |
61
+
62
+### `iconInsets`
63
+
64
+[IconInsets](options-iconInsets.mdx) are applied to the icon to translate its original position on the screen.
65
+
66
+| Type       | Required | Platform |
67
+| ---------- | -------- | -------- |
68
+| IconInsets | No       | iOS      |
69
+
70
+### `systemItem`
71
+
72
+System icon; ignored if an [icon](#icon-number) is specified. For more information, see [apple's guidelines](https://developer.apple.com/design/human-interface-guidelines/ios/icons-and-images/system-icons/).
73
+
74
+| Type                                                                                                                                                                                                                                          | Required | Platform |
75
+| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
76
+| enum('done', 'cancel', 'edit', 'save', 'add', 'flexibleSpace', 'fixedSpace', 'compose', 'reply', 'action', 'organize', 'bookmarks', 'search', 'refresh', 'stop', 'camera', 'trash', 'play', 'pause', 'rewind', 'fastForward', 'undo', 'redo') | No       | iOS      |

+ 37
- 0
website/docs/options-iconInsets.mdx View File

@@ -0,0 +1,37 @@
1
+---
2
+id: iconInsets-options
3
+title: IconInsets Options
4
+sidebar_label: IconInsets
5
+---
6
+
7
+### `top`
8
+
9
+Configure top inset
10
+
11
+| Type   | Required | Platform |
12
+| ------ | -------- | -------- |
13
+| number | No       | Both     |
14
+
15
+### `bottom`
16
+
17
+Configure bottom inset
18
+
19
+| Type   | Required | Platform |
20
+| ------ | -------- | -------- |
21
+| number | No       | Both     |
22
+
23
+### `left`
24
+
25
+Configure left inset
26
+
27
+| Type   | Required | Platform |
28
+| ------ | -------- | -------- |
29
+| number | No       | Both     |
30
+
31
+### `right`
32
+
33
+Configure right inset
34
+
35
+| Type   | Required | Platform |
36
+| ------ | -------- | -------- |
37
+| number | No       | Both     |

+ 55
- 0
website/docs/options-largeTitle.mdx View File

@@ -0,0 +1,55 @@
1
+---
2
+id: largeTitle-options
3
+title: Large Title Options
4
+sidebar_label: Large Title
5
+---
6
+
7
+Controls the top bar large title on iOS, available on iOS 11 and above.
8
+
9
+```js
10
+const options = {
11
+  topBar: {
12
+    largeTitle: {}
13
+  }
14
+};
15
+```
16
+
17
+### `visible`
18
+
19
+Controls whether the large title is visible or not.
20
+
21
+| Type    | Required | Platform |
22
+| ------- | -------- | -------- |
23
+| boolean | No       | iOS      |
24
+
25
+### `fontSize`
26
+
27
+Set the title font size. On Android this value is in `sp`.
28
+
29
+| Type   | Required | Platform |
30
+| ------ | -------- | -------- |
31
+| number | No       | iOS      |
32
+
33
+### `color`
34
+
35
+Large title text color.
36
+
37
+| Type  | Required | Platform |
38
+| ----- | -------- | -------- |
39
+| Color | No       | iOS      |
40
+
41
+### `fontFamily`
42
+
43
+Set the large title [FontFamily](fonts.mdx).
44
+
45
+| Type       | Required | Platform |
46
+| ---------- | -------- | -------- |
47
+| FontFamily | No       | iOS      |
48
+
49
+### `fontWeight`
50
+
51
+Set the font weight for the large title.
52
+
53
+| Type   | Required | Platform |
54
+| ------ | -------- | -------- |
55
+| number | No       | iOS      |

docs/docs/options-migration.md → website/docs/options-migration.mdx View File


+ 29
- 0
website/docs/options-overlay.mdx View File

@@ -0,0 +1,29 @@
1
+---
2
+id: overlay-options
3
+title: Overlay
4
+sidebar_label: Overlay
5
+---
6
+
7
+Controls overlay options
8
+
9
+```js
10
+const options = {
11
+  overlay: {
12
+
13
+  }
14
+}
15
+```
16
+
17
+### `interceptTouchOutside`
18
+Controls whether touch events outside the bounds of the overlay are to be handled by content behind the overlay. When set to true, touch events will **not** pass through to the underlying content.
19
+
20
+| Type  | Required | Platform |
21
+| ----- | -------- | -------- |
22
+| boolean | No       | Both     |
23
+
24
+### `handleKeyboardEvents`
25
+Overlays on iOS don't handle keyboard events by default. If your Overlay contains a TextInput component, you'll want to enable this option so that TextInput responds to keyboard events.
26
+
27
+| Type   | Required | Platform |
28
+| ------ | -------- | -------- |
29
+| boolean | No       | iOS     |

+ 164
- 0
website/docs/options-root.mdx View File

@@ -0,0 +1,164 @@
1
+---
2
+id: options-root
3
+title: The options object
4
+sidebar_label: Options object
5
+---
6
+
7
+```js
8
+const options = {
9
+  bottomTab,
10
+  bottomTabs,
11
+  topBar,
12
+  layout,
13
+  sideMenu,
14
+  overlay,
15
+  modal,
16
+  preview
17
+};
18
+```
19
+
20
+## `bottomTab`
21
+
22
+Controls the bottom tab icon, font, color, and more.
23
+
24
+| Type                                  | Required | Platform |
25
+| ------------------------------------- | -------- | -------- |
26
+| [BottomTabOptions](options-bottomTab.mdx) | No       | Both     |
27
+
28
+## `bottomTabs`
29
+
30
+Controls the bottom tabs container.
31
+
32
+| Type                                    | Required | Platform |
33
+| --------------------------------------- | -------- | -------- |
34
+| [BottomTabsOptions](options-bottomTabs.mdx) | No       | Both     |
35
+
36
+## `topBar`
37
+
38
+Controls the Stack top bar styling.
39
+
40
+| Type                           | Required | Platform |
41
+| ------------------------------ | -------- | -------- |
42
+| [TopBarOptions](stack-options.mdx) |          | No       |
43
+
44
+## `statusBar`
45
+
46
+Controls the system status bar styling.
47
+
48
+| Type                                  | Required | Platform |
49
+| ------------------------------------- | -------- | -------- |
50
+| [StatusBarOptions](statusBar-options.mdx) | No       | Both     |
51
+
52
+## `layout`
53
+
54
+| Type                            | Required | Platform |
55
+| ------------------------------- | -------- | -------- |
56
+| [LayoutOptions](layout-options.mdx) | No       | Both     |
57
+
58
+## `sideMenu`
59
+
60
+| Type                                | Required | Platform |
61
+| ----------------------------------- | -------- | -------- |
62
+| [SideMenuOptions](options-sideMenu.mdx) | No       | Both     |
63
+
64
+## `overlay`
65
+
66
+| Type                              | Required | Platform |
67
+| --------------------------------- | -------- | -------- |
68
+| [OverlayOptions](options-overlay.mdx) | No       | Both     |
69
+
70
+## `animations`
71
+
72
+| Type                                    | Required | Platform |
73
+| --------------------------------------- | -------- | -------- |
74
+| [AnimationsOptions](options-animations.mdx) | No       | Both     |
75
+
76
+## `modal`
77
+
78
+| Type                          | Required | Platform |
79
+| ----------------------------- | -------- | -------- |
80
+| [ModalOptions](options-modal.mdx) | No       | Both     |
81
+
82
+## `preview`
83
+
84
+| Type                              | Required | Platform |
85
+| --------------------------------- | -------- | -------- |
86
+| [PreviewOptions](preview-options.mdx) | No       | iOS      |
87
+
88
+## `splitView`
89
+
90
+| Type                                  | Required | Platform |
91
+| ------------------------------------- | -------- | -------- |
92
+| [SplitViewOptions](options-splitView.mdx) | No       | iOS      |
93
+
94
+## `fab`
95
+
96
+| Type               | Required | Platform |
97
+| ------------------ | -------- | -------- |
98
+| [Fab](fab-options.mdx) | No       | Android  |
99
+
100
+## `modalPresentationStyle`
101
+
102
+Configure the presentation style of the modal.
103
+
104
+| Type                                                                                                    | Required | Platform |
105
+| ------------------------------------------------------------------------------------------------------- | -------- | -------- |
106
+| enum('formSheet', 'pageSheet', 'fullScreen', 'overFullScreen', 'overCurrentContext', 'popOver', 'none') | No       | Both     |
107
+
108
+#### Styles supported on both platforms
109
+
110
+- **overCurrentContext** - Display the modal and do not remove previous content when the show animation ends.
111
+- **none** - default system presentation style
112
+
113
+#### Styles supported only on iOS
114
+
115
+- **formSheet** - display content centered in the screen.
116
+- **pageSheet** - partially cover the underlying content.
117
+- **overFullScreen** - display the modal in full screen mode and do not remove previous content when the show animation ends.
118
+- **popOver** - Center content on screen and dim the content behind it.
119
+
120
+The default presentation style is different on each platform.
121
+
122
+| iOS                                                                                      | Android      |
123
+| ---------------------------------------------------------------------------------------- | ------------ |
124
+| <ul><li>iOS 12 and below - `fullScreen`</li><li>iOS 13 and above - `pageSheet`</li></ul> | `fullScreen` |
125
+
126
+## `modalTransitionStyle`
127
+
128
+Configure the transition style of the modal.
129
+
130
+| Type                                                                    | Required | Platform |
131
+| ----------------------------------------------------------------------- | -------- | -------- |
132
+| enum('coverVertical', 'crossDissolve', 'flipHorizontal', 'partialCurl') | No       | Both     |
133
+
134
+## `popGesture`
135
+
136
+Enable or disable swipe back to pop gesture.
137
+
138
+| Type    | Required | Platform |
139
+| ------- | -------- | -------- |
140
+| boolean | No       | iOS      |
141
+
142
+## `backgroundImage`
143
+
144
+Background image of the screen.
145
+
146
+| Type  | Required | Platform |
147
+| ----- | -------- | -------- |
148
+| Image | No       | iOS      |
149
+
150
+## `rootBackgroundImage`
151
+
152
+Background image for the Navigation View.
153
+
154
+| Type  | Required | Platform |
155
+| ----- | -------- | -------- |
156
+| Image | No       | Android  |
157
+
158
+## `blurOnUnmount`
159
+
160
+Enable or disable automaticall blur of the focused input, dismissing keyboard on unmount.
161
+
162
+| Type    | Required | Platform | Default |
163
+| ------- | -------- | -------- | ------- |
164
+| boolean | No       | Android  | false   |

+ 39
- 0
website/docs/options-sideMenu.mdx View File

@@ -0,0 +1,39 @@
1
+---
2
+id: sideMenu-options
3
+title: Side Menu Options
4
+sidebar_label: Side Menu
5
+---
6
+
7
+```js
8
+const options = {
9
+  sideMenu: {
10
+    left: {},
11
+    right: {},
12
+    openGestureMode: "entireScreen"
13
+  }
14
+};
15
+```
16
+
17
+### `left`
18
+
19
+Configure the left side menu.
20
+
21
+| Type                                 | Required | Platform |
22
+| ------------------------------------ | -------- | -------- |
23
+| [SideMenuSide](options-sideMenuSide.mdx) | No       | Both     |
24
+
25
+### `right`
26
+
27
+Configure the right side menu.
28
+
29
+| Type                                 | Required | Platform |
30
+| ------------------------------------ | -------- | -------- |
31
+| [SideMenuSide](options-sideMenuSide.mdx) | No       | Both     |
32
+
33
+### `openGestureMode`
34
+
35
+Configure how a user is allowed to open a drawer using gestures.
36
+
37
+| Type                          | Required | Platform |
38
+| ----------------------------- | -------- | -------- |
39
+| enum('entireScreen', 'bezel') | No       | iOS      |

+ 48
- 0
website/docs/options-sideMenuSide.mdx View File

@@ -0,0 +1,48 @@
1
+---
2
+id: sideMenuSide-options
3
+title: Side Menu Side Options
4
+sidebar_label: Side Menu Side
5
+---
6
+
7
+```js
8
+const options = {
9
+  sideMenu: {
10
+    left: {
11
+      visible: false,
12
+      enabled: true
13
+    }
14
+  }
15
+};
16
+```
17
+
18
+### `visible`
19
+
20
+Show or hide the side menu.
21
+
22
+| Type    | Required | Platform |
23
+| ------- | -------- | -------- |
24
+| boolean | No       | Both     |
25
+
26
+### `enabled`
27
+
28
+Enable or disable the side menu.
29
+
30
+| Type    | Required | Platform |
31
+| ------- | -------- | -------- |
32
+| boolean | No       | Both     |
33
+
34
+### `width`
35
+
36
+Set the width of the side menu.
37
+
38
+| Type   | Required | Platform |
39
+| ------ | -------- | -------- |
40
+| number | No       | Both     |
41
+
42
+### `height`
43
+
44
+Set the height of the side menu.
45
+
46
+| Type   | Required | Platform |
47
+| ------ | -------- | -------- |
48
+| number | No       | Both     |

+ 37
- 0
website/docs/options-splitView.mdx View File

@@ -0,0 +1,37 @@
1
+---
2
+id: splitView-options
3
+title: SplitView Options
4
+sidebar_label: SplitView
5
+---
6
+
7
+### `displayMode`
8
+
9
+Master view display mode.
10
+
11
+| Type                                         | Required | Default | Platform |
12
+| -------------------------------------------- | -------- | ------- | -------- |
13
+| enum('auto', 'visible', 'hidden', 'overlay') | No       | 'auto'  | iOS      |
14
+
15
+### `primaryEdge`
16
+
17
+Master view side. Leading is left. Trailing is right.
18
+
19
+| Type                        | Required | Default   | Platform |
20
+| --------------------------- | -------- | --------- | -------- |
21
+| enum('leading', 'trailing') | No       | 'leading' | iOS      |
22
+
23
+### `minWidth`
24
+
25
+Set the minimum width of master view.
26
+
27
+| Type   | Required | Platform |
28
+| ------ | -------- | -------- |
29
+| number | No       | iOS      |
30
+
31
+### `maxWidth`
32
+
33
+Set the maximum width of master view.
34
+
35
+| Type   | Required | Platform |
36
+| ------ | -------- | -------- |
37
+| number | No       | iOS      |

+ 86
- 0
website/docs/orientation.mdx View File

@@ -0,0 +1,86 @@
1
+---
2
+id: orientation
3
+title: Orientation
4
+sidebar_label: Orientation
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+
10
+## Locking orientation
11
+Orientation can be locked either in the layout level, or across the app via default options. You can declare orientations you'd like your app to support in default options.
12
+
13
+<Tabs
14
+  defaultValue="defaultOptions"
15
+  values={[
16
+    { label: 'Locking orientation in default options', value: 'defaultOptions', },
17
+    { label: 'Locking root layout orientation', value: 'root', },
18
+    { label: 'Showing landscape modal', value: 'modal', }
19
+  ]
20
+}>
21
+<TabItem value="defaultOptions">
22
+
23
+Setting orientation in default options will affect all screens in all hierarchy levels. It's still possible to override orientation for specific screens.
24
+
25
+```js
26
+Navigation.setDefaultOptions({
27
+  layout: {
28
+    orientation: ['portrait']
29
+  }
30
+});
31
+```
32
+
33
+</TabItem>
34
+<TabItem value="modal">
35
+
36
+The following example demonstrates how to show a modal in landscape orientation.
37
+
38
+```js
39
+Navigation.showModal({
40
+  component: {
41
+    name: 'VideoPlayer'
42
+    options: {
43
+      layout: {
44
+        orientation: ['landscape']
45
+      }
46
+    }
47
+  }
48
+});
49
+```
50
+
51
+</TabItem>
52
+<TabItem value="root">
53
+
54
+Applying orientation in the root level will affect all screens in the root hierarchy level. It **will not** apply to modals.
55
+
56
+```js
57
+Navigation.setRoot({
58
+  root: {
59
+    bottomTabs: {
60
+      options: {
61
+        layout: {
62
+          orientation: ['portrait']
63
+        }
64
+      },
65
+      children: [
66
+        ...
67
+      ]
68
+    }
69
+  }
70
+});
71
+```
72
+
73
+</TabItem>
74
+</Tabs>
75
+
76
+## Changing orientation dynamically
77
+
78
+Changing orientation dynamically through `Navigation.mergeOption()` is supported only on Android.
79
+
80
+```js
81
+Navigation.mergeOptions(this.props.componentId, {
82
+  layout: {
83
+    orientation: ['landscape']
84
+  }
85
+});
86
+```

+ 62
- 0
website/docs/passing-data-to-components.mdx View File

@@ -0,0 +1,62 @@
1
+---
2
+id: passing-data-to-components
3
+title: Passing data to components
4
+sidebar_label: Passing data to components
5
+---
6
+
7
+## Initial props
8
+
9
+React components use [props](https://facebook.github.io/react-native/docs/props) to receive data when they are created. When displaying the [component](component.mdx) layout, you can pass initial props to components using the `passProps` property.
10
+
11
+In this example, we push the `UserProfile` screen and pass two initial props to it:
12
+
13
+```js
14
+Navigation.push(this.props.componentId, {
15
+  component: {
16
+    name: 'UserProfile',
17
+    id: 'PROFILE_SCREEN_ID'
18
+    passProps: {
19
+      name: 'John Doe',
20
+      status: 'online'
21
+    }
22
+  }
23
+});
24
+```
25
+
26
+:::tip Serialization
27
+passProps don't need to be serializable. You can use this mechanism to pass lambda functions or even React Components.
28
+:::
29
+
30
+## Handling passProps in static options
31
+
32
+Each component can have a static options property which is used to configure the style properties of elements on the screen when that component is displayed. 
33
+
34
+Static options can either be a simple object, or a function which accepts `passProps` as an argument. Sometimes when declaring components, not all style properties are known. For example, a user profile screen will usually have the user's name as the TopBar title text. Therefore the title must be configured dynamically when pushing the screen.
35
+
36
+Following the code example [above](passing-data-to-components.mdx#initial-props), lets see how to use props passed in the push command to set the TopBar title.
37
+
38
+```jsx
39
+class UserProfileScreen extends React.Component {
40
+  static options(props) {
41
+    return (
42
+      topBar: {
43
+        title: {
44
+          text: props.name
45
+        }
46
+      }
47
+    );
48
+  }
49
+}
50
+```
51
+
52
+## Updating props
53
+
54
+To update a component's props, use the [Navigation.updateProps()](component-api.mdx#updateprops) command. Updating props triggers the component lifecycle methods related to [updating](https://reactjs.org/docs/react-component.html#updating).
55
+
56
+Notice that we're using the component `id` in order to update props of this specific instance of the component.
57
+
58
+```js
59
+Navigation.updateProps('PROFILE_SCREEN_ID', {
60
+  status: 'offline'
61
+});
62
+```

+ 17
- 0
website/docs/playground-app.mdx View File

@@ -0,0 +1,17 @@
1
+---
2
+id: playground-app
3
+title: Playground app
4
+sidebar_label: Playground app
5
+---
6
+
7
+### Running The Project
8
+
9
+If you want to have a quick look around and test things out, you can run the playground app, bundled with this repo.
10
+
11
+1. Install dependencies via `npm install` (if you haven't already)
12
+2. Run the playground project on Android and iOS
13
+    - `npm run start` to get the packager running in the terminal, leave it open
14
+    - **iOS**: open `./playground/ios` in Xcode and run it
15
+    - **Android**: open `./playground/android` in Android Studio and run it
16
+3. You can run tests if / when you need to (list of scripts [available here](contributing.mdx#scripts)). Before you start changing things, make sure everything works.
17
+	- To easily run all tests in parallel `npm run test-all`

+ 49
- 0
website/docs/screen-lifecycle.mdx View File

@@ -0,0 +1,49 @@
1
+---
2
+id: screen-lifecycle
3
+title: Screen Lifecycle
4
+sidebar_label: Screen Lifecycle
5
+---
6
+
7
+Any React Component registered with react-native-navigation is enhanced with two additional lifecycle events:
8
+
9
+* `componentDidAppear` - called each time a component is revealed to the user
10
+* `componentDidDisappear` - called each time a component is hidden from user's view **as a result of being detached from hierarchy**
11
+
12
+These methods compliment React's liefcycle methods:
13
+
14
+* `componentDidMount` - called once, when a component is attached to hierarchy **for the first time**
15
+* `componentWillUnmount` - called once, when a component is destroyed
16
+
17
+### Mounting
18
+These methods are called in the following order when a component is created and attached to hierarchy.
19
+
20
+* constructor()
21
+* render()
22
+* componentDidMount()
23
+* componentDidAppear()
24
+
25
+### Unmounting
26
+These methods are called when a component is being removed from hierarchy
27
+
28
+* componentDidDisappear()
29
+* componentWillUnmount()
30
+
31
+### Modal
32
+
33
+When a modal is displayed, depending on the [modalPresentationStyle](options-root.mdx#modalpresentationstyle), content behind it might be detached from hierarchy. This affects the visibility events which are emitted to the content behind the modal.
34
+
35
+When Modals with `pageSheet` or `overCurrentContext` modalPresentationStyle are displayed, previous content is still visible to the user. Thus `componentDidDisappear` event is **not** emitted.
36
+
37
+Same is applied when a modal is dismissed. If it was originally presented with `pageSheet` or `overCurrentContext` modalPresentationStyle, when that modal is then dismissed, the previous context won't receive a `componentDidAppear` event.
38
+
39
+### Overlay
40
+These methods are called in the following order when a component is displayed as an Overlay:
41
+
42
+* constructor()
43
+* render()
44
+* componentDidMount()
45
+* componentDidAppear()
46
+
47
+:::note
48
+Content displayed behind an Overlay does not receive the `componentDidDisappear`, since it's still visible to user and attached to the hierarchy.
49
+:::

docs/docs/showcases.md → website/docs/showcases.mdx View File

@@ -1,4 +1,8 @@
1
-# Showcases
1
+---
2
+id: showcases
3
+title: Showcases
4
+sidebar_label: Showcases
5
+---
2 6
 
3 7
 ## Apps
4 8
 ### Hekla for Hacker News

+ 65
- 0
website/docs/sideMenu-disable.mdx View File

@@ -0,0 +1,65 @@
1
+---
2
+id: sideMenu-disable
3
+title: Disable Open and Close gesture
4
+sidebar_label: Open and Close Gesture
5
+---
6
+
7
+To open the side menu programmatically, you'll need to update the visible property of the side menu you'd like to open.
8
+
9
+The following snippet shows how to open the left side menu.
10
+```jsx
11
+Navigation.mergeOptions(componentId, {
12
+  sideMenu: {
13
+    left: {
14
+      visible: true,
15
+    },
16
+  },
17
+});
18
+```
19
+
20
+## Open by pressing on the hamburger menu
21
+The most common use case is to open the side menu by pressing the hamburger button in the TopBar. To achieve this, listen to the press event of the burger button, and open the side menu as shown above.
22
+
23
+```jsx
24
+const React = require('react');
25
+const Navigation = require('react-native-navigation');
26
+const { View, Text } = require('react-native');
27
+
28
+class SideMenuCenterScreen extends React.Component {
29
+  static options() {
30
+    return {
31
+      topBar: {
32
+        leftButtons: {
33
+          id: 'sideMenu',
34
+          icon: require('./menuIcon.png')
35
+        }
36
+      }
37
+    };
38
+  }
39
+
40
+  constructor(props) {
41
+    super(props);
42
+    Navigation.events().bindComponent(this);
43
+  }
44
+
45
+  render() {
46
+    return (
47
+      <View>
48
+        <Text>Click the hamburger icon to open the side menu</Text>
49
+      </View>
50
+    );
51
+  }
52
+
53
+  navigationButtonPressed({ buttonId }) {
54
+    if (buttonId === 'sideMenu') {
55
+      Navigation.mergeOptions(this, {
56
+        sideMenu: {
57
+          left: {
58
+            visible: true
59
+          }
60
+        }
61
+      });
62
+    }
63
+  }
64
+}
65
+```

+ 105
- 0
website/docs/sideMenu-docs.mdx View File

@@ -0,0 +1,105 @@
1
+---
2
+id: docs-sideMenu
3
+title: Side Menu
4
+sidebar_label: Side Menu
5
+---
6
+
7
+SideMenu provides access to destinations in the app from an easy to access menu which is accessible to the user via horizontal swipe gesture or a menu button.
8
+
9
+## Opening programmatically
10
+
11
+To open the side menu programmatically, you'll need to update the visible property of the side menu you'd like to open.
12
+
13
+The following snippet shows how to open the left side menu. The menu is opened by setting its visible option to visible.
14
+```jsx
15
+Navigation.mergeOptions(componentId, {
16
+  sideMenu: {
17
+    left: {
18
+      visible: true,
19
+    },
20
+  },
21
+});
22
+```
23
+
24
+## Opening via the hamburger menu
25
+The most common use case is to open the side menu by pressing the hamburger button at the TopBar. To achieve this, listen to the press event of the burger button, and open the side menu as shown above.
26
+
27
+```jsx
28
+const React = require('react');
29
+const Navigation = require('react-native-navigation');
30
+const { View, Text } = require('react-native');
31
+
32
+class SideMenuCenterScreen extends React.Component {
33
+  static options() {
34
+    return {
35
+      topBar: {
36
+        leftButtons: {
37
+          id: 'sideMenu',
38
+          icon: require('./menuIcon.png')
39
+        }
40
+      }
41
+    };
42
+  }
43
+
44
+  constructor(props) {
45
+    super(props);
46
+    Navigation.events().bindComponent(this);
47
+  }
48
+
49
+  render() {
50
+    return (
51
+      <View>
52
+        <Text>Click the hamburger icon to open the side menu</Text>
53
+      </View>
54
+    );
55
+  }
56
+
57
+  navigationButtonPressed({ buttonId }) {
58
+    if (buttonId === 'sideMenu') {
59
+      Navigation.mergeOptions(this, {
60
+        sideMenu: {
61
+          left: {
62
+            visible: true
63
+          }
64
+        }
65
+      });
66
+    }
67
+  }
68
+}
69
+```
70
+
71
+## Pushing to the center layout from a menu
72
+A common use case when using SideMenus is to interact with the center layout, e.g. pushing a screen to a stack in the center layout when a user clicks on a button from one of the menus.
73
+
74
+In order to interact with the stack, we'll first assign it a predefined id. For example:
75
+
76
+```js
77
+sideMenu: {
78
+  center: {
79
+    stack: {
80
+      id: 'CenterStack',
81
+      children: []
82
+    }
83
+  },
84
+  left: {
85
+    ...
86
+  }
87
+}
88
+```
89
+
90
+Now that we've defined an `id` for out stack, we can go ahead and push our screen to it. If we're pushing while the SideMenu is open, we'll need to make sure we close it by updating the visibility option of the relevant menu (left or right).
91
+
92
+```js
93
+Navigation.push('CenterStack', {
94
+  component: {
95
+    name: Screens.Pushed,
96
+    options: {
97
+      sideMenu: {
98
+        left: {
99
+          visible: false
100
+        }
101
+      }
102
+    }
103
+  }
104
+});
105
+```

+ 44
- 0
website/docs/sideMenu-layout.mdx View File

@@ -0,0 +1,44 @@
1
+---
2
+id: sideMenu-layout
3
+title: Side Menu
4
+sidebar_label: Side Menu
5
+---
6
+
7
+This layout allows implementing sidemenus, which can be opened by swiping from one side towards the other side.
8
+
9
+```js
10
+{
11
+  left: {
12
+    component: {}
13
+  },
14
+  center: {
15
+    stack: {
16
+      options: {},
17
+      children: [{
18
+        component: {}
19
+      }]
20
+    }
21
+  },
22
+  right: {
23
+    component: {}
24
+  }
25
+}
26
+```
27
+
28
+## `center`
29
+
30
+| Type             | Required | Description                                      |
31
+| ---------------- | -------- | ------------------------------------------------ |
32
+| [Layout](Layout.mdx) | Yes      | Center component, contains the main application. |
33
+
34
+## `left`
35
+
36
+| Type             | Required | Description                        |
37
+| ---------------- | -------- | ---------------------------------- |
38
+| [Layout](Layout.mdx) | No       | Contains the left component layout. |
39
+
40
+## `right`
41
+
42
+| Type             | Required | Description                         |
43
+| ---------------- | -------- | ----------------------------------- |
44
+| [Layout](Layout.mdx) | No       | Contains the right component layout. |

+ 177
- 0
website/docs/stack-api.mdx View File

@@ -0,0 +1,177 @@
1
+---
2
+id: stack-api
3
+title: Stack
4
+sidebar_label: Stack
5
+---
6
+
7
+import Tabs from '@theme/Tabs';
8
+import TabItem from '@theme/TabItem';
9
+
10
+## `push()`
11
+Push a screen into the stack and update the display according to the screen options.
12
+#### Parameters
13
+| Name        | Required | Type   | Description                                                                                                                                                                                                      |
14
+| ----------- | -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15
+| componentId | Yes      | string | The componentId of a screen pushed into the stack, or the id of the stack.                                                                                                                                            |
16
+| layout      | No       | Layout | The layout being pushed into the stack. Any type of layout (except stack) can be pushed into stacks. Typically, Component layout is pushed into stacks but it's possible to push SideMenu or BottomTabs as well. |
17
+
18
+#### Example
19
+
20
+<Tabs
21
+  defaultValue='component'
22
+  values={[
23
+    { label: 'Component', value: 'component', },
24
+    { label: 'Update options on push', value: 'push', },
25
+    { label: 'Push other layouts', value: 'otherLayout', },
26
+  ]
27
+}>
28
+
29
+<TabItem value='component'>
30
+The most common use case - push a single React component.
31
+
32
+```js
33
+Navigation.push(this.props.componentId, {
34
+  component: {
35
+    name: 'example.PushedScreen'
36
+  }
37
+});
38
+```
39
+
40
+</TabItem>
41
+
42
+<TabItem value='push'>
43
+Options are applied when the screen becomes visible.
44
+
45
+```js
46
+Navigation.push(this.props.componentId, {
47
+  component: {
48
+    name: 'example.PushedScreen',
49
+    options: {
50
+      topBar: {
51
+        title: {
52
+          text: 'Pushed screen title'
53
+        }
54
+      }
55
+    }
56
+  }
57
+});
58
+```
59
+
60
+</TabItem>
61
+
62
+<TabItem value='otherLayout'>
63
+Any layout type can be pushed. In this example we push a SideMenu layout.
64
+
65
+```js
66
+Navigation.push(this.props.componentId, {
67
+  sideMenu: {
68
+    left: {
69
+      component: {
70
+        name: 'drawerScreen'
71
+      }
72
+    },
73
+    center: {
74
+      component: {
75
+        name: 'centerScreen'
76
+      }
77
+    }
78
+  }
79
+});
80
+```
81
+
82
+</TabItem>
83
+
84
+</Tabs>
85
+
86
+## `pop()`
87
+Pop the top screen from the stack.
88
+#### Parameters
89
+| Name         | Required | Type                                | Description                                                           |
90
+| ------------ | -------- | ----------------------------------- | --------------------------------------------------------------------- |
91
+| componentId  | Yes      | string                              | The componentId of a screen pushed into the stack, or the stack id. |
92
+| mergeOptions | No       | [Options](options-root.mdx) | Options to be merged before popping the screen (optional).              |
93
+
94
+```js
95
+Navigation.pop(this.props.componentId);
96
+```
97
+
98
+## `popToRoot()`
99
+Pop all screens pushed into the stack.
100
+
101
+#### Parameters
102
+| Name         | Required | Type    | Description                                                           |
103
+| ------------ | -------- | ------- | --------------------------------------------------------------------- |
104
+| componentId  | Yes      | string  | The componentId of a screen pushed into the stack, or the stack id. |
105
+| mergeOptions | No       | [Options](options-root.mdx) | Options to be merged before popping the screen (optional).              |
106
+
107
+```js
108
+Navigation.popToRoot(this.props.componentId);
109
+```
110
+
111
+## `popTo()`
112
+Pop the stack to a given component.
113
+
114
+#### Parameters
115
+| Name         | Required | Type                  | Description                                              |
116
+| ------------ | -------- | --------------------- | -------------------------------------------------------- |
117
+| componentId  | Yes      | string                | The destination componentId                              |
118
+| mergeOptions | No       | [Options](options-root.mdx) | Options to be merged before popping the screen (optional). |
119
+
120
+```js
121
+Navigation.popTo(componentId);
122
+```
123
+
124
+## `setStackRoot()`
125
+Reset the stack to the given layout (accepts multiple children).
126
+
127
+#### Parameters
128
+| Name        | Required | Type                                                     | Description                                                           |
129
+| ----------- | -------- | -------------------------------------------------------- | --------------------------------------------------------------------- |
130
+| componentId | Yes      | string                                                   | The componentId of a screen pushed into the stack, or the stack id. |
131
+| layout      | Yes      | [layout](Layout.mdx) or [layout](Layout.mdx)[] | A single Component or array of components.                            |
132
+
133
+
134
+#### Example
135
+
136
+
137
+<Tabs
138
+  defaultValue='single'
139
+  values={[
140
+    { label: 'Single child', value: 'single' },
141
+    { label: 'Multiple children', value: 'multiple' }
142
+  ]
143
+}>
144
+
145
+<TabItem value='single'>
146
+
147
+```js
148
+Navigation.setStackRoot(this.props.componentId, {
149
+  component: {
150
+    name: 'example.NewRootScreen'
151
+  }
152
+});
153
+```
154
+
155
+</TabItem>
156
+
157
+<TabItem value='multiple'>
158
+
159
+In the example below we reset the stack with two components. The first one will be the root component and the second (`PushedScreen`) will be displayed. Pressing the back button (either hardware or software) will pop it, revealing the root component - `NewRootScreen`.
160
+
161
+```js
162
+Navigation.setStackRoot(this.props.componentId, [
163
+  {
164
+    component: {
165
+      name: 'NewRootScreen',
166
+    }
167
+  },
168
+  {
169
+    component: {
170
+      name: 'PushedScreen',
171
+    }
172
+  }
173
+]);
174
+```
175
+</TabItem>
176
+
177
+</Tabs>

+ 40
- 0
website/docs/stack-backButton.mdx View File

@@ -0,0 +1,40 @@
1
+---
2
+id: stack-backButton
3
+title: The Back button
4
+sidebar_label: Back button
5
+---
6
+
7
+The back button is added automatically when two or more screens are pushed into the stack.
8
+
9
+## Styling the back button
10
+The back button's style can be customised by declaring a backButton options object. This configuration can be part of a screen's static options, or default options.
11
+
12
+```js
13
+backButton: {
14
+  color: 'red',
15
+  icon: require('../../img/customChevron.png')
16
+}
17
+```
18
+
19
+## Controling visibility
20
+The back buttons visbility can be controlled with the visible property.
21
+
22
+```js
23
+backButton: {
24
+  visible: false
25
+}
26
+```
27
+
28
+## Changing visbility programmatically
29
+Back button visibility can be changed dynamically using the mergeOptions command. When using a screen's componentId, the change will affect only that specific screen. But when using the stack's id, the change will affect all screens pushed into the stack.
30
+
31
+```js
32
+Navigation.mergeOptions(this.props.componentId, {
33
+  backButton: {
34
+    visible: false
35
+  }
36
+});
37
+```
38
+
39
+## Handling the back button
40
+Handling the back button is not possible. However, you can set a left button with a chevron and handle it like you'd handle any other button and calling `Navigation.pop` when desired.

+ 10
- 0
website/docs/stack-backNavigation.mdx View File

@@ -0,0 +1,10 @@
1
+---
2
+id: stack-backNavigation
3
+title: Back Navigation
4
+sidebar_label: Back navigation
5
+---
6
+
7
+## Disabling back navigation
8
+
9
+## Handling back navigation
10
+

+ 101
- 0
website/docs/stack-buttons.mdx View File

@@ -0,0 +1,101 @@
1
+---
2
+id: stack-buttons
3
+title: TopBar Buttons
4
+sidebar_label: TopBar Buttons
5
+---
6
+
7
+Buttons can be added to the [right](#rightButtons) and [left](#leftButtons) areas of the TopBar. Buttons can have either an icon or a text. They are declared in the the options object and, as with any other option, can be updated dynamically with the `Navigation.mergeOptions` command.
8
+
9
+> When using an icon button on **Android**, you should always pass a title as well. The title is used when the button is collapsed to the overflow menu and as a tooltip when the button is long pressed.
10
+
11
+# Overflow menu
12
+It's common practice to group less important actions in a menu or an action sheet.
13
+
14
+To do so on iOS, include a button with a menu icon and open an [ActionSheet](https://facebook.github.io/react-native/docs/actionsheetios) with the relevant actions when the button is clicked.
15
+
16
+On Android, use the [showAsAction](#showasaction) options to control when the button should appear in the menu.
17
+
18
+# Left button
19
+Left buttons behave like right buttons with two caveats on Android:
20
+* Only a single left button is alowed
21
+* Textual left button isn't supported
22
+
23
+# Using a react component in a button
24
+> ⚠️At the moment, Android only supports using custom buttons in `rightButtons`.
25
+
26
+Sometimes we require more from our buttons. In order to support every product need React Components can be used as custom views of buttons.
27
+To do so, you'll first need to register the view with Navigation, just like you register your components used as screens:
28
+
29
+```js
30
+Navigation.registerComponent('ButtonComponent', () => require('./ButtonComponent'));
31
+```
32
+
33
+Now you can create buttons which use the component registered with `'ButtonComponent'` as thier custom view:
34
+
35
+```js
36
+topBar: {
37
+  rightButtons: [
38
+    {
39
+      component: 'ButtonComponent',
40
+      passProps: {
41
+        // Pass initial props to the button here
42
+      }
43
+    }
44
+  ]
45
+}
46
+```
47
+
48
+## Updating props of custom buttons
49
+To update props of a mounted compoennt used as a button, you'll first need to assign it a unique id, then call the `Navigation.updateProps()` command with the id.
50
+
51
+Calling the updateProps command will trigger React's component lifecycle methods related to [props update](https://reactjs.org/docs/react-component.html#updating)
52
+```js
53
+// Declare the button and assign it a unique id
54
+topBar: {
55
+  rightButtons: [
56
+    {
57
+      id: 'SomeUniqueId',
58
+      component: 'ButtonComponent',
59
+      passProps: {
60
+        count: 0
61
+      }
62
+    }
63
+  ]
64
+}
65
+
66
+// Update props
67
+Navigation.updateProps('SomeUniqueId', {
68
+  count: 1
69
+});
70
+```
71
+
72
+
73
+# Changing buttons dynamically
74
+As buttons are part of a screen's options, they can be modified like any other styling option using the [mergeOptions]() command.
75
+
76
+## Setting buttons
77
+The following command will set the screen's right buttons. If the screen already has Right Buttons declared - they will be overridden.
78
+
79
+```js
80
+Navigation.mergeOptions(this.props.componentId, {
81
+  topBar: {
82
+    rightButtons: [
83
+      {
84
+        id: 'myDynamicButton',
85
+        text: 'My Button'
86
+      }
87
+    ]
88
+  }
89
+});
90
+```
91
+
92
+## Removing buttons
93
+Buttons can be removed by setting zero buttons, as shown in the snippet below.
94
+
95
+```js
96
+Navigation.mergeOptions(this.props.componentId, {
97
+  topBar: {
98
+    rightButtons: []
99
+  }
100
+});
101
+```

+ 39
- 0
website/docs/stack-layout.mdx View File

@@ -0,0 +1,39 @@
1
+---
2
+id: stack-layout
3
+title: Stack
4
+sidebar_label: Stack
5
+---
6
+
7
+A stack is a container layout promoting a hierarchical navigation. It is used to navigate between screens at consecutive levels of hierarchy, steps in a flow or across an app.
8
+
9
+```js
10
+{
11
+  id: 'PROFILE_TAB',
12
+  children: [
13
+    {
14
+      component: {
15
+        id: 'PROFILE_SCREEN',
16
+        name: 'ProfileScreen'
17
+      }
18
+    }
19
+  ]
20
+}
21
+```
22
+
23
+## `id`
24
+
25
+| Type   | Required | Description                                                                                                                                                    |
26
+| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27
+| string | No       | Unique id used to interact with the view via the Navigation api, usually `Navigation.mergeOptions` which accepts the componentId as it's first argument. |
28
+
29
+## `children`
30
+
31
+| Type               | Required | Description                   |
32
+| ------------------ | -------- | ----------------------------- |
33
+| [Layout[]](Layout.mdx) | YES      | Child layouts of any kind. |
34
+
35
+## `options`
36
+
37
+| Type                    | Required | Description                                              |
38
+| ----------------------- | -------- | -------------------------------------------------------- |
39
+| [Options](options-root.mdx) | No       | Options that will apply to all screens in stack |

+ 184
- 0
website/docs/stack-options.mdx View File

@@ -0,0 +1,184 @@
1
+---
2
+id: stack-options
3
+title: Top Bar Options
4
+sidebar_label: Top Bar
5
+---
6
+
7
+## TopBar
8
+
9
+```js
10
+const options = {
11
+  topBar: {
12
+    animate: true,
13
+    title: {},
14
+    subtitle: {},
15
+    backButton: {},
16
+    background: {}
17
+  }
18
+};
19
+```
20
+
21
+### `animate`
22
+
23
+Determines if changing the TopBar visibility will be animated or not.
24
+
25
+| Type    | Required | Platform |
26
+| ------- | -------- | -------- |
27
+| boolean | No       | Both     |
28
+
29
+### `title`
30
+
31
+Controls the top bar title.
32
+
33
+| Type                   | Required | Platform |
34
+| ---------------------- | -------- | -------- |
35
+| [Title](title-options.mdx) | No       | Both     |
36
+
37
+### `subtitle`
38
+
39
+Controls the top bar subtitle.
40
+
41
+| Type                         | Required | Platform |
42
+| ---------------------------- | -------- | -------- |
43
+| [Subitle](subtitle-options.mdx) | No       | Both     |
44
+
45
+### `backButton`
46
+
47
+Controls the top bar back button.
48
+
49
+| Type                              | Required | Platform |
50
+| --------------------------------- | -------- | -------- |
51
+| [BackButton](options-backButton.mdx) | No       | Both     |
52
+
53
+### `background`
54
+
55
+Controls the top bar background.
56
+
57
+| Type                              | Required | Platform |
58
+| --------------------------------- | -------- | -------- |
59
+| [Background](options-background.mdx) | No       | Both     |
60
+
61
+### `barStyle`
62
+
63
+Control the TopBar blur style. Requires `translucent: true`.
64
+
65
+| Type                    | Required | Platform |
66
+| ----------------------- | -------- | -------- |
67
+| enum('default','black') | No       | iOS      |
68
+
69
+### `borderColor`
70
+
71
+Change the topBar border color.
72
+
73
+| Type  | Required | Platform |
74
+| ----- | -------- | -------- |
75
+| Color | No       | iOS      |
76
+
77
+### `borderHeight`
78
+
79
+Set the border height of the navbar in dp.
80
+
81
+| Type   | Required | Platform |
82
+| ------ | -------- | -------- |
83
+| number | No       | Android  |
84
+
85
+### `drawBehind`
86
+
87
+Controls if child should be drawn behind the TopBar or below it.
88
+
89
+| Type    | Required | Platform |
90
+| ------- | -------- | -------- |
91
+| boolean | No       | Both     |
92
+
93
+### `elevation`
94
+
95
+Set the elevation of the TopBar in dp. This option changes how the shadow under the TopBar looks. Setting this value to 0 will remove the shadow completely.
96
+
97
+| Type   | Required | Platform |
98
+| ------ | -------- | -------- |
99
+| number | No       | Android  |
100
+
101
+### `hideOnScroll`
102
+
103
+Hide the TopBar when a scrolling layout is scrolled.
104
+
105
+| Type    | Required | Platform |
106
+| ------- | -------- | -------- |
107
+| boolean | No       | Both     |
108
+
109
+### `hideNavBarOnFocusSearchBar`
110
+
111
+Indicates whether the navigation bar should be hidden when searching. True by default.
112
+
113
+| Type    | Required | Platform |
114
+| ------- | -------- | -------- |
115
+| boolean | No       | iOS 11+  |
116
+
117
+### `leftButtons`
118
+
119
+An array of buttons to be displayed at the right-side of the TopBar. Button layout is from left to right. See the [Buttons](button-options) section for more details.
120
+
121
+:::info Android support 
122
+Android currently only supports a single left button and does not support custom left Buttons.
123
+:::
124
+
125
+
126
+| Type                           | Required | Platform |
127
+| ------------------------------ | -------- | -------- |
128
+| [[Button]](options-button.mdx) | No       | Both     |
129
+
130
+### `leftButtonColor`
131
+
132
+Default color for left buttons.
133
+
134
+| Type  | Required | Platform |
135
+| ----- | -------- | -------- |
136
+| Color | No       | Both     |
137
+
138
+### `noBorder`
139
+
140
+Disables border at the bottom of the TopBar.
141
+
142
+| Type    | Required | Platform |
143
+| ------- | -------- | -------- |
144
+| boolean | No       | iOS      |
145
+
146
+### `rightButtons`
147
+
148
+An array of buttons to be displayed at the right side of the TopBar. Button layout is from right to left. See the [Buttons](button-options) section for more details.
149
+
150
+| Type                       | Required | Platform |
151
+| -------------------------- | -------- | -------- |
152
+| [[Button]](options-button.mdx) | No       | Both     |
153
+
154
+### `rightButtonColor`
155
+
156
+Default color for the right button.
157
+
158
+| Type  | Required | Platform |
159
+| ----- | -------- | -------- |
160
+| Color | No       | Both     |
161
+
162
+### `searchBar`
163
+
164
+Shows the UISearchBar in the TopBar.
165
+
166
+| Type    | Required | Platform |
167
+| ------- | -------- | -------- |
168
+| boolean | No       | iOS 11+  |
169
+
170
+### `searchBarHiddenWhenScrolling`
171
+
172
+Hides the UISearchBar when scrolling.
173
+
174
+| Type    | Required | Platform |
175
+| ------- | -------- | -------- |
176
+| boolean | No       | iOS 11+  |
177
+
178
+### `searchBarPlaceholder`
179
+
180
+The placeholder value in the UISearchBar.
181
+
182
+| Type   | Required | Platform |
183
+| ------ | -------- | -------- |
184
+| string | No       | iOS 11+  |

+ 56
- 0
website/docs/stack-programmatically.mdx View File

@@ -0,0 +1,56 @@
1
+---
2
+id: stack-programmatically
3
+title: Interact programmatically with the Stack
4
+sidebar_label: Interact programmatically
5
+---
6
+
7
+The Navigation object provides ways to programmatically manipulate the stack.
8
+
9
+## Interact with the Stack by componentId
10
+Each layout pushed into the stack has an id. When in the context of a component, The component's `componentId` can be used to interact with a parent stack.
11
+When using a component's componentId, the native implementation knows to perform the command on the parent Stack of this component.
12
+
13
+In this example, we push a screen onto the component's parent stack.
14
+
15
+```jsx
16
+const React = require('react');
17
+const Navigation = require('react-native-navigation');
18
+
19
+class MyComponent extends React.Component {
20
+  onButtonClick = () => {
21
+    Navigation.push(this.props.componentId, {
22
+      component: {
23
+        name: 'PUSHED_SCREEN'
24
+      }
25
+    });
26
+  }
27
+}
28
+```
29
+
30
+## Interact with the Stack by a predefined id
31
+Sometimes we're required to interact with a specific stack not from the context of a component pushed into it. To do so, assign the stack a predefined `id` and use it when invoking any stack command.
32
+
33
+```js
34
+Navigation.setRoot({
35
+  root: {
36
+    stack: {
37
+      id: 'MyStack', // This is the id we're going to use when interacting with the stack
38
+      children: [
39
+        {
40
+          component: {
41
+            name: 'SomeComponent'
42
+          }
43
+        }
44
+      ]
45
+    }
46
+  }
47
+});
48
+
49
+function push() {
50
+  Navigation.push('MyStack', {
51
+    component: {
52
+      name: 'PushedScreen'
53
+    }
54
+  });
55
+}
56
+```

+ 43
- 0
website/docs/statusBar-options.mdx View File

@@ -0,0 +1,43 @@
1
+---
2
+id: statusBar-options
3
+title: Status Bar Options
4
+sidebar_label: Status Bar
5
+---
6
+
7
+```js
8
+const options = {
9
+  statusBar: {}
10
+};
11
+```
12
+
13
+### `visible`
14
+
15
+Set the status bar visibility.
16
+
17
+| Type    | Required | Platform |
18
+| ------- | -------- | -------- |
19
+| boolean | No       | Both     |
20
+
21
+### `style`
22
+
23
+Set the text color of the status bar.
24
+
25
+| Type                  | Required | Platform | Default |
26
+| --------------------- | -------- | -------- | ------- |
27
+| enum('light', 'dark') | No       | Both     | 'light' |
28
+
29
+### `backgroundColor`
30
+
31
+Set the background color of the status bar.
32
+
33
+| Type  | Required | Platform |
34
+| ----- | -------- | -------- |
35
+| Color | No       | Android  |
36
+
37
+### `drawBehind`
38
+
39
+Draw screen behind the status bar.
40
+
41
+| Type  | Required | Platform |
42
+| ----- | -------- | -------- |
43
+| boolean | No       | Android  |

+ 48
- 0
website/docs/statusbar-docs.mdx View File

@@ -0,0 +1,48 @@
1
+---
2
+id: statusBar-docs
3
+title: StatusBar
4
+sidebar_label: StatusBar
5
+---
6
+
7
+The StatusBar appearance is controlled through options.
8
+
9
+For example, the following options will change the StatusBar background color to white will use dark colors for the StatusBar content (time, battery information, notification icons etc)
10
+
11
+```js
12
+options: {
13
+  statusBar: {
14
+    backgroundColor: 'white',
15
+    style: 'dark'
16
+  }
17
+}
18
+```
19
+
20
+:::warning Compatibility with StatusBar component
21
+React native's [StatusBar](https://reactnative.dev/docs/statusbar#__docusaurus) component is incompatible with React Native Navigation and you should avoid using it.
22
+:::
23
+
24
+## Changing StatusBar style dynamically
25
+
26
+As the StatusBar is controlled through options, it can be configured dynamically by calling `Navigation.mergeOptions` with the desired StatusBar options.
27
+
28
+For example, here's how you would hide the StatusBar dynamically
29
+
30
+```js
31
+Navigation.mergeOptions(this.props.componentId, {
32
+  statusBar: {
33
+    visible: false
34
+  }
35
+});
36
+```
37
+
38
+## How keep current StatusBar color when displaying screens
39
+
40
+When screens are displayed, the StatusBar color always changes to the color associated with the current screen. If a color isn't specified for a given screen (and thus for the StatusBar), the default (System default or from defaultOptions) color is used. Sometimes you might want to keep the current StatusBar color, for example when displaying an alert or a toast. To keep StatusBar color unchanged when displaying a screen, use `null` as a StatusBar color.
41
+
42
+```js
43
+options: {
44
+  statusBar: {
45
+    backgroundColor: null
46
+  }
47
+}
48
+```

+ 0
- 0
website/docs/styling-fonts.mdx View File


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