react-native-navigation 7.33.4 → 7.35.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 (24) hide show
  1. package/index.e2e.js +4 -0
  2. package/jest-setup.js +2 -0
  3. package/lib/Mock/Layouts/ComponentNode.ts +1 -1
  4. package/lib/android/app/src/main/java/com/reactnativenavigation/utils/MotionEvent.kt +17 -3
  5. package/lib/android/app/src/main/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleAndButtonsContainer.kt +4 -0
  6. package/lib/android/app/src/reactNative51/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  7. package/lib/android/app/src/reactNative55/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  8. package/lib/android/app/src/reactNative56/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  9. package/lib/android/app/src/reactNative57/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  10. package/lib/android/app/src/reactNative57_5/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  11. package/lib/android/app/src/reactNative60/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  12. package/lib/android/app/src/reactNative62/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  13. package/lib/android/app/src/reactNative63/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  14. package/lib/android/app/src/reactNative68/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +1 -0
  15. package/lib/android/app/src/reactNative71/java/com/reactnativenavigation/views/stack/topbar/titlebar/TitleBarReactView.kt +10 -54
  16. package/lib/dist/Mock/Layouts/ComponentNode.js +1 -1
  17. package/lib/dist/src/interfaces/NavigationComponent.d.ts +2 -2
  18. package/lib/dist/src/interfaces/NavigationComponentProps.d.ts +6 -0
  19. package/lib/dist/src/interfaces/NavigationFunctionComponent.d.ts +3 -3
  20. package/lib/ios/RNNBridgeModule.m +5 -1
  21. package/lib/src/interfaces/NavigationComponent.ts +2 -2
  22. package/lib/src/interfaces/NavigationComponentProps.ts +7 -0
  23. package/lib/src/interfaces/NavigationFunctionComponent.ts +3 -3
  24. package/package.json +11 -6
package/index.e2e.js ADDED
@@ -0,0 +1,4 @@
1
+ import { LogBox } from 'react-native';
2
+ LogBox.ignoreAllLogs();
3
+
4
+ require('./playground/index');
package/jest-setup.js CHANGED
@@ -29,6 +29,8 @@ beforeEach(() => {
29
29
  mockUILib();
30
30
  });
31
31
 
