react-native-navigation 7.23.1 → 7.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/.buildkite/pipeline.yml +51 -11
  2. package/.nvmrc +1 -0
  3. package/Mock.d.ts +1 -0
  4. package/Mock.js +4 -0
  5. package/Mock.ts +1 -1
  6. package/README.md +0 -1
  7. package/jest.config.js +40 -0
  8. package/lib/{src/Mock → Mock}/Application.tsx +0 -0
  9. package/lib/{src/Mock → Mock}/ComponentProps.tsx +0 -0
  10. package/lib/{src/Mock → Mock}/Components/BottomTabs.tsx +0 -0
  11. package/lib/{src/Mock → Mock}/Components/ComponentScreen.tsx +13 -2
  12. package/lib/{src/Mock → Mock}/Components/LayoutComponent.tsx +0 -0
  13. package/lib/{src/Mock → Mock}/Components/Modals.tsx +0 -0
  14. package/lib/{src/Mock → Mock}/Components/NavigationButton.tsx +1 -1
  15. package/lib/{src/Mock → Mock}/Components/Overlays.tsx +0 -0
  16. package/lib/{src/Mock → Mock}/Components/Stack.tsx +0 -0
  17. package/lib/{src/Mock → Mock}/Components/TopBar.tsx +2 -2
  18. package/lib/{src/Mock → Mock}/Layouts/BottomTabsNode.ts +1 -1
  19. package/lib/{src/Mock → Mock}/Layouts/ComponentNode.ts +1 -1
  20. package/lib/{src/Mock → Mock}/Layouts/LayoutNodeFactory.ts +0 -0
  21. package/lib/{src/Mock → Mock}/Layouts/Node.ts +1 -1
  22. package/lib/{src/Mock → Mock}/Layouts/ParentNode.ts +2 -2
  23. package/lib/{src/Mock → Mock}/Layouts/StackNode.ts +0 -0
  24. package/lib/{src/Mock → Mock}/Stores/EventsStore.ts +10 -2
  25. package/lib/{src/Mock → Mock}/Stores/LayoutStore.ts +3 -2
  26. package/lib/{src/Mock → Mock}/connect.ts +0 -0
  27. package/lib/Mock/constants.d.ts +2 -0
  28. package/lib/Mock/constants.js +5 -0
  29. package/lib/{src/Mock → Mock}/constants.ts +0 -0
  30. package/lib/Mock/index.d.ts +3 -0
  31. package/lib/Mock/index.js +14 -0
  32. package/lib/{src/Mock → Mock}/index.ts +0 -0
  33. package/lib/{src/Mock → Mock}/mocks/AppRegistryService.ts +0 -0
  34. package/lib/{src/Mock → Mock}/mocks/NativeCommandsSender.tsx +1 -1
  35. package/lib/{src/Mock → Mock}/mocks/NativeEventsReceiver.ts +7 -4
  36. package/lib/android/app/build.gradle +23 -21
  37. package/lib/android/app/src/main/java/com/reactnativenavigation/options/FontOptions.kt +2 -2
  38. package/lib/android/app/src/main/java/com/reactnativenavigation/options/HardwareBackButtonOptions.kt +35 -2
  39. package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutFactory.java +32 -17
  40. package/lib/android/app/src/main/java/com/reactnativenavigation/options/Options.java +1 -1
  41. package/lib/android/app/src/main/java/com/reactnativenavigation/options/parsers/TypefaceLoader.kt +16 -10
  42. package/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java +5 -2
  43. package/lib/android/app/src/main/java/com/reactnativenavigation/react/modal/ModalFrameLayout.kt +3 -3
  44. package/lib/android/app/src/main/java/com/reactnativenavigation/react/modal/ModalViewManager.kt +11 -8
  45. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/SystemUiUtils.kt +168 -0
  46. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenter.java +5 -2
  47. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsController.java +42 -2
  48. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java +12 -16
  49. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +19 -11
  50. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewController.java +2 -2
  51. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenter.java +6 -4
  52. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManager.kt +8 -3
  53. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackController.java +15 -7
  54. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenter.java +127 -138
  55. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/TopBarController.kt +183 -22
  56. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonController.kt +25 -4
  57. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonPresenter.kt +9 -1
  58. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/stack/topbar/button/ButtonSpan.kt +1 -1
  59. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +52 -71
  60. package/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java +2 -0
  61. package/lib/android/app/src/main/java/com/reactnativenavigation/views/element/animators/ReactImageMatrixAnimator.kt +2 -3
  62. package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/TopBar.java +1 -2
  63. package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/ButtonBar.kt +7 -12
  64. package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt +0 -2
  65. package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleSubTitleLayout.kt +0 -7
  66. package/lib/android/app/src/reactNative51/java/com/reactnativenavigation/react/NavigationReactNativeHost.java +2 -1
  67. package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +7 -6
  68. package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +5 -0
  69. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +5 -4
  70. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +3 -2
  71. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +5 -1
  72. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +2 -3
  73. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +25 -10
  74. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +25 -2
  75. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +1 -1
  76. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/{TitleAndButtonsMeasurer.kt → TitleAndButtonsMeasurerTest.kt} +2 -2
  77. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +2 -2
  78. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +1 -1
  79. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +572 -0
  80. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +1 -1
  81. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +2 -1
  82. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +5 -5
  83. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +1 -1
  84. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +1 -1
  85. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +7 -3
  86. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +17 -4
  87. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +2 -2
  88. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +5 -5
  89. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +1 -0
  90. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +4 -0
  91. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +6 -2
  92. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +1 -1
  93. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +13 -8
  94. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +58 -51
  95. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +219 -41
  96. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +4 -1
  97. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +2 -2
  98. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +4 -4
  99. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +1 -1
  100. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +4 -4
  101. package/lib/dist/Mock/Application.js +2 -2
  102. package/lib/dist/Mock/Components/BottomTabs.js +2 -2
  103. package/lib/dist/Mock/Components/ComponentScreen.js +15 -5
  104. package/lib/dist/Mock/Components/LayoutComponent.js +3 -2
  105. package/lib/dist/Mock/Components/Modals.js +2 -2
  106. package/lib/dist/Mock/Components/NavigationButton.d.ts +1 -1
  107. package/lib/dist/Mock/Components/NavigationButton.js +8 -10
  108. package/lib/dist/Mock/Components/Overlays.js +2 -2
  109. package/lib/dist/Mock/Components/Stack.js +2 -2
  110. package/lib/dist/Mock/Components/TopBar.d.ts +2 -2
  111. package/lib/dist/Mock/Components/TopBar.js +7 -6
  112. package/lib/dist/Mock/Layouts/BottomTabsNode.d.ts +1 -1
  113. package/lib/dist/Mock/Layouts/BottomTabsNode.js +3 -3
  114. package/lib/dist/Mock/Layouts/ComponentNode.d.ts +1 -1
  115. package/lib/dist/Mock/Layouts/ComponentNode.js +4 -4
  116. package/lib/dist/Mock/Layouts/LayoutNodeFactory.js +3 -3
  117. package/lib/dist/Mock/Layouts/Node.d.ts +1 -1
  118. package/lib/dist/Mock/Layouts/Node.js +5 -0
  119. package/lib/dist/Mock/Layouts/ParentNode.d.ts +2 -2
  120. package/lib/dist/Mock/Layouts/ParentNode.js +4 -3
  121. package/lib/dist/Mock/Layouts/StackNode.js +1 -1
  122. package/lib/dist/Mock/Stores/EventsStore.d.ts +5 -2
  123. package/lib/dist/Mock/Stores/EventsStore.js +7 -0
  124. package/lib/dist/Mock/Stores/LayoutStore.js +6 -3
  125. package/lib/dist/Mock/connect.js +1 -1
  126. package/lib/dist/Mock/index.js +1 -1
  127. package/lib/dist/Mock/mocks/NativeCommandsSender.d.ts +1 -1
  128. package/lib/dist/Mock/mocks/NativeCommandsSender.js +2 -2
  129. package/lib/dist/Mock/mocks/NativeEventsReceiver.d.ts +3 -3
  130. package/lib/dist/Mock/mocks/NativeEventsReceiver.js +6 -3
  131. package/lib/dist/{Navigation.d.ts → src/Navigation.d.ts} +0 -0
  132. package/lib/dist/{Navigation.js → src/Navigation.js} +19 -3
  133. package/lib/dist/{NavigationDelegate.d.ts → src/NavigationDelegate.d.ts} +0 -0
  134. package/lib/dist/{NavigationDelegate.js → src/NavigationDelegate.js} +1 -0
  135. package/lib/dist/{adapters → src/adapters}/AppRegistryService.d.ts +0 -0
  136. package/lib/dist/{adapters → src/adapters}/AppRegistryService.js +0 -0
  137. package/lib/dist/{adapters → src/adapters}/AssetResolver.d.ts +0 -0
  138. package/lib/dist/{adapters → src/adapters}/AssetResolver.js +0 -0
  139. package/lib/dist/src/adapters/ColorService.d.ts +3 -0
  140. package/lib/dist/{adapters → src/adapters}/ColorService.js +1 -1
  141. package/lib/dist/{adapters → src/adapters}/Constants.d.ts +0 -0
  142. package/lib/dist/{adapters → src/adapters}/Constants.js +10 -6
  143. package/lib/dist/{adapters → src/adapters}/NativeCommandsSender.d.ts +0 -0
  144. package/lib/dist/{adapters → src/adapters}/NativeCommandsSender.js +1 -0
  145. package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.d.ts +0 -0
  146. package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.js +1 -0
  147. package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.mock.d.ts +0 -0
  148. package/lib/dist/{adapters → src/adapters}/NativeEventsReceiver.mock.js +0 -0
  149. package/lib/dist/{adapters → src/adapters}/TouchablePreview.d.ts +0 -0
  150. package/lib/dist/src/adapters/TouchablePreview.js +89 -0
  151. package/lib/dist/{adapters → src/adapters}/UniqueIdProvider.d.ts +0 -0
  152. package/lib/dist/{adapters → src/adapters}/UniqueIdProvider.js +2 -2
  153. package/lib/dist/{commands → src/commands}/Commands.d.ts +0 -0
  154. package/lib/dist/{commands → src/commands}/Commands.js +24 -10
  155. package/lib/dist/{commands → src/commands}/Deprecations.d.ts +0 -0
  156. package/lib/dist/src/commands/Deprecations.js +80 -0
  157. package/lib/dist/{commands → src/commands}/LayoutTreeCrawler.d.ts +0 -0
  158. package/lib/dist/{commands → src/commands}/LayoutTreeCrawler.js +4 -2
  159. package/lib/dist/{commands → src/commands}/LayoutTreeParser.d.ts +0 -0
  160. package/lib/dist/{commands → src/commands}/LayoutTreeParser.js +1 -0
  161. package/lib/dist/{commands → src/commands}/LayoutType.d.ts +0 -0
  162. package/lib/dist/{commands → src/commands}/LayoutType.js +0 -0
  163. package/lib/dist/{commands → src/commands}/OptionsCrawler.d.ts +0 -0
  164. package/lib/dist/{commands → src/commands}/OptionsCrawler.js +6 -4
  165. package/lib/dist/{commands → src/commands}/OptionsProcessor.d.ts +1 -1
  166. package/lib/dist/{commands → src/commands}/OptionsProcessor.js +50 -42
  167. package/lib/dist/{components → src/components}/ComponentRegistry.d.ts +0 -0
  168. package/lib/dist/{components → src/components}/ComponentRegistry.js +4 -0
  169. package/lib/dist/{components → src/components}/ComponentWrapper.d.ts +0 -0
  170. package/lib/dist/{components → src/components}/ComponentWrapper.js +17 -17
  171. package/lib/dist/{components → src/components}/Modal.d.ts +0 -0
  172. package/lib/dist/{components → src/components}/Modal.js +8 -8
  173. package/lib/dist/{components → src/components}/Store.d.ts +2 -0
  174. package/lib/dist/{components → src/components}/Store.js +13 -6
  175. package/lib/dist/{events → src/events}/CommandsObserver.d.ts +0 -0
  176. package/lib/dist/{events → src/events}/CommandsObserver.js +2 -1
  177. package/lib/dist/{events → src/events}/ComponentEventsObserver.d.ts +4 -2
  178. package/lib/dist/{events → src/events}/ComponentEventsObserver.js +16 -14
  179. package/lib/dist/{events → src/events}/EventsRegistry.d.ts +2 -2
  180. package/lib/dist/{events → src/events}/EventsRegistry.js +3 -0
  181. package/lib/dist/{index.d.ts → src/index.d.ts} +0 -0
  182. package/lib/dist/src/index.js +22 -0
  183. package/lib/dist/{interfaces → src/interfaces}/CommandName.d.ts +0 -0
  184. package/lib/dist/{interfaces → src/interfaces}/CommandName.js +0 -0
  185. package/lib/dist/{interfaces → src/interfaces}/ComponentEvents.d.ts +0 -0
  186. package/lib/dist/{interfaces → src/interfaces}/ComponentEvents.js +0 -0
  187. package/lib/dist/{interfaces → src/interfaces}/EventSubscription.d.ts +0 -0
  188. package/lib/dist/{interfaces → src/interfaces}/EventSubscription.js +0 -0
  189. package/lib/dist/{interfaces → src/interfaces}/Events.d.ts +0 -0
  190. package/lib/dist/{interfaces → src/interfaces}/Events.js +0 -0
  191. package/lib/dist/{interfaces → src/interfaces}/Layout.d.ts +0 -0
  192. package/lib/dist/{interfaces → src/interfaces}/Layout.js +0 -0
  193. package/lib/dist/{interfaces → src/interfaces}/NavigationComponent.d.ts +0 -0
  194. package/lib/dist/{interfaces → src/interfaces}/NavigationComponent.js +8 -1
  195. package/lib/dist/{interfaces → src/interfaces}/NavigationComponentListener.d.ts +0 -0
  196. package/lib/dist/{interfaces → src/interfaces}/NavigationComponentListener.js +0 -0
  197. package/lib/dist/{interfaces → src/interfaces}/NavigationComponentProps.d.ts +0 -0
  198. package/lib/dist/{interfaces → src/interfaces}/NavigationComponentProps.js +0 -0
  199. package/lib/dist/{interfaces → src/interfaces}/NavigationFunctionComponent.d.ts +0 -0
  200. package/lib/dist/{interfaces → src/interfaces}/NavigationFunctionComponent.js +0 -0
  201. package/lib/dist/{interfaces → src/interfaces}/Options.d.ts +9 -0
  202. package/lib/dist/{interfaces → src/interfaces}/Options.js +0 -0
  203. package/lib/dist/{interfaces → src/interfaces}/ProcessorSubscription.d.ts +0 -0
  204. package/lib/dist/{interfaces → src/interfaces}/ProcessorSubscription.js +0 -0
  205. package/lib/dist/{interfaces → src/interfaces}/Processors.d.ts +0 -0
  206. package/lib/dist/{interfaces → src/interfaces}/Processors.js +0 -0
  207. package/lib/dist/{processors → src/processors}/LayoutProcessor.d.ts +0 -0
  208. package/lib/dist/{processors → src/processors}/LayoutProcessor.js +1 -0
  209. package/lib/dist/{processors → src/processors}/LayoutProcessorsStore.d.ts +0 -0
  210. package/lib/dist/{processors → src/processors}/LayoutProcessorsStore.js +1 -3
  211. package/lib/dist/{processors → src/processors}/OptionProcessorsStore.d.ts +0 -0
  212. package/lib/dist/{processors → src/processors}/OptionProcessorsStore.js +1 -3
  213. package/lib/dist/{types.d.ts → src/types.d.ts} +0 -0
  214. package/lib/dist/{types.js → src/types.js} +0 -0
  215. package/lib/ios/AnimationObserver.h +17 -0
  216. package/lib/ios/AnimationObserver.m +41 -0
  217. package/lib/ios/BottomTabPresenter.h +0 -3
  218. package/lib/ios/BottomTabPresenter.m +0 -8
  219. package/lib/ios/RNNAssert.h +2 -2
  220. package/lib/ios/RNNBasePresenter.h +0 -4
  221. package/lib/ios/RNNBasePresenter.m +0 -12
  222. package/lib/ios/RNNBottomTabOptions.m +2 -1
  223. package/lib/ios/RNNBottomTabsController.m +8 -8
  224. package/lib/ios/RNNBridgeManager.mm +0 -1
  225. package/lib/ios/RNNButtonBuilder.m +2 -0
  226. package/lib/ios/RNNButtonOptions.h +1 -0
  227. package/lib/ios/RNNButtonOptions.m +4 -0
  228. package/lib/ios/RNNCommandsHandler.m +15 -8
  229. package/lib/ios/RNNComponentPresenter.m +0 -4
  230. package/lib/ios/RNNComponentViewController.m +2 -4
  231. package/lib/ios/RNNDotIndicatorPresenter.m +2 -1
  232. package/lib/ios/RNNExternalViewController.m +2 -4
  233. package/lib/ios/RNNModalManager.h +2 -1
  234. package/lib/ios/RNNModalManager.m +12 -21
  235. package/lib/ios/RNNSegmentedControl.h +1 -1
  236. package/lib/ios/RNNSideMenuChildVC.m +0 -4
  237. package/lib/ios/RNNSideMenuController.m +0 -4
  238. package/lib/ios/RNNSplitViewController.m +0 -4
  239. package/lib/ios/RNNStackController.m +0 -4
  240. package/lib/ios/RNNStackPresenter.m +3 -0
  241. package/lib/ios/RNNSwizzles.m +20 -0
  242. package/lib/ios/RNNTabBarItemCreator.m +3 -2
  243. package/lib/ios/RNNUIBarButtonItem.h +2 -0
  244. package/lib/ios/RNNUIBarButtonItem.m +17 -0
  245. package/lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj +8 -0
  246. package/lib/ios/TopBarPresenter.m +8 -4
  247. package/lib/ios/UIViewController+RNNOptions.m +1 -1
  248. package/lib/src/commands/Commands.ts +6 -1
  249. package/lib/src/commands/LayoutTreeCrawler.ts +2 -2
  250. package/lib/src/commands/OptionsCrawler.ts +2 -1
  251. package/lib/src/commands/OptionsProcessor.ts +15 -13
  252. package/lib/src/components/Store.ts +9 -0
  253. package/lib/src/events/ComponentEventsObserver.ts +5 -1
  254. package/lib/src/events/EventsRegistry.ts +2 -1
  255. package/lib/src/interfaces/Options.ts +10 -0
  256. package/package.json +19 -60
  257. package/tsconfig.mocks.json +7 -0
  258. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/StatusBarUtils.java +0 -41
  259. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.java +0 -511
  260. package/lib/dist/adapters/ColorService.d.ts +0 -3
  261. package/lib/dist/adapters/TouchablePreview.js +0 -91
  262. package/lib/dist/commands/Deprecations.js +0 -82
  263. package/lib/dist/index.js +0 -22
