Browse Source

Cleanup and reorganise playground app (#4767)

* Cleanup and reorganise playground app

* Separated tests into three categories
  1. Layouts - layout specific tests and feature showcase
  2. Options - options related tests; interactions between static and dynamic options, merge options etc
  3. Navigation - general navigation features; Orientation handling, events, Overlay etc

* Fixed a few Android bugs
  1. testID wasn’t applied on TopBar react buttons
  2. static options were disregarded when creating initial BottomTab options
  3. Trying to open a none existent SideMenu would result in a crash

* Fix e2e tests

* Fix lint

* Few fixes + split push from SideMenu test into two tests

* Fixes e2e
Guy Carmeli 5 years ago
parent
commit
bfdd41fcb4
75 changed files with 2898 additions and 2001 deletions
  1. 35
    29
      e2e/ApplicationLifecycleTest.test.js
  2. 0
    55
      e2e/BackHandler.test.js
  3. 70
    0
      e2e/BottomTabs.test.js
  4. 0
    33
      e2e/ComplexLayout.test.js
  5. 78
    78
      e2e/Modals.test.js
  6. 94
    0
      e2e/Options.test.js
  7. 59
    0
      e2e/Orientation.test.js
  8. 0
    61
      e2e/Orientations.test.js
  9. 45
    0
      e2e/Overlay.test.js
  10. 0
    51
      e2e/OverlayTest.test.js
  11. 0
    120
      e2e/ScreenStack.test.js
  12. 0
    207
      e2e/ScreenStyle.test.js
  13. 39
    0
      e2e/SideMenu.test.js
  14. 100
    0
      e2e/Stack.test.js
  15. 19
    22
      e2e/StaticLifecycleEvents.test.js
  16. 0
    42
      e2e/TopLevelApi.test.js
  17. 1
    1
      e2e/init.js
  18. 1
    1
      lib/android/app/build.gradle
  19. 13
    24
      lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java
  20. 3
    0
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/TitleBarButtonController.java
  21. 2
    0
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java
  22. 1
    1
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java
  23. 2
    2
      lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuController.java
  24. 21
    0
      lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java
  25. 6
    0
      lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.java
  26. 18
    0
      lib/ios/RNNSideMenuPresenter.m
  27. 2
    1
      package.json
  28. BIN
      playground/img/clear@2x.ios.png
  29. BIN
      playground/img/clear@3x.android.png
  30. BIN
      playground/img/layouts@2x.android.png
  31. BIN
      playground/img/layouts@2x.ios.png
  32. BIN
      playground/img/list.png
  33. BIN
      playground/img/navigation@2x.android.png
  34. BIN
      playground/img/navigation@2x.ios.png
  35. BIN
      playground/img/options@2x.android.png
  36. BIN
      playground/img/options@2x.ios.png
  37. BIN
      playground/img/sideMenu.png
  38. 0
    0
      playground/img/star@2x.android.png
  39. BIN
      playground/img/star@2x.ios.png
  40. BIN
      playground/img/two@2x.png
  41. BIN
      playground/img/whatshot@2x.android.png
  42. BIN
      playground/img/whatshot@2x.ios.png
  43. 56
    137
      playground/src/app.js
  44. 4
    0
      playground/src/commons/Colors.js
  45. 16
    0
      playground/src/commons/Layouts.js
  46. 20
    0
      playground/src/commons/Options.js
  47. 9
    0
      playground/src/components/Button.js
  48. 30
    0
      playground/src/components/Root.js
  49. 0
    104
      playground/src/screens/BackHandlerScreen.js
  50. 0
    84
      playground/src/screens/CustomDialog.js
  51. 71
    0
      playground/src/screens/FirstBottomTabScreen.js
  52. 588
    0
      playground/src/screens/LayoutsScreen.js
  53. 33
    50
      playground/src/screens/LifecycleScreen.js
  54. 50
    156
      playground/src/screens/ModalScreen.js
  55. 50
    0
      playground/src/screens/NavigationScreen.js
  56. 566
    236
      playground/src/screens/OptionsScreen.js
  57. 4
    4
      playground/src/screens/OrientationDetectScreen.js
  58. 38
    0
      playground/src/screens/OrientationScreen.js
  59. 0
    48
      playground/src/screens/OrientationSelectScreen.js
  60. 55
    0
      playground/src/screens/OverlayAlert.js
  61. 59
    0
      playground/src/screens/OverlayScreen.js
  62. 99
    336
      playground/src/screens/PushedScreen.js
  63. 5
    22
      playground/src/screens/RoundedButton.js
  64. 30
    0
      playground/src/screens/Screens.js
  65. 2
    3
      playground/src/screens/SearchScreen.js
  66. 95
    0
      playground/src/screens/SecondBottomTabScreen.js
  67. 40
    0
      playground/src/screens/SideMenuCenterScreen.js
  68. 46
    0
      playground/src/screens/SideMenuLeftScreen.js
  69. 26
    0
      playground/src/screens/SideMenuRightScreen.js
  70. 78
    0
      playground/src/screens/StackScreen.js
  71. 42
    0
      playground/src/screens/StaticEventsScreen.js
  72. 9
    2
      playground/src/screens/StaticLifecycleOverlay.js
  73. 26
    40
      playground/src/screens/index.js
  74. 52
    0
      playground/src/services/Navigation.js
  75. 90
    51
      playground/src/testIDs.js

+ 35
- 29
e2e/ApplicationLifecycleTest.test.js View File

@@ -1,7 +1,6 @@
1 1
 const Utils = require('./Utils');
2 2
 const Android = require('./AndroidUtils');
3
-const testIDs = require('../playground/src/testIDs');
4
-const exec = require('shell-utils').exec;
3
+const TestIDs = require('../playground/src/testIDs');
5 4
 const _ = require('lodash');
6 5
 
7 6
 const { elementByLabel, elementById, sleep } = Utils;
@@ -13,15 +12,17 @@ describe('application lifecycle test', () => {
13 12
     await device.relaunchApp();
14 13
   });
15 14
 
16
-  test('push a screen to ensure its not there after reload', async () => {
17
-    await elementById(testIDs.PUSH_BUTTON).tap();
15
+  it('push a screen to ensure its not there after reload', async () => {
16
+    await elementById(TestIDs.STACK_BTN).tap();
17
+    await elementById(TestIDs.PUSH_BTN).tap();
18 18
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
19 19
     await device.reloadReactNative();
20
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
20
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
21 21
   });
22 22
 
23
-  test('relaunch from background', async () => {
24
-    await elementById(testIDs.PUSH_BUTTON).tap();
23
+  it('relaunch from background', async () => {
24
+    await elementById(TestIDs.STACK_BTN).tap();
25
+    await elementById(TestIDs.PUSH_BTN).tap();
25 26
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
26 27
 
27 28
     await device.sendToHome();
@@ -30,8 +31,9 @@ describe('application lifecycle test', () => {
30 31
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
31 32
   });
32 33
 
33
-  test(':android: relaunch after close with back button', async () => {
34
-    await elementById(testIDs.PUSH_BUTTON).tap();
34
+  it(':android: relaunch after close with back button', async () => {
35
+    await elementById(TestIDs.STACK_BTN).tap();
36
+    await elementById(TestIDs.PUSH_BTN).tap();
35 37
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
36 38
 
37 39
     Android.pressBack();
@@ -40,8 +42,9 @@ describe('application lifecycle test', () => {
40 42
     await expect(elementByLabel('Pushed Screen')).toBeNotVisible();
41 43
   });
42 44
 
43
-  test('device orientation does not destroy activity', async () => {
44
-    await elementById(testIDs.PUSH_BUTTON).tap();
45
+  it('device orientation does not destroy activity', async () => {
46
+    await elementById(TestIDs.STACK_BTN).tap();
47
+    await elementById(TestIDs.PUSH_BTN).tap();
45 48
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
46 49
 
47 50
     await device.setOrientation('landscape');
@@ -49,16 +52,32 @@ describe('application lifecycle test', () => {
49 52
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
50 53
   });
51 54
 
52
-  test(':android: relaunch after activity killed by system', async () => {
53
-    await elementById(testIDs.PUSH_BUTTON).tap();
55
+  it(':android: relaunch after activity killed by system', async () => {
56
+    await elementById(TestIDs.STACK_BTN).tap();
57
+    await elementById(TestIDs.PUSH_BTN).tap();
54 58
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
55 59
     await device.sendToHome();
56 60
 
57 61
     await togglePhonePermission();
62
+    await sleep(1000);
58 63
     await device.launchApp();
59 64
 
60 65
     await expect(elementByLabel('Pushed Screen')).toBeNotVisible();
61
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
66
+    await expect(elementById(TestIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
67
+  });
68
+
69
+  it(':android: pressing r twice with delay does nothing', async () => {
70
+    if (!IS_RELEASE) {
71
+      await elementById(TestIDs.STACK_BTN).tap();
72
+      await elementById(TestIDs.PUSH_BTN).tap();
73
+      await expect(elementByLabel('Pushed Screen')).toBeVisible();
74
+
75
+      Android.pressKeyCode(KEY_CODE_R);
76
+      await sleep(1000);
77
+      Android.pressKeyCode(KEY_CODE_R);
78
+
79
+      await expect(elementByLabel('Pushed Screen')).toBeVisible();
80
+    }
62 81
   });
63 82
 
64 83
   xit(':android: pressing menu opens dev menu', async () => {
@@ -71,7 +90,7 @@ describe('application lifecycle test', () => {
71 90
 
72 91
   xit(':android: pressing r twice in succession reloads React Native', async () => {
73 92
     if (!IS_RELEASE) {
74
-      await elementById(testIDs.PUSH_BUTTON).tap();
93
+      await elementById(TestIDs.PUSH_BTN).tap();
75 94
       await expect(elementByLabel('Pushed Screen')).toBeVisible();
76 95
 
77 96
       Android.pressKeyCode(KEY_CODE_R);
@@ -82,22 +101,9 @@ describe('application lifecycle test', () => {
82 101
     }
83 102
   });
84 103
 
85
-  test(':android: pressing r twice with delay does nothing', async () => {
86
-    if (!IS_RELEASE) {
87
-      await elementById(testIDs.PUSH_BUTTON).tap();
88
-      await expect(elementByLabel('Pushed Screen')).toBeVisible();
89
-
90
-      Android.pressKeyCode(KEY_CODE_R);
91
-      await sleep(1000);
92
-      Android.pressKeyCode(KEY_CODE_R);
93
-
94
-      await expect(elementByLabel('Pushed Screen')).toBeVisible();
95
-    }
96
-  });
97
-
98 104
   xit(':android: sending reload broadcast reloads react native', async () => {
99 105
     if (!IS_RELEASE) {
100
-      await elementById(testIDs.PUSH_BUTTON).tap();
106
+      await elementById(TestIDs.PUSH_BTN).tap();
101 107
       await expect(elementByLabel('Pushed Screen')).toBeVisible();
102 108
 
103 109
       Android.executeShellCommand('am broadcast -a com.reactnativenavigation.broadcast.RELOAD');

+ 0
- 55
e2e/BackHandler.test.js View File

@@ -1,55 +0,0 @@
1
-const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
3
-const Android = require('./AndroidUtils');
4
-
5
-const { elementByLabel, elementById, sleep } = Utils;
6
-
7
-describe(':android: screen stack', () => {
8
-  beforeEach(async () => {
9
-    await device.relaunchApp();
10
-  });
11
-
12
-  test('override hardware back button', async () => {
13
-    await elementByLabel('BACK HANDLER').tap();
14
-    await expect(elementByLabel('Back Handler Screen')).toBeVisible();
15
-
16
-    await elementByLabel('ADD BACK HANDLER').tap();
17
-    Android.pressBack();
18
-    await sleep(100);
19
-    await expect(elementByLabel('Back Handler Screen')).toBeVisible();
20
-
21
-    await elementByLabel('REMOVE BACK HANDLER').tap();
22
-    Android.pressBack();
23
-    await sleep(100);
24
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
25
-  });
26
-
27
-  test('override hardware back button in modal with stack', async () => {
28
-    await elementByLabel('BACK HANDLER').tap();
29
-    await expect(elementByLabel('Back Handler Screen')).toBeVisible();
30
-
31
-    await elementByLabel('SHOW MODAL WITH STACK').tap();
32
-    await elementByLabel('ADD BACK HANDLER').tap();
33
-
34
-    // Back is handled in Js
35
-    Android.pressBack();
36
-    await sleep(100);
37
-    await expect(elementByLabel('Back button pressed!')).toBeVisible();
38
-
39
-    // pop
40
-    await elementByLabel('REMOVE BACK HANDLER').tap();
41
-    Android.pressBack();
42
-    await sleep(100);
43
-    await expect(elementByLabel('Back Handler Screen')).toBeVisible();
44
-
45
-    // modal dismissed
46
-    Android.pressBack();
47
-    await sleep(100);
48
-    await expect(elementByLabel('Back Handler Screen')).toBeVisible();
49
-
50
-    // main
51
-    Android.pressBack();
52
-    await sleep(100);
53
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
54
-  });
55
-});

+ 70
- 0
e2e/BottomTabs.test.js View File

@@ -0,0 +1,70 @@
1
+const Utils = require('./Utils');
2
+const TestIDs = require('../playground/src/testIDs');
3
+const Android = require('./AndroidUtils');
4
+const { elementByLabel, elementById, sleep } = Utils;
5
+describe('BottomTabs', () => {
6
+  beforeEach(async () => {
7
+    await device.relaunchApp();
8
+    await elementById(TestIDs.BOTTOM_TABS_BTN).tap();
9
+    await expect(elementByLabel('First Tab')).toBeVisible();
10
+  });
11
+
12
+  it('switch to tab by index', async () => {
13
+    await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
14
+    await expect(elementByLabel('First Tab')).toBeNotVisible();
15
+    await expect(elementByLabel('Second Tab')).toBeVisible();
16
+  });
17
+
18
+  it('switch to tab by componentId', async () => {
19
+    await elementById(TestIDs.SWITCH_TAB_BY_COMPONENT_ID_BTN).tap();
20
+    await expect(elementByLabel('First Tab')).toBeNotVisible();
21
+    await expect(elementByLabel('Second Tab')).toBeVisible();
22
+  });
23
+
24
+  it('push bottom tabs', async () => {
25
+    await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
26
+    await elementById(TestIDs.PUSH_BTN).tap();
27
+    await expect(elementById(TestIDs.PUSHED_BOTTOM_TABS)).toBeVisible();
28
+  });
29
+
30
+  it('set Tab Bar badge on current Tab', async () => {
31
+    await elementById(TestIDs.SET_BADGE_BTN).tap();
32
+    await expect(element(by.text('NEW'))).toBeVisible();
33
+  });
34
+
35
+  it(':ios: set Tab Bar badge null on a current Tab should reset badge', async () => {
36
+    await elementById(TestIDs.SET_BADGE_BTN).tap();
37
+    await expect(element(by.text('NEW'))).toBeVisible();
38
+    await elementById(TestIDs.CLEAR_BADGE_BTN).tap();
39
+    await expect(element(by.text('NEW'))).toBeNotVisible();
40
+  });
41
+
42
+  it('merge options correctly in SideMenu inside BottomTabs layout', async () => {
43
+    await elementById(TestIDs.SWITCH_TAB_BY_INDEX_BTN).tap();
44
+    await elementById(TestIDs.SIDE_MENU_INSIDE_BOTTOM_TABS_BTN).tap();
45
+    await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
46
+
47
+    await elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN).tap();
48
+    await expect(elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN)).toBeNotVisible();
49
+  });
50
+
51
+  it(':android: hide Tab Bar', async () => {
52
+    await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
53
+    await elementById(TestIDs.HIDE_TABS_BTN).tap();
54
+    await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
55
+  });
56
+
57
+  it(':android: show Tab Bar', async () => {
58
+    await elementById(TestIDs.HIDE_TABS_BTN).tap();
59
+    await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
60
+    await elementById(TestIDs.SHOW_TABS_BTN).tap();
61
+    await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
62
+  });
63
+
64
+  it('hide Tab Bar on push', async () => {
65
+    await elementById(TestIDs.HIDE_TABS_PUSH_BTN).tap();
66
+    await expect(elementById(TestIDs.BOTTOM_TABS)).toBeNotVisible();
67
+    await elementById(TestIDs.POP_BTN).tap();
68
+    await expect(elementById(TestIDs.BOTTOM_TABS)).toBeVisible();
69
+  });
70
+});

+ 0
- 33
e2e/ComplexLayout.test.js View File

@@ -1,33 +0,0 @@
1
-const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
3
-
4
-const { elementByLabel, elementById } = Utils;
5
-
6
-describe('complex layout', () => {
7
-  beforeEach(async () => {
8
-    await device.relaunchApp();
9
-  });
10
-
11
-  test('shows external component in stack in modal', async () => {
12
-    await elementById(testIDs.COMPLEX_LAYOUT_BUTTON).tap();
13
-    await elementById(testIDs.EXTERNAL_COMPONENT_IN_STACK).tap();
14
-    await expect(elementByLabel('External component in stack')).toBeVisible();
15
-  });
16
-
17
-  test('shows external component in deep stack in modal', async () => {
18
-    await elementById(testIDs.COMPLEX_LAYOUT_BUTTON).tap();
19
-    await elementById(testIDs.EXTERNAL_COMPONENT_IN_DEEP_STACK).tap();
20
-    await expect(elementByLabel('External component in deep stack')).toBeVisible();
21
-  });
22
-
23
-  test('merge options correctly in SideMenu inside BottomTabs layout', async () => {
24
-    await elementById(testIDs.COMPLEX_LAYOUT_BUTTON).tap();
25
-    await elementById(testIDs.SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB).tap();
26
-    await elementById(testIDs.SECOND_TAB_BAR_BUTTON).tap();
27
-    await elementById(testIDs.OPEN_SIDE_MENU).tap();
28
-    await expect(elementByLabel('This is a left side menu screen')).toBeVisible();
29
-
30
-    await elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON).tap();
31
-    await expect(elementByLabel('This is a left side menu screen')).toBeNotVisible();
32
-  });
33
-});

+ 78
- 78
e2e/Modals.test.js View File

@@ -1,141 +1,141 @@
1 1
 const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
2
+const TestIDs = require('../playground/src/testIDs');
3 3
 const Android = require('./AndroidUtils');
4 4
 
5
-const { elementByLabel, elementById, tapDeviceBackAndroid } = Utils;
5
+const { elementByLabel, elementById, sleep } = Utils;
6 6
 
7 7
 describe('modal', () => {
8 8
   beforeEach(async () => {
9 9
     await device.relaunchApp();
10
+    await elementById(TestIDs.NAVIGATION_TAB).tap();
11
+    await elementById(TestIDs.MODAL_BTN).tap();
10 12
   });
11 13
 
12
-  test('show modal', async () => {
13
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
14
-    await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
14
+  it('show modal', async () => {
15
+    await expect(elementById(TestIDs.MODAL_SCREEN_HEADER)).toBeVisible();
15 16
   });
16 17
 
17
-  test('dismiss modal', async () => {
18
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
19
-    await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
20
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
21
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
18
+  it('dismiss modal', async () => {
19
+    await expect(elementById(TestIDs.MODAL_SCREEN_HEADER)).toBeVisible();
20
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
21
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
22 22
   });
23 23
 
24
-  test('unmount modal when dismissed', async () => {
25
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
26
-    await expect(elementById(testIDs.MODAL_SCREEN)).toBeVisible();
27
-    await elementById(testIDs.MODAL_LIFECYCLE_BUTTON).tap();
24
+  it('unmount modal when dismissed', async () => {
25
+    await expect(elementById(TestIDs.MODAL_SCREEN_HEADER)).toBeVisible();
26
+    await elementById(TestIDs.MODAL_LIFECYCLE_BTN).tap();
28 27
     await expect(elementByLabel('didAppear')).toBeVisible();
29
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
28
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
30 29
     await expect(elementByLabel('componentWillUnmount')).toBeVisible();
31 30
     await elementByLabel('OK').atIndex(0).tap();
32 31
     await expect(elementByLabel('didDisappear')).toBeVisible();
33 32
     await elementByLabel('OK').atIndex(0).tap();
34 33
   });
35 34
 
36
-  test('show multiple modals', async () => {
37
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
35
+  it('show multiple modals', async () => {
38 36
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
39
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
37
+    await elementById(TestIDs.MODAL_BTN).tap();
40 38
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
41
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
39
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
42 40
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
43
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
44
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
41
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
42
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
45 43
   });
46 44
 
47
-  test('dismiss unknown screen id', async () => {
48
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
45
+  it('dismiss unknown screen id', async () => {
49 46
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
50
-    await elementById(testIDs.DISMISS_UNKNOWN_MODAL_BUTTON).tap();
47
+    await elementById(TestIDs.DISMISS_UNKNOWN_MODAL_BTN).tap();
51 48
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
52
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
53
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
49
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
50
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
54 51
   });
55 52
 
56
-  test('dismiss modal by id which is not the top most', async () => {
57
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
53
+  it('dismiss modal by id which is not the top most', async () => {
58 54
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
59
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
55
+    await elementById(TestIDs.MODAL_BTN).tap();
60 56
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
61
-    await elementById(testIDs.DISMISS_PREVIOUS_MODAL_BUTTON).tap();
57
+    await elementById(TestIDs.DISMISS_PREVIOUS_MODAL_BTN).tap();
62 58
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
63
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
64
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
59
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
60
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
65 61
   });
66 62
 
67
-  test(
68
-    'dismiss all previous modals by id when they are below top presented modal',
69
-    async () => {
70
-      await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
71
-      await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
72
-      await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
73
-      await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
74
-      await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
75
-      await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
76
-
77
-      await elementById(testIDs.DISMISS_ALL_PREVIOUS_MODAL_BUTTON).tap();
78
-      await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
79
-
80
-      await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
81
-      await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
63
+  it('dismiss all previous modals by id when they are below top presented modal', async () => {
64
+    await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
65
+    await elementById(TestIDs.MODAL_BTN).tap();
66
+    await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
67
+    await elementById(TestIDs.MODAL_BTN).tap();
68
+    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
69
+
70
+    await elementById(TestIDs.DISMISS_ALL_PREVIOUS_MODAL_BTN).tap();
71
+    await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
72
+
73
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
74
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
82 75
     }
83 76
   );
84 77
 
85
-  test('dismiss some modal by id deep in the stack', async () => {
86
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
78
+  it('dismiss some modal by id deep in the stack', async () => {
87 79
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
88
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
80
+    await elementById(TestIDs.MODAL_BTN).tap();
89 81
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
90
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
82
+    await elementById(TestIDs.MODAL_BTN).tap();
91 83
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
92 84
 
93
-    await elementById(testIDs.DISMISS_FIRST_MODAL_BUTTON).tap();
85
+    await elementById(TestIDs.DISMISS_FIRST_MODAL_BTN).tap();
94 86
     await expect(elementByLabel('Modal Stack Position: 3')).toBeVisible();
95 87
 
96
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
88
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
97 89
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
98 90
 
99
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
100
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
91
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
92
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
101 93
   });
102 94
 
103
-  test('dismissAllModals', async () => {
104
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
95
+  it('dismissAllModals', async () => {
105 96
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
106
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
97
+    await elementById(TestIDs.MODAL_BTN).tap();
107 98
     await expect(elementByLabel('Modal Stack Position: 2')).toBeVisible();
108
-    await elementById(testIDs.DISMISS_ALL_MODALS_BUTTON).tap();
109
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
99
+    await elementById(TestIDs.DISMISS_ALL_MODALS_BTN).tap();
100
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
110 101
   });
111 102
 
112
-  test('push into modal', async () => {
113
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
114
-    await elementById(testIDs.PUSH_BUTTON).tap();
103
+  it('push into modal', async () => {
104
+    await elementById(TestIDs.PUSH_BTN).tap();
115 105
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
116 106
   });
117 107
 
118
-  test(':android: push into modal', async () => {
119
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
120
-    await elementById(testIDs.PUSH_BUTTON).tap();
121
-    await elementById(testIDs.PUSH_BUTTON).tap();
108
+  it(':android: push into modal and dismiss pushed screen with hardware back', async () => {
109
+    await elementById(TestIDs.PUSH_BTN).tap();
110
+    await elementById(TestIDs.PUSH_BTN).tap();
122 111
     Android.pressBack();
123 112
     await expect(elementByLabel('Pushed Screen')).toBeVisible();
124 113
   });
125 114
 
126
-  test('present modal multiple times', async () => {
127
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
128
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
129
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
130
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
131
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
115
+  it('present modal multiple times', async () => {
116
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
117
+    await elementById(TestIDs.MODAL_BTN).tap();
132 118
     await expect(elementByLabel('Modal Stack Position: 1')).toBeVisible();
133 119
   });
134 120
 
135
-  test('dismiss modal on non-modal component should not deatch component', async () => {
136
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
137
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
138
-    await elementById(testIDs.PUSH_BUTTON).tap();
139
-    await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
121
+  it(':android: override hardware back button in modal with stack', async () => {
122
+    await elementById(TestIDs.PUSH_BTN).tap();
123
+    await elementById(TestIDs.ADD_BACK_HANDLER).tap();
124
+
125
+    // Back is handled in Js
126
+    Android.pressBack();
127
+    await sleep(100);
128
+    await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
129
+
130
+    // pop
131
+    await elementById(TestIDs.REMOVE_BACK_HANDLER).tap();
132
+    Android.pressBack();
133
+    await sleep(100);
134
+    await expect(elementById(TestIDs.MODAL_SCREEN_HEADER)).toBeVisible();
135
+
136
+    // modal dismissed
137
+    Android.pressBack();
138
+    await sleep(100);
139
+    await expect(elementById(TestIDs.NAVIGATION_TAB)).toBeVisible();
140 140
   });
141 141
 });

+ 94
- 0
e2e/Options.test.js View File

@@ -0,0 +1,94 @@
1
+const Utils = require('./Utils');
2
+const Android = require('./AndroidUtils');
3
+const TestIDs = require('../playground/src/testIDs');
4
+
5
+const { elementById, elementByLabel } = Utils;
6
+
7
+describe('Options', () => {
8
+  beforeEach(async () => {
9
+    await device.relaunchApp();
10
+    await elementById(TestIDs.OPTIONS_TAB).tap();
11
+  });
12
+
13
+  it('declare options on a component', async () => {
14
+    await expect(elementByLabel('Styling Options')).toBeVisible();
15
+  });
16
+
17
+  it('change title on component component', async () => {
18
+    await expect(elementByLabel('Styling Options')).toBeVisible();
19
+    await elementById(TestIDs.CHANGE_TITLE_BTN).tap();
20
+    await expect(elementByLabel('Title Changed')).toBeVisible();
21
+  });
22
+
23
+  it('hides TopBar when pressing on Hide TopBar and shows it when pressing on Show TopBar', async () => {
24
+    await elementById(TestIDs.HIDE_TOP_BAR_BTN).tap();
25
+    await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
26
+    await elementById(TestIDs.SHOW_TOP_BAR_BTN).tap();
27
+    await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
28
+  });
29
+
30
+  it('sets right buttons', async () => {
31
+    await expect(elementById(TestIDs.BUTTON_ONE)).toBeVisible();
32
+    await expect(elementById(TestIDs.ROUND_BUTTON)).toBeVisible();
33
+  });
34
+
35
+  it('set left buttons', async () => {
36
+    await expect(elementById(TestIDs.LEFT_BUTTON)).toBeVisible();
37
+  });
38
+
39
+  it('pass props to custom button component', async () => {
40
+    await expect(elementByLabel('Two')).toExist();
41
+  });
42
+
43
+  it('pass props to custom button component should exist after push pop', async () => {
44
+    await expect(elementByLabel('Two')).toExist();
45
+    await elementById(TestIDs.PUSH_BTN).tap();
46
+    await elementById(TestIDs.POP_BTN).tap();
47
+    await expect(elementByLabel('Two')).toExist();
48
+  });
49
+
50
+  it('custom button is clickable', async () => {
51
+    await elementByLabel('Two').tap();
52
+    await expect(elementByLabel('Thanks for that :)')).toExist();
53
+  });
54
+
55
+  it('default options should apply to all screens in stack', async () => {
56
+    await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
57
+    await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
58
+    await elementById(TestIDs.PUSH_BTN).tap();
59
+    await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
60
+    await elementById(TestIDs.PUSH_BTN).tap();
61
+    await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
62
+  });
63
+
64
+  it('default options should not override static options', async () => {
65
+    await elementById(TestIDs.HIDE_TOPBAR_DEFAULT_OPTIONS).tap();
66
+    await elementById(TestIDs.PUSH_BTN).tap();
67
+    await elementById(TestIDs.POP_BTN).tap();
68
+    await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
69
+    await expect(elementByLabel('Styling Options')).toBeVisible();
70
+  });
71
+
72
+  it('set title component', async () => {
73
+    await elementById(TestIDs.SET_REACT_TITLE_VIEW).tap();
74
+    await expect(elementByLabel('Press Me')).toBeVisible();
75
+  });
76
+
77
+  it('Popping screen with yellow box should not crash', async () => {
78
+    await elementById(TestIDs.SHOW_YELLOW_BOX_BTN).tap();
79
+    await elementById(TestIDs.PUSH_BTN).tap();
80
+    await elementById(TestIDs.POP_BTN).tap();
81
+    await expect(elementByLabel('Styling Options')).toBeVisible();
82
+  });
83
+
84
+  xit('hides topBar onScroll down and shows it on scroll up', async () => {
85
+    await elementById(TestIDs.PUSH_OPTIONS_BUTTON).tap();
86
+    await elementById(TestIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
87
+    await elementById(TestIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
88
+    await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
89
+    await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
90
+    await expect(elementById(TestIDs.TOP_BAR)).toBeNotVisible();
91
+    await element(by.id(TestIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
92
+    await expect(elementById(TestIDs.TOP_BAR)).toBeVisible();
93
+  });
94
+});

+ 59
- 0
e2e/Orientation.test.js View File

@@ -0,0 +1,59 @@
1
+
2
+const Utils = require('./Utils');
3
+const TestIDs = require('../playground/src/testIDs');
4
+
5
+const { elementById } = Utils;
6
+
7
+describe(':ios: orientation', () => {
8
+
9
+  beforeEach(async () => {
10
+    await device.relaunchApp();
11
+    waitForDeviceToSettleAfterOrientationChangeAndroid = ms => new Promise(res => setTimeout(res, device.getPlatform() === 'ios' ? 0 : 400));
12
+    await elementById(TestIDs.NAVIGATION_TAB).tap();
13
+    await elementById(TestIDs.SHOW_ORIENTATION_SCREEN).tap();
14
+  });
15
+
16
+  it('default allows all', async () => {
17
+    await elementById(TestIDs.DEFAULT_ORIENTATION_BTN).tap();
18
+    waitForDeviceToSettleAfterOrientationChangeAndroid();
19
+    await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
20
+    await device.setOrientation('landscape');
21
+    waitForDeviceToSettleAfterOrientationChangeAndroid();
22
+    await expect(elementById(TestIDs.LANDSCAPE_ELEMENT)).toBeVisible();
23
+    await device.setOrientation('portrait');
24
+    waitForDeviceToSettleAfterOrientationChangeAndroid();
25
+    await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
26
+    await elementById(TestIDs.DISMISS_BTN).tap();
27
+  });
28
+
29
+  it('landscape and portrait array', async () => {
30
+    await elementById(TestIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BTN).tap();
31
+    await expect(element(by.id(TestIDs.PORTRAIT_ELEMENT))).toBeVisible();
32
+    await device.setOrientation('landscape');
33
+    waitForDeviceToSettleAfterOrientationChangeAndroid();
34
+    await expect(element(by.id(TestIDs.LANDSCAPE_ELEMENT))).toBeVisible();
35
+    await device.setOrientation('portrait');
36
+    waitForDeviceToSettleAfterOrientationChangeAndroid();
37
+    await expect(element(by.id(TestIDs.PORTRAIT_ELEMENT))).toBeVisible();
38
+    await elementById(TestIDs.DISMISS_BTN).tap();
39
+  });
40
+
41
+  it(':ios: portrait only', async () => {
42
+    await elementById(TestIDs.PORTRAIT_ORIENTATION_BTN).tap();
43
+    await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
44
+    await device.setOrientation('landscape');
45
+    await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
46
+    await device.setOrientation('portrait');
47
+    await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
48
+    await elementById(TestIDs.DISMISS_BTN).tap();
49
+  });
50
+
51
+  it(':ios: landscape only', async () => {
52
+    await elementById(TestIDs.LANDSCAPE_ORIENTATION_BTN).tap();
53
+    await device.setOrientation('landscape');
54
+    await expect(element(by.id(TestIDs.LANDSCAPE_ELEMENT))).toBeVisible();
55
+    await device.setOrientation('portrait');
56
+    await expect(element(by.id(TestIDs.LANDSCAPE_ELEMENT))).toBeVisible();
57
+    await elementById(TestIDs.DISMISS_BTN).tap();
58
+  });
59
+});

+ 0
- 61
e2e/Orientations.test.js View File

@@ -1,61 +0,0 @@
1
-
2
-const Utils = require('./Utils');
3
-const testIDs = require('../playground/src/testIDs');
4
-
5
-const { elementById } = Utils;
6
-
7
-describe(':ios: orientation', () => {
8
-
9
-  beforeEach(async () => {
10
-    await device.relaunchApp();
11
-    waitForDeviceToSettleAfterOrientationChangeAndroid = ms => new Promise(res => setTimeout(res, device.getPlatform() === 'ios' ? 0 : 400));
12
-  });
13
-
14
-  test('default allows all', async () => {
15
-    await elementById(testIDs.ORIENTATION_BUTTON).tap();
16
-    await elementById(testIDs.DEFAULT_ORIENTATION_BUTTON).tap();
17
-    waitForDeviceToSettleAfterOrientationChangeAndroid();
18
-    await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
19
-    await device.setOrientation('landscape');
20
-    waitForDeviceToSettleAfterOrientationChangeAndroid();
21
-    await expect(elementById(testIDs.LANDSCAPE_ELEMENT)).toBeVisible();
22
-    await device.setOrientation('portrait');
23
-    waitForDeviceToSettleAfterOrientationChangeAndroid();
24
-    await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
25
-    await elementById(testIDs.DISMISS_BUTTON).tap();
26
-  });
27
-
28
-  test('landscape and portrait array', async () => {
29
-    await elementById(testIDs.ORIENTATION_BUTTON).tap();
30
-    await elementById(testIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON).tap();
31
-    await expect(element(by.id(testIDs.PORTRAIT_ELEMENT))).toBeVisible();
32
-    await device.setOrientation('landscape');
33
-    waitForDeviceToSettleAfterOrientationChangeAndroid();
34
-    await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
35
-    await device.setOrientation('portrait');
36
-    waitForDeviceToSettleAfterOrientationChangeAndroid();
37
-    await expect(element(by.id(testIDs.PORTRAIT_ELEMENT))).toBeVisible();
38
-    await elementById(testIDs.DISMISS_BUTTON).tap();
39
-  });
40
-
41
-  test(':ios: portrait only', async () => {
42
-    await elementById(testIDs.ORIENTATION_BUTTON).tap();
43
-    await elementById(testIDs.PORTRAIT_ORIENTATION_BUTTON).tap();
44
-    await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
45
-    await device.setOrientation('landscape');
46
-    await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
47
-    await device.setOrientation('portrait');
48
-    await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
49
-    await elementById(testIDs.DISMISS_BUTTON).tap();
50
-  });
51
-
52
-  test(':ios: landscape only', async () => {
53
-    await elementById(testIDs.ORIENTATION_BUTTON).tap();
54
-    await elementById(testIDs.LANDSCAPE_ORIENTATION_BUTTON).tap();
55
-    await device.setOrientation('landscape');
56
-    await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
57
-    await device.setOrientation('portrait');
58
-    await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
59
-    await elementById(testIDs.DISMISS_BUTTON).tap();
60
-  });
61
-});

+ 45
- 0
e2e/Overlay.test.js View File

@@ -0,0 +1,45 @@
1
+const Utils = require('./Utils');
2
+const TestIDs = require('../playground/src/testIDs');
3
+const { elementByLabel, elementById } = Utils;
4
+
5
+describe('Overlay', () => {
6
+  beforeEach(async () => {
7
+    await device.relaunchApp();
8
+    await elementById(TestIDs.NAVIGATION_TAB).tap();
9
+    await elementById(TestIDs.OVERLAY_BTN).tap();
10
+  });
11
+
12
+  it('show and dismiss overlay', async () => {
13
+    await elementById(TestIDs.SHOW_OVERLAY_BTN).tap();
14
+    await expect(elementById(TestIDs.OVERLAY_ALERT_HEADER)).toBeVisible();
15
+    await elementById(TestIDs.DISMISS_BTN).tap();
16
+    await expect(elementById(TestIDs.OVERLAY_ALERT_HEADER)).toBeNotVisible();
17
+  });
18
+
19
+  it('overlay pass touches - true', async () => {
20
+    await elementById(TestIDs.SHOW_TOUCH_THROUGH_OVERLAY_BTN).tap();
21
+    await expect(elementById(TestIDs.SHOW_OVERLAY_BTN)).toBeVisible();
22
+    await elementById(TestIDs.ALERT_BUTTON).tap();
23
+    await expect(elementByLabel('Alert displayed')).toBeVisible();
24
+  });
25
+
26
+  it('overlay should redraw after orientation change', async () => {
27
+    await elementById(TestIDs.SHOW_OVERLAY_BTN).tap();
28
+    await device.setOrientation('landscape');
29
+    await expect(elementById(TestIDs.OVERLAY_ALERT_HEADER)).toBeVisible();
30
+  });
31
+
32
+  it('setRoot should not remove overlay', async () => {
33
+    await elementById(TestIDs.SHOW_TOUCH_THROUGH_OVERLAY_BTN).tap();
34
+    await elementById(TestIDs.SET_ROOT_BTN).tap();
35
+    await expect(elementById(TestIDs.OVERLAY_ALERT_HEADER)).toBeVisible();
36
+  });
37
+
38
+  xtest('overlay pass touches - false', async () => {
39
+    await elementById(TestIDs.SHOW_OVERLAY_BUTTON).tap();
40
+    await expect(elementById(TestIDs.SHOW_OVERLAY_BUTTON)).toBeVisible();
41
+    await expect(elementById(TestIDs.TOP_BAR_ELEMENT)).toBeVisible();
42
+    await elementById(TestIDs.HIDE_TOP_BAR_BUTTON).tap();
43
+    await expect(elementById(TestIDs.TOP_BAR_ELEMENT)).toBeVisible();
44
+  });
45
+});

+ 0
- 51
e2e/OverlayTest.test.js View File

@@ -1,51 +0,0 @@
1
-const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
3
-const { elementByLabel, elementById } = Utils;
4
-
5
-describe('Overlay', () => {
6
-  beforeEach(async () => {
7
-    await device.relaunchApp();
8
-  });
9
-
10
-  test('show and dismiss overlay', async () => {
11
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
12
-    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
13
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
14
-    await elementById(testIDs.OK_BUTTON).tap();
15
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeNotVisible();
16
-  });
17
-
18
-  test('overlay pass touches - true', async () => {
19
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
20
-    await elementById(testIDs.SHOW_TOUCH_THROUGH_OVERLAY_BUTTON).tap();
21
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
22
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
23
-    await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
24
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
25
-  });
26
-
27
-  xtest('overlay pass touches - false', async () => {
28
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
29
-    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
30
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
31
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
32
-    await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
33
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
34
-  });
35
-
36
-  test('overlay should redraw after orientation change', async () => {
37
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
38
-    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
39
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
40
-    await device.setOrientation('landscape');
41
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
42
-  });
43
-
44
-  test('setRoot should not remove overlay', async () => {
45
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
46
-    await elementById(testIDs.SHOW_OVERLAY_BUTTON).tap();
47
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
48
-    await elementById(testIDs.SET_ROOT_BUTTON).tap();
49
-    await expect(elementById(testIDs.DIALOG_HEADER)).toBeVisible();
50
-  });
51
-});

+ 0
- 120
e2e/ScreenStack.test.js View File

@@ -1,120 +0,0 @@
1
-const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
3
-const Android = require('./AndroidUtils');
4
-
5
-const { elementByLabel, elementById, sleep } = Utils;
6
-
7
-describe('screen stack', () => {
8
-  beforeEach(async () => {
9
-    await device.relaunchApp();
10
-  });
11
-
12
-  test('push and pop screen', async () => {
13
-    await elementById(testIDs.PUSH_BUTTON).tap();
14
-    await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
15
-    await elementById(testIDs.POP_BUTTON).tap();
16
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
17
-  });
18
-
19
-  test(':android: push and pop screen without animation', async () => {
20
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
21
-    await expect(elementById(testIDs.OPTIONS_SCREEN_HEADER)).toBeVisible();
22
-    Android.pressBack();
23
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
24
-  });
25
-
26
-  test('pop to specific id', async () => {
27
-    await elementById(testIDs.PUSH_BUTTON).tap();
28
-    await elementById(testIDs.PUSH_BUTTON).tap();
29
-    await elementById(testIDs.PUSH_BUTTON).tap();
30
-    await expect(elementByLabel('Stack Position: 3')).toBeVisible();
31
-    await elementById(testIDs.POP_STACK_POSITION_ONE_BUTTON).tap();
32
-    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
33
-  });
34
-
35
-  test('pop to root', async () => {
36
-    await elementById(testIDs.PUSH_BUTTON).tap();
37
-    await elementById(testIDs.PUSH_BUTTON).tap();
38
-    await elementById(testIDs.PUSH_BUTTON).tap();
39
-    await elementById(testIDs.POP_TO_ROOT).tap();
40
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
41
-  });
42
-
43
-  test('switch to tab', async () => {
44
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
45
-    await expect(elementByLabel('This is tab 1')).toBeVisible();
46
-    await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
47
-    await expect(elementByLabel('This is tab 1')).toBeNotVisible();
48
-    await expect(elementByLabel('This is tab 2')).toBeVisible();
49
-  });
50
-
51
-  test('switch to tab by cotnainerId', async () => {
52
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
53
-    await expect(elementByLabel('This is tab 1')).toBeVisible();
54
-    await elementById(testIDs.SWITCH_SECOND_TAB_BUTTON).tap();
55
-    await expect(elementByLabel('This is tab 2')).toBeVisible();
56
-    await elementById(testIDs.SWITCH_FIRST_TAB_BUTTON).tap();
57
-    await expect(elementByLabel('This is tab 1')).toBeVisible();
58
-  });
59
-
60
-  test('push stack with multiple children', async () => {
61
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
62
-    await elementById(testIDs.MODAL_WITH_STACK_BUTTON).tap();
63
-    await expect(elementByLabel('Screen 2')).toBeVisible();
64
-    await elementById(testIDs.POP_BUTTON).tap();
65
-    await expect(elementByLabel('Screen 1')).toBeVisible();
66
-  });
67
-
68
-  test('push external component with options', async () => {
69
-    await elementById(testIDs.PUSH_EXTERNAL_COMPONENT_BUTTON).tap();
70
-    await expect(elementByLabel('This is an external component')).toBeVisible();
71
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
72
-  });
73
-
74
-  test('push into a stack from BottomTabs', async () => {
75
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
76
-    await elementById(testIDs.PUSH_BUTTON).tap();
77
-    await expect(elementByLabel('Pushed Screen')).toBeVisible();
78
-    await elementById(testIDs.POP_BUTTON).tap();
79
-    await expect(elementByLabel('This is tab 1')).toBeVisible();
80
-  });
81
-
82
-  test(':ios: set stack root component should be first in stack', async () => {
83
-    await elementById(testIDs.PUSH_BUTTON).tap();
84
-    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
85
-    await elementById(testIDs.SET_STACK_ROOT_BUTTON).tap();
86
-    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
87
-    await elementById(testIDs.POP_BUTTON).tap();
88
-    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
89
-  });
90
-
91
-  test('push to stack with static id from SideMenu', async () => {
92
-    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
93
-    await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
94
-    await elementById(testIDs.LEFT_SIDE_MENU_PUSH_BUTTON).tap();
95
-    await expect(elementByLabel('Text Screen')).toBeVisible();
96
-    await elementById(testIDs.POP_BUTTON).tap();
97
-    await expect(elementByLabel('This is a side menu center screen tab 1')).toBeVisible();
98
-  });
99
-
100
-  test('pop component should not deatch component if can`t pop', async () => {
101
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
102
-    await elementById(testIDs.POP_BUTTON).tap();
103
-    await elementById(testIDs.PUSH_BUTTON).tap();
104
-    await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
105
-  });
106
-
107
-  test('push bottom tabs', async () => {
108
-    await elementById(testIDs.PUSH_BUTTON).tap();
109
-    await expect(elementById(testIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
110
-    await elementById(testIDs.PUSH_BOTTOM_TABS_BUTTON).tap();
111
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
112
-  });
113
-
114
-  test(':android: custom back button', async () => {
115
-    await elementById(testIDs.PUSH_BUTTON).tap();
116
-    await elementById(testIDs.PUSH_CUSTOM_BACK_BUTTON).tap();
117
-    await elementById(testIDs.CUSTOM_BACK_BUTTON).tap();
118
-    await expect(elementByLabel('back button clicked')).toBeVisible();
119
-  });
120
-});

+ 0
- 207
e2e/ScreenStyle.test.js View File

@@ -1,207 +0,0 @@
1
-const Utils = require('./Utils');
2
-const Android = require('./AndroidUtils');
3
-const testIDs = require('../playground/src/testIDs');
4
-
5
-const { elementById, elementByLabel } = Utils;
6
-
7
-describe('screen style', () => {
8
-  beforeEach(async () => {
9
-    await device.relaunchApp();
10
-  });
11
-
12
-  test('declare options on a component', async () => {
13
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
14
-    await expect(elementByLabel('Static Title')).toBeVisible();
15
-  });
16
-
17
-  test('change title on component component', async () => {
18
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
19
-    await expect(elementByLabel('Static Title')).toBeVisible();
20
-    await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
21
-    await expect(elementByLabel('Dynamic Title')).toBeVisible();
22
-  });
23
-
24
-  test(
25
-    'set dynamic options with valid options will do something and not crash',
26
-    async () => {
27
-      await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
28
-      await elementById(testIDs.DYNAMIC_OPTIONS_BUTTON).tap();
29
-      await expect(elementById(testIDs.OPTIONS_SCREEN_HEADER)).toBeVisible();
30
-    }
31
-  );
32
-
33
-  test(
34
-    'hides TopBar when pressing on Hide TopBar and shows it when pressing on Show TopBar',
35
-    async () => {
36
-      await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
37
-      await elementById(testIDs.HIDE_TOP_BAR_BUTTON).tap();
38
-      await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
39
-      await elementById(testIDs.SHOW_TOP_BAR_BUTTON).tap();
40
-      await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
41
-    }
42
-  );
43
-
44
-  xit('hides topBar onScroll down and shows it on scroll up', async () => {
45
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
46
-    await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
47
-    await elementById(testIDs.TOGGLE_TOP_BAR_HIDE_ON_SCROLL).tap();
48
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
49
-    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('up', 'slow');
50
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
51
-    await element(by.id(testIDs.SCROLLVIEW_ELEMENT)).swipe('down', 'fast');
52
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
53
-  });
54
-
55
-  test('set Tab Bar badge on a current Tab', async () => {
56
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
57
-    await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
58
-    await expect(element(by.text('TeSt'))).toBeVisible();
59
-  });
60
-
61
-  test('set Tab Bar badge on a current Tab appear once', async () => {
62
-    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
63
-    await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
64
-    await expect(element(by.text('TeSt'))).toBeVisible();
65
-  });
66
-
67
-  test(':ios: set Tab Bar badge null on a current Tab should reset badge', async () => {
68
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
69
-    await elementById(testIDs.SET_TAB_BADGE_BUTTON).tap();
70
-    await expect(element(by.text('TeSt'))).toBeVisible();
71
-    await elementById(testIDs.SET_TAB_BADGE_BUTTON_NULL).tap();
72
-    await expect(element(by.text('TeSt'))).toBeNotVisible();
73
-  });
74
-
75
-  test(':android: hide Tab Bar', async () => {
76
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
77
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
78
-    await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
79
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
80
-  });
81
-
82
-  test(':android: show Tab Bar', async () => {
83
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
84
-    await elementById(testIDs.HIDE_BOTTOM_TABS_BUTTON).tap();
85
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
86
-    await elementById(testIDs.SHOW_BOTTOM_TABS_BUTTON).tap();
87
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
88
-  });
89
-
90
-  test('hide Tab Bar on push', async () => {
91
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
92
-    await elementById(testIDs.HIDE_BOTTOM_TABS_ON_PUSH_BUTTON).tap();
93
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeNotVisible();
94
-    await elementById(testIDs.POP_BUTTON).tap();
95
-    await expect(elementById(testIDs.BOTTOM_TABS_ELEMENT)).toBeVisible();
96
-  });
97
-
98
-  test('side menu visibility - left', async () => {
99
-    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
100
-    await elementById(testIDs.SHOW_LEFT_SIDE_MENU_BUTTON).tap();
101
-    await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
102
-    await elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON).tap();
103
-    await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeNotVisible();
104
-  });
105
-
106
-  test('side menu visibility - right', async () => {
107
-    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
108
-    await elementById(testIDs.SHOW_RIGHT_SIDE_MENU_BUTTON).tap();
109
-    await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeVisible();
110
-    await elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON).tap();
111
-    await expect(elementById(testIDs.HIDE_RIGHT_SIDE_MENU_BUTTON)).toBeNotVisible();
112
-  });
113
-
114
-  test('set right buttons', async () => {
115
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
116
-    await expect(elementById('buttonOne')).toBeVisible();
117
-    await elementById('buttonOne').tap();
118
-    await expect(elementById('buttonTwo')).toBeVisible();
119
-    await elementById('buttonTwo').tap();
120
-    await expect(elementById('buttonOne')).toBeVisible();
121
-  });
122
-
123
-  test('set left buttons', async () => {
124
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
125
-    await expect(elementById('buttonLeft')).toBeVisible();
126
-  });
127
-
128
-  test('pass props to custom button component', async () => {
129
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
130
-    await expect(elementByLabel(`Two`)).toExist();
131
-  });
132
-
133
-  test('pass props to custom button component should exist after push pop', async () => {
134
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
135
-    await expect(elementByLabel(`Two`)).toExist();
136
-    await elementById(testIDs.SCROLLVIEW_SCREEN_BUTTON).tap();
137
-    await elementById(testIDs.POP_BUTTON).tap();
138
-    await expect(elementByLabel(`Two`)).toExist();
139
-  });
140
-
141
-  test('custom button is tapable', async () => {
142
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
143
-    await expect(elementByLabel(`Two`)).toExist();
144
-    await elementByLabel(`Two`).tap();
145
-    await expect(elementByLabel(`Thanks for that :)`)).toExist();
146
-  });
147
-
148
-  test('tab bar items visibility', async () => {
149
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
150
-    await expect(elementById(testIDs.FIRST_TAB_BAR_BUTTON)).toBeVisible();
151
-    await expect(elementById(testIDs.SECOND_TAB_BAR_BUTTON)).toBeVisible();
152
-  });
153
-
154
-  test('default options should apply to all screens in stack', async () => {
155
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
156
-    await elementById(testIDs.PUSH_DEFAULT_OPTIONS_BUTTON).tap();
157
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
158
-    await elementById(testIDs.PUSH_BUTTON).tap();
159
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
160
-  });
161
-
162
-  test('default options should not override static options', async () => {
163
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
164
-    await elementById(testIDs.PUSH_DEFAULT_OPTIONS_BUTTON).tap();
165
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeNotVisible();
166
-    await elementById(testIDs.POP_BUTTON).tap();
167
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
168
-  });
169
-
170
-  test('supports user-provided id', async () => {
171
-    await elementById(testIDs.PROVIDED_ID).tap();
172
-    await expect(elementByLabel('User provided id')).toBeVisible();
173
-  });
174
-
175
-  test('stack options should not override component options', async () => {
176
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
177
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
178
-  });
179
-
180
-  test('set title component', async () => {
181
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
182
-    await elementById(testIDs.SHOW_TOPBAR_REACT_VIEW).tap();
183
-    await expect(elementByLabel('Press Me')).toBeVisible();
184
-  });
185
-
186
-  test(':ios: set searchBar and handle onSearchUpdated event', async () => {
187
-    await elementById(testIDs.SHOW_TOPBAR_SEARCHBAR).tap();
188
-    await expect(elementByLabel('Start Typing')).toBeVisible();
189
-    await elementByLabel('Start Typing').tap();
190
-    const query = '124';
191
-    await elementByLabel('Start Typing').typeText(query);
192
-    await expect(elementById(testIDs.SEARCH_RESULT_ITEM)).toHaveText(`Item ${query}`);
193
-  });
194
-
195
-  test('default options should apply to all screens in stack', async () => {
196
-    await elementById(testIDs.PUSH_BUTTON).tap();
197
-    await expect(elementById(testIDs.TOP_BAR_ELEMENT)).toBeVisible();
198
-    await expect(elementById(testIDs.TOP_BAR_BUTTON)).toBeVisible();
199
-  });
200
-
201
-  test(':android: Popping screen with yellow box in button, title and background components should not crash', async () => {
202
-    await elementById(testIDs.PUSH_OPTIONS_BUTTON).tap();
203
-    await elementById(testIDs.SHOW_YELLOW_BOX).tap();
204
-    Android.pressBack();
205
-    await expect(elementByLabel('React Native Navigation!')).toBeVisible();
206
-  });
207
-});

+ 39
- 0
e2e/SideMenu.test.js View File

@@ -0,0 +1,39 @@
1
+const Utils = require('./Utils');
2
+const TestIDs = require('../playground/src/testIDs');
3
+const { elementByLabel, elementById } = Utils;
4
+
5
+describe('SideMenu', () => {
6
+  beforeEach(async () => {
7
+    await device.relaunchApp();
8
+    await elementById(TestIDs.SIDE_MENU_BTN).tap();
9
+  });
10
+
11
+  it('close SideMenu and push to stack with static id', async () => {
12
+    await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
13
+    await elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN).tap();
14
+    await elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN).tap();
15
+    await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
16
+    await elementById(TestIDs.POP_BTN).tap();
17
+    await expect(elementById(TestIDs.CENTER_SCREEN_HEADER)).toBeVisible();
18
+  });
19
+
20
+  it('Push to stack with static id and close SideMenu with screen options', async () => {
21
+    await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
22
+    await elementById(TestIDs.LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN).tap();
23
+    await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
24
+    await elementById(TestIDs.POP_BTN).tap();
25
+    await expect(elementById(TestIDs.CENTER_SCREEN_HEADER)).toBeVisible();
26
+  });
27
+
28
+  it('side menu visibility - left', async () => {
29
+    await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
30
+    await elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN).tap();
31
+    await expect(elementById(TestIDs.CLOSE_LEFT_SIDE_MENU_BTN)).toBeNotVisible();
32
+  });
33
+
34
+  it('side menu visibility - right', async () => {
35
+    await elementById(TestIDs.OPEN_RIGHT_SIDE_MENU_BTN).tap();
36
+    await elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN).tap();
37
+    await expect(elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN)).toBeNotVisible();
38
+  });
39
+});

+ 100
- 0
e2e/Stack.test.js View File

@@ -0,0 +1,100 @@
1
+const Utils = require('./Utils');
2
+const TestIDs = require('../playground/src/testIDs');
3
+const { elementByLabel, elementById, sleep } = Utils;
4
+const Android = require('./AndroidUtils');
5
+
6
+describe('Stack', () => {
7
+  beforeEach(async () => {
8
+    await device.relaunchApp();
9
+    await elementById(TestIDs.STACK_BTN).tap();
10
+  });
11
+
12
+  it('push and pop screen', async () => {
13
+    await elementById(TestIDs.PUSH_BTN).tap();
14
+    await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
15
+    await elementById(TestIDs.POP_BTN).tap();
16
+    await expect(elementById(TestIDs.STACK_SCREEN_HEADER)).toBeVisible();
17
+  });
18
+
19
+  it('push and pop screen without animation', async () => {
20
+    await elementById(TestIDs.PUSH_BTN).tap();
21
+    await elementById(TestIDs.PUSH_NO_ANIM_BTN).tap();
22
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
23
+    await elementById(TestIDs.POP_BTN).tap();
24
+    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
25
+  });
26
+
27
+  it('pop to specific id', async () => {
28
+    await elementById(TestIDs.PUSH_BTN).tap();
29
+    await elementById(TestIDs.PUSH_BTN).tap();
30
+    await elementById(TestIDs.PUSH_BTN).tap();
31
+    await expect(elementByLabel('Stack Position: 3')).toBeVisible();
32
+    await elementById(TestIDs.POP_TO_FIRST_SCREEN_BTN).tap();
33
+    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
34
+  });
35
+
36
+  it('pop to root', async () => {
37
+    await elementById(TestIDs.PUSH_BTN).tap();
38
+    await elementById(TestIDs.PUSH_BTN).tap();
39
+    await elementById(TestIDs.PUSH_BTN).tap();
40
+    await elementById(TestIDs.POP_TO_ROOT_BTN).tap();
41
+    await expect(elementById(TestIDs.STACK_SCREEN_HEADER)).toBeVisible();
42
+  });
43
+
44
+  it('pop component should not detach component if can`t pop', async () => {
45
+    await elementById(TestIDs.POP_NONE_EXISTENT_SCREEN_BTN).tap();
46
+    await expect(elementById(TestIDs.STACK_SCREEN_HEADER)).toBeVisible();
47
+  });
48
+
49
+  it(':android: custom back button', async () => {
50
+    await elementById(TestIDs.PUSH_CUSTOM_BACK_BTN).tap();
51
+    await elementById(TestIDs.CUSTOM_BACK_BTN).tap();
52
+    await expect(elementByLabel('back button clicked')).toBeVisible();
53
+  });
54
+
55
+  it('screen lifecycle', async () => {
56
+    await elementById(TestIDs.PUSH_LIFECYCLE_BTN).tap();
57
+    await expect(elementByLabel('didAppear')).toBeVisible();
58
+    await elementById(TestIDs.PUSH_TO_TEST_DID_DISAPPEAR_BTN).tap();
59
+    await expect(elementByLabel('didDisappear')).toBeVisible();
60
+  });
61
+
62
+  it('unmount is called on pop', async () => {
63
+    await elementById(TestIDs.PUSH_LIFECYCLE_BTN).tap();
64
+    await elementById(TestIDs.POP_BTN).tap();
65
+    await expect(elementByLabel('componentWillUnmount')).toBeVisible();
66
+    await elementByLabel('OK').atIndex(0).tap();
67
+    await expect(elementByLabel('didDisappear')).toBeVisible();
68
+  });
69
+
70
+  it(':android: override hardware back button', async () => {
71
+    await elementById(TestIDs.PUSH_BTN).tap();
72
+    await elementById(TestIDs.ADD_BACK_HANDLER).tap();
73
+    Android.pressBack();
74
+    await sleep(100);
75
+    await expect(elementById(TestIDs.PUSHED_SCREEN_HEADER)).toBeVisible();
76
+
77
+    await elementById(TestIDs.REMOVE_BACK_HANDLER).tap();
78
+    Android.pressBack();
79
+    await sleep(100);
80
+    await expect(elementById(TestIDs.STACK_SCREEN_HEADER)).toBeVisible();
81
+  });
82
+
83
+  it(':ios: set stack root component should be first in stack', async () => {
84
+    await elementById(TestIDs.PUSH_BTN).tap();
85
+    await expect(elementByLabel('Stack Position: 1')).toBeVisible();
86
+    await elementById(TestIDs.SET_STACK_ROOT_BUTTON).tap();
87
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
88
+    await elementById(TestIDs.POP_BTN).tap();
89
+    await expect(elementByLabel('Stack Position: 2')).toBeVisible();
90
+  });
91
+
92
+  it(':ios: set searchBar and handle onSearchUpdated event', async () => {
93
+    await elementById(TestIDs.SEARCH_BTN).tap();
94
+    await expect(elementByLabel('Start Typing')).toBeVisible();
95
+    await elementByLabel('Start Typing').tap();
96
+    const query = '124';
97
+    await elementByLabel('Start Typing').typeText(query);
98
+    await expect(elementById(TestIDs.SEARCH_RESULT_ITEM)).toHaveText(`Item ${query}`);
99
+  });
100
+});

+ 19
- 22
e2e/StaticLifecycleEvents.test.js View File

@@ -1,45 +1,42 @@
1 1
 const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
2
+const TestIDs = require('../playground/src/testIDs');
3 3
 const { elementByLabel, elementById } = Utils;
4 4
 
5 5
 describe('static lifecycle events', () => {
6 6
   beforeEach(async () => {
7 7
     await device.relaunchApp();
8
+    await elementById(TestIDs.NAVIGATION_TAB).tap();
9
+    await elementById(TestIDs.SHOW_STATIC_EVENTS_SCREEN).tap();
10
+    await elementById(TestIDs.STATIC_EVENTS_OVERLAY_BTN).tap();
8 11
   });
9 12
 
10
-  test('didAppear didDisappear', async () => {
11
-    await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
12
-    await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
13
-    await expect(elementByLabel('componentDidAppear | navigation.playground.StaticLifecycleOverlay')).toBeVisible();
14
-    await elementById(testIDs.PUSH_BUTTON).tap();
15
-    await expect(elementByLabel('componentDidAppear | navigation.playground.PushedScreen')).toBeVisible();
16
-    await expect(elementByLabel('componentDidDisappear | navigation.playground.WelcomeScreen')).toBeVisible();
13
+  it('didAppear didDisappear', async () => {
14
+    await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
15
+    await elementById(TestIDs.PUSH_BTN).tap();
16
+    await expect(elementByLabel('componentDidAppear | Pushed')).toBeVisible();
17
+    await expect(elementByLabel('componentDidDisappear | EventsScreen')).toBeVisible();
17 18
   });
18 19
 
19
-  test(':ios: pushing and popping screen dispatch static event', async () => {
20
-    await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
20
+  it(':ios: pushing and popping screen dispatch static event', async () => {
21 21
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
22
-    await expect(elementByLabel('componentDidAppear | navigation.playground.StaticLifecycleOverlay')).toBeVisible();
23
-    await elementById(testIDs.PUSH_BUTTON).tap();
22
+    await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
23
+    await elementById(TestIDs.PUSH_BTN).tap();
24 24
     await expect(elementByLabel('push')).toBeVisible();
25
-    await elementById(testIDs.POP_BUTTON).tap();
25
+    await elementById(TestIDs.POP_BTN).tap();
26 26
     await expect(elementByLabel('pop')).toBeVisible();
27 27
   });
28 28
 
29
-  test(':ios: showModal and dismissModal dispatch static event', async () => {
30
-    await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
31
-    await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
32
-    await expect(elementByLabel('componentDidAppear | navigation.playground.StaticLifecycleOverlay')).toBeVisible();
33
-    await elementById(testIDs.SHOW_MODAL_BUTTON).tap();
29
+  it(':ios: showModal and dismissModal dispatch static event', async () => {
30
+    await elementById(TestIDs.MODAL_BTN).tap();
34 31
     await expect(elementByLabel('showModal')).toBeVisible();
35
-    await elementById(testIDs.DISMISS_MODAL_BUTTON).tap();
32
+    await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
36 33
     await expect(elementByLabel('dismissModal')).toBeVisible();
37 34
   });
38 35
 
39
-  test(':ios: unmounts when dismissed', async () => {
40
-    await elementById(testIDs.PUSH_STATIC_LIFECYCLE_BUTTON).tap();
36
+  it(':ios: unmounts when dismissed', async () => {
37
+    await elementById(TestIDs.PUSH_BTN).tap();
41 38
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
42
-    await elementById(testIDs.DISMISS_BUTTON).tap();
39
+    await elementById(TestIDs.DISMISS_BTN).tap();
43 40
     await expect(elementByLabel('Overlay Unmounted')).toBeVisible();
44 41
     await elementByLabel('OK').tap();
45 42
   });

+ 0
- 42
e2e/TopLevelApi.test.js View File

@@ -1,42 +0,0 @@
1
-const Utils = require('./Utils');
2
-const testIDs = require('../playground/src/testIDs');
3
-
4
-const { elementByLabel, elementById } = Utils;
5
-
6
-describe('top level api', () => {
7
-  beforeEach(async () => {
8
-    await device.relaunchApp();
9
-  });
10
-
11
-  test('shows welcome screen', async () => {
12
-    await expect(elementById(testIDs.WELCOME_SCREEN_HEADER)).toBeVisible();
13
-  });
14
-
15
-  test('switch to tab based app, passProps and functions', async () => {
16
-    await elementById(testIDs.TAB_BASED_APP_BUTTON).tap();
17
-    await expect(elementByLabel('This is tab 1')).toBeVisible();
18
-    await expect(elementByLabel('Hello from a function!')).toBeVisible();
19
-  });
20
-
21
-  test(':ios: switch to tabs with side menus', async () => {
22
-    await elementById(testIDs.TAB_BASED_APP_SIDE_BUTTON).tap();
23
-    await elementById(testIDs.CENTERED_TEXT_HEADER).swipe('right');
24
-    await expect(elementById(testIDs.HIDE_LEFT_SIDE_MENU_BUTTON)).toBeVisible();
25
-  });
26
-
27
-  test('screen lifecycle', async () => {
28
-    await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
29
-    await expect(elementByLabel('didAppear')).toBeVisible();
30
-    await elementById(testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON).tap();
31
-    await expect(elementByLabel('didDisappear')).toBeVisible();
32
-  });
33
-
34
-  test('unmount is called on pop', async () => {
35
-    await elementById(testIDs.PUSH_LIFECYCLE_BUTTON).tap();
36
-    await expect(elementByLabel('didAppear')).toBeVisible();
37
-    await elementById(testIDs.POP_BUTTON).tap();
38
-    await expect(elementByLabel('componentWillUnmount')).toBeVisible();
39
-    await elementByLabel('OK').atIndex(0).tap();
40
-    await expect(elementByLabel('didDisappear')).toBeVisible();
41
-  });
42
-});

+ 1
- 1
e2e/init.js View File

@@ -4,7 +4,7 @@ const exec = require('shell-utils').exec;
4 4
 const adapter = require('detox/runners/jest/adapter');
5 5
 
6 6
 jest.setTimeout(300000);
7
-jasmine.getEnv().addReporter(adapter); // don't forget this line
7
+jasmine.getEnv().addReporter(adapter);
8 8
 
9 9
 beforeAll(async () => {
10 10
   await detox.init(config, {launchApp: false});

+ 1
- 1
lib/android/app/build.gradle View File

@@ -87,7 +87,7 @@ dependencies {
87 87
     implementation 'com.android.support:appcompat-v7:26.1.0'
88 88
     implementation 'com.android.support:support-v4:26.1.0'
89 89
 
90
-    implementation 'com.github.wix-playground:ahbottomnavigation:2.4.8'
90
+    implementation 'com.github.wix-playground:ahbottomnavigation:2.4.9'
91 91
     implementation 'com.github.wix-playground:reflow-animator:1.0.4'
92 92
     implementation 'com.github.clans:fab:1.6.4'
93 93
 

+ 13
- 24
lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java View File

@@ -1,21 +1,18 @@
1 1
 package com.reactnativenavigation.presentation;
2 2
 
3
-import android.content.Context;
4
-import android.graphics.drawable.Drawable;
5
-import android.support.annotation.NonNull;
6
-import android.support.annotation.VisibleForTesting;
7
-import android.support.v4.content.ContextCompat;
3
+import android.content.*;
4
+import android.graphics.drawable.*;
5
+import android.support.annotation.*;
6
+import android.support.v4.content.*;
8 7
 
9
-import com.reactnativenavigation.parse.BottomTabOptions;
10
-import com.reactnativenavigation.parse.Options;
11
-import com.reactnativenavigation.utils.ImageLoader;
12
-import com.reactnativenavigation.utils.ImageLoadingListenerAdapter;
13
-import com.reactnativenavigation.viewcontrollers.ViewController;
14
-import com.reactnativenavigation.viewcontrollers.bottomtabs.BottomTabFinder;
15
-import com.reactnativenavigation.views.BottomTabs;
8
+import com.reactnativenavigation.parse.*;
9
+import com.reactnativenavigation.utils.*;
10
+import com.reactnativenavigation.viewcontrollers.*;
11
+import com.reactnativenavigation.viewcontrollers.bottomtabs.*;
12
+import com.reactnativenavigation.views.*;
16 13
 import com.reactnativenavigation.views.Component;
17 14
 
18
-import java.util.List;
15
+import java.util.*;
19 16
 
20 17
 public class BottomTabPresenter {
21 18
     private final Context context;
@@ -47,7 +44,7 @@ public class BottomTabPresenter {
47 44
 
48 45
     public void applyOptions() {
49 46
         for (int i = 0; i < tabs.size(); i++) {
50
-            BottomTabOptions tab = tabs.get(i).options.copy().withDefaultOptions(defaultOptions).bottomTabOptions;
47
+            BottomTabOptions tab = tabs.get(i).resolveCurrentOptions(defaultOptions).bottomTabOptions;
51 48
             bottomTabs.setBadge(i, tab.badge.get(""));
52 49
             bottomTabs.setBadgeColor(tab.badgeColor.get(null));
53 50
             bottomTabs.setTitleTypeface(i, tab.fontFamily);
@@ -57,6 +54,7 @@ public class BottomTabPresenter {
57 54
             bottomTabs.setTitleInactiveColor(i, tab.textColor.get(null));
58 55
             bottomTabs.setTitleInactiveTextSizeInSp(i, tab.fontSize.hasValue() ? Float.valueOf(tab.fontSize.get()) : null);
59 56
             bottomTabs.setTitleActiveTextSizeInSp(i, tab.selectedFontSize.hasValue() ? Float.valueOf(tab.selectedFontSize.get()) : null);
57
+            bottomTabs.setTag(i, tab.testId.get(null));
60 58
         }
61 59
     }
62 60
 
@@ -78,16 +76,7 @@ public class BottomTabPresenter {
78 76
                     bottomTabs.setIcon(index, drawable);
79 77
                 }
80 78
             });
79
+            if (bto.testId.hasValue()) bottomTabs.setTag(index, bto.testId.get());
81 80
         }
82 81
     }
83
-
84
-    @VisibleForTesting
85
-    public int getDefaultSelectedTextColor() {
86
-        return defaultSelectedTextColor;
87
-    }
88
-
89
-    @VisibleForTesting
90
-    public int getDefaultTextColor() {
91
-        return defaultTextColor;
92
-    }
93 82
 }

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/TitleBarButtonController.java View File

@@ -164,6 +164,9 @@ public class TitleBarButtonController extends ViewController<TitleBarReactButton
164 164
     private void setTestId(Toolbar toolbar, Text testId) {
165 165
         if (!testId.hasValue()) return;
166 166
         UiUtils.runOnPreDrawOnce(toolbar, () -> {
167
+            if (button.hasComponent() && view != null) {
168
+                view.setTag(testId.get());
169
+            }
167 170
             ActionMenuView buttonsLayout = ViewUtils.findChildByClass(toolbar, ActionMenuView.class);
168 171
             List<TextView> buttons = ViewUtils.findChildrenByClass(buttonsLayout, TextView.class);
169 172
             for (TextView view : buttons) {

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/ViewController.java View File

@@ -152,6 +152,8 @@ public abstract class ViewController<T extends ViewGroup> implements ViewTreeObs
152 152
             task.run((StackController) parentController);
153 153
         } else if (this instanceof StackController) {
154 154
             task.run((StackController) this);
155
+        } else if (parentController != null){
156
+            parentController.performOnParentStack(task);
155 157
         }
156 158
     }
157 159
 

+ 1
- 1
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java View File

@@ -135,7 +135,7 @@ public class BottomTabsController extends ParentController implements AHBottomNa
135 135
 
136 136
     @Override
137 137
     protected ViewController getCurrentChild() {
138
-        return tabs.get(bottomTabs.getCurrentItem());
138
+        return tabs.get(bottomTabs == null ? 0 : bottomTabs.getCurrentItem());
139 139
     }
140 140
 
141 141
     @Override

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuController.java View File

@@ -18,7 +18,7 @@ import com.reactnativenavigation.utils.CommandListener;
18 18
 import com.reactnativenavigation.viewcontrollers.ChildControllersRegistry;
19 19
 import com.reactnativenavigation.viewcontrollers.ParentController;
20 20
 import com.reactnativenavigation.viewcontrollers.ViewController;
21
-import com.reactnativenavigation.views.Component;
21
+import com.reactnativenavigation.views.*;
22 22
 
23 23
 import java.util.ArrayList;
24 24
 import java.util.Collection;
@@ -50,7 +50,7 @@ public class SideMenuController extends ParentController<DrawerLayout> implement
50 50
     @NonNull
51 51
 	@Override
52 52
 	protected DrawerLayout createView() {
53
-        DrawerLayout sideMenu = new DrawerLayout(getActivity());
53
+        DrawerLayout sideMenu = new SideMenu(getActivity());
54 54
         presenter.bindView(sideMenu);
55 55
         sideMenu.addDrawerListener(this);
56 56
         return sideMenu;

+ 21
- 0
lib/android/app/src/main/java/com/reactnativenavigation/views/SideMenu.java View File

@@ -0,0 +1,21 @@
1
+package com.reactnativenavigation.views;
2
+
3
+import android.content.*;
4
+import android.support.annotation.*;
5
+import android.support.v4.widget.*;
6
+import android.util.*;
7
+
8
+public class SideMenu extends DrawerLayout {
9
+    public SideMenu(@NonNull Context context) {
10
+        super(context);
11
+    }
12
+
13
+    @Override
14
+    public void openDrawer(int gravity, boolean animate) {
15
+        try {
16
+            super.openDrawer(gravity, animate);
17
+        } catch (IllegalArgumentException e) {
18
+            Log.w("RNN", "Tried to open sideMenu, but it's not defined");
19
+        }
20
+    }
21
+}

+ 6
- 0
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.java View File

@@ -293,6 +293,12 @@ public class BottomTabsControllerTest extends BaseTest {
293 293
         assertThat(uut.getSelectedIndex()).isOne();
294 294
     }
295 295
 
296
+    @Test
297
+    public void resolveCurrentOptions_returnsFirstTabIfInvokedBeforeViewIsCreated() {
298
+        uut = createBottomTabs();
299
+        assertThat(uut.getCurrentChild()).isEqualTo(tabs.get(0));
300
+    }
301
+
296 302
     @Test
297 303
     public void buttonPressInvokedOnCurrentTab() {
298 304
         uut.ensureViewIsCreated();

+ 18
- 0
lib/ios/RNNSideMenuPresenter.m View File

@@ -18,6 +18,24 @@
18 18
 	[sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
19 19
 	
20 20
 	[sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
21
+	
22
+	if (options.sideMenu.left.width.hasValue) {
23
+		[sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
24
+	}
25
+	
26
+	if (options.sideMenu.right.width.hasValue) {
27
+		[sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get];
28
+	}
29
+	
30
+	if (options.sideMenu.left.visible.hasValue) {
31
+		[sideMenuController side:MMDrawerSideLeft visible:options.sideMenu.left.visible.get];
32
+		[options.sideMenu.left.visible consume];
33
+	}
34
+	
35
+	if (options.sideMenu.right.visible.hasValue) {
36
+		[sideMenuController side:MMDrawerSideRight visible:options.sideMenu.right.visible.get];
37
+		[options.sideMenu.right.visible consume];
38
+	}
21 39
 }
22 40
 
23 41
 - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {

+ 2
- 1
package.json View File

@@ -57,6 +57,7 @@
57 57
     "lodash": "4.17.x",
58 58
     "prop-types": "15.x.x",
59 59
     "react-lifecycles-compat": "2.0.0",
60
+    "react-native-ui-lib": "^3.17.2",
60 61
     "tslib": "1.9.3"
61 62
   },
62 63
   "devDependencies": {
@@ -156,4 +157,4 @@
156 157
       }
157 158
     }
158 159
   }
159
-}
160
+}

BIN
playground/img/clear@2x.ios.png View File


BIN
playground/img/clear@3x.android.png View File


BIN
playground/img/layouts@2x.android.png View File


BIN
playground/img/layouts@2x.ios.png View File


BIN
playground/img/list.png View File


BIN
playground/img/navigation@2x.android.png View File


BIN
playground/img/navigation@2x.ios.png View File


BIN
playground/img/options@2x.android.png View File


BIN
playground/img/options@2x.ios.png View File


BIN
playground/img/sideMenu.png View File


playground/img/two_selected@2x.png → playground/img/star@2x.android.png View File


BIN
playground/img/star@2x.ios.png View File


BIN
playground/img/two@2x.png View File


BIN
playground/img/whatshot@2x.android.png View File


BIN
playground/img/whatshot@2x.ios.png View File


+ 56
- 137
playground/src/app.js View File

@@ -1,12 +1,16 @@
1
+// @ts-check
1 2
 const { Navigation } = require('react-native-navigation');
2 3
 const { registerScreens } = require('./screens');
3 4
 const { Platform } = require('react-native');
5
+const { setDefaultOptions } = require('./commons/Options')
6
+const testIDs = require('./testIDs');
7
+const Screens = require('./screens/Screens');
4 8
 
5 9
 if (Platform.OS === 'android') {
6 10
   alert = (title) => {
7 11
     Navigation.showOverlay({
8 12
       component: {
9
-        name: 'navigation.playground.alert',
13
+        name: Screens.Alert,
10 14
         passProps: {
11 15
           title
12 16
         },
@@ -26,147 +30,62 @@ if (Platform.OS === 'android') {
26 30
 function start() {
27 31
   registerScreens();
28 32
   Navigation.events().registerAppLaunchedListener(async () => {
29
-    Navigation.setDefaultOptions({
30
-      layout: {
31
-        componentBackgroundColor: '#e8e8e8',
32
-        orientation: ['portrait']
33
-      },
34
-      bottomTab: {
35
-        textColor: '#1B4C77',
36
-        selectedTextColor: '#0f0',
37
-        fontFamily: 'HelveticaNeue-Italic',
38
-        fontSize: 13
39
-      },
40
-      _animations: {
41
-        push: {
42
-          waitForRender: false,
43
-        }
44
-      },
45
-      animations: {
46
-        setRoot: {
47
-          alpha: {
48
-            from: 0,
49
-            to: 1,
50
-            duration: 300
51
-          },
52
-          waitForRender: true
53
-        },
54
-        _push: {
55
-          topBar: {
56
-            id: 'TEST',
57
-            alpha: {
58
-              from: 0,
59
-              to: 1,
60
-              duration: 500,
61
-              interpolation: 'accelerate'
62
-            }
63
-          },
64
-          bottomTabs: {
65
-            y: {
66
-              from: 1000,
67
-              to: 0,
68
-              duration: 500,
69
-              interpolation: 'decelerate',
70
-            },
71
-            alpha: {
72
-              from: 0,
73
-              to: 1,
74
-              duration: 500,
75
-              interpolation: 'decelerate'
76
-            }
77
-          },
78
-          content: {
79
-            y: {
80
-              from: 1000,
81
-              to: 0,
82
-              duration: 500,
83
-              interpolation: 'accelerate',
84
-            },
85
-            alpha: {
86
-              from: 0,
87
-              to: 1,
88
-              duration: 500,
89
-              interpolation: 'accelerate'
90
-            }
91
-          }
92
-        },
93
-        _pop: {
94
-          topBar: {
95
-            id: 'TEST',
96
-            alpha: {
97
-              from: 1,
98
-              to: 0,
99
-              duration: 500,
100
-              interpolation: 'accelerate'
101
-            }
102
-          },
103
-          bottomTabs: {
104
-            y: {
105
-              from: 0,
106
-              to: 100,
107
-              duration: 500,
108
-              interpolation: 'accelerate',
109
-            },
110
-            alpha: {
111
-              from: 1,
112
-              to: 0,
113
-              duration: 500,
114
-              interpolation: 'accelerate'
115
-            }
116
-          },
117
-          bottomTabs: {
118
-            y: {
119
-              from: 0,
120
-              to: 100,
121
-              duration: 500,
122
-              interpolation: 'decelerate',
123
-            },
124
-            alpha: {
125
-              from: 1,
126
-              to: 0,
127
-              duration: 500,
128
-              interpolation: 'decelerate'
129
-            }
130
-          },
131
-          content: {
132
-            y: {
133
-              from: 0,
134
-              to: 1000,
135
-              duration: 500,
136
-              interpolation: 'decelerate',
137
-            },
138
-            alpha: {
139
-              from: 1,
140
-              to: 0,
141
-              duration: 500,
142
-              interpolation: 'decelerate'
143
-            }
144
-          }
145
-        }
146
-      }
147
-    });
148
-
149
-    // await Navigation.showModal({
150
-    //   stack: {
151
-    //     children: [
152
-    //       {
153
-    //         component: {
154
-    //           name: 'navigation.playground.ModalScreen'
155
-    //         }
156
-    //       }
157
-    //     ]
158
-    //   }
159
-    // });
33
+    setDefaultOptions();
160 34
 
161 35
     Navigation.setRoot({
162 36
       root: {
163
-        stack: {
164
-          id: 'TEST',
37
+        bottomTabs: {
165 38
           children: [
166 39
             {
167
-              component: {
168
-                name: 'navigation.playground.WelcomeScreen'
169
-                // name: 'navigation.playground.CustomTransitionOrigin'
40
+              stack: {
41
+                children: [
42
+                  {
43
+                    component: {
44
+                      name: 'Layouts'
45
+                    }
46
+                  }
47
+                ],
48
+                options: {
49
+                  bottomTab: {
50
+                    text: 'Layouts',
51
+                    icon: require('../img/layouts.png'),
52
+                    testID: testIDs.LAYOUTS_TAB
53
+                  }
54
+                }
55
+              }
56
+            },
57
+            {
58
+              stack: {
59
+                children: [
60
+                  {
61
+                    component: {
62
+                      name: 'Options'
63
+                    }
64
+                  }
65
+                ],
66
+                options: {
67
+                  topBar: {
68
+                    title: {
69
+                      text: 'Default Title'
70
+                    }
71
+                  },
72
+                  bottomTab: {
73
+                    text: 'Options',
74
+                    icon: require('../img/options.png'),
75
+                    testID: testIDs.OPTIONS_TAB
76
+                  }
77
+                }
78
+              }
79
+            },
80
+            {
81
+              stack: {
82
+                children: [
83
+                  {
84
+                    component: {
85
+                      name: 'Navigation'
86
+                    }
87
+                  }
88
+                ]
170 89
               }
171 90
             }
172 91
           ]

+ 4
- 0
playground/src/commons/Colors.js View File

@@ -0,0 +1,4 @@
1
+module.exports = {
2
+  background: '#e8e8e8',
3
+  primary: '#5847ff'
4
+}

+ 16
- 0
playground/src/commons/Layouts.js View File

@@ -0,0 +1,16 @@
1
+const { isString, isArray } = require('lodash');
2
+
3
+const stack = (rawChildren, id) => {
4
+  const childrenArray = isArray(rawChildren) ? rawChildren : [rawChildren];
5
+  const children = childrenArray.map(child => component(child));
6
+  return { stack: { children, id } };
7
+}
8
+
9
+const component = (component, options) => {
10
+  return isString(component) ? { component: { name: component, options } } : component;
11
+}
12
+
13
+module.exports = {
14
+  stack,
15
+  component
16
+}

+ 20
- 0
playground/src/commons/Options.js View File

@@ -0,0 +1,20 @@
1
+const { Navigation } = require('react-native-navigation');
2
+const Colors = require('./Colors');
3
+
4
+const setDefaultOptions = () => Navigation.setDefaultOptions({
5
+  layout: {
6
+    componentBackgroundColor: Colors.background,
7
+    orientation: ['portrait']
8
+  },
9
+  bottomTabs: {
10
+    titleDisplayMode: 'alwaysShow'
11
+  },
12
+  bottomTab: {
13
+    selectedIconColor: Colors.primary,
14
+    selectedTextColor: Colors.primary
15
+  }
16
+});
17
+
18
+module.exports = {
19
+  setDefaultOptions
20
+}

+ 9
- 0
playground/src/components/Button.js View File

@@ -0,0 +1,9 @@
1
+const React = require('react');
2
+const {Button} = require('react-native-ui-lib');
3
+module.exports = (props) =>
4
+  <Button
5
+    {...props}
6
+    style={{
7
+      marginBottom: 8,
8
+    }}
9
+  />;

+ 30
- 0
playground/src/components/Root.js View File

@@ -0,0 +1,30 @@
1
+const React = require('react');
2
+const { View, Text, StyleSheet } = require('react-native');
3
+
4
+module.exports = (props) =>
5
+  <View style={[props.style, styles.root]}>
6
+    {props.children}
7
+    {props.componentId && <View style={styles.footer}>
8
+      {props.footer && <Text style={styles.footerText}>{props.footer}</Text>}
9
+      <Text style={styles.footerText}>{`this.props.componentId = ${props.componentId}`}</Text>
10
+    </View>}
11
+  </View>;
12
+
13
+const styles = StyleSheet.create({
14
+  root: {
15
+    flex: 1,
16
+    flexDirection: 'column',
17
+    alignItems: 'center',
18
+    padding: 16
19
+  },
20
+  footer: {
21
+    flex: 1,
22
+    justifyContent: 'flex-end',
23
+    alignItems: 'center'
24
+  },
25
+  footerText: {
26
+    fontSize: 10,
27
+    color: '#888',
28
+    marginTop: 10
29
+  }
30
+});

+ 0
- 104
playground/src/screens/BackHandlerScreen.js View File

@@ -1,104 +0,0 @@
1
-const React = require('react');
2
-const { Component } = require('react');
3
-const { Navigation } = require('react-native-navigation');
4
-const { View, Text, Button, BackHandler } = require('react-native');
5
-
6
-class BackHandlerScreen extends Component {
7
-  static options() {
8
-    return {
9
-      topBar: {
10
-        title: {
11
-          text: 'Back Handler',
12
-          color: 'black',
13
-          fontSize: 16
14
-        }
15
-      }
16
-    };
17
-  }
18
-
19
-  constructor(props) {
20
-    super(props);
21
-    this.backHandler = () => {
22
-      this.setState({
23
-        backPress: 'Back button pressed!'
24
-      });
25
-      return true;
26
-    };
27
-    this.state = {
28
-      backPress: ''
29
-    };
30
-  }
31
-
32
-  render() {
33
-    return (
34
-      <View style={styles.root}>
35
-        <Text style={styles.h1}>{`Back Handler Screen`}</Text>
36
-        <Text style={styles.h2}>{this.state.backPress}</Text>
37
-        <Button title='add back handler' onPress={() => this.addBackHandler()} />
38
-        <Button title='remove back handler' onPress={() => this.removeBackHandler()} />
39
-        <Button title='show single component modal' onPress={() => this.showModal()} />
40
-        <Button title='show modal with stack' onPress={() => this.showModalWitchStack()} />
41
-      </View>
42
-    );
43
-  }
44
-
45
-  addBackHandler() {
46
-    BackHandler.addEventListener('hardwareBackPress', this.backHandler);
47
-  }
48
-
49
-  removeBackHandler() {
50
-    BackHandler.removeEventListener('hardwareBackPress', this.backHandler);
51
-  }
52
-
53
-  showModal() {
54
-    Navigation.showModal({
55
-      component: {
56
-        name: 'navigation.playground.BackHandlerModalScreen'
57
-      }
58
-    });
59
-  }
60
-
61
-  showModalWitchStack() {
62
-    Navigation.showModal({
63
-      stack: {
64
-        children: [
65
-          {
66
-            component: {
67
-              name: 'navigation.playground.BackHandlerModalScreen'
68
-            }
69
-          },
70
-          {
71
-            component: {
72
-              name: 'navigation.playground.BackHandlerModalScreen'
73
-            }
74
-          }
75
-        ]
76
-      }
77
-    });
78
-  }
79
-
80
-  componentWillUnmount() {
81
-    BackHandler.removeEventListener('hardwareBackPress', this.backHandler);
82
-  }
83
-}
84
-
85
-const styles = {
86
-  root: {
87
-    flex: 1,
88
-    backgroundColor: 'white',
89
-    justifyContent: 'center',
90
-    alignItems: 'center'
91
-  },
92
-  h2: {
93
-    fontSize: 12,
94
-    textAlign: 'center',
95
-    margin: 10
96
-  },
97
-  footer: {
98
-    fontSize: 10,
99
-    color: '#888',
100
-    marginTop: 10
101
-  }
102
-};
103
-
104
-module.exports = BackHandlerScreen;

+ 0
- 84
playground/src/screens/CustomDialog.js View File

@@ -1,84 +0,0 @@
1
-const React = require('react');
2
-const { PureComponent } = require('react');
3
-
4
-const { Text, Button, View, Alert, Platform } = require('react-native');
5
-const { Navigation } = require('react-native-navigation');
6
-
7
-const testIDs = require('../testIDs');
8
-
9
-class CustomDialog extends PureComponent {
10
-  static options() {
11
-    return {
12
-      statusBarBackgroundColor: 'green'
13
-    };
14
-  }
15
-
16
-  render() {
17
-    return (
18
-      <View style={styles.root}>
19
-        <Text style={styles.h1} testID={testIDs.DIALOG_HEADER}>Test view</Text>
20
-        <Button title='OK' testID={testIDs.OK_BUTTON} onPress={() => this.onCLickOk()} />
21
-        <Button title='Set Root' testID={testIDs.SET_ROOT_BUTTON} onPress={() => this.onCLickSetRoot()} />
22
-        <Button title='Set Intercept touch' testID={testIDs.SET_INTERCEPT_TOUCH} onPress={() => this.onCLickSetInterceptTouch()} />
23
-      </View>
24
-    );
25
-  }
26
-
27
-  didDisappear() {
28
-    if (Platform.OS === 'android') {
29
-      Alert.alert('Overlay disappeared');
30
-    }
31
-  }
32
-
33
-  onCLickOk() {
34
-    Navigation.dismissOverlay(this.props.componentId);
35
-  }
36
-
37
-  onCLickSetRoot() {
38
-    Navigation.setRoot({
39
-      root: {
40
-        component: {
41
-          name: 'navigation.playground.TextScreen'
42
-        }
43
-      }
44
-    });
45
-  }
46
-
47
-  onCLickSetInterceptTouch() {
48
-    Navigation.mergeOptions(this.props.componentId, {
49
-      overlay: {
50
-        interceptTouchOutside: false
51
-      }
52
-    });
53
-  }
54
-}
55
-
56
-const styles = {
57
-  root: {
58
-    backgroundColor: 'green',
59
-    justifyContent: 'center',
60
-    alignItems: 'center',
61
-    height: 140,
62
-    bottom: 0,
63
-    position: 'absolute',
64
-    left: 0,
65
-    right: 0
66
-  },
67
-  h1: {
68
-    fontSize: 24,
69
-    textAlign: 'center',
70
-    margin: 10
71
-  },
72
-  h2: {
73
-    fontSize: 12,
74
-    textAlign: 'center',
75
-    margin: 10
76
-  },
77
-  footer: {
78
-    fontSize: 10,
79
-    color: '#888',
80
-    marginTop: 10
81
-  }
82
-};
83
-
84
-module.exports = CustomDialog;

+ 71
- 0
playground/src/screens/FirstBottomTabScreen.js View File

@@ -0,0 +1,71 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const Navigation = require('./../services/Navigation');
5
+const Screens = require('./Screens');
6
+const { component } = require('../commons/Layouts');
7
+const {
8
+  SWITCH_TAB_BY_INDEX_BTN,
9
+  SWITCH_TAB_BY_COMPONENT_ID_BTN,
10
+  SET_BADGE_BTN,
11
+  CLEAR_BADGE_BTN,
12
+  HIDE_TABS_BTN,
13
+  SHOW_TABS_BTN,
14
+  HIDE_TABS_PUSH_BTN
15
+} = require('../testIDs')
16
+
17
+class FirstBottomTabScreen extends React.Component {
18
+  static options() {
19
+    return {
20
+      topBar: {
21
+        title: {
22
+          text: 'First Tab'
23
+        }
24
+      },
25
+      bottomTab: {
26
+        icon: require('../../img/whatshot.png'),
27
+        text: 'Tab 1'
28
+      }
29
+    };
30
+  }
31
+
32
+  render() {
33
+    return (
34
+      <Root componentId={this.props.componentId}>
35
+        <Button label='Switch Tab by Index' testID={SWITCH_TAB_BY_INDEX_BTN} onPress={this.switchTabByIndex} />
36
+        <Button label='Switch Tab by componentId' testID={SWITCH_TAB_BY_COMPONENT_ID_BTN} onPress={this.switchTabByComponentId} />
37
+        <Button label='Set Badge' testID={SET_BADGE_BTN} onPress={() => this.setBadge('NEW')} />
38
+        <Button label='Clear Badge' testID={CLEAR_BADGE_BTN} onPress={() => this.setBadge(null)} />
39
+        <Button label='Hide Tabs' testID={HIDE_TABS_BTN} onPress={() => this.toggleTabs(false)} />
40
+        <Button label='Show Tabs' testID={SHOW_TABS_BTN} onPress={() => this.toggleTabs(true)} />
41
+        <Button label='Hide Tabs on Push' testID={HIDE_TABS_PUSH_BTN} onPress={this.hideTabsOnPush} />
42
+      </Root>
43
+    );
44
+  }
45
+
46
+  switchTabByIndex = () => Navigation.mergeOptions(this, {
47
+    bottomTabs: {
48
+      currentTabIndex: 1
49
+    }
50
+  });
51
+
52
+  switchTabByComponentId = () => Navigation.mergeOptions(this, {
53
+    bottomTabs: {
54
+      currentTabId: 'SecondTab'
55
+    }
56
+  });
57
+
58
+  setBadge = (badge) => Navigation.mergeOptions(this, {
59
+    bottomTab: { badge }
60
+  });
61
+
62
+  toggleTabs = (visible) => Navigation.mergeOptions(this, {
63
+    bottomTabs: { visible }
64
+  });
65
+
66
+  hideTabsOnPush = () => Navigation.push(this, component(Screens.Pushed, {
67
+    bottomTabs: { visible: false }
68
+  }));
69
+}
70
+
71
+module.exports = FirstBottomTabScreen;

+ 588
- 0
playground/src/screens/LayoutsScreen.js View File

@@ -0,0 +1,588 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const {
5
+  WELCOME_SCREEN_HEADER,
6
+  STACK_BTN,
7
+  BOTTOM_TABS_BTN,
8
+  BOTTOM_TABS,
9
+  SIDE_MENU_BTN
10
+} = require('../testIDs');
11
+const Screens = require('./Screens');
12
+const Navigation = require('../services/Navigation');
13
+const {stack, component} = require('../commons/Layouts');
14
+
15
+class LayoutsScreen extends React.Component {
16
+  static options() {
17
+    return {
18
+      topBar: {
19
+        testID: WELCOME_SCREEN_HEADER,
20
+        title: {
21
+          text: 'React Native Navigation'
22
+        }
23
+      }
24
+    };
25
+  }
26
+
27
+  render() {
28
+    return (
29
+      <Root componentId={this.props.componentId}>
30
+        <Button label='Stack' testID={STACK_BTN} onPress={this.stack} />
31
+        <Button label='BottomTabs' testID={BOTTOM_TABS_BTN} onPress={this.bottomTabs} />
32
+        <Button label='SideMenu' testID={SIDE_MENU_BTN} onPress={this.sideMenu} />
33
+      </Root>
34
+    );
35
+  }
36
+
37
+  stack = () => Navigation.showModal(Screens.StackScreen);
38
+
39
+  bottomTabs = () => Navigation.showModal({
40
+    bottomTabs: {
41
+      children: [
42
+        stack(Screens.FirstBottomTabsScreen),
43
+        stack({
44
+          component: {
45
+            name: Screens.SecondBottomTabsScreen
46
+          }
47
+        }, 'SecondTab'
48
+        )
49
+      ],
50
+      options: {
51
+        bottomTabs: {
52
+          testID: BOTTOM_TABS
53
+        }
54
+      }
55
+    }
56
+  });
57
+
58
+  sideMenu = () => Navigation.showModal({
59
+    sideMenu: {
60
+      left: {...component(Screens.SideMenuLeft)},
61
+      center: {
62
+        ...stack({
63
+          component: {
64
+            id: 'SideMenuCenter',
65
+            name: Screens.SideMenuCenter
66
+          }
67
+        })
68
+      },
69
+      right: {...component(Screens.SideMenuRight)}
70
+    }
71
+  });
72
+
73
+  onClickSwitchToTabs = () => {
74
+    Navigation.setRoot({
75
+      root: {
76
+        bottomTabs: {
77
+          id: 'BottomTabs',
78
+          children: [
79
+            {
80
+              stack: {
81
+                id: 'TAB1_ID',
82
+                children: [
83
+                  {
84
+                    component: {
85
+                      name: 'navigation.playground.TextScreen',
86
+                      passProps: {
87
+                        text: 'This is tab 1',
88
+                        myFunction: () => 'Hello from a function!'
89
+                      },
90
+                      options: {
91
+                        topBar: {
92
+                          visible: true,
93
+                          animate: false,
94
+                          title: {
95
+                            text: 'React Native Navigation!'
96
+                          }
97
+                        },
98
+                        bottomTab: {
99
+                          text: 'Tab 1',
100
+                          icon: require('../images/colored_tab_icon.png'),
101
+                          testID: testIDs.FIRST_TAB_BAR_BUTTON
102
+                        }
103
+                      }
104
+                    }
105
+                  }
106
+                ],
107
+                options: {
108
+                  topBar: {
109
+                    visible: false
110
+                  }
111
+                }
112
+              }
113
+            },
114
+            {
115
+              stack: {
116
+                children: [
117
+                  {
118
+                    component: {
119
+                      name: 'navigation.playground.TextScreen',
120
+                      passProps: {
121
+                        text: 'This is tab 2'
122
+                      }
123
+                    }
124
+                  }
125
+                ],
126
+                options: {
127
+                  bottomTab: {
128
+                    text: 'Tab 2',
129
+                    icon: require('../images/two.png'),
130
+                    iconColor: '#1B4C77',
131
+                    selectedIconColor: '#0f0',
132
+                    testID: testIDs.SECOND_TAB_BAR_BUTTON
133
+                  }
134
+                }
135
+              }
136
+            },
137
+            {
138
+              component: {
139
+                name: 'navigation.playground.TextScreen',
140
+                passProps: {
141
+                  text: 'This is tab 3',
142
+                  myFunction: () => 'Hello from a function!'
143
+                },
144
+                options: {
145
+                  topBar: {
146
+                    visible: true,
147
+                    animate: false
148
+                  },
149
+                  bottomTab: {
150
+                    text: 'Tab 3',
151
+                    icon: require('../images/one.png'),
152
+                    iconColor: '#1B4C77',
153
+                    selectedIconColor: '#0f0',
154
+                    selectedIcon: require('../images/one.png')
155
+                  }
156
+                }
157
+              }
158
+            }
159
+          ],
160
+          options: {
161
+            bottomTabs: {
162
+              titleDisplayMode: 'alwaysShow',
163
+              testID: testIDs.BOTTOM_TABS_ELEMENT
164
+            }
165
+          }
166
+        }
167
+      }
168
+    });
169
+  }
170
+
171
+  onClickSwitchToSideMenus = () => {
172
+    Navigation.setRoot({
173
+      root: {
174
+        sideMenu: {
175
+          left: {
176
+            component: {
177
+              name: 'navigation.playground.SideMenuScreen',
178
+              passProps: {
179
+                side: 'left'
180
+              }
181
+            }
182
+          },
183
+          center: {
184
+            bottomTabs: {
185
+              children: [
186
+                {
187
+                  stack: {
188
+                    id: 'tab1Stack',
189
+                    children: [
190
+                      {
191
+                        component: {
192
+                          name: 'navigation.playground.TextScreen',
193
+                          passProps: {
194
+                            text: 'This is a side menu center screen tab 1'
195
+                          }
196
+                        }
197
+                      }
198
+                    ],
199
+                    options: {
200
+                      bottomTab: {
201
+                        iconColor: 'red',
202
+                        textColor: 'red',
203
+                        selectedIconColor: 'purple',
204
+                        selectedTextColor: 'purple',
205
+                        text: 'Tab 1',
206
+                        icon: require('../images/one.png'),
207
+                        testID: testIDs.FIRST_TAB_BAR_BUTTON
208
+                      }
209
+                    }
210
+                  }
211
+                },
212
+                {
213
+                  stack: {
214
+                    children: [
215
+                      {
216
+                        component: {
217
+                          name: 'navigation.playground.TextScreen',
218
+                          passProps: {
219
+                            text: 'This is a side menu center screen tab 2'
220
+                          }
221
+                        }
222
+                      }
223
+                    ],
224
+                    options: {
225
+                      bottomTab: {
226
+                        text: 'Tab 2',
227
+                        icon: require('../images/two.png'),
228
+                        testID: testIDs.SECOND_TAB_BAR_BUTTON
229
+                      }
230
+                    }
231
+                  }
232
+                },
233
+                {
234
+                  stack: {
235
+                    children: [
236
+                      {
237
+                        component: {
238
+                          name: 'navigation.playground.TextScreen',
239
+                          passProps: {
240
+                            text: 'This is a side menu center screen tab 3'
241
+                          }
242
+                        }
243
+                      }
244
+                    ],
245
+                    options: {
246
+                      bottomTab: {
247
+                        text: 'Tab 3',
248
+                        icon: require('../images/three.png'),
249
+                        testID: testIDs.SECOND_TAB_BAR_BUTTON
250
+                      }
251
+                    }
252
+                  }
253
+                }
254
+              ],
255
+              options: {
256
+                bottomTab: {
257
+                  textColor: '#AED581',
258
+                  iconColor: '#AED581',
259
+                  selectedTextColor: '#90CAF9',
260
+                  selectedIconColor: '#90CAF9',
261
+                  fontFamily: 'HelveticaNeue-Italic',
262
+                  fontSize: 13
263
+                }
264
+              }
265
+            }
266
+          },
267
+          right: {
268
+            component: {
269
+              name: 'navigation.playground.SideMenuScreen',
270
+              passProps: {
271
+                side: 'right'
272
+              }
273
+            }
274
+          }
275
+        }
276
+      }
277
+    });
278
+  }
279
+
280
+  onClickPush = async () => {
281
+    await Navigation.push(this.props.componentId, {
282
+      component: {
283
+        name: 'navigation.playground.PushedScreen',
284
+        options: {
285
+          layout: {
286
+
287
+          },
288
+          topBar: {
289
+            title: {
290
+              text: 'pushed',
291
+              color: '#0000ff',
292
+              fontSize: 14
293
+            },
294
+            subtitle: {
295
+              text: 'subtitle',
296
+              fontSize: 10,
297
+              color: '#00ff00'
298
+            }
299
+          }
300
+        }
301
+      }
302
+    });
303
+  }
304
+
305
+  onClickPushContextScreen = async () => {
306
+    await Navigation.push(this.props.componentId, {
307
+      component: {
308
+        name: 'navigation.playground.ContextScreen',
309
+      }
310
+    })
311
+  }
312
+
313
+  onClickPushExternalComponent = async () => {
314
+    await Navigation.push(this.props.componentId, {
315
+      externalComponent: {
316
+        name: 'RNNCustomComponent',
317
+        passProps: {
318
+          text: 'This is an external component'
319
+        },
320
+        options: {
321
+          topBar: {
322
+            title: {
323
+              text: 'pushed'
324
+            },
325
+            visible: true,
326
+            testID: testIDs.TOP_BAR_ELEMENT
327
+          }
328
+        }
329
+      }
330
+    });
331
+  }
332
+
333
+  onClickLifecycleScreen = () => {
334
+    Navigation.push(this.props.componentId, {
335
+      component: {
336
+        name: 'navigation.playground.LifecycleScreen'
337
+      }
338
+    });
339
+  }
340
+
341
+  onClickShowStaticLifecycleOverlay = () => {
342
+    Navigation.showOverlay({
343
+      component: {
344
+        name: 'navigation.playground.StaticLifecycleOverlay',
345
+        options: {
346
+          overlay: {
347
+            interceptTouchOutside: false
348
+          }
349
+        }
350
+      }
351
+    });
352
+  }
353
+
354
+  onClickShowModal = async () => {
355
+    await Navigation.showModal({
356
+      stack: {
357
+        children: [
358
+          {
359
+            component: {
360
+              name: 'navigation.playground.ModalScreen'
361
+            }
362
+          }
363
+        ]
364
+      }
365
+    });
366
+  }
367
+
368
+  onClickShowRedbox = () => {
369
+    undefined();
370
+  }
371
+
372
+  onClickShowPreview = async ({reactTag}) => {
373
+    await Navigation.push(this.props.componentId, {
374
+      component: {
375
+        name: 'navigation.playground.PushedScreen',
376
+        options: {
377
+          animations: {
378
+            push: {
379
+              enabled: false
380
+            }
381
+          },
382
+          preview: reactTag ? {
383
+            reactTag,
384
+            height: 300,
385
+            commit: true,
386
+            actions: [{
387
+              id: 'action-cancel',
388
+              title: 'Cancel'
389
+            }, {
390
+              id: 'action-delete',
391
+              title: 'Delete',
392
+              actions: [{
393
+                id: 'action-delete-sure',
394
+                title: 'Are you sure?',
395
+                style: 'destructive'
396
+              }]
397
+            }]
398
+          } : undefined,
399
+        }
400
+      }
401
+    });
402
+  }
403
+
404
+  onClickPushOptionsScreen = () => {
405
+    Navigation.push(this.props.componentId, {
406
+      component: {
407
+        name: 'navigation.playground.OptionsScreen',
408
+        options: {
409
+          animations: {
410
+            push: {
411
+              enabled: false
412
+            }
413
+          }
414
+        }
415
+      }
416
+    });
417
+  }
418
+
419
+  onClickPushTopTabsScreen = () => {
420
+    Navigation.push(this.props.componentId, {
421
+      topTabs: {
422
+        children: [
423
+          {
424
+            component: {
425
+              name: 'navigation.playground.TopTabOptionsScreen',
426
+              passProps: {
427
+                title: 'Tab 1',
428
+                text: 'This is top tab 1'
429
+              },
430
+              options: {
431
+                topTab: {
432
+                  title: 'Tab 1'
433
+                },
434
+                topBar: {
435
+                  title: {
436
+                    text: 'One'
437
+                  }
438
+                }
439
+              }
440
+            }
441
+          },
442
+          {
443
+            component: {
444
+              name: 'navigation.playground.TopTabScreen',
445
+              passProps: {
446
+                title: 'Tab 2',
447
+                text: 'This is top tab 2'
448
+              },
449
+              options: {
450
+                topTab: {
451
+                  title: 'Tab 2',
452
+                  titleFontFamily: 'HelveticaNeue-Italic'
453
+                },
454
+                topBar: {
455
+                  title: {
456
+                    text: 'Two'
457
+                  }
458
+                }
459
+              }
460
+            }
461
+          },
462
+          {
463
+            component: {
464
+              name: 'navigation.playground.TopTabScreen',
465
+              passProps: {
466
+                title: 'Tab 3',
467
+                text: 'This is top tab 3'
468
+              },
469
+              options: {
470
+                topTab: {
471
+                  title: 'Tab 3'
472
+                },
473
+                topBar: {
474
+                  title: {
475
+                    text: 'Three'
476
+                  }
477
+                }
478
+              }
479
+            }
480
+          }
481
+        ],
482
+        options: {
483
+          topTabs: {
484
+            selectedTabColor: '#12766b',
485
+            unselectedTabColor: 'red',
486
+            fontSize: 6
487
+          }
488
+        }
489
+      }
490
+    });
491
+  }
492
+
493
+  onClickBackHandler = () => {
494
+    Navigation.push(this.props.componentId, {
495
+      component: {
496
+        name: 'navigation.playground.BackHandlerScreen'
497
+      }
498
+    });
499
+  }
500
+
501
+  onClickPushOrientationMenuScreen = () => {
502
+    Navigation.push(this.props.componentId, {
503
+      component: {
504
+        name: 'navigation.playground.OrientationSelectScreen'
505
+      }
506
+    });
507
+  }
508
+
509
+  onClickProvidedId = () => {
510
+    Navigation.showModal({
511
+      stack: {
512
+        children: [
513
+          {
514
+            component: {
515
+              name: 'navigation.playground.TextScreen',
516
+              id: 'my unique id'
517
+            }
518
+          }
519
+        ]
520
+      }
521
+    });
522
+    Navigation.mergeOptions('my unique id', {
523
+      topBar: {
524
+        title: {
525
+          text: 'User provided id'
526
+        }
527
+      }
528
+    });
529
+  }
530
+
531
+  onClickComplexLayout = () => {
532
+    Navigation.showModal({
533
+      component: {
534
+        name: 'navigation.playground.ComplexLayout'
535
+      }
536
+    });
537
+  }
538
+
539
+  onClickSplitView = () => {
540
+    Navigation.setRoot({
541
+      root: {
542
+        splitView: {
543
+          id: 'SPLITVIEW_ID',
544
+          master: {
545
+            stack: {
546
+              id: 'MASTER_ID',
547
+              children: [
548
+                {
549
+                  component: {
550
+                    name: 'navigation.playground.WelcomeScreen'
551
+                  },
552
+                },
553
+              ]
554
+            },
555
+          },
556
+          detail: {
557
+            stack: {
558
+              id: 'DETAILS_ID',
559
+              children: [
560
+                {
561
+                  component: {
562
+                    name: 'navigation.playground.WelcomeScreen'
563
+                  },
564
+                },
565
+              ]
566
+            }
567
+          },
568
+          options: {
569
+            displayMode: 'auto',
570
+            primaryEdge: 'leading',
571
+            minWidth: 150,
572
+            maxWidth: 300,
573
+          },
574
+        },
575
+      },
576
+    });
577
+  }
578
+
579
+  onClickSearchBar = () => {
580
+    Navigation.push(this.props.componentId, {
581
+      component: {
582
+        name: 'navigation.playground.SearchControllerScreen'
583
+      }
584
+    });
585
+  };
586
+}
587
+
588
+module.exports = LayoutsScreen;

+ 33
- 50
playground/src/screens/LifecycleScreen.js View File

@@ -1,19 +1,31 @@
1 1
 const React = require('react');
2
-const { Component } = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button');
4
+const Navigation = require('../services/Navigation');
5
+const Screens = require('./Screens');
6
+const {
7
+  PUSH_TO_TEST_DID_DISAPPEAR_BTN,
8
+  DISMISS_MODAL_BTN,
9
+  POP_BTN
10
+} = require('../testIDs');
3 11
 
4
-const { View, Text, Button } = require('react-native');
5
-
6
-const { Navigation } = require('react-native-navigation');
7
-const testIDs = require('../testIDs');
12
+class LifecycleScreen extends React.Component {
13
+  static options() {
14
+    return {
15
+      topBar: {
16
+        title: {
17
+          text: 'Lifecycle Screen'
18
+        }
19
+      }
20
+    }
21
+  }
22
+  state = {
23
+    text: 'nothing yet'
24
+  };
8 25
 
9
-class LifecycleScreen extends Component {
10 26
   constructor(props) {
11 27
     super(props);
12
-    this.onClickPush = this.onClickPush.bind(this);
13
-    this.state = {
14
-      text: 'nothing yet'
15
-    };
16
-    this.subscription = Navigation.events().bindComponent(this);
28
+    Navigation.events().bindComponent(this);
17 29
   }
18 30
 
19 31
   componentDidAppear() {
@@ -25,7 +37,6 @@ class LifecycleScreen extends Component {
25 37
   }
26 38
 
27 39
   componentWillUnmount() {
28
-    this.subscription.remove();
29 40
     alert('componentWillUnmount'); // eslint-disable-line no-alert
30 41
   }
31 42
 
@@ -35,47 +46,19 @@ class LifecycleScreen extends Component {
35 46
 
36 47
   render() {
37 48
     return (
38
-      <View style={styles.root}>
39
-        <Text style={styles.h1}>{`Lifecycle Screen`}</Text>
40
-        <Text style={styles.h1}>{this.state.text}</Text>
41
-        <Button title='Push to test didDisappear' testID={testIDs.PUSH_TO_TEST_DID_DISAPPEAR_BUTTON} onPress={this.onClickPush} />
42
-        {this.props.isModal ?
43
-          (<Button title='Dismiss' testID={testIDs.DISMISS_MODAL_BUTTON} onPress={() => this.onClickDismiss()} />)
44
-          : (<Button title='Pop' testID={testIDs.POP_BUTTON} onPress={() => this.onClickPop()} />)}
45
-        <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
46
-      </View>
49
+      <Root componentId={this.props.componentId} footer={this.state.text}>
50
+        <Button label='Push to test didDisappear' testID={PUSH_TO_TEST_DID_DISAPPEAR_BTN} onPress={this.push} />
51
+        {this.renderCloseButton()}
52
+      </Root>
47 53
     );
48 54
   }
49 55
 
50
-  onClickPush() {
51
-    Navigation.push(this.props.componentId, { component: { name: 'navigation.playground.TextScreen' } });
52
-  }
53
-
54
-  onClickPop() {
55
-    Navigation.pop(this.props.componentId);
56
-  }
56
+  renderCloseButton = () => this.props.isModal ?
57
+        <Button label='Dismiss' testID={DISMISS_MODAL_BTN} onPress={this.dismiss} /> :
58
+        <Button label='Pop' testID={POP_BTN} onPress={this.pop} />;
57 59
 
58
-  onClickDismiss() {
59
-    Navigation.dismissModal(this.props.componentId);
60
-  }
60
+  push = () => Navigation.push(this, Screens.Pushed);
61
+  pop = () => Navigation.pop(this);
62
+  dismiss = () => Navigation.dismissModal(this);
61 63
 }
62 64
 module.exports = LifecycleScreen;
63
-
64
-const styles = {
65
-  root: {
66
-    flexGrow: 1,
67
-    justifyContent: 'center',
68
-    alignItems: 'center',
69
-    backgroundColor: '#f5fcff'
70
-  },
71
-  h1: {
72
-    fontSize: 24,
73
-    textAlign: 'center',
74
-    margin: 10
75
-  },
76
-  footer: {
77
-    fontSize: 10,
78
-    color: '#888',
79
-    marginTop: 10
80
-  }
81
-};

+ 50
- 156
playground/src/screens/ModalScreen.js View File

@@ -1,14 +1,23 @@
1 1
 const _ = require('lodash');
2
-
3 2
 const React = require('react');
4
-const { Component } = require('react');
5
-
6
-const { View, Text, Button } = require('react-native');
7
-
8
-const { Navigation } = require('react-native-navigation');
9
-const testIDs = require('../testIDs');
10
-
11
-class ModalScreen extends Component {
3
+const Root = require('../components/Root');
4
+const Button = require('../components/Button')
5
+const Navigation = require('./../services/Navigation');
6
+const Screens = require('./Screens');
7
+const {
8
+  PUSH_BTN,
9
+  MODAL_SCREEN_HEADER,
10
+  MODAL_BTN,
11
+  DISMISS_MODAL_BTN,
12
+  DISMISS_UNKNOWN_MODAL_BTN,
13
+  MODAL_LIFECYCLE_BTN,
14
+  DISMISS_PREVIOUS_MODAL_BTN,
15
+  DISMISS_ALL_PREVIOUS_MODAL_BTN,
16
+  DISMISS_ALL_MODALS_BTN,
17
+  DISMISS_FIRST_MODAL_BTN,
18
+} = require('../testIDs');
19
+
20
+class ModalScreen extends React.Component {
12 21
   static options() {
13 22
     return {
14 23
       statusBar: {
@@ -16,181 +25,66 @@ class ModalScreen extends Component {
16 25
         drawBehind: true,
17 26
         backgroundColor: 'transparent'
18 27
       },
19
-      layout: {
20
-        orientation: ['portrait'],
21
-        backgroundColor: '#f5fcff'
22
-      },
23
-      _animations: {
24
-        showModal: {
25
-          waitForRender: true
28
+      topBar: {
29
+        testID: MODAL_SCREEN_HEADER,
30
+        title: {
31
+          text: 'Modal'
26 32
         }
27 33
       }
28 34
     };
29 35
   }
30 36
 
31
-  constructor(props) {
32
-    super(props);
33
-    // this.simulateLongRunningTask();
34
-    this.onClickShowModal = this.onClickShowModal.bind(this);
35
-    this.onClickDismissModal = this.onClickDismissModal.bind(this);
36
-    this.onClickDismissPreviousModal = this.onClickDismissPreviousModal.bind(this);
37
-    this.onClickDismissUnknownModal = this.onClickDismissUnknownModal.bind(this);
38
-    this.onClickDismissAllPreviousModals = this.onClickDismissAllPreviousModals.bind(this);
39
-    this.onClickDismissFirstInStack = this.onClickDismissFirstInStack.bind(this);
40
-    this.onClickDismissAllModals = this.onClickDismissAllModals.bind(this);
41
-    this.onClickPushScreen = this.onClickPushScreen.bind(this);
42
-    this.onShowModalWithDeepStack = this.onShowModalWithDeepStack.bind(this);
43
-    this.onClickModalLifecycle = this.onClickModalLifecycle.bind(this);
44
-  }
45
-
46
-  simulateLongRunningTask = () => {
47
-    // tslint:disable-next-line
48
-    for (let i = 0; i < Math.pow(2, 25); i++);
49
-  }
50
-
51 37
   render() {
52 38
     return (
53
-      <View style={styles.root}>
54
-        <Text style={styles.h1} testID={testIDs.MODAL_SCREEN}>{`Modal Screen`}</Text>
55
-        <Text style={styles.footer}>{`Modal Stack Position: ${this.getModalPosition()}`}</Text>
56
-        <Button title='Show Modal' testID={testIDs.SHOW_MODAL_BUTTON} onPress={this.onClickShowModal} />
57
-        <Button title='Dismiss Modal' testID={testIDs.DISMISS_MODAL_BUTTON} onPress={this.onClickDismissModal} />
58
-        <Button title='Dismiss Unknown Modal' testID={testIDs.DISMISS_UNKNOWN_MODAL_BUTTON} onPress={this.onClickDismissUnknownModal} />
59
-        <Button title='Dismiss All Modals' testID={testIDs.DISMISS_ALL_MODALS_BUTTON} onPress={this.onClickDismissAllModals} />
60
-        <Button title='Test Modal Lifecycle' testID={testIDs.MODAL_LIFECYCLE_BUTTON} onPress={this.onClickModalLifecycle} />
61
-        <Button title='Push screen' testID={testIDs.PUSH_BUTTON} onPress={this.onClickPushScreen} />
62
-        <Button title='Show Modal With Stack' testID={testIDs.MODAL_WITH_STACK_BUTTON} onPress={this.onShowModalWithDeepStack} />
63
-        {this.getPreviousModalId() ? (<Button title='Dismiss Previous Modal' testID={testIDs.DISMISS_PREVIOUS_MODAL_BUTTON}
64
-          onPress={this.onClickDismissPreviousModal} />) : undefined}
65
-        {this.props.previousModalIds ? (<Button title='Dismiss ALL Previous Modals' testID={testIDs.DISMISS_ALL_PREVIOUS_MODAL_BUTTON}
66
-          onPress={this.onClickDismissAllPreviousModals} />) : undefined}
67
-        {this.props.previousModalIds ? (<Button title='Dismiss First In Stack' testID={testIDs.DISMISS_FIRST_MODAL_BUTTON}
68
-          onPress={this.onClickDismissFirstInStack} />) : undefined}
69
-        <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
70
-      </View>
39
+      <Root componentId={this.props.componentId} footer={`Modal Stack Position: ${this.getModalPosition()}`}>
40
+        <Button label='Show Modal' testID={MODAL_BTN} onPress={this.showModal} />
41
+        <Button label='Dismiss Modal' testID={DISMISS_MODAL_BTN} onPress={this.dismissModal} />
42
+        <Button label='Dismiss Unknown Modal' testID={DISMISS_UNKNOWN_MODAL_BTN} onPress={this.dismissUnknownModal} />
43
+        <Button label='Modal Lifecycle' testID={MODAL_LIFECYCLE_BTN} onPress={this.modalLifecycle} />
44
+        {this.getPreviousModalId() && (<Button label='Dismiss Previous Modal' testID={DISMISS_PREVIOUS_MODAL_BTN} onPress={this.dismissPreviousModal} />)}
45
+        {this.props.previousModalIds && (<Button label='Dismiss All Previous Modals' testID={DISMISS_ALL_PREVIOUS_MODAL_BTN} onPress={this.dismissAllPreviousModals} />)}
46
+        <Button label='Dismiss All Modals' testID={DISMISS_ALL_MODALS_BTN} onPress={this.dismissAllModals} />
47
+        {this.props.previousModalIds && (<Button label='Dismiss First Modal' testID={DISMISS_FIRST_MODAL_BTN} onPress={this.dismissFirstModal} />)}
48
+        <Button label='Push screen' testID={PUSH_BTN} onPress={this.pushScreen} />
49
+      </Root>
71 50
     );
72 51
   }
73 52
 
74
-  onClickShowModal() {
53
+  showModal = () => {
75 54
     Navigation.showModal({
76 55
       component: {
77
-        name: 'navigation.playground.ModalScreen',
56
+        name: Screens.Modal,
78 57
         passProps: {
79 58
           modalPosition: this.getModalPosition() + 1,
80 59
           previousModalIds: _.concat([], this.props.previousModalIds || [], this.props.componentId)
81
-        },
82
-        options: {
83
-          animated: false
84 60
         }
85 61
       }
86 62
     });
87 63
   }
88 64
 
89
-  async onClickDismissModal() {
90
-    await Navigation.dismissModal(this.props.componentId);
91
-  }
65
+  dismissModal = async () => await Navigation.dismissModal(this.props.componentId);
92 66
 
93
-  onClickDismissPreviousModal() {
94
-    Navigation.dismissModal(this.getPreviousModalId());
95
-  }
67
+  dismissPreviousModal = () => Navigation.dismissModal(this.getPreviousModalId());
96 68
 
97
-  onClickDismissUnknownModal() {
98
-    Navigation.dismissModal('unknown');
99
-  }
69
+  dismissUnknownModal = () => Navigation.dismissModal('unknown');
100 70
 
101
-  onClickDismissAllPreviousModals() {
102
-    _.forEach(this.props.previousModalIds, (id) => Navigation.dismissModal(id));
103
-  }
71
+  dismissAllPreviousModals = () => _.forEach(this.props.previousModalIds, (id) => Navigation.dismissModal(id));
104 72
 
105
-  onClickDismissFirstInStack() {
106
-    Navigation.dismissModal(_.head(this.props.previousModalIds));
107
-  }
73
+  dismissFirstModal = () => Navigation.dismissModal(_.head(this.props.previousModalIds));
108 74
 
109
-  onClickDismissAllModals() {
110
-    Navigation.dismissAllModals();
111
-  }
112
-
113
-  onClickModalLifecycle() {
114
-    Navigation.showModal({
115
-      component: {
116
-        name: 'navigation.playground.LifecycleScreen',
117
-        passProps: {
118
-          isModal: true,
119
-        },
120
-        options: {
121
-          animated: false
122
-        }
123
-      }
124
-    });
125
-  }
75
+  dismissAllModals = () => Navigation.dismissAllModals();
126 76
 
127
-  onClickPushScreen() {
128
-    Navigation.push(this.props.componentId, {
129
-      component: {
130
-        name: `navigation.playground.PushedScreen`,
131
-        passProps: {
132
-          text: 'Pushed from modal'
133
-        }
134
-      }
135
-    });
136
-  }
77
+  modalLifecycle = () => Navigation.showModal({
78
+    component: {
79
+      name: Screens.Lifecycle,
80
+      passProps: { isModal: true }
81
+    }
82
+  });
137 83
 
138
-  onShowModalWithDeepStack() {
139
-    Navigation.showModal({
140
-      stack: {
141
-        children: [
142
-          {
143
-            component: {
144
-              name: `navigation.playground.TextScreen`,
145
-              passProps: {
146
-                text: 'Screen 1'
147
-              }
148
-            }
149
-          },
150
-          {
151
-            component: {
152
-              name: `navigation.playground.TextScreen`,
153
-              passProps: {
154
-                text: 'Screen 2'
155
-              }
156
-            }
157
-          }
158
-        ]
159
-      }
160
-    });
161
-  }
84
+  pushScreen = () => Navigation.push(this, Screens.Pushed);
162 85
 
163
-  getModalPosition() {
164
-    return (this.props.modalPosition || 1);
165
-  }
86
+  getModalPosition = () => this.props.modalPosition || 1;
166 87
 
167
-  getPreviousModalId() {
168
-    return _.last(this.props.previousModalIds);
169
-  }
88
+  getPreviousModalId = () => _.last(this.props.previousModalIds);
170 89
 }
171
-
172
-const styles = {
173
-  root: {
174
-    flexGrow: 1,
175
-    justifyContent: 'center',
176
-    alignItems: 'center',
177
-    backgroundColor: '#f5fcff'
178
-  },
179
-  h1: {
180
-    fontSize: 24,
181
-    textAlign: 'center',
182
-    margin: 10
183
-  },
184
-  h2: {
185
-    fontSize: 12,
186
-    textAlign: 'center',
187
-    margin: 10
188
-  },
189
-  footer: {
190
-    fontSize: 10,
191
-    color: '#888',
192
-    marginTop: 10
193
-  }
194
-};
195
-
196 90
 module.exports = ModalScreen;

+ 50
- 0
playground/src/screens/NavigationScreen.js View File

@@ -0,0 +1,50 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const Navigation = require('./../services/Navigation');
5
+const {
6
+  NAVIGATION_TAB,
7
+  MODAL_BTN,
8
+  OVERLAY_BTN,
9
+  EXTERNAL_COMP_BTN,
10
+  SHOW_STATIC_EVENTS_SCREEN,
11
+  SHOW_ORIENTATION_SCREEN
12
+} = require('../testIDs');
13
+const Screens = require('./Screens');
14
+
15
+class NavigationScreen extends React.Component {
16
+  static options() {
17
+    return {
18
+      topBar: {
19
+        title: {
20
+          text: 'Navigation'
21
+        }
22
+      },
23
+      bottomTab: {
24
+        text: 'Navigation',
25
+        icon: require('../../img/navigation.png'),
26
+        testID: NAVIGATION_TAB
27
+      }
28
+    };
29
+  }
30
+
31
+  render() {
32
+    return (
33
+      <Root componentId={this.props.componentId}>
34
+        <Button label='Modal' testID={MODAL_BTN} onPress={this.showModal} />
35
+        <Button label='Overlay' testID={OVERLAY_BTN} onPress={this.showOverlay} />
36
+        <Button label='External Component' testID={EXTERNAL_COMP_BTN} onPress={this.externalComponent} />
37
+        <Button label='Static Events' testID={SHOW_STATIC_EVENTS_SCREEN} onPress={this.pushStaticEventsScreen} />
38
+        <Button label='Orientation' testID={SHOW_ORIENTATION_SCREEN} onPress={this.orientation} />
39
+      </Root>
40
+    );
41
+  }
42
+
43
+  showModal = () => Navigation.showModal(Screens.Modal);
44
+  showOverlay = () => Navigation.showModal(Screens.Overlay);
45
+  externalComponent = () => Navigation.showModal(Screens.ExternalComponent);
46
+  pushStaticEventsScreen = () => Navigation.showModal(Screens.EventsScreen)
47
+  orientation = () => Navigation.showModal(Screens.Orientation);
48
+}
49
+
50
+module.exports = NavigationScreen;

+ 566
- 236
playground/src/screens/OptionsScreen.js View File

@@ -1,118 +1,57 @@
1 1
 const React = require('react');
2 2
 const { Component } = require('react');
3
+const Root = require('../components/Root');
4
+const Button = require('../components/Button')
5
+const Navigation = require('../services/Navigation');
6
+const Screens = require('./Screens');
7
+const Colors = require('../commons/Colors');
8
+const {
9
+  CHANGE_TITLE_BTN,
10
+  HIDE_TOP_BAR_BTN,
11
+  SHOW_TOP_BAR_BTN,
12
+  TOP_BAR,
13
+  ROUND_BUTTON,
14
+  BUTTON_ONE,
15
+  LEFT_BUTTON,
16
+  PUSH_BTN,
17
+  HIDE_TOPBAR_DEFAULT_OPTIONS,
18
+  SHOW_YELLOW_BOX_BTN,
19
+  SET_REACT_TITLE_VIEW
20
+} = require('../testIDs');
3 21
 
4
-const { View, Text, Button, Platform, StatusBar } = require('react-native');
5
-
6
-const { Navigation } = require('react-native-navigation');
7
-const testIDs = require('../testIDs');
8
-
9
-const BUTTON_ONE = 'buttonOne';
10
-const BUTTON_TWO = 'buttonTwo';
11
-const CUSTOM_BUTTON = 'customButton';
12
-const CUSTOM_BUTTON2 = 'customButton2';
13
-const BUTTON_LEFT = 'buttonLeft';
14
-const FAB = 'fab';
15
-const TOPBAR_HEIGHT = 67;
16
-
17
-class OptionsScreen extends Component {
18
-  constructor(props) {
19
-    super(props);
20
-    Navigation.events().bindComponent(this);
21
-  }
22
-
22
+class Options extends Component {
23 23
   static options() {
24 24
     return {
25
-      statusBar: {
26
-        style: 'dark',
27
-        backgroundColor: '#EDEDED'
28
-      },
29 25
       topBar: {
26
+        visible: true,
27
+        testID: TOP_BAR,
30 28
         title: {
31
-          text: 'Static Title',
32
-          _height: TOPBAR_HEIGHT,
33
-          color: 'black',
34
-          fontSize: 16,
35
-          alignment: 'center',
36
-          fontFamily: 'HelveticaNeue-Italic'
37
-        },
38
-        largeTitle: {
39
-          visible: false
40
-        },
41
-        subtitle: {
42
-          text: 'Static Subtitle',
43
-          color: 'red',
44
-          fontFamily: 'HelveticaNeue-Italic',
45
-          alignment: 'center'
46
-        },
47
-        background: {
48
-          component: {
49
-            name: 'TopBarBackground',
50
-            passProps: {
51
-              color: '#bbdefb'
52
-            }
53
-          }
29
+          text: 'Styling Options'
54 30
         },
55
-        ...Platform.select({
56
-          android: { drawBehind: true },
57
-          ios: { drawBehind: false, }
58
-        }),
59
-        _height: TOPBAR_HEIGHT,
60
-        visible: true,
61
-        testID: testIDs.TOP_BAR_ELEMENT,
62
-        borderColor: 'red',
63
-        borderHeight: 1,
64 31
         rightButtons: [
65
-          // {
66
-          //   id: CUSTOM_BUTTON,
67
-          //   testID: CUSTOM_BUTTON,
68
-          //   component: 'CustomTextButton'
69
-          // },
70 32
           {
71
-            id: CUSTOM_BUTTON2,
72
-            testID: CUSTOM_BUTTON2,
33
+            id: 'ONE',
34
+            testID: BUTTON_ONE,
35
+            text: 'One',
36
+            color: Colors.primary
37
+          },
38
+          {
39
+            id: 'ROUND',
40
+            testID: ROUND_BUTTON,
73 41
             component: {
74
-              name: 'CustomRoundedButton',
42
+              name: Screens.RoundButton,
75 43
               passProps: {
76 44
                 title: 'Two'
77 45
               }
78 46
             }
79
-          },
80
-          {
81
-            id: BUTTON_ONE,
82
-            testID: BUTTON_ONE,
83
-            text: 'One',
84
-            fontFamily: 'HelveticaNeue-Italic',
85
-            fontSize: 28,
86
-            color: 'red'
87 47
           }
88 48
         ],
89
-        leftButtons: {
90
-          id: BUTTON_LEFT,
91
-          testID: BUTTON_LEFT,
92
-          icon: require('../../img/navicon_add.png'),
93
-          text: 'Left',
94
-          color: 'purple'
95
-        }
96
-      },
97
-      fab: {
98
-        id: FAB,
99
-        backgroundColor: 'orange',
100
-        clickColor: 'orange',
101
-        rippleColor: 'red',
102
-        alignHorizontally: 'left',
103
-        actions: [
104
-          {
105
-            id: 'fab1',
106
-            backgroundColor: 'blue',
107
-            clickColor: 'blue',
108
-            rippleColor: 'aquamarine',
109
-          },
49
+        leftButtons: [
110 50
           {
111
-            id: 'fab2',
112
-            backgroundColor: 'blueviolet',
113
-            clickColor: 'blueviolet',
114
-            size: 'mini',
115
-            rippleColor: 'aquamarine',
51
+            id: 'LEFT',
52
+            testID: LEFT_BUTTON,
53
+            icon: require('../../img/clear.png'),
54
+            color: Colors.primary
116 55
           }
117 56
         ]
118 57
       }
@@ -121,228 +60,621 @@ class OptionsScreen extends Component {
121 60
 
122 61
   render() {
123 62
     return (
124
-      <View style={styles.root}>
125
-        <View style={{ width: 2, height: 2, backgroundColor: 'red', alignSelf: 'center' }} />
126
-        <Text style={styles.h1} testID={testIDs.OPTIONS_SCREEN_HEADER}>{`Options Screen`}</Text>
127
-        <Button title='Dynamic Options' testID={testIDs.DYNAMIC_OPTIONS_BUTTON} onPress={this.onClickDynamicOptions} />
128
-        <Button title='Show Top Bar' testID={testIDs.SHOW_TOP_BAR_BUTTON} onPress={this.onClickShowTopBar} />
129
-        <Button title='Hide Top Bar' testID={testIDs.HIDE_TOP_BAR_BUTTON} onPress={this.onClickHideTopBar} />
130
-        <Button title='Top Bar Transparent' onPress={this.onClickTopBarTransparent} />
131
-        <Button title='Top Bar Opaque' onPress={this.onClickTopBarOpaque} />
132
-        <Button title='scrollView Screen' testID={testIDs.SCROLLVIEW_SCREEN_BUTTON} onPress={this.onClickScrollViewScreen} />
133
-        <Button title='Custom Transition' testID={testIDs.CUSTOM_TRANSITION_BUTTON} onPress={this.onClickCustomTransition} />
134
-        {Platform.OS === 'android' && <Button title='Hide fab' testID={testIDs.HIDE_FAB} onPress={this.onClickFab} />}
135
-        <Button title='Show overlay' testID={testIDs.SHOW_OVERLAY_BUTTON} onPress={() => this.onClickShowOverlay(true)} />
136
-        <Button title='Show touch through overlay' testID={testIDs.SHOW_TOUCH_THROUGH_OVERLAY_BUTTON} onPress={() => this.onClickShowOverlay(false)} />
137
-        <Button title='Push Default Options Screen' testID={testIDs.PUSH_DEFAULT_OPTIONS_BUTTON} onPress={this.onClickPushDefaultOptionsScreen} />
138
-        <Button title='Show TopBar react view' testID={testIDs.SHOW_TOPBAR_REACT_VIEW} onPress={this.onShowTopBarReactView} />
139
-        {Platform.OS === 'android' && <Button title='Push' testID={testIDs.PUSH_BUTTON} onPress={this.onPush} />}
140
-        <Button title='Show Yellow Box' testID={testIDs.SHOW_YELLOW_BOX} onPress={() => console.warn('Yellow Box')} />
141
-        <Text style={styles.footer}>{`this.props.containerId = ${this.props.containerId}`}</Text>
142
-      </View>
63
+      <Root componentId={this.props.componentId}>
64
+        <Button label='Change title' testID={CHANGE_TITLE_BTN} onPress={this.changeTitle} />
65
+        <Button label='Hide TopBar' testID={HIDE_TOP_BAR_BTN} onPress={this.hideTopBar} />
66
+        <Button label='Show TopBar' testID={SHOW_TOP_BAR_BTN} onPress={this.showTopBar} />
67
+        <Button label='Push' testID={PUSH_BTN} onPress={this.push} />
68
+        <Button label='Hide TopBar in DefaultOptions' testID={HIDE_TOPBAR_DEFAULT_OPTIONS} onPress={this.hideTopBarInDefaultOptions} />
69
+        <Button label='Set React Title View' testID={SET_REACT_TITLE_VIEW} onPress={this.setReactTitleView} />
70
+        <Button label='Show Yellow Box' testID={SHOW_YELLOW_BOX_BTN} onPress={() => console.warn('Yellow Box')} />
71
+      </Root>
143 72
     );
144 73
   }
145 74
 
146
-  navigationButtonPressed({buttonId}) {
147
-    if (buttonId === BUTTON_ONE) {
148
-      Navigation.mergeOptions(this.props.componentId, {
149
-        topBar: {
150
-          rightButtons: [{
151
-            id: BUTTON_TWO,
152
-            testID: BUTTON_TWO,
153
-            text: 'Two',
154
-            icon: require('../../img/navicon_add.png'),
155
-            disableIconTint: true,
156
-            showAsAction: 'ifRoom',
157
-            color: 'green',
158
-            fontSize: 28,
159
-            fontWeight: '800'
160
-          }],
161
-          leftButtons: []
75
+  changeTitle = () => Navigation.mergeOptions(this, {
76
+    topBar: {
77
+      title: {
78
+        text: 'Title Changed'
79
+      }
80
+    }
81
+  });
82
+
83
+  hideTopBar = () => Navigation.mergeOptions(this, {
84
+    topBar: {
85
+      visible: false
86
+    }
87
+  });
88
+
89
+  showTopBar = () => Navigation.mergeOptions(this, {
90
+    topBar: {
91
+      visible: true
92
+    }
93
+  });
94
+
95
+  push = () => Navigation.push(this, Screens.Pushed);
96
+
97
+  hideTopBarInDefaultOptions = () => {
98
+    Navigation.setDefaultOptions({
99
+      topBar: {
100
+        visible: false,
101
+        title: {
102
+          text: 'Default Title'
162 103
         }
163
-      });
164
-    } else if (buttonId === BUTTON_TWO) {
165
-      Navigation.mergeOptions(this.props.componentId, {
166
-        topBar: {
167
-          rightButtons: [{
168
-            id: BUTTON_ONE,
169
-            testID: BUTTON_ONE,
170
-            text: 'One',
171
-            color: 'red'
172
-          }],
173
-          leftButtons: [{
174
-            id: BUTTON_LEFT,
175
-            testID: BUTTON_LEFT,
176
-            icon: require('../../img/navicon_add.png'),
177
-            text: 'Left',
178
-            color: 'purple'
179
-          }]
104
+      }
105
+    });
106
+  }
107
+
108
+  setReactTitleView = () => Navigation.mergeOptions(this, {
109
+    topBar: {
110
+      title: {
111
+        component: {
112
+          name: Screens.ReactTitleView,
113
+          alignment: 'center'
180 114
         }
181
-      });
182
-    } else if (buttonId === BUTTON_LEFT) {
183
-      Navigation.pop(this.props.componentId);
115
+      }
184 116
     }
117
+  });
118
+
119
+  //       <Button title='Switch to tab based app' testID={testIDs.TAB_BASED_APP_BUTTON} onPress={this.onClickSwitchToTabs} />
120
+  //       <Button title='Switch to app with side menus' testID={testIDs.TAB_BASED_APP_SIDE_BUTTON} onPress={this.onClickSwitchToSideMenus} />
121
+  //       {Platform.OS === 'ios' && <Button title='Switch to split view based app' testID={testIDs.SPLIT_VIEW_BUTTON} onPress={this.onClickSplitView} />}
122
+  //       <Button title='Push Lifecycle Screen' testID={testIDs.PUSH_LIFECYCLE_BUTTON} onPress={this.onClickLifecycleScreen} />
123
+  //       <Button title='Static Lifecycle Events' testID={testIDs.PUSH_STATIC_LIFECYCLE_BUTTON} onPress={this.onClickShowStaticLifecycleOverlay} />
124
+  //       <Button title='Push' testID={testIDs.PUSH_BUTTON} onPress={this.onClickPush} />
125
+  //       {false && <Button title='Push Context Screen' testID={testIDs.PUSH_CONTEXT_SCREEN_BUTTON} onPress={this.onClickPushContextScreen} />}
126
+  //       {Platform.OS === 'ios' && <Button testID={testIDs.SHOW_PREVIEW_BUTTON} onPress={this.onClickPush} onPressIn={this.onClickShowPreview} title='Push Preview' />}
127
+  //       <Button title='Push Options Screen' testID={testIDs.PUSH_OPTIONS_BUTTON} onPress={this.onClickPushOptionsScreen} />
128
+  //       <Button title='Push External Component' testID={testIDs.PUSH_EXTERNAL_COMPONENT_BUTTON} onPress={this.onClickPushExternalComponent} />
129
+  //       {Platform.OS === 'android' && <Button title='Push Top Tabs screen' testID={testIDs.PUSH_TOP_TABS_BUTTON} onPress={this.onClickPushTopTabsScreen} />}
130
+  //       {Platform.OS === 'android' && <Button title='Back Handler' testID={testIDs.BACK_HANDLER_BUTTON} onPress={this.onClickBackHandler} />}
131
+  //       <Button title='Show Modal' testID={testIDs.SHOW_MODAL_BUTTON} onPress={this.onClickShowModal} />
132
+  //       <Button title='Show Redbox' testID={testIDs.SHOW_REDBOX_BUTTON} onPress={this.onClickShowRedbox} />
133
+  //       <Button title='Orientation' testID={testIDs.ORIENTATION_BUTTON} onPress={this.onClickPushOrientationMenuScreen} />
134
+  //       <Button title='Provided Id' testID={testIDs.PROVIDED_ID} onPress={this.onClickProvidedId} />
135
+  //       <Button title='Complex Layout' testID={testIDs.COMPLEX_LAYOUT_BUTTON} onPress={this.onClickComplexLayout} />
136
+  //       <Button title='Push SearchBar' testID={testIDs.SHOW_TOPBAR_SEARCHBAR} onPress={this.onClickSearchBar} />
137
+  //       <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
138
+
139
+  onClickSwitchToTabs = () => {
140
+    Navigation.setRoot({
141
+      root: {
142
+        bottomTabs: {
143
+          id: 'BottomTabs',
144
+          children: [
145
+            {
146
+              stack: {
147
+                id: 'TAB1_ID',
148
+                children: [
149
+                  {
150
+                    component: {
151
+                      name: 'navigation.playground.TextScreen',
152
+                      passProps: {
153
+                        text: 'This is tab 1',
154
+                        myFunction: () => 'Hello from a function!'
155
+                      },
156
+                      options: {
157
+                        topBar: {
158
+                          visible: true,
159
+                          animate: false,
160
+                          title: {
161
+                            text: 'React Native Navigation!'
162
+                          }
163
+                        },
164
+                        bottomTab: {
165
+                          text: 'Tab 1',
166
+                          icon: require('../images/colored_tab_icon.png'),
167
+                          testID: testIDs.FIRST_TAB_BAR_BUTTON
168
+                        }
169
+                      }
170
+                    }
171
+                  }
172
+                ],
173
+                options: {
174
+                  topBar: {
175
+                    visible: false
176
+                  }
177
+                }
178
+              }
179
+            },
180
+            {
181
+              stack: {
182
+                children: [
183
+                  {
184
+                    component: {
185
+                      name: 'navigation.playground.TextScreen',
186
+                      passProps: {
187
+                        text: 'This is tab 2'
188
+                      }
189
+                    }
190
+                  }
191
+                ],
192
+                options: {
193
+                  bottomTab: {
194
+                    text: 'Tab 2',
195
+                    icon: require('../images/two.png'),
196
+                    iconColor: '#1B4C77',
197
+                    selectedIconColor: '#0f0',
198
+                    testID: testIDs.SECOND_TAB_BAR_BUTTON
199
+                  }
200
+                }
201
+              }
202
+            },
203
+            {
204
+              component: {
205
+                name: 'navigation.playground.TextScreen',
206
+                passProps: {
207
+                  text: 'This is tab 3',
208
+                  myFunction: () => 'Hello from a function!'
209
+                },
210
+                options: {
211
+                  topBar: {
212
+                    visible: true,
213
+                    animate: false
214
+                  },
215
+                  bottomTab: {
216
+                    text: 'Tab 3',
217
+                    icon: require('../images/one.png'),
218
+                    iconColor: '#1B4C77',
219
+                    selectedIconColor: '#0f0',
220
+                    selectedIcon: require('../images/one.png')
221
+                  }
222
+                }
223
+              }
224
+            }
225
+          ],
226
+          options: {
227
+            bottomTabs: {
228
+              titleDisplayMode: 'alwaysShow',
229
+              testID: testIDs.BOTTOM_TABS_ELEMENT
230
+            }
231
+          }
232
+        }
233
+      }
234
+    });
185 235
   }
186 236
 
187
-  onClickDynamicOptions = () => {
188
-    Navigation.mergeOptions(this.props.componentId, {
189
-      topBar: {
190
-        title: {
191
-          text: 'Dynamic Title',
192
-          color: '#00FFFF',
193
-          fontSize: 20,
194
-          fontFamily: 'HelveticaNeue-CondensedBold'
195
-        },
196
-        largeTitle: {
197
-          visible: false
237
+  onClickSwitchToSideMenus = () => {
238
+    Navigation.setRoot({
239
+      root: {
240
+        sideMenu: {
241
+          left: {
242
+            component: {
243
+              name: 'navigation.playground.SideMenuScreen',
244
+              passProps: {
245
+                side: 'left'
246
+              }
247
+            }
248
+          },
249
+          center: {
250
+            bottomTabs: {
251
+              children: [
252
+                {
253
+                  stack: {
254
+                    id: 'tab1Stack',
255
+                    children: [
256
+                      {
257
+                        component: {
258
+                          name: 'navigation.playground.TextScreen',
259
+                          passProps: {
260
+                            text: 'This is a side menu center screen tab 1'
261
+                          },
262
+                          // options: {
263
+                          //   bottomTab: {
264
+                          //     iconColor: 'red',
265
+                          //     textColor: 'red',
266
+                          //     selectedIconColor: 'purple',
267
+                          //     selectedTextColor: 'purple',
268
+                          //   }
269
+                          // }
270
+                        }
271
+                      }
272
+                    ],
273
+                    options: {
274
+                      bottomTab: {
275
+                        iconColor: 'red',
276
+                        textColor: 'red',
277
+                        selectedIconColor: 'purple',
278
+                        selectedTextColor: 'purple',
279
+                        text: 'Tab 1',
280
+                        icon: require('../images/one.png'),
281
+                        testID: testIDs.FIRST_TAB_BAR_BUTTON
282
+                      }
283
+                    }
284
+                  }
285
+                },
286
+                {
287
+                  stack: {
288
+                    children: [
289
+                      {
290
+                        component: {
291
+                          name: 'navigation.playground.TextScreen',
292
+                          passProps: {
293
+                            text: 'This is a side menu center screen tab 2'
294
+                          }
295
+                        }
296
+                      }
297
+                    ],
298
+                    options: {
299
+                      bottomTab: {
300
+                        text: 'Tab 2',
301
+                        icon: require('../images/two.png'),
302
+                        testID: testIDs.SECOND_TAB_BAR_BUTTON
303
+                      }
304
+                    }
305
+                  }
306
+                },
307
+                {
308
+                  stack: {
309
+                    children: [
310
+                      {
311
+                        component: {
312
+                          name: 'navigation.playground.TextScreen',
313
+                          passProps: {
314
+                            text: 'This is a side menu center screen tab 3'
315
+                          }
316
+                        }
317
+                      }
318
+                    ],
319
+                    options: {
320
+                      bottomTab: {
321
+                        text: 'Tab 3',
322
+                        icon: require('../images/three.png'),
323
+                        testID: testIDs.SECOND_TAB_BAR_BUTTON
324
+                      }
325
+                    }
326
+                  }
327
+                }
328
+              ],
329
+              options: {
330
+                bottomTab: {
331
+                  textColor: '#AED581',
332
+                  iconColor: '#AED581',
333
+                  selectedTextColor: '#90CAF9',
334
+                  selectedIconColor: '#90CAF9',
335
+                  fontFamily: 'HelveticaNeue-Italic',
336
+                  fontSize: 13
337
+                }
338
+              }
339
+            }
340
+          },
341
+          right: {
342
+            component: {
343
+              name: 'navigation.playground.SideMenuScreen',
344
+              passProps: {
345
+                side: 'right'
346
+              }
347
+            }
348
+          }
198 349
         }
199 350
       }
200 351
     });
201 352
   }
202 353
 
203
-  onClickScrollViewScreen = () => {
204
-    Navigation.push(this.props.componentId, {
354
+  onClickPush = async () => {
355
+    await Navigation.push(this.props.componentId, {
205 356
       component: {
206
-        name: 'navigation.playground.ScrollViewScreen'
357
+        name: 'navigation.playground.PushedScreen',
358
+        options: {
359
+          layout: {
360
+
361
+          },
362
+          topBar: {
363
+            title: {
364
+              text: 'pushed',
365
+              color: '#0000ff',
366
+              fontSize: 14
367
+            },
368
+            subtitle: {
369
+              text: 'subtitle',
370
+              fontSize: 10,
371
+              color: '#00ff00'
372
+            }
373
+          }
374
+        }
207 375
       }
208 376
     });
209 377
   }
210 378
 
211
-  onClickCustomTransition = () => {
212
-    Navigation.push(this.props.componentId, {
379
+  onClickPushContextScreen = async () => {
380
+    await Navigation.push(this.props.componentId, {
213 381
       component: {
214
-        name: 'navigation.playground.CustomTransitionOrigin'
382
+        name: 'navigation.playground.ContextScreen',
215 383
       }
216
-    });
384
+    })
217 385
   }
218 386
 
219
-  onClickTopBarTransparent = () => {
220
-    Navigation.mergeOptions(this.props.componentId, {
221
-      topBar: {
222
-        background: {
223
-          color: 'transparent'
387
+  onClickPushExternalComponent = async () => {
388
+    await Navigation.push(this.props.componentId, {
389
+      externalComponent: {
390
+        name: 'RNNCustomComponent',
391
+        passProps: {
392
+          text: 'This is an external component'
393
+        },
394
+        options: {
395
+          topBar: {
396
+            title: {
397
+              text: 'pushed'
398
+            },
399
+            visible: true,
400
+            testID: testIDs.TOP_BAR_ELEMENT
401
+          }
224 402
         }
225 403
       }
226 404
     });
227 405
   }
228 406
 
229
-  onClickTopBarOpaque = () => {
230
-    Navigation.mergeOptions(this.props.componentId, {
231
-      topBar: {
232
-        background: {
233
-          color: 'white'
234
-        }
407
+  onClickLifecycleScreen = () => {
408
+    Navigation.push(this.props.componentId, {
409
+      component: {
410
+        name: 'navigation.playground.LifecycleScreen'
235 411
       }
236 412
     });
237 413
   }
238 414
 
239
-  onClickShowTopBar = () => {
240
-    Navigation.mergeOptions('TEST', {
241
-      topBar: {
242
-        visible: true,
243
-        animate: true
415
+  onClickShowStaticLifecycleOverlay = () => {
416
+    Navigation.showOverlay({
417
+      component: {
418
+        name: 'navigation.playground.StaticLifecycleOverlay',
419
+        options: {
420
+          overlay: {
421
+            interceptTouchOutside: false
422
+          }
423
+        }
244 424
       }
245 425
     });
246 426
   }
247 427
 
248
-  onClickHideTopBar = () => {
249
-    Navigation.mergeOptions(this.props.componentId, {
250
-      topBar: {
251
-        visible: false,
252
-        animate: true
428
+  onClickShowModal = async () => {
429
+    await Navigation.showModal({
430
+      stack: {
431
+        children: [
432
+          {
433
+            component: {
434
+              name: 'navigation.playground.ModalScreen'
435
+            }
436
+          }
437
+        ]
253 438
       }
254 439
     });
255 440
   }
256 441
 
257
-  onClickFab = () => {
258
-    Navigation.mergeOptions(this.props.componentId, {
259
-      fab: {
260
-        id: FAB,
261
-        visible: false
262
-        // backgroundColor: 'green'
442
+  onClickShowRedbox = () => {
443
+    undefined();
444
+  }
445
+
446
+  onClickShowPreview = async ({ reactTag }) => {
447
+    await Navigation.push(this.props.componentId, {
448
+      component: {
449
+        name: 'navigation.playground.PushedScreen',
450
+        options: {
451
+          animations: {
452
+            push: {
453
+              enabled: false
454
+            }
455
+          },
456
+          preview: reactTag ? {
457
+            reactTag,
458
+            height: 300,
459
+            commit: true,
460
+            actions: [{
461
+              id: 'action-cancel',
462
+              title: 'Cancel'
463
+            }, {
464
+              id: 'action-delete',
465
+              title: 'Delete',
466
+              actions: [{
467
+                id: 'action-delete-sure',
468
+                title: 'Are you sure?',
469
+                style: 'destructive'
470
+              }]
471
+            }]
472
+          } : undefined,
473
+        }
263 474
       }
264 475
     });
265 476
   }
266 477
 
267
-  onClickShowOverlay = async (interceptTouchOutside) => {
268
-    await Navigation.showOverlay({
478
+  onClickPushOptionsScreen = () => {
479
+    Navigation.push(this.props.componentId, {
269 480
       component: {
270
-        name: 'navigation.playground.CustomDialog',
481
+        name: 'navigation.playground.OptionsScreen',
271 482
         options: {
272
-          layout: {
273
-            componentBackgroundColor: 'transparent'
483
+          animations: {
484
+            push: {
485
+              enabled: false
486
+            }
487
+          }
488
+        }
489
+      }
490
+    });
491
+  }
492
+
493
+  onClickPushTopTabsScreen = () => {
494
+    Navigation.push(this.props.componentId, {
495
+      topTabs: {
496
+        children: [
497
+          {
498
+            component: {
499
+              name: 'navigation.playground.TopTabOptionsScreen',
500
+              passProps: {
501
+                title: 'Tab 1',
502
+                text: 'This is top tab 1'
503
+              },
504
+              options: {
505
+                topTab: {
506
+                  title: 'Tab 1'
507
+                },
508
+                topBar: {
509
+                  title: {
510
+                    text: 'One'
511
+                  }
512
+                }
513
+              }
514
+            }
274 515
           },
275
-          overlay: {
276
-            interceptTouchOutside: false
516
+          {
517
+            component: {
518
+              name: 'navigation.playground.TopTabScreen',
519
+              passProps: {
520
+                title: 'Tab 2',
521
+                text: 'This is top tab 2'
522
+              },
523
+              options: {
524
+                topTab: {
525
+                  title: 'Tab 2',
526
+                  titleFontFamily: 'HelveticaNeue-Italic'
527
+                },
528
+                topBar: {
529
+                  title: {
530
+                    text: 'Two'
531
+                  }
532
+                }
533
+              }
534
+            }
535
+          },
536
+          {
537
+            component: {
538
+              name: 'navigation.playground.TopTabScreen',
539
+              passProps: {
540
+                title: 'Tab 3',
541
+                text: 'This is top tab 3'
542
+              },
543
+              options: {
544
+                topTab: {
545
+                  title: 'Tab 3'
546
+                },
547
+                topBar: {
548
+                  title: {
549
+                    text: 'Three'
550
+                  }
551
+                }
552
+              }
553
+            }
554
+          }
555
+        ],
556
+        options: {
557
+          topTabs: {
558
+            selectedTabColor: '#12766b',
559
+            unselectedTabColor: 'red',
560
+            fontSize: 6
277 561
           }
278 562
         }
279 563
       }
280 564
     });
281 565
   }
282 566
 
283
-  onClickPushDefaultOptionsScreen = () => {
284
-    Navigation.setDefaultOptions({
285
-      topBar: {
286
-        visible: false,
287
-        animate: false
567
+  onClickBackHandler = () => {
568
+    Navigation.push(this.props.componentId, {
569
+      component: {
570
+        name: 'navigation.playground.BackHandlerScreen'
288 571
       }
289 572
     });
573
+  }
290 574
 
575
+  onClickPushOrientationMenuScreen = () => {
291 576
     Navigation.push(this.props.componentId, {
292 577
       component: {
293
-        name: 'navigation.playground.PushedScreen'
578
+        name: 'navigation.playground.OrientationSelectScreen'
294 579
       }
295 580
     });
296 581
   }
297 582
 
298
-  onShowTopBarReactView = () => {
299
-    Navigation.mergeOptions(this.props.componentId, {
583
+  onClickProvidedId = () => {
584
+    Navigation.showModal({
585
+      stack: {
586
+        children: [
587
+          {
588
+            component: {
589
+              name: 'navigation.playground.TextScreen',
590
+              id: 'my unique id'
591
+            }
592
+          }
593
+        ]
594
+      }
595
+    });
596
+    Navigation.mergeOptions('my unique id', {
300 597
       topBar: {
301 598
         title: {
302
-          component: {
303
-            name: 'navigation.playground.CustomTopBar',
304
-            alignment: 'center'
305
-          }
599
+          text: 'User provided id'
306 600
         }
307 601
       }
308 602
     });
309 603
   }
310 604
 
311
-  onPush = () => {
312
-    Navigation.push(this.props.componentId, {
605
+  onClickComplexLayout = () => {
606
+    Navigation.showModal({
313 607
       component: {
314
-        name: 'navigation.playground.PushedScreen',
315
-        options: {
316
-          topBar: {
317
-            title: {
318
-              text: 'pushed'
608
+        name: 'navigation.playground.ComplexLayout'
609
+      }
610
+    });
611
+  }
612
+
613
+  onClickSplitView = () => {
614
+    Navigation.setRoot({
615
+      root: {
616
+        splitView: {
617
+          id: 'SPLITVIEW_ID',
618
+          master: {
619
+            stack: {
620
+              id: 'MASTER_ID',
621
+              children: [
622
+                {
623
+                  component: {
624
+                    name: 'navigation.playground.WelcomeScreen'
625
+                  },
626
+                },
627
+              ]
319 628
             },
320
-            subtitle: {
321
-              text: 'subtitle'
629
+          },
630
+          detail: {
631
+            stack: {
632
+              id: 'DETAILS_ID',
633
+              children: [
634
+                {
635
+                  component: {
636
+                    name: 'navigation.playground.WelcomeScreen'
637
+                  },
638
+                },
639
+              ]
322 640
             }
323
-          }
324
-        }
641
+          },
642
+          options: {
643
+            displayMode: 'auto',
644
+            primaryEdge: 'leading',
645
+            minWidth: 150,
646
+            maxWidth: 300,
647
+          },
648
+        },
649
+      },
650
+    });
651
+  }
652
+  onClickSearchBar = () => {
653
+    Navigation.push(this.props.componentId, {
654
+      component: {
655
+        name: 'navigation.playground.SearchControllerScreen'
325 656
       }
326 657
     });
327 658
   }
328 659
 }
329 660
 
661
+module.exports = Options;
662
+
330 663
 const styles = {
331 664
   root: {
332 665
     flexGrow: 1,
333 666
     justifyContent: 'center',
334 667
     alignItems: 'center',
335
-    backgroundColor: 'white'
668
+  },
669
+  bar: {
670
+    flex: 1,
671
+    flexDirection: 'column',
672
+    justifyContent: 'space-between'
336 673
   },
337 674
   h1: {
338 675
     fontSize: 24,
339 676
     textAlign: 'center',
340
-    margin: 10
341
-  },
342
-  h2: {
343
-    fontSize: 12,
344
-    textAlign: 'center',
345
-    margin: 10
677
+    margin: 30
346 678
   },
347 679
   footer: {
348 680
     fontSize: 10,
@@ -350,5 +682,3 @@ const styles = {
350 682
     marginTop: 10
351 683
   }
352 684
 };
353
-
354
-module.exports = OptionsScreen;

+ 4
- 4
playground/src/screens/OrientationDetectScreen.js View File

@@ -4,7 +4,7 @@ const { Component } = require('react');
4 4
 const { View, Text, Button } = require('react-native');
5 5
 
6 6
 const { Navigation } = require('react-native-navigation');
7
-const testIDs = require('../testIDs');
7
+const TestIDs = require('../testIDs');
8 8
 
9 9
 class OrientationDetectScreen extends Component {
10 10
   constructor(props) {
@@ -23,11 +23,11 @@ class OrientationDetectScreen extends Component {
23 23
     return (
24 24
       <View style={styles.root} onLayout={this.detectHorizontal}>
25 25
         <Text style={styles.h1}>{`Orientation Screen`}</Text>
26
-        <Button title='Dismiss' testID={testIDs.DISMISS_BUTTON} onPress={() => Navigation.dismissModal(this.props.componentId)} />
26
+        <Button title='Dismiss' testID={TestIDs.DISMISS_BTN} onPress={() => Navigation.dismissModal(this.props.componentId)} />
27 27
         <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
28 28
         {this.state.horizontal ?
29
-        <Text style={styles.footer} testID={testIDs.LANDSCAPE_ELEMENT}>Landscape</Text> :
30
-        <Text style={styles.footer} testID={testIDs.PORTRAIT_ELEMENT}>Portrait</Text>}
29
+        <Text style={styles.footer} testID={TestIDs.LANDSCAPE_ELEMENT}>Landscape</Text> :
30
+        <Text style={styles.footer} testID={TestIDs.PORTRAIT_ELEMENT}>Portrait</Text>}
31 31
       </View>
32 32
     );
33 33
   }

+ 38
- 0
playground/src/screens/OrientationScreen.js View File

@@ -0,0 +1,38 @@
1
+const React = require('react');
2
+const { Component } = require('react');
3
+const Root = require('../components/Root');
4
+const Button = require('../components/Button')
5
+const { Navigation } = require('react-native-navigation');
6
+const Screens = require('./Screens');
7
+const {
8
+  DEFAULT_ORIENTATION_BTN,
9
+  LANDSCAPE_PORTRAIT_ORIENTATION_BTN,
10
+  LANDSCAPE_ORIENTATION_BTN,
11
+  PORTRAIT_ORIENTATION_BTN
12
+} = require('../testIDs');
13
+
14
+class OrientationScreen extends Component {
15
+  render() {
16
+    return (
17
+      <Root componentId={this.props.componentId}>
18
+        <Button label='Default' testID={DEFAULT_ORIENTATION_BTN} onPress={() => this.orientation('default')} />
19
+        <Button label='Landscape and Portrait' testID={LANDSCAPE_PORTRAIT_ORIENTATION_BTN} onPress={() => this.orientation(['landscape', 'portrait'])} />
20
+        <Button label='Portrait' testID={PORTRAIT_ORIENTATION_BTN} onPress={() => this.orientation('portrait')} />
21
+        <Button label='Landscape' testID={LANDSCAPE_ORIENTATION_BTN} onPress={() => this.orientation(['landscape'])} />
22
+      </Root>
23
+    );
24
+  }
25
+
26
+  orientation(orientation) {
27
+    Navigation.showModal({
28
+      component: {
29
+        name: Screens.OrientationDetect,
30
+        passProps: {
31
+          orientation
32
+        }
33
+      }
34
+    });
35
+  }
36
+}
37
+
38
+module.exports = OrientationScreen;

+ 0
- 48
playground/src/screens/OrientationSelectScreen.js View File

@@ -1,48 +0,0 @@
1
-const React = require('react');
2
-const { Component } = require('react');
3
-
4
-const { View, Text, Button } = require('react-native');
5
-
6
-const { Navigation } = require('react-native-navigation');
7
-const testIDs = require('../testIDs');
8
-
9
-class OrientationSelectScreen extends Component {
10
-  render() {
11
-    return (
12
-      <View style={styles.root}>
13
-        <Text style={styles.h1}>{`Orientation Menu`}</Text>
14
-        <Button title='default' testID={testIDs.DEFAULT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen('default')} />
15
-        <Button title='landscape and portrait' testID={testIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen(['landscape', 'portrait'])} />
16
-        <Button title='portrait only' testID={testIDs.PORTRAIT_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen('portrait')} />
17
-        <Button title='landscape only' testID={testIDs.LANDSCAPE_ORIENTATION_BUTTON} onPress={() => this.onClickOrientationScreen(['landscape'])} />
18
-      </View>
19
-    );
20
-  }
21
-
22
-  onClickOrientationScreen(orientation) {
23
-    Navigation.showModal({
24
-      component: {
25
-        name: 'navigation.playground.OrientationDetectScreen',
26
-        passProps: {
27
-          orientation
28
-        }
29
-      }
30
-    });
31
-  }
32
-}
33
-
34
-module.exports = OrientationSelectScreen;
35
-
36
-const styles = {
37
-  root: {
38
-    flexGrow: 1,
39
-    justifyContent: 'center',
40
-    alignItems: 'center',
41
-    backgroundColor: '#f5fcff'
42
-  },
43
-  h1: {
44
-    fontSize: 24,
45
-    textAlign: 'center',
46
-    margin: 10
47
-  }
48
-};

+ 55
- 0
playground/src/screens/OverlayAlert.js View File

@@ -0,0 +1,55 @@
1
+const React = require('react');
2
+
3
+const { Text, Button, View, Alert, Platform } = require('react-native');
4
+const { Navigation } = require('react-native-navigation');
5
+
6
+const {
7
+  OVERLAY_ALERT_HEADER,
8
+  DISMISS_BTN,
9
+  SET_ROOT_BUTTON,
10
+  SET_INTERCEPT_TOUCH
11
+} = require('../testIDs');
12
+
13
+class OverlayAlert extends React.PureComponent {
14
+  render() {
15
+    return (
16
+      <View style={styles.root}>
17
+        <Text style={styles.title} testID={OVERLAY_ALERT_HEADER}>Test view</Text>
18
+        <Button title='Dismiss' testID={DISMISS_BTN} onPress={this.dismiss} />
19
+        <Button title='Set Root' testID={SET_ROOT_BUTTON} onPress={this.setRoot} />
20
+        <Button title='Set Intercept touch' testID={SET_INTERCEPT_TOUCH} onPress={this.setInterceptTouch} />
21
+      </View>
22
+    );
23
+  }
24
+
25
+  dismiss = () => Navigation.dismissOverlay(this.props.componentId);
26
+  setRoot = () => Navigation.setRoot({
27
+    root: {
28
+      component: {
29
+        name: 'navigation.playground.TextScreen'
30
+      }
31
+    }
32
+  });
33
+  setInterceptTouch = () => Navigation.mergeOptions(this.props.componentId, {
34
+    overlay: {
35
+      interceptTouchOutside: false
36
+    }
37
+  });
38
+}
39
+
40
+const styles = {
41
+  root: {
42
+    position: 'absolute',
43
+    backgroundColor: 'green',
44
+    alignItems: 'center',
45
+    height: 160,
46
+    bottom: 0,
47
+    left: 0,
48
+    right: 0
49
+  },
50
+  title: {
51
+    marginTop: 8
52
+  }
53
+};
54
+
55
+module.exports = OverlayAlert;

+ 59
- 0
playground/src/screens/OverlayScreen.js View File

@@ -0,0 +1,59 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const { component } = require('../commons/Layouts');
5
+const Navigation = require('../services/Navigation');
6
+const {
7
+  SHOW_OVERLAY_BTN,
8
+  SHOW_TOUCH_THROUGH_OVERLAY_BTN,
9
+  ALERT_BUTTON,
10
+  SET_ROOT_BTN
11
+} = require('../testIDs');
12
+const Screens = require('./Screens');
13
+
14
+class OverlayScreen extends React.Component {
15
+  static options() {
16
+    return {
17
+      topBar: {
18
+        title: {
19
+          text: 'Overlay'
20
+        }
21
+      }
22
+    };
23
+  }
24
+
25
+  render() {
26
+    return (
27
+      <Root componentId={this.props.componentId}>
28
+        <Button label='Alert' testID={ALERT_BUTTON} onPress={() => alert('Alert displayed')} />
29
+        <Button label='Show overlay' testID={SHOW_OVERLAY_BTN} onPress={() => this.showOverlay(true)} />
30
+        <Button label='Show touch through overlay' testID={SHOW_TOUCH_THROUGH_OVERLAY_BTN} onPress={() => this.showOverlay(false)} />
31
+        <Button label='Set Root' testID={SET_ROOT_BTN} onPress={this.setRoot} />
32
+      </Root>
33
+    );
34
+  }
35
+
36
+  showOverlay = (interceptTouchOutside) => Navigation.showOverlay(Screens.OverlayAlert, {
37
+    layout: { componentBackgroundColor: 'transparent' },
38
+    overlay: { interceptTouchOutside }
39
+  });
40
+
41
+  setRoot = () => Navigation.setRoot({ root: component(Screens.Pushed) })
42
+
43
+  // await Navigation.showOverlay({
44
+  //   component: {
45
+  //     name: 'navigation.playground.CustomDialog',
46
+  //     options: {
47
+  //       layout: {
48
+  //         componentBackgroundColor: 'transparent'
49
+  //       },
50
+  //       overlay: {
51
+  //         interceptTouchOutside: false
52
+  //       }
53
+  //     }
54
+  //   }
55
+  // });
56
+  // });
57
+}
58
+
59
+module.exports = OverlayScreen;

+ 99
- 336
playground/src/screens/PushedScreen.js View File

@@ -1,30 +1,36 @@
1 1
 const _ = require('lodash');
2 2
 const React = require('react');
3
-const {Component} = require('react');
4
-const {View, Text, Platform} = require('react-native');
5
-const {Navigation} = require('react-native-navigation');
6
-const Button = require('./Button');
7
-const testIDs = require('../testIDs');
8
-
9
-class PushedScreen extends Component {
3
+const { BackHandler } = require('react-native');
4
+const Navigation = require('../services/Navigation');
5
+const Root = require('../components/Root');
6
+const Button = require('../components/Button');
7
+const {
8
+  PUSHED_SCREEN_HEADER,
9
+  TOP_BAR_BTN,
10
+  PUSH_BTN,
11
+  POP_BTN,
12
+  PUSH_NO_ANIM_BTN,
13
+  POP_TO_FIRST_SCREEN_BTN,
14
+  POP_TO_ROOT_BTN,
15
+  ADD_BACK_HANDLER,
16
+  REMOVE_BACK_HANDLER,
17
+  SET_STACK_ROOT_BUTTON
18
+} = require('../testIDs');
19
+const Screens = require('./Screens');
20
+
21
+class PushedScreen extends React.Component {
10 22
   static options() {
11 23
     return {
12
-      _statusBar: {
13
-        visible: false,
14
-        drawBehind: true
15
-      },
16 24
       topBar: {
17
-        testID: testIDs.TOP_BAR_ELEMENT,
25
+        testID: PUSHED_SCREEN_HEADER,
26
+        title: {
27
+          text: 'Pushed Screen'
28
+        },
18 29
         rightButtons: {
19 30
           id: 'singleBtn',
20 31
           text: 'single',
21
-          testID: testIDs.TOP_BAR_BUTTON
22
-        },
23
-        rightButtonColor: 'red',
24
-       noBorder: true
25
-      },
26
-      bottomTabs: {
27
-        visible: false
32
+          testID: TOP_BAR_BTN
33
+        }
28 34
       }
29 35
     };
30 36
   }
@@ -32,367 +38,124 @@ class PushedScreen extends Component {
32 38
   constructor(props) {
33 39
     super(props);
34 40
     Navigation.events().bindComponent(this);
35
-    if (this.props.simulateLongRunningTask) {
36
-      this.simulateLongRunningTask();
37
-    }
38
-    this.onClickPush = this.onClickPush.bind(this);
39
-    this.onClickPushBottomTabs = this.onClickPushBottomTabs.bind(this);
40
-    this.onClickPop = this.onClickPop.bind(this);
41
-    this.onClickPopPrevious = this.onClickPopPrevious.bind(this);
42
-    this.onClickPopToFirstPosition = this.onClickPopToFirstPosition.bind(this);
43
-    this.onClickPopToRoot = this.onClickPopToRoot.bind(this);
44
-    this.onClickSetStackRoot = this.onClickSetStackRoot.bind(this);
45
-    this.state = {disabled: false};
46
-  }
47
-
48
-  simulateLongRunningTask() {
49
-    // tslint:disable-next-line
50
-    for (let i = 0; i < Math.pow(2, 25); i++);
51
-  }
52
-
53
-  navigationButtonPressed({buttonId}) {
54
-    if (buttonId === 'backPress') {
55
-      alert('back button clicked')
56
-    }
57
-  }
58
-
59
-  listeners = [];
60
-
61
-  componentDidMount() {
62
-    this.listeners.push(
63
-      Navigation.events().registerComponentDidAppearListener((event) => {
64
-        if (this.state.previewComponentId === event.componentId) {
65
-          this.setState({disabled: event.type === 'ComponentDidAppear'});
66
-        }
67
-      })
68
-    );
69
-    if (Platform.OS === 'ios') {
70
-      // this.listeners.push(
71
-      //   Navigation.events().registerNativeEventListener((name, params) => {
72
-      //     if (name === 'previewContext') {
73
-      //       const { previewComponentId } = params;
74
-      //       this.setState({ previewComponentId });
75
-      //     }
76
-      //   })
77
-      // );
78
-    }
79 41
   }
80 42
 
81
-  componentWillUnmount() {
82
-    this.listeners.forEach(listener => listener.remove && listener.remove());
43
+  navigationButtonPressed({ buttonId }) {
44
+    if (buttonId === 'backPress') alert('back button clicked')
83 45
   }
84 46
 
85 47
   render() {
86 48
     const stackPosition = this.getStackPosition();
87 49
     return (
88
-      <View style={styles.root}>
89
-        <Text testID={testIDs.PUSHED_SCREEN_HEADER} style={styles.h1}>{`Pushed Screen`}</Text>
90
-        <Text style={styles.h2}>{`Stack Position: ${stackPosition}`}</Text>
91
-        <Button title='Push' testID={testIDs.PUSH_BUTTON} onPress={this.onClickPush} />
92
-        <Button title='Push bottomTabs' testID={testIDs.PUSH_BOTTOM_TABS_BUTTON} onPress={this.onClickPushBottomTabs} />
93
-        {Platform.OS === 'ios' && <Button testID={testIDs.SHOW_PREVIEW_BUTTON} onPress={this.onClickPush} onPressIn={this.onClickShowPreview} title='Push Preview' />}
94
-        <Button title='Pop' testID={testIDs.POP_BUTTON} onPress={this.onClickPop} />
95
-        <Button title='Pop Previous' testID={testIDs.POP_PREVIOUS_BUTTON} onPress={this.onClickPopPrevious} />
96
-        <Button title='Pop To Root' testID={testIDs.POP_TO_ROOT} onPress={this.onClickPopToRoot} />
97
-        <Button title='Set Stack Root' testID={testIDs.SET_STACK_ROOT_BUTTON} onPress={this.onClickSetStackRoot} />
98
-        <Button title='Push and Wait for Render' testID={testIDs.PUSH_BUTTON_WAIT_FOR_RENDER} onPress={this.onClickPushWaitForRender} />
99
-        <Button title='Push custom back button' testID={testIDs.PUSH_CUSTOM_BACK_BUTTON} onPress={this.onClickPushCustomBackButton} />
100
-        {stackPosition > 2 && <Button title='Pop To Stack Position 1' testID={testIDs.POP_STACK_POSITION_ONE_BUTTON} onPress={this.onClickPopToFirstPosition} />}
101
-        <Text style={styles.footer}>{`this.props.componentId = ${this.props.componentId}`}</Text>
102
-      </View>
50
+      <Root componentId={this.props.componentId} footer={`Stack Position: ${stackPosition}`}>
51
+        <Button label='Push' testID={PUSH_BTN} onPress={this.push} />
52
+        <Button label='Pop' testID={POP_BTN} onPress={this.pop} />
53
+        <Button label='Push Without Animation' testID={PUSH_NO_ANIM_BTN} onPress={this.pushWithoutAnimations} />
54
+        {stackPosition > 2 && <Button label='Pop to First Screen' testID={POP_TO_FIRST_SCREEN_BTN} onPress={this.popToFirstScreen} />}
55
+        <Button label='Pop to Root' testID={POP_TO_ROOT_BTN} onPress={this.popToRoot} />
56
+        <Button label='Add BackHandler' testID={ADD_BACK_HANDLER} onPress={this.addBackHandler} />
57
+        <Button label='Remove BackHandler' testID={REMOVE_BACK_HANDLER} onPress={this.removeBackHandler} />
58
+        <Button label='Set Stack Root' testID={SET_STACK_ROOT_BUTTON} onPress={this.setStackRoot} />
59
+      </Root>
103 60
     );
104 61
   }
105 62
 
106
-  onClickShowPreview = async ({reactTag}) => {
107
-    await Navigation.push(this.props.componentId, {
108
-      component: {
109
-        name: 'navigation.playground.PushedScreen',
110
-        passProps: {
111
-          stackPosition: this.getStackPosition() + 1,
112
-          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
113
-        },
114
-        options: {
115
-          topBar: {
116
-            title: {
117
-              text: `Pushed ${this.getStackPosition() + 1}`
118
-            }
119
-          },
120
-          animations: {
121
-            push: {
122
-              enabled: false
123
-            }
124
-          },
125
-          preview: {
126
-            reactTag,
127
-            height: 400,
128
-            commit: true,
129
-            actions: [{
130
-              id: 'action-cancel',
131
-              title: 'Cancel'
132
-            }]
63
+  push = () => Navigation.push(this, {
64
+    component: {
65
+      name: Screens.Pushed,
66
+      passProps: this.createPassProps(),
67
+      options: {
68
+        topBar: {
69
+          title: {
70
+            text: `Pushed ${this.getStackPosition() + 1}`
133 71
           }
134 72
         }
135 73
       }
136
-    });
137
-  }
138
-
139
-  async onClickPush() {
140
-    if (this.state.disabled) {
141
-      return;
142 74
     }
143
-
144
-    await Navigation.push(this.props.componentId, {
145
-      component: {
146
-        name: 'navigation.playground.PushedScreen',
147
-        passProps: {
148
-          stackPosition: this.getStackPosition() + 1,
149
-          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
150
-        },
151
-        options: {
152
-          topBar: {
153
-            title: {
154
-              text: `Pushed ${this.getStackPosition() + 1}`
155
-            }
156
-          }
75
+  });
76
+
77
+  pop = () => Navigation.pop(this);
78
+
79
+  pushWithoutAnimations = () => Navigation.push(this, {
80
+    component: {
81
+      name: Screens.Pushed,
82
+      passProps: this.createPassProps(),
83
+      options: {
84
+        animations: {
85
+          push: { enabled: false },
86
+          pop: { enabled: false }
157 87
         }
158 88
       }
159
-    });
160
-  }
161
-
162
-  async onClickPop() {
163
-    await Navigation.pop(this.props.componentId);
164
-  }
165
-
166
-  async onClickPopPrevious() {
167
-    await Navigation.pop(_.last(this.props.previousScreenIds));
168
-  }
169
-
170
-  async onClickPopToFirstPosition() {
171
-    await Navigation.popTo(this.props.previousScreenIds[0]);
172
-  }
89
+    }
90
+  });
173 91
 
174
-  async onClickPopToRoot() {
175
-    await Navigation.popToRoot(this.props.componentId);
176
-  }
92
+  popToFirstScreen = () => Navigation.popTo(this.props.previousScreenIds[0]);
177 93
 
178
-  async onClickSetStackRoot() {
179
-    await Navigation.setStackRoot(this.props.componentId, [
180
-      {
181
-        component: {
182
-          name: 'navigation.playground.PushedScreen',
183
-          passProps: {
184
-            stackPosition: this.getStackPosition() + 1,
185
-            previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
186
-          },
187
-          options: {
188
-            animations: {
189
-              setStackRoot: {
190
-                enabled: false
191
-              }
192
-            },
193
-            topBar: {
194
-              title: {
195
-                text: `Pushed ${this.getStackPosition() + 1} a`
196
-              }
197
-            }
198
-          }
199
-        }
200
-      },
201
-      {
202
-        component: {
203
-          name: 'navigation.playground.PushedScreen',
204
-          passProps: {
205
-            stackPosition: this.getStackPosition() + 1,
206
-            previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
207
-          },
208
-          options: {
209
-            animations: {
210
-              setStackRoot: {
211
-                enabled: false
212
-              }
213
-            },
214
-            topBar: {
215
-              title: {
216
-                text: `Pushed ${this.getStackPosition() + 1} b`
217
-              }
218
-            }
219
-          }
220
-        }
221
-      }
222
-    ]);
223
-  }
94
+  popToRoot = () => Navigation.popToRoot(this);
224 95
 
225
-  onClickPushWaitForRender = async () => {
226
-    await Navigation.push(this.props.componentId, {
96
+  setStackRoot = () => Navigation.setStackRoot(this, [
97
+    {
227 98
       component: {
228
-        name: 'navigation.playground.PushedScreen',
99
+        name: Screens.Pushed,
229 100
         passProps: {
230 101
           stackPosition: this.getStackPosition() + 1,
231
-          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId),
232
-          simulateLongRunningTask: true
102
+          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
233 103
         },
234 104
         options: {
235
-          layout: {
236
-            backgroundColor: 'transparent'
105
+          animations: {
106
+            setStackRoot: {
107
+              enabled: false
108
+            }
237 109
           },
238 110
           topBar: {
239 111
             title: {
240
-              text: `Pushed ${this.getStackPosition() + 1}`
241
-            }
242
-          },
243
-          animations: {
244
-            push: {
245
-              waitForRender: true
112
+              text: `Pushed ${this.getStackPosition() + 1} a`
246 113
             }
247 114
           }
248 115
         }
249 116
       }
250
-    });
251
-  }
252
-
253
-  onClickPushCustomBackButton = async () => {
254
-    Navigation.push(this.props.componentId, {
117
+    },
118
+    {
255 119
       component: {
256
-        name: 'navigation.playground.PushedScreen',
120
+        name: Screens.Pushed,
257 121
         passProps: {
258 122
           stackPosition: this.getStackPosition() + 1,
259
-          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId),
123
+          previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
260 124
         },
261 125
         options: {
262
-          topBar: {
263
-            backButton: {
264
-              id: 'backPress',
265
-              icon: require('../../img/navicon_add.png'),
266
-              visible: true,
267
-              color: 'black',
268
-              testID: testIDs.CUSTOM_BACK_BUTTON
269
-            }
270
-          }
271
-        }
272
-      }
273
-    });
274
-  }
275
-
276
-  async onClickPushBottomTabs() {
277
-    await Navigation.push(this.props.componentId, {
278
-      bottomTabs: {
279
-        id: 'BottomTabs',
280
-        children: [
281
-          {
282
-            stack: {
283
-              id: 'TAB1_ID',
284
-              children: [
285
-                {
286
-                  component: {
287
-                    name: 'navigation.playground.TextScreen',
288
-                    passProps: {
289
-                      text: 'This is tab 1',
290
-                      myFunction: () => 'Hello from a function!'
291
-                    },
292
-                    options: {
293
-                      topBar: {
294
-                        visible: true,
295
-                        animate: false,
296
-                        title: {
297
-                          text: 'React Native Navigation!'
298
-                        }
299
-                      },
300
-                      bottomTab: {
301
-                        text: 'Tab 1',
302
-                        icon: require('../images/one.png'),
303
-                        selectedIcon: require('../images/one.png'),
304
-                        testID: testIDs.FIRST_TAB_BAR_BUTTON
305
-                      }
306
-                    }
307
-                  }
308
-                }
309
-              ],
310
-              options: {
311
-                topBar: {
312
-                  visible: false
313
-                }
314
-              }
315
-            }
316
-          },
317
-          {
318
-            stack: {
319
-              children: [
320
-                {
321
-                  component: {
322
-                    name: 'navigation.playground.TextScreen',
323
-                    passProps: {
324
-                      text: 'This is tab 2'
325
-                    }
326
-                  }
327
-                }
328
-              ],
329
-              options: {
330
-                bottomTab: {
331
-                  text: 'Tab 2',
332
-                  icon: require('../images/two.png'),
333
-                  testID: testIDs.SECOND_TAB_BAR_BUTTON
334
-                }
335
-              }
126
+          animations: {
127
+            setStackRoot: {
128
+              enabled: false
336 129
             }
337 130
           },
338
-          {
339
-            component: {
340
-              name: 'navigation.playground.TextScreen',
341
-              passProps: {
342
-                text: 'This is tab 3',
343
-                myFunction: () => 'Hello from a function!'
344
-              },
345
-              options: {
346
-                topBar: {
347
-                  visible: true,
348
-                  animate: false
349
-                },
350
-                bottomTab: {
351
-                  text: 'Tab 3',
352
-                  icon: require('../images/one.png'),
353
-                  selectedIcon: require('../images/one.png')
354
-                }
355
-              }
131
+          topBar: {
132
+            title: {
133
+              text: `Pushed ${this.getStackPosition() + 1} b`
356 134
             }
357 135
           }
358
-        ],
359
-        options: {
360
-          bottomTabs: {
361
-            titleDisplayMode: 'alwaysShow',
362
-            testID: testIDs.BOTTOM_TABS_ELEMENT
363
-          }
364 136
         }
365 137
       }
138
+    }
139
+  ]);
140
+
141
+  addBackHandler = () => BackHandler.addEventListener('hardwareBackPress', this.backHandler);
142
+
143
+  removeBackHandler = () => BackHandler.removeEventListener('hardwareBackPress', this.backHandler);
144
+
145
+  backHandler = () => {
146
+    this.setState({
147
+      backPress: 'Back button pressed!'
366 148
     });
367
-  }
149
+    return true;
150
+  };
368 151
 
369
-  getStackPosition() {
370
-    return this.props.stackPosition || 1;
371
-  }
152
+  createPassProps = () => {
153
+    return {
154
+      stackPosition: this.getStackPosition() + 1,
155
+      previousScreenIds: _.concat([], this.props.previousScreenIds || [], this.props.componentId)
156
+    }
157
+  };
158
+  getStackPosition = () => this.props.stackPosition || 1;
372 159
 }
373 160
 
374
-const styles = {
375
-  root: {
376
-    flexGrow: 1,
377
-    justifyContent: 'center',
378
-    alignItems: 'center',
379
-    backgroundColor: '#f5fcff'
380
-  },
381
-  h1: {
382
-    fontSize: 24,
383
-    textAlign: 'center',
384
-    margin: 10
385
-  },
386
-  h2: {
387
-    fontSize: 12,
388
-    textAlign: 'center',
389
-    margin: 10
390
-  },
391
-  footer: {
392
-    fontSize: 10,
393
-    color: '#888',
394
-    marginTop: 10
395
-  }
396
-};
397
-
398 161
 module.exports = PushedScreen;

playground/src/screens/CustomRoundedButton.js → playground/src/screens/RoundedButton.js View File

@@ -6,11 +6,11 @@ const {
6 6
   TouchableOpacity,
7 7
   Text,
8 8
   Alert,
9
-  Platform
10 9
 } = require('react-native');
10
+const Colors = require('../commons/Colors');
11 11
 const { Navigation } = require('react-native-navigation');
12 12
 
13
-class CustomRoundedButton extends Component {
13
+class RoundedButton extends Component {
14 14
 
15 15
   constructor(props) {
16 16
     super(props);
@@ -18,23 +18,6 @@ class CustomRoundedButton extends Component {
18 18
     this.state = {};
19 19
   }
20 20
 
21
-  componentDidAppear() {
22
-    console.log('RNN', 'CRB.componentDidAppear');
23
-  }
24
-
25
-  componentDidDisappear() {
26
-    console.log('RNN', `CRB.componentDidDisappear`);
27
-  }
28
-
29
-  componentDidMount() {
30
-    console.log('RNN', `CRB.componentDidMount`);
31
-  }
32
-
33
-  componentWillUnmount() {
34
-    this.subscription.remove();
35
-    console.log('RNN', `CRB.componentWillUnmount`);
36
-  }
37
-
38 21
   render() {
39 22
     return (
40 23
       <View style={styles.container}>
@@ -48,7 +31,7 @@ class CustomRoundedButton extends Component {
48 31
   }
49 32
 }
50 33
 
51
-module.exports = CustomRoundedButton;
34
+module.exports = RoundedButton;
52 35
 
53 36
 const styles = StyleSheet.create({
54 37
   container: {
@@ -62,11 +45,11 @@ const styles = StyleSheet.create({
62 45
     width: 40,
63 46
     height: 40,
64 47
     borderRadius: 20,
65
-    backgroundColor: 'red',
48
+    backgroundColor: Colors.primary,
66 49
     justifyContent: 'center',
67 50
   },
68 51
   text: {
69
-    color: 'black',
52
+    color: 'white',
70 53
     alignSelf: 'center'
71 54
   }
72 55
 });

+ 30
- 0
playground/src/screens/Screens.js View File

@@ -0,0 +1,30 @@
1
+module.exports = {
2
+  ExternalComponent: 'ExternalComponent',
3
+  Pushed: 'Pushed',
4
+  Layouts: 'Layouts',
5
+  Options: 'Options',
6
+  StackScreen: 'StackScreen',
7
+  Pushed: 'Pushed',
8
+  Modal: 'Modal',
9
+  Overlay: 'Overlay',
10
+  OverlayAlert: 'OverlayAlert',
11
+  Lifecycle: 'Lifecycle',
12
+  BackHandler: 'BackHandler',
13
+  BottomTabs: 'BottomTabs',
14
+  FirstBottomTabsScreen: 'FirstBottomTabsScreen',
15
+  SecondBottomTabsScreen: 'SecondBottomTabsScreen',
16
+  Navigation: 'Navigation',
17
+  NativeScreen: 'RNNCustomComponent',
18
+  RoundButton: 'CustomRoundedButton',
19
+  ReactTitleView: 'ReactTitleView',
20
+  EventsScreen: 'EventsScreen',
21
+  EventsOverlay: 'EventsOverlay',
22
+  SideMenuLeft: 'SideMenuLeft',
23
+  SideMenuRight: 'SideMenuRight',
24
+  SideMenuCenter: 'SideMenuCenter',
25
+  FlatListScreen: 'FlatListScreen',
26
+  Alert: 'Alert',
27
+  Orientation: 'Orientation',
28
+  OrientationDetect: 'OrientationDetect',
29
+  Search: 'Search'
30
+}

+ 2
- 3
playground/src/screens/SearchScreen.js View File

@@ -19,9 +19,8 @@ for(let i = 0; i < 200; i++) {
19 19
   ITEMS.push({key: `Item ${i}`});
20 20
 }
21 21
 
22
-class SearchControllerScreen extends Component {
22
+class SearchScreen extends Component {
23 23
   static options() {
24
-   
25 24
     return {
26 25
       topBar: {
27 26
         title: {
@@ -113,7 +112,7 @@ class SearchControllerScreen extends Component {
113 112
   }
114 113
 }
115 114
 
116
-module.exports = SearchControllerScreen;
115
+module.exports = SearchScreen;
117 116
 
118 117
 const styles = StyleSheet.create({
119 118
   contentContainer: {},

+ 95
- 0
playground/src/screens/SecondBottomTabScreen.js View File

@@ -0,0 +1,95 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const Screens = require('./Screens');
5
+const Navigation = require('./../services/Navigation');
6
+const { stack, component } = require('./../commons/Layouts');
7
+const {
8
+  SIDE_MENU_INSIDE_BOTTOM_TABS_BTN,
9
+  PUSH_BTN,
10
+  PUSHED_BOTTOM_TABS,
11
+  SIDE_MENU_TAB,
12
+  FLAT_LIST_BTN
13
+} = require('../testIDs')
14
+
15
+class SecondBottomTabScreen extends React.Component {
16
+  static options() {
17
+    return {
18
+      topBar: {
19
+        title: {
20
+          text: 'Second Tab'
21
+        }
22
+      },
23
+      bottomTab: {
24
+        icon: require('../../img/star.png'),
25
+        text: 'Tab 2'
26
+      }
27
+    };
28
+  }
29
+
30
+  render() {
31
+    return (
32
+      <Root componentId={this.props.componentId}>
33
+        <Button label='Push BottomTabs' testID={PUSH_BTN} onPress={this.pushBottomTabs} />
34
+        <Button label='SideMenu inside BottomTabs' testID={SIDE_MENU_INSIDE_BOTTOM_TABS_BTN} onPress={this.sideMenuInsideBottomTabs} />
35
+      </Root>
36
+    );
37
+  }
38
+
39
+  pushBottomTabs = () => Navigation.push(this, {
40
+    bottomTabs: {
41
+      children: [
42
+        component(Screens.Pushed, {
43
+          bottomTab: {
44
+            icon: require('../../img/whatshot.png'),
45
+            text: 'Tab 1',
46
+            testID: PUSHED_BOTTOM_TABS
47
+          }
48
+        }),
49
+        component(Screens.Pushed, {
50
+          bottomTab: {
51
+            icon: require('../../img/star.png'),
52
+            text: 'Tab 2'
53
+          }
54
+        })
55
+      ]
56
+    }
57
+  });
58
+
59
+  sideMenuInsideBottomTabs = () => {
60
+    Navigation.showModal({
61
+      bottomTabs: {
62
+        children: [
63
+          {
64
+            sideMenu: {
65
+              left: { ...component(Screens.SideMenuLeft) },
66
+              center: stack(Screens.SideMenuCenter),
67
+              options: {
68
+                bottomTab: {
69
+                  text: 'SideMenu',
70
+                  icon: require('../../img/sideMenu.png'),
71
+                  testID: SIDE_MENU_TAB
72
+                }
73
+              }
74
+            }
75
+          },
76
+          {
77
+            sideMenu: {
78
+              left: { ...component(Screens.SideMenuLeft) },
79
+              center: stack(Screens.FlatListScreen),
80
+              options: {
81
+                bottomTab: {
82
+                  text: 'FlatList',
83
+                  icon: require('../../img/list.png'),
84
+                  testID: FLAT_LIST_BTN
85
+                }
86
+              }
87
+            }
88
+          }
89
+        ]
90
+      }
91
+    });
92
+  }
93
+}
94
+
95
+module.exports = SecondBottomTabScreen;

+ 40
- 0
playground/src/screens/SideMenuCenterScreen.js View File

@@ -0,0 +1,40 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const Navigation = require('../services/Navigation');
5
+const {
6
+  OPEN_LEFT_SIDE_MENU_BTN,
7
+  OPEN_RIGHT_SIDE_MENU_BTN,
8
+  CENTER_SCREEN_HEADER
9
+} = require('../testIDs');
10
+const Screens = require('./Screens');
11
+
12
+class SideMenuCenterScreen extends React.Component {
13
+  static options() {
14
+    return {
15
+      topBar: {
16
+        testID: CENTER_SCREEN_HEADER,
17
+        title: {
18
+          text: 'Center'
19
+        }
20
+      }
21
+    };
22
+  }
23
+
24
+  render() {
25
+    return (
26
+      <Root componentId={this.props.componentId}>
27
+        <Button label='Open Left' testID={OPEN_LEFT_SIDE_MENU_BTN} onPress={() => this.open('left')} />
28
+        <Button label='Open Right' testID={OPEN_RIGHT_SIDE_MENU_BTN} onPress={() => this.open('right')} />
29
+      </Root>
30
+    );
31
+  }
32
+
33
+  open = (side) => Navigation.mergeOptions(this, {
34
+    sideMenu: {
35
+      [side]: { visible: true }
36
+    }
37
+  });
38
+}
39
+
40
+module.exports = SideMenuCenterScreen;

+ 46
- 0
playground/src/screens/SideMenuLeftScreen.js View File

@@ -0,0 +1,46 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const Colors = require('../commons/Colors');
5
+const Navigation = require('../services/Navigation');
6
+const Screens = require('./Screens');
7
+const {
8
+  LEFT_SIDE_MENU_PUSH_BTN,
9
+  CLOSE_LEFT_SIDE_MENU_BTN,
10
+  LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN
11
+} = require('../testIDs');
12
+
13
+class SideMenuLeftScreen extends React.Component {
14
+  render() {
15
+    return (
16
+      <Root componentId={this.props.componentId} style={{ backgroundColor: Colors.background }}>
17
+        <Button label='Push' testID={LEFT_SIDE_MENU_PUSH_BTN} onPress={this.push} />
18
+        <Button label='Push and Close' testID={LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN} onPress={this.pushAndClose} />
19
+        <Button label='Close' testID={CLOSE_LEFT_SIDE_MENU_BTN} onPress={this.close} />
20
+      </Root>
21
+    );
22
+  }
23
+
24
+  push = () => Navigation.push('SideMenuCenter', Screens.Pushed);
25
+
26
+  pushAndClose = () => Navigation.push('SideMenuCenter', {
27
+    component: {
28
+      name: Screens.Pushed,
29
+      options: {
30
+        sideMenu: {
31
+          left: {
32
+            visible: false
33
+          }
34
+        }
35
+      }
36
+    }
37
+  });
38
+
39
+  close = () => Navigation.mergeOptions(this, {
40
+    sideMenu: {
41
+      left: { visible: false }
42
+    }
43
+  });
44
+}
45
+
46
+module.exports = SideMenuLeftScreen;

+ 26
- 0
playground/src/screens/SideMenuRightScreen.js View File

@@ -0,0 +1,26 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button')
4
+const Colors = require('../commons/Colors');
5
+const Navigation = require('../services/Navigation');
6
+const {
7
+  CLOSE_RIGHT_SIDE_MENU_BTN
8
+} = require('../testIDs');
9
+
10
+class SideMenuRightScreen extends React.Component {
11
+  render() {
12
+    return (
13
+      <Root componentId={this.props.componentId} style={{backgroundColor: Colors.background}}>
14
+        <Button label='Close' testID={CLOSE_RIGHT_SIDE_MENU_BTN} onPress={this.close} />
15
+      </Root>
16
+    );
17
+  }
18
+
19
+  close = () => Navigation.mergeOptions(this, {
20
+    sideMenu: {
21
+      right: { visible: false }
22
+    }
23
+  });
24
+}
25
+
26
+module.exports = SideMenuRightScreen;

+ 78
- 0
playground/src/screens/StackScreen.js View File

@@ -0,0 +1,78 @@
1
+const React = require('react');
2
+const Root = require('../components/Root');
3
+const Button = require('../components/Button');
4
+const Screens = require('./Screens');
5
+const Navigation = require('../services/Navigation');
6
+const {stack, component} = require('../commons/Layouts');
7
+const {
8
+  PUSH_BTN,
9
+  STACK_SCREEN_HEADER,
10
+  PUSH_LIFECYCLE_BTN,
11
+  POP_NONE_EXISTENT_SCREEN_BTN,
12
+  PUSH_CUSTOM_BACK_BTN,
13
+  CUSTOM_BACK_BTN,
14
+  SEARCH_BTN,
15
+  SET_STACK_ROOT_BTN
16
+} = require('../testIDs');
17
+
18
+class StackScreen extends React.Component {
19
+  static options() {
20
+    return {
21
+      topBar: {
22
+        testID: STACK_SCREEN_HEADER,
23
+        title: {
24
+          text: 'Stack'
25
+        }
26
+      }
27
+    }
28
+  }
29
+
30
+  state = {
31
+    backPress: ''
32
+  };
33
+
34
+  render() {
35
+    return (
36
+      <Root componentId={this.props.componentId}>
37
+        <Button label='Push' testID={PUSH_BTN} onPress={this.push} />
38
+        <Button label='Push Lifecycle Screen' testID={PUSH_LIFECYCLE_BTN} onPress={this.pushLifecycleScreen} />
39
+        <Button label='Pop None Existent Screen' testID={POP_NONE_EXISTENT_SCREEN_BTN} onPress={this.popNoneExistent} />
40
+        <Button label='Push Custom Back Button' testID={PUSH_CUSTOM_BACK_BTN} onPress={this.pushCustomBackButton} />
41
+        <Button label='Set Stack Root' testID={SET_STACK_ROOT_BTN} onPress={this.setStackRoot} />
42
+        <Button label='Search' testID={SEARCH_BTN} onPress={this.search} />
43
+      </Root>
44
+    );
45
+  }
46
+
47
+  push = () => Navigation.push(this, Screens.Pushed);
48
+
49
+  pushLifecycleScreen = () => Navigation.push(this, Screens.Lifecycle);
50
+
51
+  popNoneExistent = () => Navigation.pop('noneExistentComponentId');
52
+
53
+  pushCustomBackButton = () => Navigation.push(this, {
54
+    component: {
55
+      name: Screens.Pushed,
56
+      options: {
57
+        topBar: {
58
+          backButton: {
59
+            id: 'backPress',
60
+            icon: require('../../img/navicon_add.png'),
61
+            visible: true,
62
+            color: 'black',
63
+            testID: CUSTOM_BACK_BTN
64
+          }
65
+        }
66
+      }
67
+    }
68
+  });
69
+
70
+  search = () => Navigation.push(this, Screens.Search);
71
+
72
+  setStackRoot = () => Navigation.setStackRoot(this, stack([
73
+    component(Screens.Pushed, { topBar: { title: { text: 'Screen A' } } }),
74
+    component(Screens.Pushed, { topBar: { title: { text: 'Screen B' } } }),
75
+  ]));
76
+}
77
+
78
+module.exports = StackScreen;

+ 42
- 0
playground/src/screens/StaticEventsScreen.js View File

@@ -0,0 +1,42 @@
1
+const React = require('react');
2
+const Navigation = require('../services/Navigation');
3
+const Root = require('../components/Root');
4
+const Button = require('../components/Button');
5
+const {
6
+  PUSH_BTN,
7
+  POP_BTN,
8
+  STATIC_EVENTS_OVERLAY_BTN,
9
+  MODAL_BTN
10
+} = require('../testIDs');
11
+const Screens = require('./Screens');
12
+
13
+class StaticEventsScreen extends React.Component {
14
+  render() {
15
+    return (
16
+      <Root componentId={this.props.componentId}>
17
+        <Button label='Show Overlay' testID={STATIC_EVENTS_OVERLAY_BTN} onPress={this.showEventsOverlay} />
18
+        <Button label='Push' testID={PUSH_BTN} onPress={this.push} />
19
+        <Button label='Pop' testID={POP_BTN} onPress={this.pop} />
20
+        <Button label='Show Modal' testID={MODAL_BTN} onPress={this.showModal} />
21
+      </Root>
22
+    );
23
+  }
24
+
25
+  showModal = () => {
26
+    Navigation.showModal({
27
+      component: {
28
+        name: Screens.Modal
29
+      }
30
+    });
31
+  }
32
+
33
+  showEventsOverlay = () => Navigation.showOverlay(Screens.EventsOverlay, {
34
+    overlay: {
35
+      interceptTouchOutside: false
36
+    }
37
+  });
38
+  push = () => Navigation.push(this, Screens.Pushed);
39
+  pop = () => Navigation.pop(this);
40
+}
41
+
42
+module.exports = StaticEventsScreen;

+ 9
- 2
playground/src/screens/StaticLifecycleOverlay.js View File

@@ -2,9 +2,16 @@ const React = require('react');
2 2
 const { Component } = require('react');
3 3
 const { View, Text, TouchableOpacity } = require('react-native');
4 4
 const { Navigation } = require('react-native-navigation');
5
-const testIDs = require('../testIDs');
5
+const TestIDs = require('../testIDs');
6 6
 
7 7
 class StaticLifecycleOverlay extends Component {
8
+  static options() {
9
+    return {
10
+      layout: {
11
+        componentBackgroundColor: 'transparent'
12
+      }
13
+    }
14
+  }
8 15
   constructor(props) {
9 16
     super(props);
10 17
     this.state = {
@@ -83,7 +90,7 @@ class StaticLifecycleOverlay extends Component {
83 90
         style={styles.dismissBtn}
84 91
         onPress={() => Navigation.dismissOverlay(this.props.componentId)}
85 92
       >
86
-        <Text testID={testIDs.DISMISS_BUTTON} style={{ color: 'red', alignSelf: 'center' }}>X</Text>
93
+        <Text testID={TestIDs.DISMISS_BTN} style={{ color: 'red', alignSelf: 'center' }}>X</Text>
87 94
       </TouchableOpacity>
88 95
     );
89 96
   }

+ 26
- 40
playground/src/screens/index.js View File

@@ -1,72 +1,58 @@
1 1
 const React = require('react');
2 2
 const { Navigation } = require('react-native-navigation');
3
-const WelcomeScreen = require('./WelcomeScreen');
4
-const TextScreen = require('./TextScreen');
5
-const PushedScreen = require('./PushedScreen');
6
-const LifecycleScreen = require('./LifecycleScreen');
7
-const StaticLifecycleOverlay = require('./StaticLifecycleOverlay');
8
-const ModalScreen = require('./ModalScreen');
9
-const OptionsScreen = require('./OptionsScreen');
10
-const OrientationSelectScreen = require('./OrientationSelectScreen');
11
-const OrientationDetectScreen = require('./OrientationDetectScreen');
12 3
 const ScrollViewScreen = require('./ScrollViewScreen');
13 4
 const CustomTransitionOrigin = require('./CustomTransitionOrigin');
14 5
 const CustomTransitionDestination = require('./CustomTransitionDestination');
15
-const CustomDialog = require('./CustomDialog');
16 6
 const CustomDialogWithScroll = require('./complexlayouts/CustomDialogWithScroll');
17
-const BandHandlerScreen = require('./BackHandlerScreen');
18
-const SideMenuScreen = require('./SideMenuScreen');
19 7
 const TopTabScreen = require('./TopTabScreen');
20 8
 const TopTabOptionsScreen = require('./TopTabOptionsScreen');
21
-const CustomTopBar = require('./CustomTopBar');
22
-const Alert = require('./Alert');
23
-const BackHandlerModalScreen = require('./BackHandlerModalScreen');
24 9
 const CustomTextButton = require('./CustomTextButton');
25
-const CustomRoundedButton = require('./CustomRoundedButton');
26 10
 const TopBarBackground = require('./TopBarBackground');
27
-const ComplexLayout = require('./ComplexLayout');
28
-const SearchScreen = require('./SearchScreen');
29 11
 const KeyboardScreen = require('./KeyboardScreen');
30
-const BottomTabSideMenuScreen = require('./complexlayouts/BottomTabSideMenuScreen');
31
-const FlatListScreen = require('./FlatListScreen');
32 12
 const ContextScreen = require('./ContextScreen');
33 13
 const { ContextProvider } = require('../context');
14
+const Screens = require('./Screens');
34 15
 
35 16
 function registerScreens() {
17
+  Navigation.registerComponent(Screens.Layouts, () => require('./LayoutsScreen'));
18
+  Navigation.registerComponent(Screens.Options, () => require('./OptionsScreen'));
19
+  Navigation.registerComponent(Screens.StackScreen, () => require('./StackScreen'));
20
+  Navigation.registerComponent(Screens.Pushed, () => require('./PushedScreen'));
21
+  Navigation.registerComponent(Screens.Modal, () => require('./ModalScreen'))
22
+  Navigation.registerComponent(Screens.Navigation, () => require('./NavigationScreen'));
23
+  Navigation.registerComponent(Screens.FirstBottomTabsScreen, () => require('./FirstBottomTabScreen'));
24
+  Navigation.registerComponent(Screens.SecondBottomTabsScreen, () => require('./SecondBottomTabScreen'));
25
+  Navigation.registerComponent(Screens.Lifecycle, () => require('./LifecycleScreen'));
26
+  Navigation.registerComponent(Screens.Overlay, () => require('./OverlayScreen'));
27
+  Navigation.registerComponent(Screens.OverlayAlert, () => require('./OverlayAlert'));
28
+  Navigation.registerComponent(Screens.RoundButton, () => require('./RoundedButton'));
29
+  Navigation.registerComponent(Screens.ReactTitleView, () => require('./CustomTopBar'));
30
+  Navigation.registerComponent(Screens.EventsScreen, () => require('./StaticEventsScreen'));
31
+  Navigation.registerComponent(Screens.EventsOverlay, () => require('./StaticLifecycleOverlay'));
32
+  Navigation.registerComponent(Screens.SideMenuLeft, () => require('./SideMenuLeftScreen'));
33
+  Navigation.registerComponent(Screens.SideMenuCenter, () => require('./SideMenuCenterScreen'));
34
+  Navigation.registerComponent(Screens.SideMenuRight, () => require('./SideMenuRightScreen'));
35
+  Navigation.registerComponent(Screens.FlatListScreen, () => require('./FlatListScreen'));
36
+  Navigation.registerComponent(Screens.Alert, () => require('./Alert'));
37
+  Navigation.registerComponent(Screens.Orientation, () => require('./OrientationScreen'));
38
+  Navigation.registerComponent(Screens.OrientationDetect, () => require('./OrientationDetectScreen'));
39
+  Navigation.registerComponent(Screens.Search, () => require('./SearchScreen'));
40
+
36 41
   Navigation.registerComponent(`navigation.playground.CustomTransitionDestination`, () => CustomTransitionDestination);
37 42
   Navigation.registerComponent(`navigation.playground.CustomTransitionOrigin`, () => CustomTransitionOrigin);
38 43
   Navigation.registerComponent(`navigation.playground.ScrollViewScreen`, () => ScrollViewScreen);
39
-  Navigation.registerComponent(`navigation.playground.WelcomeScreen`, () => WelcomeScreen);
40
-  Navigation.registerComponent(`navigation.playground.ModalScreen`, () => ModalScreen);
41
-  Navigation.registerComponent(`navigation.playground.LifecycleScreen`, () => LifecycleScreen);
42
-  Navigation.registerComponent(`navigation.playground.StaticLifecycleOverlay`, () => StaticLifecycleOverlay);
43
-  Navigation.registerComponent(`navigation.playground.TextScreen`, () => TextScreen);
44
-  Navigation.registerComponent('navigation.playground.PushedScreen', () => PushedScreen);
45
-  Navigation.registerComponent('navigation.playground.ContextScreen',() => (props) =>
44
+  Navigation.registerComponent('navigation.playground.ContextScreen', () => (props) =>
46 45
     <ContextProvider>
47 46
       <ContextScreen {...props} />
48 47
     </ContextProvider>,
49 48
     () => ContextScreen);
50
-  Navigation.registerComponent(`navigation.playground.OptionsScreen`, () => OptionsScreen);
51
-  Navigation.registerComponent(`navigation.playground.OrientationSelectScreen`, () => OrientationSelectScreen);
52
-  Navigation.registerComponent(`navigation.playground.OrientationDetectScreen`, () => OrientationDetectScreen);
53 49
   Navigation.registerComponent('navigation.playground.CustomDialog', () => CustomDialog);
54 50
   Navigation.registerComponent('navigation.playground.CustomDialogWithScroll', () => CustomDialogWithScroll);
55
-  Navigation.registerComponent('navigation.playground.BackHandlerScreen', () => BandHandlerScreen);
56
-  Navigation.registerComponent('navigation.playground.SideMenuScreen', () => SideMenuScreen);
57 51
   Navigation.registerComponent('navigation.playground.TopTabScreen', () => TopTabScreen);
58 52
   Navigation.registerComponent('navigation.playground.TopTabOptionsScreen', () => TopTabOptionsScreen);
59
-  Navigation.registerComponent('navigation.playground.CustomTopBar', () => CustomTopBar);
60
-  Navigation.registerComponent('navigation.playground.alert', () => Alert);
61
-  Navigation.registerComponent('navigation.playground.BackHandlerModalScreen', () => BackHandlerModalScreen);
62
-  Navigation.registerComponent('navigation.playground.ComplexLayout', () => ComplexLayout);
63 53
   Navigation.registerComponent('CustomTextButton', () => CustomTextButton);
64
-  Navigation.registerComponent('CustomRoundedButton', () => CustomRoundedButton);
65 54
   Navigation.registerComponent('TopBarBackground', () => TopBarBackground);
66
-  Navigation.registerComponent('navigation.playground.SearchControllerScreen', () => SearchScreen);
67 55
   Navigation.registerComponent('navigation.playground.KeyboardScreen', () => KeyboardScreen);
68
-  Navigation.registerComponent('complexLayout.bottomTabThatOpensSideMenu', () => BottomTabSideMenuScreen);
69
-  Navigation.registerComponent('navigation.playground.FlatListScreen', () => FlatListScreen);
70 56
 }
71 57
 
72 58
 module.exports = {

+ 52
- 0
playground/src/services/Navigation.js View File

@@ -0,0 +1,52 @@
1
+const { isString, get } = require('lodash');
2
+const { stack, component } = require('../commons/Layouts');
3
+const { Navigation } = require('react-native-navigation');
4
+
5
+const push = (selfOrCompId, screen) => Navigation.push(compId(selfOrCompId), isString(screen) ? component(screen) : screen);
6
+
7
+const pushExternalComponent = (self, name, passProps) => Navigation.push(self.props.componentId, {
8
+  externalComponent: {
9
+    name,
10
+    passProps
11
+  }
12
+});
13
+
14
+const pop = (selfOrCompId) => Navigation.pop(compId(selfOrCompId));
15
+
16
+const showModal = (screen) => Navigation.showModal(isString(screen) ? stack(screen) : screen);
17
+
18
+const dismissModal = (selfOrCompId) => Navigation.dismissModal(compId(selfOrCompId));
19
+
20
+const dismissAllModals = () => Navigation.dismissAllModals();
21
+
22
+const showOverlay = (name, options) => Navigation.showOverlay(component(name, options));
23
+
24
+const dismissOverlay = (name) => Navigation.dismissOverlay(name);
25
+
26
+const popToRoot = (self) => Navigation.popToRoot(self.props.componentId);
27
+
28
+const mergeOptions = (self, options) => Navigation.mergeOptions(self.props.componentId, options);
29
+
30
+const setStackRoot = (self, root) => Navigation.setStackRoot(self.props.componentId, root)
31
+
32
+const compId = (selfOrCompId) => {
33
+  return get(selfOrCompId, 'props.componentId', selfOrCompId);
34
+}
35
+
36
+module.exports = {
37
+  mergeOptions,
38
+  push,
39
+  pushExternalComponent,
40
+  pop,
41
+  popToRoot,
42
+  showModal,
43
+  dismissModal,
44
+  dismissAllModals,
45
+  showOverlay,
46
+  dismissOverlay,
47
+  events: Navigation.events.bind(Navigation),
48
+  popTo: Navigation.popTo.bind(Navigation),
49
+  setDefaultOptions: Navigation.setDefaultOptions.bind(Navigation),
50
+  setRoot: Navigation.setRoot.bind(Navigation),
51
+  setStackRoot
52
+}

+ 90
- 51
playground/src/testIDs.js View File

@@ -1,92 +1,132 @@
1 1
 
2 2
 module.exports = {
3
+  // Layouts
4
+  STACK_BTN: 'STACK_BUTTON',
5
+  BOTTOM_TABS_BTN: 'BOTTOM_TABS_BUTTON',
6
+  EXTERNAL_COMP_BTN: 'EXTERNAL_COMPONENT_BUTTON',
7
+  LAYOUTS_TAB: 'LAYOUTS_TAB',
8
+  NAVIGATION_TAB: 'NAVIGATION_TAB',
9
+  OPTIONS_TAB: 'OPTIONS_TAB',
10
+  SIDE_MENU_INSIDE_BOTTOM_TABS_BTN: 'SIDE_MENU_INSIDE_BOTTOM_TABS',
11
+  OVERLAY_BTN: 'OVERLAY_BTN',
12
+  SIDE_MENU_BTN: 'SIDE_MENU_BTN',
13
+  MODAL_BTN: 'SHOW_MODAL_BUTTON',
14
+  DISMISS_MODAL_BTN: 'DISMISS_MODAL_BUTTON',
15
+  MODAL_SCREEN_HEADER: 'MODAL_SCREEN_HEADER',
16
+  ALERT_BUTTON: 'ALERT_BUTTON',
17
+  OVERLAY_ALERT_HEADER: 'OVERLAY_ALERT_HEADER',
18
+  SHOW_OVERLAY_BTN: 'SHOW_OVERLAY_BTN',
19
+  SHOW_TOUCH_THROUGH_OVERLAY_BTN: 'SHOW_TOUCH_THROUGH_OVERLAY_BTN',
20
+  DISMISS_BTN: 'DISMISS_BTN',
21
+  STACK_SCREEN_HEADER: 'STACK_SCREEN_HEADER',
22
+  PUSH_NO_ANIM_BTN: 'PUSH_NO_ANIM_BTN',
23
+  POP_TO_FIRST_SCREEN_BTN: 'POP_TO_FIRST_SCREEN_BTN',
24
+  POP_NONE_EXISTENT_SCREEN: 'POP_NONE_EXISTENT_SCREEN',
25
+  MULTI_CHILD_STACK_BTN: 'MULTI_CHILD_STACK_BTN',
26
+  EXTERNAL_COMP_SCREEN_HEADER: 'EXTERNAL_COMPONENT_SCREEN_HEADER',
27
+  TOP_BAR: 'TOP_BAR',
28
+  PUSH_BTN: 'PUSH_BUTTON',
29
+  SHOW_STATIC_EVENTS_SCREEN: 'SHOW_STATIC_EVENTS_SCREEN',
30
+  POP_BTN: 'POP_BUTTON',
31
+  BACK_HANDLER_BTN: 'BACK_HANDLER_BUTTON',
32
+  POP_TO_ROOT_BTN: 'POP_TO_ROOT',
33
+  POP_NONE_EXISTENT_SCREEN_BTN: 'POP_NONE_EXISTENT_SCREEN_BTN',
34
+  TOP_BAR_BTN: 'TOP_BAR_BUTTON',
35
+  CUSTOM_BACK_BTN: 'CUSTOM_BACK_BUTTON',
36
+  PUSH_CUSTOM_BACK_BTN: 'PUSH_CUSTOM_BACK_BTN',
37
+  SWITCH_TAB_BY_INDEX_BTN: 'SWITCH_TAB_BY_INDEX_BTN',
38
+  SWITCH_TAB_BY_COMPONENT_ID_BTN: 'SWITCH_TAB_BY_COMPONENT_ID_BTN',
39
+  PUSHED_BOTTOM_TABS: 'PUSHED_BOTTOM_TABS',
40
+  CHANGE_TITLE_BTN: 'CHANGE_TITLE_BTN',
41
+  SHOW_TOP_BAR_BTN: 'SHOW_TOP_BAR_BUTTON',
42
+  HIDE_TOP_BAR_BTN: 'HIDE_TOP_BAR_BUTTON',
43
+  SET_BADGE_BTN: 'SET_BADGE_BTN',
44
+  CLEAR_BADGE_BTN: 'CLEAR_BADGE_BTN',
45
+  BOTTOM_TABS: 'BOTTOM_TABS',
46
+  HIDE_TABS_BTN: 'HIDE_TABS_BTN',
47
+  SHOW_TABS_BTN: 'SHOW_TABS_BTN',
48
+  HIDE_TABS_PUSH_BTN: 'HIDE_TABS_PUSH_BTN',
49
+  ROUND_BUTTON: 'ROUND_BUTTON',
50
+  BUTTON_ONE: 'BUTTON_ONE',
51
+  LEFT_BUTTON: 'LEFT_BUTTON',
52
+  HIDE_TOPBAR_DEFAULT_OPTIONS: 'HIDE_TOPBAR_DEFAULT_OPTIONS',
53
+  SET_TOPBAR_REACT_VIEW: 'SET_TOPBAR_REACT_VIEW',
54
+  SHOW_YELLOW_BOX_BTN: 'SHOW_YELLOW_BOX_BTN',
55
+  SET_REACT_TITLE_VIEW: 'SET_REACT_TITLE_VIEW',
56
+  STATIC_EVENTS_OVERLAY_BTN: 'STATIC_EVENTS_OVERLAY_BTN',
57
+  PUSH_LIFECYCLE_BTN: 'PUSH_LIFECYCLE_BTN',
58
+  MODAL_LIFECYCLE_BTN: 'MODAL_LIFECYCLE_BTN',
59
+  DISMISS_ALL_PREVIOUS_MODAL_BTN: 'DISMISS_ALL_PREVIOUS_MODAL_BTN',
60
+  DISMISS_PREVIOUS_MODAL_BTN: 'DISMISS_PREVIOUS_MODAL_BTN',
61
+  DISMISS_UNKNOWN_MODAL_BTN: 'DISMISS_UNKNOWN_MODAL_BTN',
62
+  PUSH_TO_TEST_DID_DISAPPEAR_BTN: 'PUSH_TO_TEST_DID_DISAPPEAR_BTN',
63
+  SET_ROOT_BTN: 'SET_ROOT_BTN',
64
+  ADD_BACK_HANDLER: 'ADD_BACK_HANDLER',
65
+  REMOVE_BACK_HANDLER: 'REMOVE_BACK_HANDLER',
66
+  OPEN_LEFT_SIDE_MENU_BTN: 'OPEN_LEFT_SIDE_MENU_BTN',
67
+  OPEN_RIGHT_SIDE_MENU_BTN: 'OPEN_RIGHT_SIDE_MENU_BUTTON',
68
+  CLOSE_LEFT_SIDE_MENU_BTN: 'CLOSE_LEFT_SIDE_MENU_BTN',
69
+  CLOSE_RIGHT_SIDE_MENU_BTN: 'CLOSE_RIGHT_SIDE_MENU_BTN',
70
+  SIDE_MENU_PUSH_BTN: 'SIDE_MENU_PUSH_BUTTON',
71
+  LEFT_SIDE_MENU_PUSH_BTN: 'LEFT_SIDE_MENU_PUSH_BUTTON',
72
+  LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN: 'LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN',
73
+  RIGHT_SIDE_MENU_PUSH_BTN: 'RIGHT_SIDE_MENU_PUSH_BUTTON',
74
+  CENTER_SCREEN_HEADER: 'CENTER_SCREEN_HEADER',
75
+  SIDE_MENU_TAB: 'SIDE_MENU_TAB',
76
+  FLAT_LIST_BTN: 'FLAT_LIST_BTN',
77
+  SHOW_ORIENTATION_SCREEN: 'SHOW_ORIENTATION_SCREEN',
78
+  DEFAULT_ORIENTATION_BTN: 'DEFAULT_ORIENTATION_BTN',
79
+  LANDSCAPE_PORTRAIT_ORIENTATION_BTN: 'LANDSCAPE_PORTRAIT_ORIENTATION_BTN',
80
+  PORTRAIT_ORIENTATION_BTN: 'PORTRAIT_ORIENTATION_BTN',
81
+  LANDSCAPE_ORIENTATION_BTN: 'LANDSCAPE_ORIENTATION_BTN',
82
+  DISMISS_BTN: 'DISMISS_BTN',
83
+  SEARCH_BTN: 'SEARCH_BTN',
84
+  SET_STACK_ROOT_BTN: 'SET_STACK_ROOT_BTN',
3 85
 
4 86
   // Buttons
5 87
   TAB_BASED_APP_BUTTON: `TAB_BASED_APP_BUTTON`,
6 88
   TAB_BASED_APP_SIDE_BUTTON: `TAB_BASED_APP_SIDE_BUTTON`,
7
-  PUSH_LIFECYCLE_BUTTON: `PUSH_LIFECYCLE_BUTTON`,
8 89
   PUSH_STATIC_LIFECYCLE_BUTTON: `PUSH_STATIC_LIFECYCLE_BUTTON`,
9
-  PUSH_BUTTON: `PUSH_BUTTON`,
10 90
   PUSH_CONTEXT_SCREEN_BUTTON: `PUSH_CONTEXT_SCREEN_BUTTON`,
11
-  SHOW_YELLOW_BOX: `SHOW_YELLOW_BOX`,
12
-  SIDE_MENU_PUSH_BUTTON: `SIDE_MENU_PUSH_BUTTON`,
13
-  LEFT_SIDE_MENU_PUSH_BUTTON: `leftSIDE_MENU_PUSH_BUTTON`,
14
-  RIGHT_SIDE_MENU_PUSH_BUTTON: `rightSIDE_MENU_PUSH_BUTTON`,
15 91
   PUSH_OPTIONS_BUTTON: `PUSH_OPTIONS_BUTTON`,
16 92
   PUSH_DEFAULT_OPTIONS_BUTTON: `PUSH_DEFAULT_OPTIONS_BUTTON`,
17
-  SHOW_TOPBAR_REACT_VIEW: `SHOW_TOPBAR_REACT_VIEW`,
18
-  BACK_HANDLER_BUTTON: `BACK_HANDLER_BUTTON`,
19
-  CUSTOM_BACK_BUTTON: `CUSTOM_BACK_BUTTON`,
20
-  SHOW_MODAL_BUTTON: `SHOW_MODAL_BUTTON`,
21 93
   SHOW_REDBOX_BUTTON: `SHOW_REDBOX_BUTTON`,
22
-  ORIENTATION_BUTTON: `ORIENTATION_BUTTON`,
94
+  ORIENTATION_BTN: `ORIENTATION_BUTTON`,
23 95
   PROVIDED_ID: `PROVIDED_ID`,
24
-  DISMISS_MODAL_BUTTON: `DISMISS_MODAL_BUTTON`,
25
-  DISMISS_UNKNOWN_MODAL_BUTTON: `DISMISS_UNKNOWN_MODAL_BUTTON`,
26
-  DISMISS_ALL_MODALS_BUTTON: `DISMISS_ALL_MODALS_BUTTON`,
27
-  DISMISS_PREVIOUS_MODAL_BUTTON: `DISMISS_PREVIOUS_MODAL_BUTTON`,
28
-  DISMISS_ALL_PREVIOUS_MODAL_BUTTON: `DISMISS_ALL_PREVIOUS_MODAL_BUTTON`,
29
-  DISMISS_FIRST_MODAL_BUTTON: `DISMISS_FIRST_MODAL_BUTTON`,
30
-  DEFAULT_ORIENTATION_BUTTON: `DEFAULT_ORIENTATION_BUTTON`,
31
-  LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON: `LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON`,
32
-  PORTRAIT_ORIENTATION_BUTTON: `PORTRAIT_ORIENTATION_BUTTON`,
33
-  LANDSCAPE_ORIENTATION_BUTTON: `LANDSCAPE_ORIENTATION_BUTTON`,
34
-  DISMISS_BUTTON: `DISMISS_BUTTON`,
35
-  POP_BUTTON: `POP_BUTTON`,
96
+  DISMISS_ALL_MODALS_BTN: `DISMISS_ALL_MODALS_BUTTON`,
97
+  DISMISS_FIRST_MODAL_BTN: `DISMISS_FIRST_MODAL_BUTTON`,
36 98
   POP_PREVIOUS_BUTTON: `POP_PREVIOUS_BUTTON`,
37
-  POP_TO_ROOT: `POP_TO_ROOT`,
38 99
   POP_STACK_POSITION_ONE_BUTTON: `POP_STACK_POSITION_ONE_BUTTON`,
39
-  SWITCH_SECOND_TAB_BUTTON: `SWITCH_SECOND_TAB_BUTTON`,
40
-  SWITCH_FIRST_TAB_BUTTON: `SWITCH_FIRST_TAB_BUTTON`,
41 100
   DYNAMIC_OPTIONS_BUTTON: `DYNAMIC_OPTIONS_BUTTON`,
42
-  SHOW_TOP_BAR_BUTTON: `SHOW_TOP_BAR_BUTTON`,
43
-  HIDE_TOP_BAR_BUTTON: `HIDE_TOP_BAR_BUTTON`,
44
-  TOP_BAR_BUTTON: `TOP_BAR_BUTTON`,
45 101
   SCROLLVIEW_SCREEN_BUTTON: `SCROLLVIEW_SCREEN_BUTTON`,
46 102
   HIDE_FAB: `HIDE_FAB`,
47 103
   SHOW_SNACKBAR_BUTTON: `SHOW_SNACKBAR_BUTTON`,
48 104
   TOGGLE_TOP_BAR_HIDE_ON_SCROLL: `TOGGLE_TOP_BAR_HIDE_ON_SCROLL`,
49 105
   SET_TAB_BADGE_BUTTON: `SET_TAB_BADGE_BUTTON`,
50 106
   SET_TAB_BADGE_BUTTON_NULL: `SET_TAB_BADGE_BUTTON_NULL`,
51
-  PUSH_TO_TEST_DID_DISAPPEAR_BUTTON: `PUSH_TO_TEST_DID_DISAPPEAR_BUTTON`,
52 107
   PUSH_BUTTON_WAIT_FOR_RENDER: `PUSH_AND_WAIT_FOR_RENDER`,
53 108
   PUSH_CUSTOM_BACK_BUTTON: `PUSH_CUSTOM_BACK_BUTTON`,
54
-  SHOW_LEFT_SIDE_MENU_BUTTON: `SHOW_LEFT_SIDE_MENU_BUTTON`,
55
-  SHOW_RIGHT_SIDE_MENU_BUTTON: `SHOW_RIGHT_SIDE_MENU_BUTTON`,
56
-  HIDE_LEFT_SIDE_MENU_BUTTON: `HIDE_LEFT_SIDE_MENU_BUTTON`,
57
-  HIDE_RIGHT_SIDE_MENU_BUTTON: `HIDE_RIGHT_SIDE_MENU_BUTTON`,
58
-  HIDE_BOTTOM_TABS_BUTTON: `HIDE_BOTTOM_TABS_BUTTON`,
59 109
   SHOW_BOTTOM_TABS_BUTTON: `SHOW_BOTTOM_TABS_BUTTON`,
60 110
   FIRST_TAB_BAR_BUTTON: `FIRST_TAB_BAR_BUTTON`,
61
-  SECOND_TAB_BAR_BUTTON: `SECOND_TAB_BAR_BUTTON`,
62
-  THIRD_TAB_BAR_BUTTON: `THIRD_TAB_BAR_BUTTON`,
63
-  SHOW_OVERLAY_BUTTON: `SHOW_OVERLAY_BUTTON`,
111
+  SECOND_TAB_BAR_BTN: `SECOND_TAB_BAR_BUTTON`,
112
+  THIRD_TAB_BAR_BTN: `THIRD_TAB_BAR_BUTTON`,
64 113
   SHOW_TOUCH_THROUGH_OVERLAY_SCROLLER: `SHOW_TOUCH_THROUGH_OVERLAY_SCROLLER`,
65
-  SHOW_TOUCH_THROUGH_OVERLAY_BUTTON: `SHOW_TOUCH_THROUGH_OVERLAY_BUTTON`,
66 114
   OK_BUTTON: `OK_BUTTON`,
67 115
   MODAL_WITH_STACK_BUTTON: `MODAL_WITH_STACK_BUTTON`,
68 116
   CUSTOM_TRANSITION_BUTTON: `CUSTOM_TRANSITION_BUTTON`,
69
-  PUSH_EXTERNAL_COMPONENT_BUTTON: `PUSH_EXTERNAL_COMPONENT_BUTTON`,
70 117
   COMPLEX_LAYOUT_BUTTON: `COMPLEX_LAYOUT_BUTTON`,
71 118
   EXTERNAL_COMPONENT_IN_STACK: `EXTERNAL_COMPONENT_IN_STACK`,
72
-  EXTERNAL_COMPONENT_IN_DEEP_STACK: `EXTERNAL_COMPONENT_IN_DEEP_STACK`,
73
-  SET_STACK_ROOT_BUTTON: `SET_STACK_ROOT_BUTTON`,
74
-  MODAL_LIFECYCLE_BUTTON: `MODAL_LIFECYCLE_BUTTON`,
75 119
   SPLIT_VIEW_BUTTON: `SPLIT_VIEW_BUTTON`,
76 120
   SHOW_PREVIEW_BUTTON: `SHOW_PREVIEW_BUTTON`,
77
-  SHOW_TOPBAR_SEARCHBAR: `SHOW_TOPBAR_SEARCHBAR`,
78 121
   SEARCH_RESULT_ITEM: `SEARCH_RESULT_ITEM`,
79
-  HIDE_BOTTOM_TABS_ON_PUSH_BUTTON: `HIDE_BOTTOM_TABS_ON_PUSH_BUTTON`,
80 122
   SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB: `SIDE_MENU_LAYOUT_INSIDE_BOTTOM_TAB`,
81
-  OPEN_SIDE_MENU: `OPEN_SIDE_MENU`,
82
-  SET_ROOT_BUTTON: `SET_ROOT_BUTTON`,
83 123
   SET_INTERCEPT_TOUCH: `SET_INTERCEPT_TOUCH`,
84 124
   PUSH_BOTTOM_TABS_BUTTON: `PUSH_BOTTOM_TABS_BUTTON`,
85
-  
125
+  SET_STACK_ROOT_BUTTON: `SET_STACK_ROOT_BUTTON`,
126
+
86 127
   // Elements
87 128
   SCROLLVIEW_ELEMENT: `SCROLLVIEW_ELEMENT`,
88 129
   BOTTOM_TABS_ELEMENT: `BOTTOM_TABS_ELEMENT`,
89
-  TOP_BAR_ELEMENT: `TOP_BAR_ELEMENT`,
90 130
   LANDSCAPE_ELEMENT: `LANDSCAPE_ELEMENT`,
91 131
   PORTRAIT_ELEMENT: `PORTRAIT_ELEMENT`,
92 132
 
@@ -95,6 +135,5 @@ module.exports = {
95 135
   PUSHED_SCREEN_HEADER: `PUSHED_SCREEN_HEADER`,
96 136
   OPTIONS_SCREEN_HEADER: `OPTIONS_SCREEN_HEADER`,
97 137
   MODAL_SCREEN: `MODAL_SCREEN`,
98
-  CENTERED_TEXT_HEADER: `CENTERED_TEXT_HEADER`,
99
-  DIALOG_HEADER: `DIALOG_HEADER`
138
+  CENTERED_TEXT_HEADER: `CENTERED_TEXT_HEADER`
100 139
 };