32
+ setImmediate = (callback) => callback();
33
+
32
34
  const mockUILib = () => {
33
35
  const NativeModules = require('react-native').NativeModules;
34
36
  NativeModules.KeyboardTrackingViewTempManager = {};
@@ -13,7 +13,7 @@ export default class ComponentNode extends ParentNode {
13
13
 
14
14
  public componentDidMount() {
15
15
  this.componentDidMountOnce = true;
16
- this.componentDidAppearPending && this.componentDidAppear();
16
+ this.componentDidAppearPending && setImmediate(() => this.componentDidAppear());
17
17
  }
18
18
 
19
19
  public componentDidAppear() {
@@ -3,11 +3,25 @@ package com.reactnativenavigation.utils
3
3
  import android.graphics.Rect
4
4
  import android.view.MotionEvent
5
5
  import android.view.View
6
+ import android.view.ViewGroup
7
+ import com.reactnativenavigation.BuildConfig
6
8
 
7
9
  val hitRect = Rect()
8
10
 
9
11
  fun MotionEvent.coordinatesInsideView(view: View?): Boolean {
10
- view ?: return false
11
- view.getHitRect(hitRect)
12
- return hitRect.contains(x.toInt(), y.toInt())
12
+ if (BuildConfig.REACT_NATVE_VERSION_MINOR < 71) {
13
+ view ?: return false
14
+ view.getHitRect(hitRect)
15
+ return hitRect.contains(x.toInt(), y.toInt())
16
+ } else {
17
+ val viewGroup = (view as? ViewGroup)?.getChildAt(0) as? ViewGroup ?: return false
18
+
19
+ return if (viewGroup.childCount > 0) {
20
+ val content = viewGroup.getChildAt(0)
21
+ content.getHitRect(hitRect)
22
+ hitRect.contains(x.toInt(), y.toInt())
23
+ } else {
24
+ false
25
+ }
26
+ }
13
27
  }
@@ -153,6 +153,10 @@ class TitleAndButtonsContainer(context: Context) : ViewGroup(context) {
153
153
  val isCenter = titleComponentAlignment == Alignment.Center
154
154
  val titleHeightMeasureSpec = MeasureSpec.makeMeasureSpec(containerHeight, MeasureSpec.AT_MOST)
155
155
  val titleWidthMeasureSpec = makeTitleAtMostWidthMeasureSpec(containerWidth, rightBarWidth, leftBarWidth, isCenter)
156
+ if (titleComponent is TitleBarReactView) {
157
+ titleComponent.centered = isCenter
158
+ }
159
+
156
160
  titleComponent.measure(titleWidthMeasureSpec, titleHeightMeasureSpec)
157
161
  }
158
162
 
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -9,6 +9,7 @@ import com.reactnativenavigation.react.ReactView
9
9
  @SuppressLint("ViewConstructor")
10
10
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
11
11
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
12
+ var centered: Boolean = false
12
13
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
13
14
  super.onMeasure(interceptReactRootViewMeasureSpec(widthMeasureSpec), heightMeasureSpec)
14
15
  }
@@ -11,61 +11,17 @@ import com.reactnativenavigation.react.ReactView
11
11
  @SuppressLint("ViewConstructor")
12
12
  class TitleBarReactView(context: Context?, reactInstanceManager: ReactInstanceManager?, componentId: String?,
13
13
  componentName: String?) : ReactView(context, reactInstanceManager, componentId, componentName) {
14
+ var centered: Boolean = false
14
15
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
15
- super.onMeasure(interceptReactRootViewMeasureSpecWidth(widthMeasureSpec), interceptReactRootViewMeasureSpecHeight(heightMeasureSpec))
16
- }
17
-
18
- private fun interceptReactRootViewMeasureSpecWidth(widthMeasureSpec: Int): Int {
19
- // This is a HACK.
20
- // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
21
- // It's causing infinite measurements, that hung up the UI.
22
- // Intercepting largest child by width, and use its width as (parent) ReactRootView width fixed that.
23
- // See for more details https://github.com/wix/react-native-navigation/pull/7096
24
- val measuredWidth = this.getLastRootViewChildMaxWidth()
25
-
26
- return MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY)
27
- }
28
-
29
- private fun interceptReactRootViewMeasureSpecHeight(heightMeasureSpec: Int): Int {
30
- // This is a HACK.
31
- // ReactRootView has problematic behavior when setting width to WRAP_CONTENT,
32
- // It's causing infinite measurements, that hung up the UI.
33
- // Intercepting largest child by height, and use its height as (parent) ReactRootView width fixed that.
34
- // See for more details https://github.com/wix/react-native-navigation/pull/7096
35
- val measuredHeight = this.getLastRootViewChild()?.height
36
-
37
- return if (measuredHeight != null) MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY) else
38
- heightMeasureSpec
39
- }
40
-
41
- private fun getLastRootViewChildMaxWidth(): Int {
42
- if (rootViewGroup.children.count() == 0) {
43
- return 0
44
- }
45
- var maxWidth = rootViewGroup.width
46
- var next = rootViewGroup as Any
47
- while(next is ViewGroup) { //try {
48
- if (next.width > maxWidth) {
49
- maxWidth = next.width
50
- }
51
- if (next.children.count() == 0) break
52
- next.children.first().also { next = it }
53
- }
54
- return maxWidth
55
- }
56
-
57
- private fun getLastRootViewChild(): View? {
58
- if (rootViewGroup.children.count() == 0) {
59
- return null
60
- }
61
- var rootViewGroupLastChild: View = rootViewGroup
62
- var next = rootViewGroup as Any
63
- while(next is ViewGroup) { //try {
64
- rootViewGroupLastChild = next
65
- if (next.children.count() == 0) break
66
- next.children.first().also { next = it }
16
+ var titleHeightMeasureSpec: Int
17
+ var titleWidthMeasureSpec: Int
18
+ if (centered) {
19
+ titleHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
20
+ titleWidthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
21
+ } else {
22
+ titleHeightMeasureSpec = heightMeasureSpec
23
+ titleWidthMeasureSpec = widthMeasureSpec
67
24
  }
68
- @Suppress("UNREACHABLE_CODE")
69
- return rootViewGroupLastChild
25
+ super.onMeasure(titleWidthMeasureSpec, titleHeightMeasureSpec)
70
26
  }
71
27
  }
@@ -12,7 +12,7 @@ class ComponentNode extends ParentNode_1.default {
12
12
  }
13
13
  componentDidMount() {
14
14
  this.componentDidMountOnce = true;
15
- this.componentDidAppearPending && this.componentDidAppear();
15
+ this.componentDidAppearPending && setImmediate(() => this.componentDidAppear());
16
16
  }