@@ -0,0 +1,572 @@
1
+ package com.reactnativenavigation.viewcontrollers.bottomtabs
2
+
3
+ import android.app.Activity
4
+ import android.graphics.Color
5
+ import android.view.Gravity
6
+ import android.view.View
7
+ import android.view.ViewGroup.MarginLayoutParams
8
+ import androidx.coordinatorlayout.widget.CoordinatorLayout
9
+ import com.aurelhubert.ahbottomnavigation.AHBottomNavigation.TitleState
10
+ import com.reactnativenavigation.BaseTest
11
+ import com.reactnativenavigation.TestUtils
12
+ import com.reactnativenavigation.mocks.ImageLoaderMock.mock
13
+ import com.reactnativenavigation.mocks.SimpleViewController
14
+ import com.reactnativenavigation.mocks.TypefaceLoaderMock
15
+ import com.reactnativenavigation.options.BottomTabsOptions
16
+ import com.reactnativenavigation.options.HwBackBottomTabsBehaviour
17
+ import com.reactnativenavigation.options.Options
18
+ import com.reactnativenavigation.options.params.*
19
+ import com.reactnativenavigation.react.CommandListenerAdapter
20
+ import com.reactnativenavigation.react.events.EventEmitter
21
+ import com.reactnativenavigation.utils.OptionHelper
22
+ import com.reactnativenavigation.utils.SystemUiUtils.getStatusBarHeight
23
+ import com.reactnativenavigation.utils.SystemUiUtils.saveStatusBarHeight
24
+ import com.reactnativenavigation.viewcontrollers.bottomtabs.attacher.BottomTabsAttacher
25
+ import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry
26
+ import com.reactnativenavigation.viewcontrollers.fakes.FakeParentController
27
+ import com.reactnativenavigation.viewcontrollers.parent.ParentController
28
+ import com.reactnativenavigation.viewcontrollers.stack.StackController
29
+ import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter
30
+ import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController
31
+ import com.reactnativenavigation.views.bottomtabs.BottomTabs
32
+ import com.reactnativenavigation.views.bottomtabs.BottomTabsContainer
33
+ import com.reactnativenavigation.views.bottomtabs.BottomTabsLayout
34
+ import org.assertj.core.api.Java6Assertions
35
+ import org.junit.Test
36
+ import org.mockito.ArgumentCaptor
37
+ import org.mockito.ArgumentMatchers
38
+ import org.mockito.Mockito
39
+ import org.mockito.kotlin.any
40
+ import org.mockito.kotlin.eq
41
+ import org.mockito.kotlin.times
42
+ import java.util.*
43
+
44
+ class BottomTabsControllerTest : BaseTest() {
45
+ private lateinit var activity: Activity
46
+ private lateinit var bottomTabs: BottomTabs
47
+ private lateinit var bottomTabsContainer: BottomTabsContainer
48
+ private lateinit var uut: BottomTabsController
49
+ private val initialOptions = Options()
50
+ private lateinit var child1: ViewController<*>
51
+ private lateinit var child2: ViewController<*>
52
+ private lateinit var child3: ViewController<*>
53
+ private lateinit var stackChild: ViewController<*>
54
+ private lateinit var child4: StackController
55
+ private lateinit var child5: ViewController<*>
56
+ private val tabOptions = OptionHelper.createBottomTabOptions()
57
+ private val imageLoaderMock = mock()
58
+ private lateinit var eventEmitter: EventEmitter
59
+ private lateinit var childRegistry: ChildControllersRegistry
60
+ private lateinit var tabs: MutableList<ViewController<*>>
61
+ private lateinit var presenter: BottomTabsPresenter
62
+ private lateinit var bottomTabPresenter: BottomTabPresenter
63
+ private lateinit var tabsAttacher: BottomTabsAttacher
64
+ override fun beforeEach() {
65
+ super.beforeEach()
66
+ activity = newActivity()
67
+ childRegistry = ChildControllersRegistry()
68
+ eventEmitter = Mockito.mock(EventEmitter::class.java)
69
+ prepareViewsForTests()
70
+ saveStatusBarHeight(63)
71
+ }
72
+
73
+ @Test
74
+ fun createView_checkProperStructure() {
75
+ idleMainLooper()
76
+ Java6Assertions.assertThat(uut.view).isInstanceOf(CoordinatorLayout::class.java)
77
+ Java6Assertions.assertThat(uut.view.getChildAt(uut.view.childCount - 1)).isInstanceOf(
78
+ BottomTabsContainer::class.java
79
+ )
80
+ Java6Assertions.assertThat((uut.bottomTabsContainer.layoutParams as CoordinatorLayout.LayoutParams).gravity)
81
+ .isEqualTo(Gravity.BOTTOM)
82
+ }
83
+
84
+ @Test
85
+ fun createView_tabsWithoutIconsAreAccepted() {
86
+ tabOptions.bottomTabOptions.icon = NullText()
87
+ prepareViewsForTests()
88
+ Java6Assertions.assertThat(uut.bottomTabs.itemsCount).isEqualTo(tabs.size)
89
+ }
90
+
91
+ @Test
92
+ fun createView_showTitlesWhenAllTabsDontHaveIcons() {
93
+ tabOptions.bottomTabOptions.icon = NullText()
94
+ Java6Assertions.assertThat(tabOptions.bottomTabsOptions.titleDisplayMode.hasValue()).isFalse
95
+ prepareViewsForTests()
96
+ presenter.applyOptions(Options.EMPTY)
97
+ Java6Assertions.assertThat(bottomTabsContainer.bottomTabs.titleState).isEqualTo(TitleState.ALWAYS_SHOW)
98
+ }
99
+
100
+ @Test(expected = RuntimeException::class)
101
+ fun setTabs_ThrowWhenMoreThan5() {
102
+ tabs.add(SimpleViewController(activity, childRegistry, "6", tabOptions))
103
+ createBottomTabs()
104
+ idleMainLooper()
105
+ }
106
+
107
+ @Test
108
+ fun parentControllerIsSet() {
109
+ uut = createBottomTabs()
110
+ for (tab in tabs) {
111
+ Java6Assertions.assertThat(tab.parentController).isEqualTo(uut)
112
+ }
113
+ }
114
+
115
+ @Test
116
+ fun setTabs_allChildViewsAreAttachedToHierarchy() {
117
+ uut.onViewWillAppear()
118
+ Java6Assertions.assertThat(uut.view.childCount).isEqualTo(6)
119
+ for (child in uut.childControllers) {
120
+ Java6Assertions.assertThat(child.view.parent).isNotNull
121
+ }
122
+ }
123
+
124
+ @Test
125
+ fun setTabs_firstChildIsVisibleOtherAreGone() {
126
+ uut.onViewWillAppear()
127
+ for (i in uut.childControllers.indices) {
128
+ Java6Assertions.assertThat(uut.view.getChildAt(i)).isEqualTo(tabs[i].view)
129
+ Java6Assertions.assertThat(uut.view.getChildAt(i).visibility)
130
+ .isEqualTo(if (i == 0) View.VISIBLE else View.INVISIBLE)
131
+ }
132
+ }
133
+
134
+ @Test
135
+ fun onTabSelected() {
136
+ uut.ensureViewIsCreated()
137
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
138
+ Java6Assertions.assertThat(((uut.childControllers as List<*>)[0] as ViewController<*>).view.visibility)
139
+ .isEqualTo(
140
+ View.VISIBLE
141
+ )
142
+ uut.onTabSelected(3, false)
143
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(3)
144
+ Java6Assertions.assertThat(((uut.childControllers as List<*>)[0] as ViewController<*>).view.visibility)
145
+ .isEqualTo(
146
+ View.INVISIBLE
147
+ )
148
+ Java6Assertions.assertThat(((uut.childControllers as List<*>)[3] as ViewController<*>).view.visibility)
149
+ .isEqualTo(
150
+ View.VISIBLE
151
+ )
152
+ Mockito.verify(eventEmitter).emitBottomTabSelected(0, 3)
153
+ }
154
+
155
+ @Test
156
+ fun onTabReSelected() {
157
+ uut.ensureViewIsCreated()
158
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
159
+ uut.onTabSelected(0, true)
160
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
161
+ Java6Assertions.assertThat(((uut.childControllers as List<*>)[0] as ViewController<*>).view.parent).isNotNull
162
+ Mockito.verify(eventEmitter).emitBottomTabSelected(0, 0)
163
+ }
164
+
165
+ @Test
166
+ fun handleBack_DelegatesToSelectedChild() {
167
+ uut.ensureViewIsCreated()
168
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isFalse
169
+ uut.selectTab(4)
170
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isTrue
171
+ Mockito.verify(child5).handleBack(ArgumentMatchers.any())
172
+ }
173
+
174
+ @Test
175
+ fun `handleBack - PrevSelection - reselect tab selection history of navigation when root has bottom tabs`() {
176
+ val options = Options().apply {
177
+ hardwareBack.bottomTabOnPress = HwBackBottomTabsBehaviour.PrevSelection
178
+ }
179
+ prepareViewsForTests(options = options)
180
+ idleMainLooper()
181
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
182
+
183
+ uut.selectTab(1)
184
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(1)
185
+
186
+ uut.selectTab(3)
187
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(3)
188
+
189
+ uut.selectTab(2)
190
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(2)
191
+
192
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isTrue
193
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(3)
194
+
195
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isTrue
196
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(1)
197
+
198
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isTrue
199
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
200
+
201
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isFalse
202
+ }
203
+
204
+ @Test
205
+ fun `handleBack - JumpToFirst - reselect first tab`() {
206
+ val options = Options().apply {
207
+ hardwareBack.bottomTabOnPress = HwBackBottomTabsBehaviour.JumpToFirst
208
+ }
209
+ prepareViewsForTests(options = options)
210
+ idleMainLooper()
211
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
212
+
213
+ uut.selectTab(1)
214
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(1)
215
+
216
+ uut.selectTab(3)
217
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(3)
218
+
219
+ uut.selectTab(2)
220
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(2)
221
+
222
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isTrue
223
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
224
+
225
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isFalse
226
+ }
227
+
228
+ @Test
229
+ fun `handleBack - Default - should exit app with no reselection`() {
230
+
231
+ prepareViewsForTests()
232
+ idleMainLooper()
233
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
234
+
235
+ uut.selectTab(1)
236
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(1)
237
+
238
+ uut.selectTab(3)
239
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(3)
240
+
241
+ uut.selectTab(2)
242
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(2)
243
+
244
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isFalse
245
+ }
246
+
247
+ @Test
248
+ fun `handleBack - Exit - reselect first tab`() {
249
+ val options = Options().apply {
250
+ hardwareBack.bottomTabOnPress = HwBackBottomTabsBehaviour.Exit
251
+ }
252
+ prepareViewsForTests(options = options)
253
+ idleMainLooper()
254
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(0)
255
+
256
+ uut.selectTab(1)
257
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(1)
258
+
259
+ uut.selectTab(3)
260
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(3)
261
+
262
+ uut.selectTab(2)
263
+ Java6Assertions.assertThat(uut.selectedIndex).isEqualTo(2)
264
+
265
+ Java6Assertions.assertThat(uut.handleBack(CommandListenerAdapter())).isFalse
266
+ }
267
+
268
+ @Test
269
+ fun applyChildOptions_bottomTabsOptionsAreClearedAfterApply() {
270
+ val parent = Mockito.mock(ParentController::class.java)
271
+ uut.parentController = parent
272
+ child1.options.bottomTabsOptions.backgroundColor = ThemeColour(Colour(Color.RED))
273
+ child1.onViewWillAppear()
274
+ val optionsCaptor = ArgumentCaptor.forClass(
275
+ Options::class.java
276
+ )
277
+ Mockito.verify(parent).applyChildOptions(optionsCaptor.capture(), ArgumentMatchers.any())
278
+ Java6Assertions.assertThat(optionsCaptor.value.bottomTabsOptions.backgroundColor.hasValue()).isFalse
279
+ }
280
+
281
+ @Test
282
+ fun applyOptions_bottomTabsCreateViewOnlyOnce() {
283
+ idleMainLooper()
284
+ Mockito.verify(presenter).applyOptions(any())
285
+ Mockito.verify(bottomTabsContainer.bottomTabs, times(2))
286
+ .superCreateItems() // first time when view is created, second time when options are applied
287
+ }
288
+
289
+ @Test
290
+ fun onSizeChanged_recreateItemsIfSizeHasChanged() {
291
+ val numberOfPreviousInvocations = 1
292
+ bottomTabs.onSizeChanged(0, 0, 0, 0)
293
+ Mockito.verify(bottomTabs, Mockito.times(numberOfPreviousInvocations)).superCreateItems()
294
+ bottomTabs.onSizeChanged(100, 0, 0, 0)
295
+ Mockito.verify(bottomTabs, Mockito.times(numberOfPreviousInvocations)).superCreateItems()
296
+ bottomTabs.onSizeChanged(1080, 147, 0, 0)
297
+ Mockito.verify(bottomTabs, Mockito.times(numberOfPreviousInvocations + 1)).superCreateItems()
298
+ bottomTabs.onSizeChanged(1920, 147, 0, 0)
299
+ Mockito.verify(bottomTabs, Mockito.times(numberOfPreviousInvocations + 2)).superCreateItems()
300
+ Mockito.`when`(bottomTabs.itemsCount).thenReturn(0)
301
+ bottomTabs.onSizeChanged(1080, 147, 0, 0)
302
+ Mockito.verify(bottomTabs, Mockito.times(numberOfPreviousInvocations + 2)).superCreateItems()
303
+ }
304
+
305
+ @Test
306
+ fun mergeOptions_currentTabIndex() {
307
+ uut.ensureViewIsCreated()
308
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
309
+ val options = Options()
310
+ options.bottomTabsOptions.currentTabIndex = Number(1)
311
+ uut.mergeOptions(options)
312
+ Java6Assertions.assertThat(uut.selectedIndex).isOne
313
+ Mockito.verify(eventEmitter, Mockito.times(0)).emitBottomTabSelected(
314
+ ArgumentMatchers.any(
315
+ Int::class.java
316
+ ), ArgumentMatchers.any(Int::class.java)
317
+ )
318
+ }
319
+
320
+ @Test
321
+ fun mergeOptions_drawBehind() {
322
+ Java6Assertions.assertThat(uut.getBottomInset(child1)).isEqualTo(uut.bottomTabs.height)
323
+ val o1 = Options()
324
+ o1.bottomTabsOptions.drawBehind = Bool(true)
325
+ child1.mergeOptions(o1)
326
+ Java6Assertions.assertThat(uut.getBottomInset(child1)).isEqualTo(0)
327
+ val o2 = Options()
328
+ o2.topBar.title.text = Text("Some text")
329
+ child1.mergeOptions(o1)
330
+ Java6Assertions.assertThat(uut.getBottomInset(child1)).isEqualTo(0)
331
+ }
332
+
333
+ @Test
334
+ fun mergeOptions_drawBehind_stack() {
335
+ uut.ensureViewIsCreated()
336
+ uut.selectTab(3)
337
+ Java6Assertions.assertThat((stackChild.view.layoutParams as MarginLayoutParams).bottomMargin).isEqualTo(
338
+ bottomTabs.height
339
+ )
340
+ val o1 = Options()
341
+ o1.bottomTabsOptions.drawBehind = Bool(true)
342
+ stackChild.mergeOptions(o1)
343
+ Java6Assertions.assertThat((stackChild.view.layoutParams as MarginLayoutParams).bottomMargin).isEqualTo(0)
344
+ }
345
+
346
+ @Test
347
+ fun mergeOptions_mergesBottomTabOptions() {
348
+ val options = Options()
349
+ uut.mergeOptions(options)
350
+ Mockito.verify(bottomTabPresenter).mergeOptions(options)
351
+ }
352
+
353
+ @Test
354
+ fun applyChildOptions_resolvedOptionsAreUsed() {
355
+ val childOptions = Options()
356
+ val pushedScreen = SimpleViewController(activity, childRegistry, "child4.1", childOptions)
357
+ disablePushAnimation(pushedScreen)
358
+ child4 = spyOnStack(pushedScreen)
359
+ tabs = ArrayList(listOf(child4))
360
+ tabsAttacher = BottomTabsAttacher(tabs, presenter, Options.EMPTY)
361
+ initialOptions.bottomTabsOptions.currentTabIndex = Number(0)
362
+ val resolvedOptions = Options()
363
+ uut = object : BottomTabsController(
364
+ activity,
365
+ tabs,
366
+ childRegistry,
367
+ eventEmitter,
368
+ imageLoaderMock,
369
+ "uut",
370
+ initialOptions,
371
+ Presenter(activity, Options()),
372
+ tabsAttacher,
373
+ presenter,
374
+ BottomTabPresenter(activity, tabs, mock(), TypefaceLoaderMock(), Options())
375
+ ) {
376
+ override fun resolveCurrentOptions(): Options {
377
+ return resolvedOptions
378
+ }
379
+
380
+ override fun createBottomTabs(): BottomTabs {
381
+ return object : BottomTabs(activity) {
382
+ override fun createItems() {}
383
+ }
384
+ }
385
+ }
386
+ activity.setContentView(uut.view)
387
+ idleMainLooper()
388
+ Mockito.verify(presenter, Mockito.times(2))
389
+ .applyChildOptions(eq(resolvedOptions), any())
390
+ }
391
+
392
+ @Test
393
+ fun child_mergeOptions_currentTabIndex() {
394
+ uut.ensureViewIsCreated()
395
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
396
+ val options = Options()
397
+ options.bottomTabsOptions.currentTabIndex = Number(1)
398
+ child1.mergeOptions(options)
399
+ Java6Assertions.assertThat(uut.selectedIndex).isOne
400
+ }
401
+
402
+ @Test
403
+ fun resolveCurrentOptions_returnsFirstTabIfInvokedBeforeViewIsCreated() {
404
+ uut = createBottomTabs()
405
+ Java6Assertions.assertThat(uut.currentChild).isEqualTo(tabs[0])
406
+ }
407
+
408
+ @Test
409
+ fun buttonPressInvokedOnCurrentTab() {
410
+ uut.ensureViewIsCreated()
411
+ uut.selectTab(4)
412
+ uut.sendOnNavigationButtonPressed("btn1")
413
+ Mockito.verify(child5, Mockito.times(1)).sendOnNavigationButtonPressed("btn1")
414
+ }
415
+
416
+ @Test
417
+ fun push() {
418
+ uut.selectTab(3)
419
+ val stackChild2 = SimpleViewController(activity, childRegistry, "stackChild2", Options())
420
+ disablePushAnimation(stackChild2)
421
+ TestUtils.hideBackButton(stackChild2)
422
+ Java6Assertions.assertThat(child4.size()).isEqualTo(1)
423
+ child4.push(stackChild2, CommandListenerAdapter())
424
+ Java6Assertions.assertThat(child4.size()).isEqualTo(2)
425
+ }
426
+
427
+ @Test
428
+ fun oneTimeOptionsAreAppliedOnce() {
429
+ val options = Options()
430
+ options.bottomTabsOptions.currentTabIndex = Number(1)
431
+ Java6Assertions.assertThat(uut.selectedIndex).isZero
432
+ uut.mergeOptions(options)
433
+ Java6Assertions.assertThat(uut.selectedIndex).isOne
434
+ Java6Assertions.assertThat(uut.options.bottomTabsOptions.currentTabIndex.hasValue()).isFalse
435
+ Java6Assertions.assertThat(uut.initialOptions.bottomTabsOptions.currentTabIndex.hasValue()).isFalse
436
+ }
437
+
438
+ @Test
439
+ fun selectTab() {
440
+ uut.selectTab(1)
441
+ Mockito.verify(tabsAttacher).onTabSelected(tabs[1])
442
+ }
443
+
444
+ @Test
445
+ fun selectTab_onViewDidAppearIsInvokedAfterSelection() {
446
+ uut.selectTab(1)
447
+ Mockito.verify(child2).onViewDidAppear()
448
+ }
449
+
450
+ @Test
451
+ fun creatingTabs_onViewDidAppearInvokedAfterInitialTabIndexSet() {
452
+ val options = Options.EMPTY.copy()
453
+ options.bottomTabsOptions.currentTabIndex = Number(1)
454
+ prepareViewsForTests(options.bottomTabsOptions)
455
+ idleMainLooper()
456
+ Mockito.verify(tabs[0], Mockito.times(0)).onViewDidAppear()
457
+ Mockito.verify(tabs[1], Mockito.times(1)).onViewDidAppear()
458
+ Mockito.verify(tabs[2], Mockito.times(0)).onViewDidAppear()
459
+ Mockito.verify(tabs[3], Mockito.times(0)).onViewDidAppear()
460
+ Mockito.verify(tabs[4], Mockito.times(0)).onViewDidAppear()
461
+ }
462
+
463
+ @Test
464
+ fun topInset() {
465
+ Java6Assertions.assertThat(child1.topInset).isEqualTo(statusBarHeight)
466
+ Java6Assertions.assertThat(child2.topInset).isEqualTo(statusBarHeight)
467
+ child1.options.statusBar.drawBehind = Bool(true)
468
+ Java6Assertions.assertThat(child1.topInset).isEqualTo(0)
469
+ Java6Assertions.assertThat(child2.topInset).isEqualTo(statusBarHeight)
470
+ Java6Assertions.assertThat(stackChild.topInset).isEqualTo(statusBarHeight + child4.topBar.height)
471
+ }
472
+
473
+ @Test
474
+ fun bottomInset_defaultOptionsAreTakenIntoAccount() {
475
+ val defaultOptions = Options()
476
+ defaultOptions.bottomTabsOptions.visible = Bool(false)
477
+ Java6Assertions.assertThat(uut.getBottomInset(child1)).isEqualTo(bottomTabs.height)
478
+ uut.setDefaultOptions(defaultOptions)
479
+ Java6Assertions.assertThat(uut.getBottomInset(child1)).isZero
480
+ }
481
+
482
+ @Test
483
+ fun destroy() {
484
+ uut.destroy()
485
+ Mockito.verify(tabsAttacher).destroy()
486
+ }
487
+
488
+ private fun prepareViewsForTests(
489
+ bottomTabsOptions: BottomTabsOptions = initialOptions.bottomTabsOptions,
490
+ options: Options = initialOptions, defaultOptions: Options = initialOptions
491
+ ) {
492
+ if(::uut.isInitialized){
493
+ uut.destroy()
494
+ }
495
+ // ObjectUtils.perform(uut, { obj: BottomTabsController -> obj.destroy() })
496
+ bottomTabs = Mockito.spy(object : BottomTabs(activity) {
497
+ override fun superCreateItems() {}
498
+ })
499
+ bottomTabsContainer = Mockito.spy(BottomTabsContainer(activity, bottomTabs))
500
+ createChildren()
501
+ tabs = mutableListOf(child1, child2, child3, child4, child5)
502
+ defaultOptions.bottomTabsOptions = bottomTabsOptions
503
+ presenter = Mockito.spy(BottomTabsPresenter(tabs, defaultOptions, BottomTabsAnimator()))
504
+ bottomTabPresenter =
505
+ Mockito.spy(BottomTabPresenter(activity, tabs, mock(), TypefaceLoaderMock(), defaultOptions))
506
+ tabsAttacher = Mockito.spy(BottomTabsAttacher(tabs, presenter, defaultOptions))
507
+ uut = createBottomTabs(options = options, defaultOptions = defaultOptions)
508
+ activity.setContentView(FakeParentController(activity, childRegistry, uut).view)
509
+ }
510
+
511
+ private fun createChildren() {
512
+ child1 = Mockito.spy(SimpleViewController(activity, childRegistry, "child1", tabOptions))
513
+ child2 = Mockito.spy(SimpleViewController(activity, childRegistry, "child2", tabOptions))
514
+ child3 = Mockito.spy(SimpleViewController(activity, childRegistry, "child3", tabOptions))
515
+ stackChild = Mockito.spy(SimpleViewController(activity, childRegistry, "stackChild", tabOptions))
516
+ child4 = spyOnStack(stackChild)
517
+ child5 = Mockito.spy(SimpleViewController(activity, childRegistry, "child5", tabOptions))
518
+ Mockito.`when`(child5.handleBack(any())).thenReturn(true)
519
+ }
520
+
521
+ private fun spyOnStack(initialChild: ViewController<*>?): StackController {
522
+ val build = TestUtils.newStackController(activity)
523
+ .setInitialOptions(tabOptions)
524
+ .build()
525
+ val stack = Mockito.spy(build)
526
+ disablePushAnimation(initialChild)
527
+ stack.ensureViewIsCreated()
528
+ stack.push(initialChild, CommandListenerAdapter())
529
+ return stack
530
+ }
531
+
532
+ private fun createBottomTabs(
533
+ options: Options = initialOptions,
534
+ defaultOptions: Options = initialOptions
535
+ ): BottomTabsController {
536
+ return object : BottomTabsController(
537
+ activity,
538
+ tabs,
539
+ childRegistry,
540
+ eventEmitter,
541
+ imageLoaderMock,
542
+ "uut",
543
+ options,
544
+ Presenter(activity, defaultOptions),
545
+ tabsAttacher,
546
+ presenter,
547
+ bottomTabPresenter
548
+ ) {
549
+ override fun ensureViewIsCreated() {
550
+ super.ensureViewIsCreated()
551
+ uut.view.layout(0, 0, 1000, 1000)
552
+ }
553
+
554
+ override fun createView(): BottomTabsLayout {
555
+ val view = super.createView()
556
+ this@BottomTabsControllerTest.bottomTabs.layoutParams.height = 100
557
+ return view
558
+ }
559
+
560
+ override fun createBottomTabsContainer(): BottomTabsContainer {
561
+ return this@BottomTabsControllerTest.bottomTabsContainer
562
+ }
563
+
564
+ override fun createBottomTabs(): BottomTabs {
565
+ return this@BottomTabsControllerTest.bottomTabs
566
+ }
567
+ }
568
+ }
569
+
570
+ private val statusBarHeight: Int
571
+ get() = getStatusBarHeight(activity)
572
+ }
@@ -3,7 +3,7 @@ package com.reactnativenavigation.viewcontrollers.bottomtabs
3
3
  import android.animation.AnimatorSet
