react-native-navigation 7.24.3 → 7.25.1

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 (121) hide show
  1. package/lib/android/app/build.gradle +12 -9
  2. package/lib/android/app/src/main/java/com/reactnativenavigation/options/Options.java +2 -0
  3. package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutInsets.kt +44 -0
  4. package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutOptions.kt +71 -0
  5. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/PrimitiveExt.kt +9 -0
  6. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +4 -3
  7. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java +5 -0
  8. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +23 -7
  9. package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +12 -3
  10. package/lib/dist/src/interfaces/Options.d.ts +10 -0
  11. package/lib/ios/RNNBasePresenter.m +17 -0
  12. package/lib/ios/RNNBottomTabsController.m +1 -0
  13. package/lib/ios/RNNBridgeManager.mm +5 -3
  14. package/lib/ios/RNNComponentViewController.m +5 -0
  15. package/lib/ios/RNNLayoutOptions.h +2 -1
  16. package/lib/ios/RNNLayoutOptions.m +4 -0
  17. package/lib/ios/RNNModalHostViewManagerHandler.h +11 -0
  18. package/lib/ios/RNNModalHostViewManagerHandler.m +40 -0
  19. package/lib/ios/RNNModalManager.h +2 -2
  20. package/lib/ios/RNNModalManager.m +0 -26
  21. package/lib/ios/RNNStackPresenter.m +1 -0
  22. package/lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj +8 -0
  23. package/lib/src/interfaces/Options.ts +12 -0
  24. package/package.json +3 -1
  25. package/.buildkite/pipeline.yml +0 -59
  26. package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutOptions.java +0 -48
  27. package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +0 -178
  28. package/lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java +0 -43
  29. package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +0 -23
  30. package/lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java +0 -35
  31. package/lib/android/app/src/test/java/com/reactnativenavigation/TestUtils.java +0 -62
  32. package/lib/android/app/src/test/java/com/reactnativenavigation/fakes/IconResolverFake.kt +0 -8
  33. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/BackDrawable.java +0 -30
  34. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +0 -49
  35. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +0 -18
  36. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java +0 -15
  37. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleOverlay.java +0 -54
  38. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java +0 -113
  39. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java +0 -79
  40. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java +0 -18
  41. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestReactView.java +0 -71
  42. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarButtonCreatorMock.java +0 -34
  43. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarReactViewCreatorMock.java +0 -20
  44. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopBarBackgroundViewCreatorMock.java +0 -20
  45. package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +0 -21
  46. package/lib/android/app/src/test/java/com/reactnativenavigation/options/LayoutNodeParserTest.java +0 -51
  47. package/lib/android/app/src/test/java/com/reactnativenavigation/options/OptionsTest.java +0 -315
  48. package/lib/android/app/src/test/java/com/reactnativenavigation/options/OrientationOptionsTest.java +0 -81
  49. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TopBarButtonsTest.kt +0 -95
  50. package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +0 -122
  51. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/BoolParserTest.java +0 -28
  52. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/ColorParseTest.java +0 -50
  53. package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/JSONParserTest.java +0 -64
  54. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +0 -56
  55. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/RenderCheckerTest.java +0 -59
  56. package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java +0 -35
  57. package/lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationModuleTest.java +0 -102
  58. package/lib/android/app/src/test/java/com/reactnativenavigation/react/ReloadListenerTest.java +0 -24
  59. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/AnimationHelper.kt +0 -33
  60. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonPresenterTest.java +0 -241
  61. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonSpanTest.java +0 -57
  62. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java +0 -17
  63. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +0 -78
  64. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +0 -47
  65. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/NativeCommandListenerTest.java +0 -60
  66. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java +0 -16
  67. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java +0 -26
  68. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java +0 -19
  69. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/SystemUiUtilsTest.kt +0 -27
  70. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt +0 -357
  71. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleBarHelper.java +0 -54
  72. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +0 -29
  73. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +0 -22
  74. package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ViewHelper.java +0 -9
  75. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java +0 -149
  76. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenterTest.java +0 -206
  77. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAttacherTest.java +0 -62
  78. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +0 -589
  79. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +0 -173
  80. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AfterInitialTabTest.java +0 -38
  81. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AttachModeTest.java +0 -86
  82. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/OnSwitchToTabTest.java +0 -31
  83. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/TogetherTest.java +0 -20
  84. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/button/NavigationIconResolverTest.java +0 -78
  85. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +0 -80
  86. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistryTest.java +0 -56
  87. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +0 -216
  88. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewControllerTest.java +0 -97
  89. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/FragmentCreatorMock.java +0 -34
  90. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/SomeFragment.java +0 -8
  91. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +0 -33
  92. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorMock.java +0 -40
  93. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +0 -213
  94. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +0 -319
  95. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +0 -367
  96. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +0 -898
  97. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +0 -254
  98. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +0 -108
  99. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +0 -299
  100. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +0 -446
  101. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelperTest.java +0 -77
  102. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/FloatingActionButtonTest.java +0 -154
  103. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/IdStackTest.java +0 -114
  104. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +0 -241
  105. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +0 -1165
  106. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +0 -1081
  107. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarButtonControllerTest.java +0 -61
  108. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarReactViewControllerTest.java +0 -43
  109. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarButtonControllerTest.java +0 -120
  110. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +0 -432
  111. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +0 -249
  112. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +0 -337
  113. package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegateTest.java +0 -68
  114. package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java +0 -60
  115. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +0 -477
  116. package/lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java +0 -82
  117. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +0 -109
  118. package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreatorFake.kt +0 -36
  119. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +0 -101
  120. package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +0 -40
  121. package/lib/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +0 -1
