react-native-navigation 7.24.3 → 7.25.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.
- package/lib/android/app/build.gradle +12 -9
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/Options.java +2 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutInsets.kt +44 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/layout/LayoutOptions.kt +71 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/utils/PrimitiveExt.kt +9 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewController.java +4 -3
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/navigator/Navigator.java +5 -0
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/Presenter.java +23 -7
- package/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewController.java +12 -3
- package/lib/dist/src/interfaces/Options.d.ts +10 -0
- package/lib/ios/RNNBasePresenter.m +17 -0
- package/lib/ios/RNNBottomTabsController.m +1 -0
- package/lib/ios/RNNComponentViewController.m +5 -0
- package/lib/ios/RNNLayoutOptions.h +2 -1
- package/lib/ios/RNNLayoutOptions.m +4 -0
- package/lib/ios/RNNStackPresenter.m +1 -0
- package/lib/src/interfaces/Options.ts +12 -0
- package/package.json +3 -1
- package/.buildkite/pipeline.yml +0 -59
- package/lib/android/app/src/main/java/com/reactnativenavigation/options/LayoutOptions.java +0 -48
- package/lib/android/app/src/test/java/com/reactnativenavigation/BaseTest.java +0 -178
- package/lib/android/app/src/test/java/com/reactnativenavigation/EnvironmentTest.java +0 -43
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestActivity.java +0 -23
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestApplication.java +0 -35
- package/lib/android/app/src/test/java/com/reactnativenavigation/TestUtils.java +0 -62
- package/lib/android/app/src/test/java/com/reactnativenavigation/fakes/IconResolverFake.kt +0 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/BackDrawable.java +0 -30
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/ImageLoaderMock.kt +0 -49
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/Mocks.kt +0 -18
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleComponentViewController.java +0 -15
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleOverlay.java +0 -54
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/SimpleViewController.java +0 -113
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java +0 -79
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentViewCreator.java +0 -18
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestReactView.java +0 -71
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarButtonCreatorMock.java +0 -34
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TitleBarReactViewCreatorMock.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TopBarBackgroundViewCreatorMock.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/mocks/TypefaceLoaderMock.kt +0 -21
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/LayoutNodeParserTest.java +0 -51
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/OptionsTest.java +0 -315
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/OrientationOptionsTest.java +0 -81
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TopBarButtonsTest.kt +0 -95
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/TransitionAnimationOptionsTest.kt +0 -122
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/BoolParserTest.java +0 -28
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/ColorParseTest.java +0 -50
- package/lib/android/app/src/test/java/com/reactnativenavigation/options/parsers/JSONParserTest.java +0 -64
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/PresenterTest.java +0 -56
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/RenderCheckerTest.java +0 -59
- package/lib/android/app/src/test/java/com/reactnativenavigation/presentation/SideMenuPresenterTest.java +0 -35
- package/lib/android/app/src/test/java/com/reactnativenavigation/react/NavigationModuleTest.java +0 -102
- package/lib/android/app/src/test/java/com/reactnativenavigation/react/ReloadListenerTest.java +0 -24
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/AnimationHelper.kt +0 -33
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonPresenterTest.java +0 -241
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ButtonSpanTest.java +0 -57
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/CompatUtilsTest.java +0 -17
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/LayoutFactoryTest.java +0 -78
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/MotionEventTest.kt +0 -47
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/NativeCommandListenerTest.java +0 -60
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/OptionHelper.java +0 -16
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java +0 -26
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/StringUtilsTest.java +0 -19
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/SystemUiUtilsTest.kt +0 -27
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt +0 -357
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleBarHelper.java +0 -54
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiThreadTest.java +0 -29
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/UiUtilsTest.java +0 -22
- package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ViewHelper.java +0 -9
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java +0 -149
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabPresenterTest.java +0 -206
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsAttacherTest.java +0 -62
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsControllerTest.kt +0 -589
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/BottomTabsPresenterTest.kt +0 -173
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AfterInitialTabTest.java +0 -38
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/AttachModeTest.java +0 -86
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/OnSwitchToTabTest.java +0 -31
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/bottomtabs/attacher/modes/TogetherTest.java +0 -20
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/button/NavigationIconResolverTest.java +0 -78
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllerTest.java +0 -80
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistryTest.java +0 -56
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/component/ComponentViewControllerTest.java +0 -216
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/ExternalComponentViewControllerTest.java +0 -97
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/FragmentCreatorMock.java +0 -34
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/externalcomponent/SomeFragment.java +0 -8
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/fakes/FakeParentController.kt +0 -33
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorMock.java +0 -40
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalAnimatorTest.kt +0 -213
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalPresenterTest.java +0 -319
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/modal/ModalStackTest.java +0 -367
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/NavigatorTest.java +0 -898
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/navigator/RootPresenterTest.kt +0 -254
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayManagerTest.java +0 -108
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/parent/ParentControllerTest.java +0 -299
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/sidemenu/SideMenuControllerTest.java +0 -446
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/BackButtonHelperTest.java +0 -77
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/FloatingActionButtonTest.java +0 -154
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/IdStackTest.java +0 -114
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackAnimatorTest.kt +0 -241
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackControllerTest.kt +0 -1165
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/StackPresenterTest.kt +0 -1081
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarButtonControllerTest.java +0 -61
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TitleBarReactViewControllerTest.java +0 -43
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarButtonControllerTest.java +0 -120
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/stack/TopBarControllerTest.kt +0 -432
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/toptabs/TopTabsViewControllerTest.java +0 -249
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/ViewControllerTest.java +0 -337
- package/lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/viewcontroller/YellowBoxDelegateTest.java +0 -68
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/OverlayTouchDelegateTest.java +0 -60
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TitleAndButtonsContainerTest.kt +0 -477
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java +0 -82
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/BaseViewAnimatorTest.kt +0 -109
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/animations/DefaultViewAnimatorCreatorFake.kt +0 -36
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsContainerTest.kt +0 -101
- package/lib/android/app/src/test/java/com/reactnativenavigation/views/bottomtabs/BottomTabsTest.kt +0 -40
- package/lib/android/app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +0 -1
package/lib/android/app/src/test/java/com/reactnativenavigation/utils/ReflectionUtilsTest.java
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.utils;
|
|
2
|
-
|
|
3
|
-
import com.reactnativenavigation.*;
|
|
4
|
-
|
|
5
|
-
import org.junit.*;
|
|
6
|
-
|
|
7
|
-
import static org.assertj.core.api.Java6Assertions.*;
|
|
8
|
-
|
|
9
|
-
public class ReflectionUtilsTest extends BaseTest {
|
|
10
|
-
|
|
11
|
-
static class Foo {
|
|
12
|
-
private String bar = "old value";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@Test
|
|
16
|
-
public void setField() throws Exception {
|
|
17
|
-
Foo target = new Foo();
|
|
18
|
-
ReflectionUtils.setField(target, "bar", "a new value");
|
|
19
|
-
assertThat(target.bar).isEqualTo("a new value");
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Test
|
|
23
|
-
public void getDeclaredField() throws Exception {
|
|
24
|
-
assertThat(ReflectionUtils.getDeclaredField(new Foo(), "bar")).isEqualTo("old value");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.utils;
|
|
2
|
-
|
|
3
|
-
import com.reactnativenavigation.*;
|
|
4
|
-
|
|
5
|
-
import org.junit.*;
|
|
6
|
-
|
|
7
|
-
import static org.assertj.core.api.Java6Assertions.*;
|
|
8
|
-
|
|
9
|
-
public class StringUtilsTest extends BaseTest {
|
|
10
|
-
@Test
|
|
11
|
-
public void isEqual() throws Exception {
|
|
12
|
-
assertThat(StringUtils.isEqual(null, "a")).isFalse();
|
|
13
|
-
assertThat(StringUtils.isEqual("a", null)).isFalse();
|
|
14
|
-
assertThat(StringUtils.isEqual("a", "b")).isFalse();
|
|
15
|
-
assertThat(StringUtils.isEqual("a", "A")).isFalse();
|
|
16
|
-
assertThat(StringUtils.isEqual("a", "a")).isTrue();
|
|
17
|
-
assertThat(StringUtils.isEqual("", "")).isTrue();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
package com.reactnativenavigation.utils
|
|
2
|
-
|
|
3
|
-
import android.graphics.Color
|
|
4
|
-
import android.view.Window
|
|
5
|
-
import com.reactnativenavigation.BaseTest
|
|
6
|
-
import com.reactnativenavigation.utils.SystemUiUtils.STATUS_BAR_HEIGHT_TRANSLUCENCY
|
|
7
|
-
import org.junit.Test
|
|
8
|
-
import org.mockito.Mockito
|
|
9
|
-
import org.mockito.kotlin.verify
|
|
10
|
-
import kotlin.math.ceil
|
|
11
|
-
|
|
12
|
-
class SystemUiUtilsTest : BaseTest() {
|
|
13
|
-
|
|
14
|
-
@Test
|
|
15
|
-
fun `setStatusBarColor - should change color considering alpha`() {
|
|
16
|
-
val window = Mockito.mock(Window::class.java)
|
|
17
|
-
val alphaColor = Color.argb(44, 22, 255, 255)
|
|
18
|
-
val color = Color.argb(255, 22, 255, 255)
|
|
19
|
-
SystemUiUtils.setStatusBarColor(window, alphaColor, false)
|
|
20
|
-
|
|
21
|
-
verify(window).statusBarColor = alphaColor
|
|
22
|
-
|
|
23
|
-
SystemUiUtils.setStatusBarColor(window, color, true)
|
|
24
|
-
|
|
25
|
-
verify(window).statusBarColor = Color.argb(ceil(STATUS_BAR_HEIGHT_TRANSLUCENCY*255).toInt(), 22, 255, 255)
|
|
26
|
-
}
|
|
27
|
-
}
|
package/lib/android/app/src/test/java/com/reactnativenavigation/utils/TitleAndButtonsMeasurerTest.kt
DELETED
|
@@ -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
|
-
}
|