4
4
  import android.content.res.Configuration
5
5
  import android.graphics.Color
6
- import com.nhaarman.mockitokotlin2.*
6
+ import org.mockito.kotlin.*
7
7
  import com.reactnativenavigation.BaseTest
8
8
  import com.reactnativenavigation.mocks.SimpleViewController
9
9
  import com.reactnativenavigation.options.Options
@@ -32,6 +32,7 @@ public class ChildControllerTest extends BaseTest {
32
32
  }
33
33
  };
34
34
  ParentController<?> parent = Mockito.mock(ParentController.class);
35
+ Mockito.when(parent.resolveChildOptions(uut)).thenReturn(Options.EMPTY);
35
36
  uut.setParentController(parent);
36
37
  }
37
38
 
@@ -55,7 +56,7 @@ public class ChildControllerTest extends BaseTest {
55
56
 
56
57
  Options options = new Options();
57
58
  uut.mergeOptions(options);
58
- verify(presenter).mergeOptions(uut.getView(), options);
59
+ verify(presenter).mergeOptions(uut, options);
59
60
  }
60
61
 
61
62
  @Test
@@ -11,7 +11,7 @@ import com.reactnativenavigation.mocks.TestComponentLayout;
11
11
  import com.reactnativenavigation.mocks.TestReactView;