17
17
  componentDidAppear() {
18
18
  if (this.componentDidMountOnce) {
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { NavigationButtonPressedEvent, SearchBarUpdatedEvent, SearchBarCancelPressedEvent, PreviewCompletedEvent, ScreenPoppedEvent, ComponentWillAppearEvent, ComponentDidAppearEvent, ComponentDidDisappearEvent } from './ComponentEvents';
3
- import { NavigationComponentProps } from './NavigationComponentProps';
3
+ import { NavigationProps } from './NavigationComponentProps';
4
4
  import { Options } from './Options';
5
- export declare class NavigationComponent<Props = {}, State = {}, Snapshot = any> extends React.Component<Props & NavigationComponentProps, State, Snapshot> {
5
+ export declare class NavigationComponent<Props = {}, State = {}, Snapshot = any> extends React.Component<Props & NavigationProps, State, Snapshot> {
6
6
  /**
7
7
  * Options used to apply a style configuration when the screen appears.
8
8
  *
@@ -1,4 +1,10 @@
1
+ /**
2
+ * @deprecated This type replaced with NavigationProps
3
+ */
1
4
  export interface NavigationComponentProps {
2
5
  componentId: string;
6
+ }
7
+ export interface NavigationProps {
8
+ componentId: string;
3
9
  componentName: string;
4
10
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { NavigationComponentProps } from './NavigationComponentProps';
2
+ import { NavigationProps } from './NavigationComponentProps';
3
3
  import { Options } from './Options';
4
- export interface NavigationFunctionComponent<Props = {}> extends React.FunctionComponent<Props & NavigationComponentProps> {
5
- options?: ((props: Props & NavigationComponentProps) => Options) | Options;
4
+ export interface NavigationFunctionComponent<Props = {}> extends React.FunctionComponent<Props & NavigationProps> {
5
+ options?: ((props: Props & NavigationProps) => Options) | Options;
6
6
  }
@@ -245,7 +245,11 @@ RCT_EXPORT_METHOD(getNavigationConstants
245
245
  }
246
246
 
247
247
  RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getNavigationConstantsSync) {
248
- return [Constants getConstants];
248
+ __block NSDictionary *c;
249
+ RCTUnsafeExecuteOnMainQueueSync(^{
250
+ c = [Constants getConstants];
251
+ });
252
+ return c;
249
253
  }
250
254
 
251
255
  @end
@@ -9,11 +9,11 @@ import {
9
9
  ComponentDidAppearEvent,
10
10
  ComponentDidDisappearEvent,
11
11
  } from './ComponentEvents';
12
- import { NavigationComponentProps } from './NavigationComponentProps';
12
+ import { NavigationProps } from './NavigationComponentProps';
13
13
  import { Options } from './Options';
14
14
 
15
15
  export class NavigationComponent<Props = {}, State = {}, Snapshot = any> extends React.Component<
16
- Props & NavigationComponentProps,
16
+ Props & NavigationProps,
17
17
  State,
18
18
  Snapshot
19
19
  > {
@@ -1,4 +1,11 @@
1
+ /**
2
+ * @deprecated This type replaced with NavigationProps
3
+ */
1
4
  export interface NavigationComponentProps {
2
5
  componentId: string;
6
+ }
7
+
8
+ export interface NavigationProps {
9
+ componentId: string;
3
10
  componentName: string;
4
11
  }
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { NavigationComponentProps } from './NavigationComponentProps';
2
+ import { NavigationProps } from './NavigationComponentProps';
3
3
  import { Options } from './Options';
4
4
 
5
5
  export interface NavigationFunctionComponent<Props = {}>
6
- extends React.FunctionComponent<Props & NavigationComponentProps> {
7
- options?: ((props: Props & NavigationComponentProps) => Options) | Options;
6
+ extends React.FunctionComponent<Props & NavigationProps> {
7
+ options?: ((props: Props & NavigationProps) => Options) | Options;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-navigation",
3
- "version": "7.33.4",
3
+ "version": "7.35.0",
4
4
  "description": "React Native Navigation - truly native navigation for iOS and Android",
5
5
  "license": "MIT",
6
6
  "nativePackage": true,
@@ -88,10 +88,10 @@
88
88
  "@types/react-test-renderer": "16.9.2",
89
89
  "@typescript-eslint/eslint-plugin": "4.33.0",
90
90
  "@typescript-eslint/parser": "4.33.0",
91
- "babel-jest": "^29.5.0",
91
+ "babel-jest": "^27.0.0",
92
92
  "clang-format": "^1.4.0",
93
93
  "detox": "20.9.0",
94
- "detox-testing-library-rnn-adapter": "2.x.x",
94
+ "detox-testing-library-rnn-adapter": "^2.0.3",
95
95
  "eslint": "7.32.0",
96
96
  "eslint-config-prettier": "6.11.0",
97
97
  "eslint-plugin-prettier": "3.1.4",
@@ -130,8 +130,11 @@
130
130
  "*.{h,m,mm}": "node ./scripts/check-clang-format"
131
131
  },
132
132
  "detox": {
133
- "test-runner": "jest",
134
- "specs": "",
133
+ "testRunner": {
134
+ "args": {
135
+ "config": "e2e/jest.config.js"
136
+ }
137
+ },
135
138
  "artifacts": {
136
139
  "plugins": {
137
140
  "log": "all",
@@ -168,7 +171,8 @@
168
171
  "ios.debug": {
169
172
  "type": "ios.app",
170
173
  "binaryPath": "playground/ios/DerivedData/playground/Build/Products/Debug-iphonesimulator/playground.app",
171
- "build": ":"
174
+ "start": "npm start -- --e2e",
175
+ "build": "RCT_NO_LAUNCH_PACKAGER=true xcodebuild build -scheme playground -workspace playground/ios/playground.xcworkspace -sdk iphonesimulator -configuration Debug -derivedDataPath playground/ios/DerivedData/playground ONLY_ACTIVE_ARCH=YES -quiet -UseModernBuildSystem=YES"
172
176
  },
173
177
  "ios.release": {
174
178
  "type": "ios.app",
@@ -178,6 +182,7 @@
178
182
  "android.debug": {
179
183
  "type": "android.apk",
180
184
  "binaryPath": "playground/android/app/build/outputs/apk/debug/app-debug.apk",
185
+ "start": "npm start -- --e2e",
181
186
  "build": "cd playground/android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug"
182
187
  },
183
188
  "android.release": {