@@ -1,357 +0,0 @@
1
- package com.reactnativenavigation.utils
2
-
3
- import com.reactnativenavigation.BaseTest
4
- import com.reactnativenavigation.views.stack.topbar.titlebar.DEFAULT_LEFT_MARGIN_PX
5
- import com.reactnativenavigation.views.stack.topbar.titlebar.resolveHorizontalTitleBoundsLimit
6
- import com.reactnativenavigation.views.stack.topbar.titlebar.resolveLeftButtonsBounds
7
- import com.reactnativenavigation.views.stack.topbar.titlebar.resolveRightButtonsBounds
8
- import org.junit.Test
9
- import kotlin.test.assertEquals
10
-
11
- class TitleAndButtonsMeasurerTest : BaseTest() {
12
- private val parentWidth = 1080
13
-
14
- @Test
15
- fun `left buttons should be at parent start`() {
16
- val barWidth = 200
17
- val isRTL = false
18
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
19
-
20
- assertEquals(0, left)
21
- assertEquals(barWidth, right)
22
- }
23
-
24
- @Test
25
- fun `left buttons should not exceed parent width`() {
26
- val barWidth = parentWidth + 1
27
- val isRTL = false
28
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
29
-
30
- assertEquals(0, left)
31
- assertEquals(parentWidth, right)
32
- }
33
-
34
- @Test
35
- fun `RTL - left buttons should be at parent end`() {
36
- val barWidth = 200
37
- val isRTL = true
38
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
39
-
40
- assertEquals(parentWidth - barWidth, left)
41
- assertEquals(parentWidth, right)
42
- }
43
-
44
- @Test
45
- fun `RTL - left buttons should not exceed parent left`() {
46
- val barWidth = parentWidth + 1
47
- val isRTL = true
48
- val (left, right) = resolveLeftButtonsBounds(parentWidth, barWidth, isRTL)
49
-
50
- assertEquals(0, left)
51
- assertEquals(parentWidth, right)
52
- }
53
-
54
- @Test
55
- fun `right buttons should be at parent end`() {
56
- val barWidth = 200
57
- val isRTL = false
58
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
59
-
60
- assertEquals(parentWidth - barWidth, left)
61
- assertEquals(parentWidth, right)
62
- }
63
-
64
- @Test
65
- fun `right buttons should not exceed parent start`() {
66
- val barWidth = parentWidth + 1
67
- val isRTL = false
68
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
69
-
70
- assertEquals(0, left)
71
- assertEquals(parentWidth, right)
72
- }
73
-
74
- @Test
75
- fun `RTL - right buttons should be at parent start`() {
76
- val barWidth = 200
77
- val isRTL = true
78
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
79
-
80
- assertEquals(0, left)
81
- assertEquals(barWidth, right)
82
- }
83
-
84
- @Test
85
- fun `RTL - right buttons should not exceed parent end`() {
86
- val barWidth = parentWidth + 1
87
- val isRTL = true
88
- val (left, right) = resolveRightButtonsBounds(parentWidth, barWidth, isRTL)
89
-
90
- assertEquals(0, left)
91
- assertEquals(parentWidth, right)
92
- }
93
-
94
- @Test
95
- fun `No Buttons - Aligned start - Title should be at default left margin bar width and right margin`() {
96
- val barWidth = 200
97
- val leftButtons = 0
98
- val rightButtons = 0
99
- val isRTL = false
100
- val center = false
101
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
102
-
103
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
104
- assertEquals(DEFAULT_LEFT_MARGIN_PX + barWidth + DEFAULT_LEFT_MARGIN_PX, right)
105
- }
106
-
107
- @Test
108
- fun `RTL - No Buttons - Aligned start - Title should be at the end with default margins`() {
109
- val barWidth = 200
110
- val leftButtons = 0
111
- val rightButtons = 0
112
- val isRTL = true
113
- val center = false
114
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
115
-
116
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX - barWidth - DEFAULT_LEFT_MARGIN_PX, left)
117
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
118
- }
119
-
120
- @Test
121
- fun `RTL - No Buttons - Aligned start - Title should not exceed boundaries`() {
122
- val barWidth = parentWidth + 1
123
- val leftButtons = 0
124
- val rightButtons = 0
125
- val isRTL = true
126
- val center = false
127
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
128
-
129
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
130
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
131
- }
132
-
133
- @Test
134
- fun `No Buttons - Aligned start - Title should not exceed parent boundaries`() {
135
- val barWidth = parentWidth + 1
136
- val leftButtons = 0
137
- val rightButtons = 0
138
- val isRTL = false
139
- val center = false
140
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
141
-
142
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
143
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
144
- }
145
-
146
-
147
- @Test
148
- fun `No Buttons - Aligned center - Title should not exceed parent boundaries`() {
149
- val barWidth = parentWidth + 1
150
- val leftButtons = 0
151
- val rightButtons = 0
152
- val isRTL = false
153
- val center = true
154
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
155
-
156
- assertEquals(0, left)
157
- assertEquals(parentWidth, right)
158
- }
159
-
160
- @Test
161
- fun `No Buttons - Aligned center - Title should have no margin and in center`() {
162
- val barWidth = 200
163
- val leftButtons = 0
164
- val rightButtons = 0
165
- val isRTL = false
166
- val center = true
167
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
168
-
169
- assertEquals(parentWidth / 2 - barWidth / 2, left)
170
- assertEquals(parentWidth / 2 + barWidth / 2, right)
171
- }
172
-
173
- @Test
174
- fun `RTL - No Buttons - Aligned center - Title should have no effect`() {
175
- val barWidth = 200
176
- val leftButtons = 0
177
- val rightButtons = 0
178
- val isRTL = true
179
- val center = true
180
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
181
-
182
- assertEquals(parentWidth / 2 - barWidth / 2, left)
183
- assertEquals(parentWidth / 2 + barWidth / 2, right)
184
- }
185
-
186
- @Test
187
- fun `Left Buttons - Aligned start - Title should be after left buttons with default margins`() {
188
- val barWidth = 200
189
- val leftButtons = 100
190
- val rightButtons = 0
191
- val isRTL = false
192
- val center = false
193
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
194
-
195
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
196
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX + barWidth + DEFAULT_LEFT_MARGIN_PX, right)
197
- }
198
-
199
- @Test
200
- fun `Left Buttons - Aligned start - Title should not exceed boundaries`() {
201
- val barWidth = parentWidth + 1
202
- val leftButtons = 100
203
- val rightButtons = 0
204
- val isRTL = false
205
- val center = false
206
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
207
-
208
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
209
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX, right)
210
- }
211
-
212
- @Test
213
- fun `RTL - Left Buttons - Aligned start - Title should be after left (right) buttons with default margins`() {
214
- val barWidth = 200
215
- val leftButtons = 100
216
- val rightButtons = 0
217
- val isRTL = true
218
- val center = false
219
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
220
-
221
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX - leftButtons - barWidth - DEFAULT_LEFT_MARGIN_PX, left)
222
- assertEquals(parentWidth - DEFAULT_LEFT_MARGIN_PX - leftButtons, right)
223
- }
224
-
225
- @Test
226
- fun `RTL - Left Buttons - Aligned start - Title should not exceed boundaries`() {
227
- val barWidth = parentWidth + 1
228
- val leftButtons = 100
229
- val rightButtons = 0
230
- val isRTL = true
231
- val center = false
232
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
233
-
234
- assertEquals(DEFAULT_LEFT_MARGIN_PX, left)
235
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX, right)
236
- }
237
-
238
-
239
- @Test
240
- fun `Left Buttons - Aligned center - Title should be at center`() {
241
- val barWidth = 200
242
- val leftButtons = 100
243
- val rightButtons = 0
244
- val isRTL = false
245
- val center = true
246
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
247
-
248
- assertEquals(parentWidth / 2 - barWidth / 2, left)
249
- assertEquals(parentWidth / 2 + barWidth / 2, right)
250
- }
251
-
252
- @Test
253
- fun `Left Buttons - Aligned center - Title should not exceed boundaries`() {
254
- val parentWidth = 1000
255
- val barWidth = 500
256
- val leftButtons = 300
257
- val rightButtons = 0
258
- val isRTL = false
259
- val center = true
260
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
261
- val expectedOverlap = leftButtons - (parentWidth / 2 - barWidth / 2)
262
- assertEquals(parentWidth / 2 - barWidth / 2 + expectedOverlap, left)
263
- assertEquals(parentWidth / 2 + barWidth / 2 - expectedOverlap, right)
264
- }
265
-
266
- @Test
267
- fun `RTL - Left Buttons - Aligned center - Title should not exceed boundaries`() {
268
- val parentWidth = 1000
269
- val barWidth = 500
270
- val leftButtons = 300
271
- val rightButtons = 0
272
- val isRTL = true
273
- val center = true
274
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
275
- val expectedOverlap = leftButtons - (parentWidth / 2 - barWidth / 2)
276
- assertEquals(parentWidth / 2 - barWidth / 2 + expectedOverlap, left)
277
- assertEquals(parentWidth / 2 + barWidth / 2 - expectedOverlap, right)
278
- }
279
-
280
-
281
- @Test
282
- fun `Left + Right Buttons - Aligned center - Title should not exceed boundaries`() {
283
- val parentWidth = 1000
284
- val barWidth = 500
285
- val leftButtons = 300
286
- val rightButtons = 350
287
- val isRTL = false
288
- val center = true
289
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
290
- assertEquals(leftButtons, left)
291
- assertEquals(parentWidth - rightButtons, right)
292
- }
293
-
294
- @Test
295
- fun `RTL - Left + Right Buttons - Aligned center - Title should not exceed boundaries`() {
296
- val parentWidth = 1000
297
- val barWidth = 500
298
- val leftButtons = 300
299
- val rightButtons = 350
300
- val isRTL = true
301
- val center = true
302
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
303
- assertEquals(rightButtons, left)
304
- assertEquals(parentWidth - leftButtons, right)
305
- }
306
-
307
- @Test
308
- fun `Left + Right Buttons - Aligned start - Title should not exceed boundaries`() {
309
- val parentWidth = 1000
310
- val barWidth = 500
311
- val leftButtons = 300
312
- val rightButtons = 350
313
- val isRTL = false
314
- val center = false
315
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
316
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
317
- assertEquals(parentWidth - rightButtons - DEFAULT_LEFT_MARGIN_PX, right)
318
- }
319
-
320
- @Test
321
- fun `Left + Right Buttons - Aligned start - Title should'nt take amount of needed width only between buttons only`() {
322
- val barWidth = 100
323
- val leftButtons = 300
324
- val rightButtons = 350
325
- val isRTL = false
326
- val center = false
327
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
328
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX, left)
329
- assertEquals(leftButtons + DEFAULT_LEFT_MARGIN_PX + barWidth + DEFAULT_LEFT_MARGIN_PX, right)
330
- }
331
-
332
- @Test
333
- fun `RTL - Left + Right Buttons - Aligned start - Title should not exceed boundaries`() {
334
- val parentWidth = 1000
335
- val barWidth = 500
336
- val leftButtons = 300
337
- val rightButtons = 350
338
- val isRTL = true
339
- val center = false
340
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
341
- assertEquals(rightButtons + DEFAULT_LEFT_MARGIN_PX, left)
342
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX, right)
343
- }
344
-
345
- @Test
346
- fun `RTL - Left + Right Buttons - Aligned start - Title should take amount of needed width only`() {
347
- val parentWidth = 1000
348
- val barWidth = 100
349
- val leftButtons = 300
350
- val rightButtons = 100
351
- val isRTL = true
352
- val center = false
353
- val (left, right) = resolveHorizontalTitleBoundsLimit(parentWidth, barWidth, leftButtons, rightButtons, center, isRTL)
354
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX - barWidth - DEFAULT_LEFT_MARGIN_PX, left)
355
- assertEquals(parentWidth - leftButtons - DEFAULT_LEFT_MARGIN_PX, right)
356
- }
357
- }
@@ -1,54 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import android.app.Activity;
4
-
5
- import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonPresenter;
6
- import com.reactnativenavigation.mocks.ImageLoaderMock;
7
- import com.reactnativenavigation.mocks.TitleBarButtonCreatorMock;
8
- import com.reactnativenavigation.options.ComponentOptions;
9
- import com.reactnativenavigation.options.ButtonOptions;
10
- import com.reactnativenavigation.options.params.Text;
11
- import com.reactnativenavigation.viewcontrollers.stack.topbar.button.ButtonController;
12
- import com.reactnativenavigation.viewcontrollers.stack.topbar.button.IconResolver;
13
-
14
- public class TitleBarHelper {
15
- public static ButtonOptions textualButton(String text) {
16
- ButtonOptions button = new ButtonOptions();
17
- button.id = text + CompatUtils.generateViewId();
18
- button.text = new Text(text);
19
- return button;
20
- }
21
-
22
- public static ButtonOptions reactViewButton(String name) {
23
- ButtonOptions button = new ButtonOptions();
24
- button.id = name + CompatUtils.generateViewId();
25
- button.component = new ComponentOptions();
26
- button.component.name = new Text("com.example" + name + CompatUtils.generateViewId());
27
- button.component.componentId = new Text(name + CompatUtils.generateViewId());
28
- return button;
29
- }
30
-
31
- public static ComponentOptions titleComponent(String componentId) {
32
- ComponentOptions component = new ComponentOptions();
33
- component.componentId = new Text(componentId);
34
- component.name = new Text(componentId);
35
- return component;
36
- }
37
-
38
- public static ButtonOptions iconButton(String id, String icon) {
39
- ButtonOptions button = new ButtonOptions();
40
- button.id = "someButton";
41
- button.icon = new Text(icon);
42
- return button;
43
- }
44
-
45
-
46
- public static ButtonController createButtonController(Activity activity, ButtonOptions button) {
47
- return new ButtonController(activity,
48
- new ButtonPresenter(activity, button, new IconResolver(activity, ImageLoaderMock.mock())),
49
- button,
50
- new TitleBarButtonCreatorMock(),
51
- buttonId -> {}
52
- );
53
- }
54
- }
@@ -1,29 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import com.reactnativenavigation.*;
4
-
5
- import org.junit.*;
6
- import org.robolectric.shadows.*;
7
-
8
- import static org.mockito.Mockito.*;
9
-
10
- public class UiThreadTest extends BaseTest {
11
- @Test
12
- public void postOnUiThread() throws Exception {
13
- Runnable task = mock(Runnable.class);
14
- ShadowLooper.pauseMainLooper();
15
- UiThread.post(task);
16
- verifyNoInteractions(task);
17
- ShadowLooper.runUiThreadTasks();
18
- verify(task, times(1)).run();
19
- }
20
-
21
- @Test
22
- public void postDelayedOnUiThread() throws Exception {
23
- Runnable task = mock(Runnable.class);
24
- UiThread.postDelayed(task, 1000);
25
- verifyNoInteractions(task);
26
- ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
27
- verify(task, times(1)).run();
28
- }
29
- }
@@ -1,22 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import android.view.*;
4
-
5
- import com.reactnativenavigation.*;
6
-
7
- import org.junit.*;
8
-
9
- import static org.mockito.Mockito.*;
10
-
11
- public class UiUtilsTest extends BaseTest {
12
- @Test
13
- public void runOnPreDrawOnce() {
14
- View view = new View(newActivity());
15
- Runnable task = mock(Runnable.class);
16
- verifyNoInteractions(task);
17
-
18
- UiUtils.runOnPreDrawOnce(view, task);
19
- dispatchPreDraw(view);
20
- verify(task, times(1)).run();
21
- }
22
- }
@@ -1,9 +0,0 @@
1
- package com.reactnativenavigation.utils;
2
-
3
- import android.view.View;
4
-
5
- public class ViewHelper {
6
- public static boolean isVisible(View view) {
7
- return view != null && view.getParent() != null && view.getVisibility() == View.VISIBLE;
8
- }
9
- }
@@ -1,149 +0,0 @@
1
- package com.reactnativenavigation.viewcontrollers;
2
-
3
- import android.app.Activity;
4
- import android.content.Context;
5
- import android.content.res.Configuration;
6
- import android.graphics.Color;
7
- import android.graphics.drawable.ColorDrawable;
8
- import android.view.View;
9
- import android.widget.RelativeLayout;
10
-
11
- import com.reactnativenavigation.BaseTest;
12
- import com.reactnativenavigation.TestUtils;
13
- import com.reactnativenavigation.mocks.TestComponentLayout;
14
- import com.reactnativenavigation.mocks.TestReactView;
15
- import com.reactnativenavigation.options.Options;
16
- import com.reactnativenavigation.options.params.Bool;
17
- import com.reactnativenavigation.options.params.Colour;
18
- import com.reactnativenavigation.options.params.ThemeColour;
19
- import com.reactnativenavigation.options.params.Text;
20
- import com.reactnativenavigation.viewcontrollers.component.ComponentPresenter;
21
- import com.reactnativenavigation.viewcontrollers.viewcontroller.Presenter;
22
- import com.reactnativenavigation.react.CommandListenerAdapter;
23
- import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
24
- import com.reactnativenavigation.viewcontrollers.component.ComponentViewController;
25
- import com.reactnativenavigation.viewcontrollers.stack.StackController;
26
- import com.reactnativenavigation.viewcontrollers.stack.topbar.TopBarController;
27
- import com.reactnativenavigation.viewcontrollers.viewcontroller.IReactView;
28
- import com.reactnativenavigation.views.stack.StackLayout;
29
- import com.reactnativenavigation.views.stack.topbar.TopBar;
30
-
31
- import org.junit.Test;
32
-
33
- import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
34
- import static org.assertj.core.api.Java6Assertions.assertThat;
35
- import static org.mockito.Mockito.spy;
36
-
37
- public class OptionsApplyingTest extends BaseTest {
38
- private Activity activity;
39
- private StackController stack;
40
- private ComponentViewController uut;
41
- private IReactView view;
42
- private Options initialNavigationOptions;
43
- private TopBar topBar;
44
-
45
- @Override
46
- public void beforeEach() {
47
- super.beforeEach();
48
- activity = newActivity();
49
- initialNavigationOptions = new Options();
50
- view = spy(new TestComponentLayout(activity, new TestReactView(activity)));
51
- view.asView().setLayoutParams(new RelativeLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
52
- uut = new ComponentViewController(activity,
53
- new ChildControllersRegistry(),
54
- "componentId1",
55
- "componentName",
56
- (activity1, componentId, componentName) -> view,
57
- initialNavigationOptions,
58
- new Presenter(activity, new Options()),
59
- new ComponentPresenter(Options.EMPTY)
60
- ) {
61
- @Override
62
- public boolean isViewShown() {
63
- return true;
64
- }
65
- };
66
- TopBarController topBarController = new TopBarController() {
67
- @Override
68
- protected TopBar createTopBar(Context context, StackLayout stackLayout) {
69
- topBar = spy(super.createTopBar(context, stackLayout));
70
- return topBar;
71
- }
72
- };
73
- stack = TestUtils.newStackController(activity)
74
- .setTopBarController(topBarController)
75
- .build();
76
- stack.ensureViewIsCreated();
77
- stack.getView().layout(0, 0, 1000, 1000);
78
- stack.getTopBar().layout(0, 0, 1000, 100);
79
- activity.setContentView(stack.getView());
80
- disablePushAnimation(uut);
81
- }
82
-
83
- @SuppressWarnings("ConstantConditions")
84
- @Test
85
- public void applyNavigationOptionsHandlesNoParentStack() {
86
- uut.setParentController(null);
87
- assertThat(uut.getParentController()).isNull();
88
- uut.ensureViewIsCreated();
89
- uut.onViewWillAppear();
90
- assertThat(uut.getParentController()).isNull();
91
- }
92
-
93
- @Test
94
- public void initialOptionsAppliedOnAppear() {
95
- uut.options.topBar.title.text = new Text("the title");
96
- StackController stackController = TestUtils.newStackController(activity).build();
97
- stackController.ensureViewIsCreated();
98
- stackController.push(uut, new CommandListenerAdapter());
99
- assertThat(stackController.getTopBar().getTitle()).isEmpty();
100
-
101
- uut.onViewWillAppear();
102
- assertThat(stackController.getTopBar().getTitle()).isEqualTo("the title");
103
- }
104
-
105
- @Test
106
- public void mergeNavigationOptionsUpdatesCurrentOptions() {
107
- assertThat(uut.options.topBar.title.text.get("")).isEmpty();
108
- Options options = new Options();
109
- options.topBar.title.text = new Text("new title");
110
- uut.mergeOptions(options);
111
- assertThat(uut.options.topBar.title.text.get()).isEqualTo("new title");
112
- }
113
-
114
- @Test
115
- public void reappliesOptionsOnMerge() {
116
- assertThat(stack.getTopBar().getTitle()).isEmpty();
117
- stack.push(uut, new CommandListenerAdapter());
118
-
119
- Options opts = new Options();
120
- opts.topBar.title.text = new Text("the new title");
121
- uut.mergeOptions(opts);
122
-
123
- assertThat(stack.getTopBar().getTitle()).isEqualTo("the new title");
124
- }
125
-
126
- @Test
127
- public void appliesTopBackBackgroundColor() {
128
- uut.options.topBar.background.color = new ThemeColour(new Colour(Color.RED));
129
- stack.push(uut, new CommandListenerAdapter());
130
- idleMainLooper();
131
- assertThat(((ColorDrawable) stack.getTopBar().getBackground()).getColor()).isEqualTo(Color.RED);
132
- }
133
-
134
- @Test
135
- public void appliesTopBarVisible() {
136
- stack.push(uut, new CommandListenerAdapter());
137
-
138
- assertThat(uut.initialOptions).isSameAs(initialNavigationOptions);
139
- initialNavigationOptions.topBar.title.text = new Text("the title");
140
- assertThat(stack.getTopBar().getVisibility()).isNotEqualTo(View.GONE);
141
-
142
- Options opts = new Options();
143
- opts.topBar.visible = new Bool(false);
144
- opts.topBar.animate = new Bool(false);
145
- uut.mergeOptions(opts);
146
-
147
- assertThat(stack.getTopBar().getVisibility()).isEqualTo(View.GONE);
148
- }
149
- }