12
12
  import com.reactnativenavigation.options.Options;
13
13
  import com.reactnativenavigation.options.params.Bool;
14
- import com.reactnativenavigation.utils.StatusBarUtils;
14
+ import com.reactnativenavigation.utils.SystemUiUtils;
15
15
  import com.reactnativenavigation.views.component.ComponentLayout;
16
16
 
17
17
  import org.assertj.core.api.Java6Assertions;
@@ -31,7 +31,7 @@ public class ComponentViewControllerTest extends BaseTest {
31
31
  public void beforeEach() {
32
32
  super.beforeEach();
33
33
  activity = newActivity();
34
- StatusBarUtils.saveStatusBarHeight(63);
34
+ SystemUiUtils.saveStatusBarHeight(63);
35
35
  view = Mockito.spy(new TestComponentLayout(activity, new TestReactView(activity)));
36
36
  parent = TestUtils.newStackController(activity).build();
37
37
  Presenter presenter = new Presenter(activity, new Options());
@@ -138,7 +138,7 @@ public class ComponentViewControllerTest extends BaseTest {
138
138
  Options options = new Options();
139
139
  Java6Assertions.assertThat(uut.isViewShown()).isFalse();
140
140
  uut.mergeOptions(options);
141
- Mockito.verifyZeroInteractions(presenter);
141
+ Mockito.verifyNoInteractions(presenter);
142
142
 
143
143
  Mockito.when(uut.isViewShown()).thenReturn(true);
144
144
  uut.mergeOptions(options);
@@ -156,13 +156,13 @@ public class ComponentViewControllerTest extends BaseTest {
156
156
  public void getTopInset_returnsStatusBarHeight() {
157
157
  //noinspection ConstantConditions
158
158
  uut.setParentController(null);
159
- Java6Assertions.assertThat(uut.getTopInset()).isEqualTo(StatusBarUtils.getStatusBarHeight(activity));
159
+ Java6Assertions.assertThat(uut.getTopInset()).isEqualTo(SystemUiUtils.getStatusBarHeight(activity));
160
160
  }
161
161
 
162
162
  @Test
163
163
  public void getTopInset_resolveWithParent() {
164
164
  Java6Assertions
165
- .assertThat(uut.getTopInset()).isEqualTo(StatusBarUtils.getStatusBarHeight(activity) + parent.getTopInset(uut));
165
+ .assertThat(uut.getTopInset()).isEqualTo(SystemUiUtils.getStatusBarHeight(activity) + parent.getTopInset(uut));
166
166
  }
167
167
 
168
168
  @Test
@@ -2,7 +2,7 @@ package com.reactnativenavigation.viewcontrollers.fakes
2
2
 
3
3
  import android.app.Activity
4
4
  import androidx.coordinatorlayout.widget.CoordinatorLayout
5
- import com.nhaarman.mockitokotlin2.mock
5
+ import org.mockito.kotlin.mock
6
6
  import com.reactnativenavigation.options.Options
7
7
  import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter
8
8
  import com.reactnativenavigation.utils.CompatUtils
@@ -1,7 +1,7 @@
1
1
  package com.reactnativenavigation.viewcontrollers.modal
2
2
 
3
3
  import android.app.Activity
4
- import com.nhaarman.mockitokotlin2.*
4
+ import org.mockito.kotlin.*
5
5
  import com.reactnativenavigation.BaseTest
6
6
  import com.reactnativenavigation.mocks.SimpleViewController
7
7
  import com.reactnativenavigation.options.*