mattermost-mobile-upstream/patches/react-native-navigation+7.45.0.patch
Mattermost Build ad3de88ab4
MM-68274 - Adding watermark capability in mobile (#9682) (#9695)
* MM-68274 - Adding watermark capability in mobile

* Resolving mobile comments

* Fix watermark overlay on Android

* Updating mobile

* Updating test and watermark

* Update watermark

* Update app/screens/home/channel_list/channel_list.test.tsx



* Update tests

---------


(cherry picked from commit fbf37dd515)

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Your Name <larkox@gmail.com>
2026-04-16 16:58:40 +05:00

665 lines
36 KiB
Diff

diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java
index f3f0d5a..970296d 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/NavigationActivity.java
@@ -1,13 +1,12 @@
package com.reactnativenavigation;
-import android.annotation.TargetApi;
import android.content.Intent;
import android.content.res.Configuration;
-import android.os.Build;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
+import com.facebook.react.ReactActivity;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.PermissionAwareActivity;
import com.facebook.react.modules.core.PermissionListener;
@@ -24,9 +23,8 @@ import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-public class NavigationActivity extends AppCompatActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity, JsDevReloadHandler.ReloadListener {
+public class NavigationActivity extends ReactActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity, JsDevReloadHandler.ReloadListener {
@Nullable
private PermissionListener mPermissionListener;
@@ -49,7 +47,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
);
navigator.bindViews();
getReactGateway().onActivityCreated(this);
- setBackPressedCallback();
+ // setBackPressedCallback();
StatusBarPresenter.Companion.init(this);
}
@@ -96,15 +94,16 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
@Override
public void invokeDefaultOnBackPressed() {
- if (!navigator.handleBack(new CommandListenerAdapter())) {
- callback.setEnabled(false);
- NavigationActivity.super.onBackPressed();
- callback.setEnabled(true);
- }
+ // if (!navigator.handleBack(new CommandListenerAdapter())) {
+ // callback.setEnabled(false);
+ // NavigationActivity.super.onBackPressed();
+ // callback.setEnabled(true);
+ // }
+ super.invokeDefaultOnBackPressed();
}
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
getReactGateway().onActivityResult(this, requestCode, resultCode, data);
}
@@ -126,7 +125,6 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
return navigator;
}
- @TargetApi(Build.VERSION_CODES.M)
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) {
mPermissionListener = listener;
requestPermissions(permissions, requestCode);
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.java
index 4056b28..ea730d6 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/options/OverlayOptions.java
@@ -8,12 +8,18 @@ import org.json.JSONObject;
public class OverlayOptions {
public Bool interceptTouchOutside = new NullBool();
+ /**
+ * When true, touches inside the overlay's React content bounds are not delivered to the
+ * overlay and fall through to the underlying navigator content (Android only).
+ */
+ public Bool androidIgnoreTouchInside = new NullBool();
public static OverlayOptions parse(JSONObject json) {
OverlayOptions options = new OverlayOptions();
if (json == null) return options;
options.interceptTouchOutside = BoolParser.parse(json,"interceptTouchOutside");
+ options.androidIgnoreTouchInside = BoolParser.parse(json, "androidIgnoreTouchInside");
return options;
}
}
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java
index 4cc09eb..857bbd4 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java
@@ -31,6 +31,7 @@ import com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController;
import java.util.ArrayList;
import java.util.Objects;
+import java.util.Optional;
import static com.reactnativenavigation.utils.UiUtils.pxToDp;
@@ -60,21 +61,28 @@ public class NavigationModule extends ReactContextBaseJavaModule {
public void onHostPause() {
super.onHostPause();
UiUtils.runOnMainThread(() -> {
- if (activity() != null) navigator().onHostPause();
+ if (activity() != null) navigator().ifPresent(Navigator::onHostPause);
});
}
@Override
public void onHostResume() {
- eventEmitter = new EventEmitter(reactContext);
- navigator().setEventEmitter(eventEmitter);
- layoutFactory.init(
- activity(),
- eventEmitter,
- navigator().getChildRegistry(),
- ((NavigationApplication) activity().getApplication()).getExternalComponents()
- );
- UiUtils.runOnMainThread(() -> navigator().onHostResume());
+ try {
+ eventEmitter = new EventEmitter(reactContext);
+ if (navigator().isPresent()) {
+ Navigator navigator = navigator().get();
+ navigator.setEventEmitter(eventEmitter);
+ layoutFactory.init(
+ activity(),
+ eventEmitter,
+ navigator.getChildRegistry(),
+ ((NavigationApplication) activity().getApplication()).getExternalComponents()
+ );
+ UiUtils.runOnMainThread(navigator::onHostResume);
+ }
+ } catch (ClassCastException e) {
+ // The most current activity is not a NavigationActivity
+ }
}
});
}
@@ -116,7 +124,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
final LayoutNode layoutTree = LayoutNodeParser.parse(Objects.requireNonNull(jsonParser.parse(rawLayoutTree).optJSONObject("root")));
handle(() -> {
final ViewController<?> viewController = layoutFactory.create(layoutTree);
- navigator().setRoot(viewController, new NativeCommandListener("setRoot", commandId, promise, eventEmitter, now), reactInstanceManager);
+ navigator().ifPresent(nav -> nav.setRoot(viewController, new NativeCommandListener("setRoot", commandId, promise, eventEmitter, now), reactInstanceManager));
});
}
@@ -125,13 +133,13 @@ public class NavigationModule extends ReactContextBaseJavaModule {
handle(() -> {
Options defaultOptions = parse(options);
layoutFactory.setDefaultOptions(defaultOptions);
- navigator().setDefaultOptions(defaultOptions);
+ navigator().ifPresent(nav -> nav.setDefaultOptions(defaultOptions));
});
}
@ReactMethod
public void mergeOptions(String onComponentId, @Nullable ReadableMap options) {
- handle(() -> navigator().mergeOptions(onComponentId, parse(options)));
+ handle(() -> navigator().ifPresent(nav -> nav.mergeOptions(onComponentId, parse(options))));
}
@ReactMethod
@@ -139,7 +147,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(rawLayoutTree));
handle(() -> {
final ViewController<?> viewController = layoutFactory.create(layoutTree);
- navigator().push(onComponentId, viewController, new NativeCommandListener("push", commandId, promise, eventEmitter, now));
+ navigator().ifPresent(nav -> nav.push(onComponentId, viewController, new NativeCommandListener("push", commandId, promise, eventEmitter, now)));
});
}
@@ -151,23 +159,23 @@ public class NavigationModule extends ReactContextBaseJavaModule {
final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(children.getMap(i)));
_children.add(layoutFactory.create(layoutTree));
}
- navigator().setStackRoot(onComponentId, _children, new NativeCommandListener("setStackRoot", commandId, promise, eventEmitter, now));
+ navigator().ifPresent(nav -> nav.setStackRoot(onComponentId, _children, new NativeCommandListener("setStackRoot", commandId, promise, eventEmitter, now)));
});
}
@ReactMethod
public void pop(String commandId, String componentId, @Nullable ReadableMap mergeOptions, Promise promise) {
- handle(() -> navigator().pop(componentId, parse(mergeOptions), new NativeCommandListener("pop", commandId, promise, eventEmitter, now)));
+ handle(() -> navigator().ifPresent(nav -> nav.pop(componentId, parse(mergeOptions), new NativeCommandListener("pop", commandId, promise, eventEmitter, now))));
}
@ReactMethod
public void popTo(String commandId, String componentId, @Nullable ReadableMap mergeOptions, Promise promise) {
- handle(() -> navigator().popTo(componentId, parse(mergeOptions), new NativeCommandListener("popTo", commandId, promise, eventEmitter, now)));
+ handle(() -> navigator().ifPresent(nav -> nav.popTo(componentId, parse(mergeOptions), new NativeCommandListener("popTo", commandId, promise, eventEmitter, now))));
}
@ReactMethod
public void popToRoot(String commandId, String componentId, @Nullable ReadableMap mergeOptions, Promise promise) {
- handle(() -> navigator().popToRoot(componentId, parse(mergeOptions), new NativeCommandListener("popToRoot", commandId, promise, eventEmitter, now)));
+ handle(() -> navigator().ifPresent(nav -> nav.popToRoot(componentId, parse(mergeOptions), new NativeCommandListener("popToRoot", commandId, promise, eventEmitter, now))));
}
@ReactMethod
@@ -175,21 +183,21 @@ public class NavigationModule extends ReactContextBaseJavaModule {
final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(rawLayoutTree));
handle(() -> {
final ViewController<?> viewController = layoutFactory.create(layoutTree);
- navigator().showModal(viewController, new NativeCommandListener("showModal", commandId, promise, eventEmitter, now));
+ navigator().ifPresent(nav -> nav.showModal(viewController, new NativeCommandListener("showModal", commandId, promise, eventEmitter, now)));
});
}
@ReactMethod
public void dismissModal(String commandId, String componentId, @Nullable ReadableMap mergeOptions, Promise promise) {
handle(() -> {
- navigator().mergeOptions(componentId, parse(mergeOptions));
- navigator().dismissModal(componentId, new NativeCommandListener("dismissModal", commandId, promise, eventEmitter, now));
+ navigator().ifPresent(nav -> nav.mergeOptions(componentId, parse(mergeOptions)));
+ navigator().ifPresent(nav -> nav.dismissModal(componentId, new NativeCommandListener("dismissModal", commandId, promise, eventEmitter, now)));
});
}
@ReactMethod
public void dismissAllModals(String commandId, @Nullable ReadableMap mergeOptions, Promise promise) {
- handle(() -> navigator().dismissAllModals(parse(mergeOptions), new NativeCommandListener("dismissAllModals", commandId, promise, eventEmitter, now)));
+ handle(() -> navigator().ifPresent(nav -> nav.dismissAllModals(parse(mergeOptions), new NativeCommandListener("dismissAllModals", commandId, promise, eventEmitter, now))));
}
@ReactMethod
@@ -197,22 +205,25 @@ public class NavigationModule extends ReactContextBaseJavaModule {
final LayoutNode layoutTree = LayoutNodeParser.parse(jsonParser.parse(rawLayoutTree));
handle(() -> {
final ViewController<?> viewController = layoutFactory.create(layoutTree);
- navigator().showOverlay(viewController, new NativeCommandListener("showOverlay", commandId, promise, eventEmitter, now));
+ navigator().ifPresent(nav -> nav.showOverlay(viewController, new NativeCommandListener("showOverlay", commandId, promise, eventEmitter, now)));
});
}
@ReactMethod
public void dismissOverlay(String commandId, String componentId, Promise promise) {
- handle(() -> navigator().dismissOverlay(componentId, new NativeCommandListener("dismissOverlay", commandId, promise, eventEmitter, now)));
+ handle(() -> navigator().ifPresent(nav -> nav.dismissOverlay(componentId, new NativeCommandListener("dismissOverlay", commandId, promise, eventEmitter, now))));
}
@ReactMethod
public void dismissAllOverlays(String commandId, Promise promise) {
- handle(() -> navigator().dismissAllOverlays(new NativeCommandListener("dismissAllOverlays", commandId, promise, eventEmitter, now)));
+ handle(() -> navigator().ifPresent(nav -> nav.dismissAllOverlays(new NativeCommandListener("dismissAllOverlays", commandId, promise, eventEmitter, now))));
}
- private Navigator navigator() {
- return activity().getNavigator();
+ private Optional<Navigator> navigator() {
+ if (activity() instanceof NavigationActivity) {
+ return Optional.ofNullable(((NavigationActivity)activity()).getNavigator());
+ }
+ return Optional.empty();
}
private Options parse(@Nullable ReadableMap mergeOptions) {
@@ -223,22 +234,26 @@ public class NavigationModule extends ReactContextBaseJavaModule {
protected void handle(Runnable task) {
UiThread.post(() -> {
- if (getCurrentActivity() != null && !activity().isFinishing()) {
- task.run();
+ try {
+ if (getCurrentActivity() != null && !activity().isFinishing()) {
+ task.run();
+ }
+ } catch (ClassCastException e) {
+ // The most current activity is not a NavigationActivity)
}
});
}
- protected NavigationActivity activity() {
- return (NavigationActivity) getCurrentActivity();
+ protected Activity activity() {
+ return getCurrentActivity();
}
@Override
- public void onCatalystInstanceDestroy() {
- final NavigationActivity navigationActivity = activity();
+ public void invalidate() {
+ final NavigationActivity navigationActivity = (NavigationActivity)activity();
if (navigationActivity != null) {
navigationActivity.onCatalystInstanceDestroy();
}
- super.onCatalystInstanceDestroy();
+ super.invalidate();
}
}
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java
index 0db6f39..0b265b7 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/react/ReactView.java
@@ -10,7 +10,6 @@ import androidx.annotation.RestrictTo;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactRootView;
import com.facebook.react.bridge.ReactContext;
-import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.uimanager.JSTouchDispatcher;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.events.EventDispatcher;
@@ -35,7 +34,7 @@ public class ReactView extends ReactRootView implements IReactView, Renderable {
this.componentId = componentId;
this.componentName = componentName;
jsTouchDispatcher = new JSTouchDispatcher(this);
- setIsFabric(ReactFeatureFlags.enableFabricRenderer);
+ setIsFabric(false);
}
@Override
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java
index f014bff..e4ccc55 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildController.java
@@ -6,8 +6,10 @@ import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.CallSuper;
+import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
+import android.view.WindowManager;
import com.reactnativenavigation.options.Options;
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
@@ -93,6 +95,18 @@ public abstract class ChildController<T extends ViewGroup> extends ViewControlle
}
protected WindowInsetsCompat onApplyWindowInsets(View view, WindowInsetsCompat insets) {
+ Activity activity = getActivity();
+ Insets ime = insets.getInsets(WindowInsetsCompat.Type.ime());
+ if (activity != null) {
+ int softInputMode = activity.getWindow().getAttributes().softInputMode;
+ if (softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING && !isRoot()) {
+ view.setPadding(ime.left, ime.top, ime.right, 0);
+ return WindowInsetsCompat.CONSUMED;
+ }
+ }
+ if (!isRoot()) {
+ view.setPadding(0, 0, 0, 0);
+ }
return insets;
}
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistry.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistry.java
index b74c5f4..045aa53 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistry.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/child/ChildControllersRegistry.java
@@ -14,7 +14,7 @@ public class ChildControllersRegistry {
public void onViewDisappear(ChildController<?> child) {
if (isTopChild(child)) {
children.pop();
- if (!children.isEmpty()) children.peek().onViewBroughtToFront();
+ if (!children.isEmpty() && !children.peek().isDestroyed()) children.peek().onViewBroughtToFront();
} else {
children.remove(child);
}
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentPresenter.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentPresenter.java
index 1f915f9..a31a9ad 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentPresenter.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/component/ComponentPresenter.java
@@ -27,6 +27,8 @@ public class ComponentPresenter extends ComponentPresenterBase {
public void mergeOptions(ComponentLayout view, Options options) {
if (options.overlayOptions.interceptTouchOutside.hasValue())
view.setInterceptTouchOutside(options.overlayOptions.interceptTouchOutside);
+ if (options.overlayOptions.androidIgnoreTouchInside.hasValue())
+ view.setAndroidIgnoreTouchInside(options.overlayOptions.androidIgnoreTouchInside);
setBackgroundColor(view, options);
}
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java
index 845b882..e7315f4 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/component/ComponentLayout.java
@@ -69,12 +69,17 @@ public class ComponentLayout extends CoordinatorLayout implements ReactComponent
public void applyOptions(Options options) {
touchDelegate.setInterceptTouchOutside(options.overlayOptions.interceptTouchOutside);
+ touchDelegate.setAndroidIgnoreTouchInside(options.overlayOptions.androidIgnoreTouchInside);
}
public void setInterceptTouchOutside(Bool interceptTouchOutside) {
touchDelegate.setInterceptTouchOutside(interceptTouchOutside);
}
+ public void setAndroidIgnoreTouchInside(Bool androidIgnoreTouchInside) {
+ touchDelegate.setAndroidIgnoreTouchInside(androidIgnoreTouchInside);
+ }
+
@Override
public void sendOnNavigationButtonPressed(String buttonId) {
reactView.sendOnNavigationButtonPressed(buttonId);
diff --git a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/touch/OverlayTouchDelegate.kt b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/touch/OverlayTouchDelegate.kt
index 2c789ae..8f60226 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/touch/OverlayTouchDelegate.kt
+++ b/node_modules/react-native-navigation/lib/android/app/src/main/java/com/reactnativenavigation/views/touch/OverlayTouchDelegate.kt
@@ -10,17 +10,25 @@ import com.reactnativenavigation.views.component.ComponentLayout
open class OverlayTouchDelegate(private val component: ComponentLayout, private val reactView: ReactView) {
var interceptTouchOutside: Bool = NullBool()
+ var androidIgnoreTouchInside: Bool = NullBool()
fun onInterceptTouchEvent(event: MotionEvent): Boolean {
- return when (interceptTouchOutside.hasValue() && event.actionMasked == MotionEvent.ACTION_DOWN) {
- true -> handleDown(event)
- false -> component.superOnInterceptTouchEvent(event)
+ val useOverlayTouchHandling =
+ event.actionMasked == MotionEvent.ACTION_DOWN &&
+ (interceptTouchOutside.hasValue() || androidIgnoreTouchInside.hasValue())
+ return when {
+ useOverlayTouchHandling -> handleDown(event)
+ else -> component.superOnInterceptTouchEvent(event)
}
}
@VisibleForTesting
- open fun handleDown(event: MotionEvent) = when (event.coordinatesInsideView(reactView.getChildAt(0))) {
- true -> component.superOnInterceptTouchEvent(event)
- false -> interceptTouchOutside.isFalse
+ open fun handleDown(event: MotionEvent) = when {
+ event.coordinatesInsideView(reactView.getChildAt(0)) && androidIgnoreTouchInside.isTrue() ->
+ true
+ event.coordinatesInsideView(reactView.getChildAt(0)) ->
+ component.superOnInterceptTouchEvent(event)
+ else ->
+ interceptTouchOutside.isFalse()
}
}
\ No newline at end of file
diff --git a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReactGateway.java b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReactGateway.java
index 035ec31..630b8d4 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReactGateway.java
+++ b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/ReactGateway.java
@@ -69,4 +69,10 @@ public class ReactGateway {
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
host.getReactInstanceManager().onActivityResult(activity, requestCode, resultCode, data);
}
+
+ public void onWindowFocusChanged(boolean hasFocus) {
+ if (host.hasInstance()) {
+ host.getReactInstanceManager().onWindowFocusChange(hasFocus);
+ }
+ }
}
diff --git a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt
index 551f72b..e27c8aa 100644
--- a/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt
+++ b/node_modules/react-native-navigation/lib/android/app/src/reactNative71/java/com/reactnativenavigation/react/modal/ModalContentLayout.kt
@@ -49,17 +49,23 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
updateFirstChildView()
}
}
- override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent) {
- mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
+ override fun onChildStartedNativeGesture(child: View, androidEvent: MotionEvent?) {
+ androidEvent?.let {
+ mJSTouchDispatcher.onChildStartedNativeGesture(it, this.getEventDispatcher()!!)
+ }
}
- override fun onChildStartedNativeGesture(androidEvent: MotionEvent) {
- mJSTouchDispatcher.onChildStartedNativeGesture(androidEvent, this.getEventDispatcher())
+ override fun onChildStartedNativeGesture(androidEvent: MotionEvent?) {
+ androidEvent?.let {
+ mJSTouchDispatcher.onChildStartedNativeGesture(it, this.getEventDispatcher()!!)
+ }
}
- override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent) {
- mJSTouchDispatcher.onChildEndedNativeGesture(androidEvent, this.getEventDispatcher())
+ override fun onChildEndedNativeGesture(child: View, androidEvent: MotionEvent?) {
+ androidEvent?.let {
+ mJSTouchDispatcher.onChildEndedNativeGesture(it, this.getEventDispatcher()!!)
+ }
}
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
- private fun getEventDispatcher(): EventDispatcher {
+ private fun getEventDispatcher(): EventDispatcher? {
val reactContext: ReactContext = this.getReactContext()
return reactContext.getNativeModule(UIManagerModule::class.java)!!.eventDispatcher
}
@@ -74,12 +80,16 @@ class ModalContentLayout(context: Context?) : ReactViewGroup(context), RootView{
}
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
- mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
+ getEventDispatcher()?.let {
+ mJSTouchDispatcher.handleTouchEvent(event, it)
+ }
return super.onInterceptTouchEvent(event)
}
override fun onTouchEvent(event: MotionEvent): Boolean {
- mJSTouchDispatcher.handleTouchEvent(event, getEventDispatcher())
+ getEventDispatcher()?.let {
+ mJSTouchDispatcher.handleTouchEvent(event, it)
+ }
super.onTouchEvent(event)
return true
}
diff --git a/node_modules/react-native-navigation/lib/dist/src/interfaces/Options.d.ts b/node_modules/react-native-navigation/lib/dist/src/interfaces/Options.d.ts
index 08c7298..adcbcfd 100644
--- a/node_modules/react-native-navigation/lib/dist/src/interfaces/Options.d.ts
+++ b/node_modules/react-native-navigation/lib/dist/src/interfaces/Options.d.ts
@@ -1012,6 +1012,13 @@ export interface OverlayOptions {
* Capture touches outside of the Component View
*/
interceptTouchOutside?: boolean;
+ /**
+ * When true, touches inside the overlay's React content bounds are not delivered to the overlay
+ * and fall through to the underlying navigator content.
+ * #### (Android specific)
+ * @default false
+ */
+ androidIgnoreTouchInside?: boolean;
/**
* Control whether this Overlay should handle Keyboard events.
* Set this to true if your Overlay contains a TextInput.
diff --git a/node_modules/react-native-navigation/lib/ios/RNNComponentViewController.m b/node_modules/react-native-navigation/lib/ios/RNNComponentViewController.m
index fc482a6..9406bbf 100644
--- a/node_modules/react-native-navigation/lib/ios/RNNComponentViewController.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNComponentViewController.m
@@ -94,6 +94,7 @@
}];
}];
self.reactView.backgroundColor = UIColor.clearColor;
+ self.reactView.frame = UIScreen.mainScreen.bounds;
self.reactView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.reactView setFrame:self.view.frame];
[self.view addSubview:self.reactView];
diff --git a/node_modules/react-native-navigation/lib/ios/RNNOverlayWindow.m b/node_modules/react-native-navigation/lib/ios/RNNOverlayWindow.m
index b44f24f..a7d2ec9 100644
--- a/node_modules/react-native-navigation/lib/ios/RNNOverlayWindow.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNOverlayWindow.m
@@ -9,6 +9,8 @@
if ([hitTestResult isKindOfClass:[UIWindow class]] ||
[hitTestResult.subviews.firstObject isKindOfClass:RNNReactView.class] ||
+ [hitTestResult isKindOfClass:NSClassFromString(@"RNCSafeAreaView")] ||
+ [hitTestResult isKindOfClass:NSClassFromString(@"RNCSafeAreaProvider")] ||
[hitTestResult isKindOfClass:[RCTModalHostView class]] ||
[hitTestResult isKindOfClass:NSClassFromString(@"RCTRootComponentView")]) {
return nil;
diff --git a/node_modules/react-native-navigation/lib/ios/RNNTitleViewHelper.m b/node_modules/react-native-navigation/lib/ios/RNNTitleViewHelper.m
index db0ed23..b548589 100644
--- a/node_modules/react-native-navigation/lib/ios/RNNTitleViewHelper.m
+++ b/node_modules/react-native-navigation/lib/ios/RNNTitleViewHelper.m
@@ -36,6 +36,20 @@
@implementation RNNTitleViewHelper
+- (CGFloat)maxTitleViewWidthForNavigationBarBounds:(CGRect)navigationBarBounds {
+ CGFloat w = CGRectGetWidth(navigationBarBounds);
+ if (w > 0) {
+ return w;
+ }
+ return CGRectGetWidth(UIScreen.mainScreen.bounds);
+}
+
+- (void)configureSingleLineTruncatingLabel:(UILabel *)label {
+ label.numberOfLines = 1;
+ label.lineBreakMode = NSLineBreakByTruncatingTail;
+ label.adjustsFontSizeToFitWidth = NO;
+}
+
- (instancetype)initWithTitleViewOptions:(RNNTitleOptions *)titleOptions
subTitleOptions:(RNNSubtitleOptions *)subtitleOptions
parentTestID:(Text *)parentTestID
@@ -94,15 +108,21 @@
- (void)centerTitleView:(CGRect)navigationBarBounds
titleLabel:(UILabel *)titleLabel
subtitleLabel:(UILabel *)subtitleLabel {
+ CGFloat maxWidth = [self maxTitleViewWidthForNavigationBarBounds:navigationBarBounds];
+
+ CGFloat titleW = titleLabel ? CGRectGetWidth(titleLabel.bounds) : 0;
+ CGFloat subtitleW = subtitleLabel ? CGRectGetWidth(subtitleLabel.bounds) : 0;
+ CGFloat contentWidth = MAX(titleW, subtitleW);
+ CGFloat titleViewWidth = MIN(MAX(contentWidth, 0), maxWidth);
+
CGRect titleViewFrame = navigationBarBounds;
- titleViewFrame.size.width = MAX(titleLabel.frame.size.width, subtitleLabel.frame.size.width);
- ;
+ titleViewFrame.size.width = titleViewWidth;
self.titleView.frame = titleViewFrame;
for (UIView *view in self.titleView.subviews) {
CGRect viewFrame = view.frame;
- viewFrame.size.width = self.titleView.frame.size.width;
- viewFrame.origin.x = (self.titleView.frame.size.width - viewFrame.size.width) / 2;
+ viewFrame.size.width = titleViewWidth;
+ viewFrame.origin.x = (CGRectGetWidth(self.titleView.bounds) - viewFrame.size.width) / 2;
view.frame = viewFrame;
}
}
@@ -126,11 +146,15 @@
[subtitleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.subtitle
attributes:fontAttributes]];
- CGSize labelSize = [subtitleLabel.text sizeWithAttributes:fontAttributes];
- CGRect labelframe = subtitleLabel.frame;
- labelframe.size = labelSize;
- subtitleLabel.frame = labelframe;
- [subtitleLabel sizeToFit];
+ [self configureSingleLineTruncatingLabel:subtitleLabel];
+
+ CGFloat maxWidth = [self maxTitleViewWidthForNavigationBarBounds:self.titleView.bounds];
+ CGSize fitSize =
+ [subtitleLabel sizeThatFits:CGSizeMake(maxWidth, CGFLOAT_MAX)];
+ CGFloat labelWidth = MIN(fitSize.width, maxWidth);
+ subtitleLabel.frame =
+ CGRectMake(0, CGRectGetMinY(subtitleFrame), labelWidth, fitSize.height);
+
subtitleLabel.textAlignment = NSTextAlignmentCenter;
if (_subtitleOptions.color.hasValue) {
UIColor *color = _subtitleOptions.color.get;
@@ -166,11 +190,12 @@
[titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title
attributes:fontAttributes]];
- CGSize labelSize = [titleLabel.text sizeWithAttributes:fontAttributes];
- CGRect labelframe = titleLabel.frame;
- labelframe.size = labelSize;
- titleLabel.frame = labelframe;
- [titleLabel sizeToFit];
+ [self configureSingleLineTruncatingLabel:titleLabel];
+
+ CGFloat maxWidth = [self maxTitleViewWidthForNavigationBarBounds:self.titleView.bounds];
+ CGSize fitSize = [titleLabel sizeThatFits:CGSizeMake(maxWidth, CGFLOAT_MAX)];
+ CGFloat labelWidth = MIN(fitSize.width, maxWidth);
+ titleLabel.frame = CGRectMake(0, CGRectGetMinY(titleFrame), labelWidth, fitSize.height);
if (!self.subtitle) {
titleLabel.center = self.titleView.center;
diff --git a/node_modules/react-native-navigation/lib/src/interfaces/Options.ts b/node_modules/react-native-navigation/lib/src/interfaces/Options.ts
index f0923ed..b96ad42 100644
--- a/node_modules/react-native-navigation/lib/src/interfaces/Options.ts
+++ b/node_modules/react-native-navigation/lib/src/interfaces/Options.ts
@@ -1,5 +1,5 @@
// tslint:disable jsdoc-format
-import { ImageRequireSource, ImageSourcePropType, Insets, OpaqueColorValue } from 'react-native';
+import type { ImageRequireSource, ImageSourcePropType, Insets, OpaqueColorValue } from 'react-native';
// TODO: Import ColorValue instead when upgrading @types/react-native to 0.63+
// Only assign PlatformColor or DynamicColorIOS as a Color symbol!
@@ -1106,6 +1106,13 @@ export interface OverlayOptions {
* Capture touches outside of the Component View
*/
interceptTouchOutside?: boolean;
+ /**
+ * When true, touches inside the overlay's React content bounds are not delivered to the overlay
+ * and fall through to the underlying navigator content.
+ * #### (Android specific)
+ * @default false
+ */
+ androidIgnoreTouchInside?: boolean;
/**
* Control whether this Overlay should handle Keyboard events.
* Set this to true if your Overlay contains a TextInput.