NTP-17996 | RN Changes for iOS (#14059)
This commit is contained in:
@@ -4,8 +4,10 @@ import React, { useCallback, useEffect } from "react";
|
||||
import {
|
||||
EmitterSubscription,
|
||||
NativeEventEmitter,
|
||||
NativeModules,
|
||||
NativeScrollEvent,
|
||||
NativeSyntheticEvent,
|
||||
Platform,
|
||||
View,
|
||||
} from "react-native";
|
||||
import Animated, {
|
||||
@@ -32,6 +34,7 @@ import {
|
||||
HOME,
|
||||
INITIAL_Y_VALUE,
|
||||
NativeEventNameConstants,
|
||||
OsTypeConstants,
|
||||
QUOTE_OFFER_SCREEN,
|
||||
} from "../../../../common/constants";
|
||||
import { sendAsAnalyticsEvent } from "../../../../common/hooks/useAnalyticsEvent";
|
||||
@@ -61,7 +64,10 @@ const QuoteOfferScreen = ({
|
||||
const y = useSharedValue(0);
|
||||
const lastScrollPosition = useSharedValue(0);
|
||||
const navigation = useNavigation();
|
||||
const nativeEventListener = new NativeEventEmitter();
|
||||
const nativeEventListener =
|
||||
Platform.OS === OsTypeConstants.ANDROID
|
||||
? new NativeEventEmitter()
|
||||
: new NativeEventEmitter(NativeModules.DeviceEventEmitterModule);
|
||||
const derivedY = useDerivedValue(() => y.value);
|
||||
let reloadPageEventListener = {} as EmitterSubscription;
|
||||
const animationConfig = {
|
||||
|
||||
@@ -12,3 +12,8 @@ export const ApiMethod = {
|
||||
DELETE: "DELETE",
|
||||
PATCH: "PATCH",
|
||||
};
|
||||
|
||||
export enum OsTypeConstants {
|
||||
IOS = "ios",
|
||||
ANDROID = "android",
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ export const useBottomSheet = (
|
||||
const replaceBottomSheet = (modalView: ModalView) => {
|
||||
setTimeout(() => {
|
||||
removeBottomSheet();
|
||||
}, BOTTOMSHEET_ANIMATION_DURATION);
|
||||
setTimeout(() => {
|
||||
addBottomSheet(modalView);
|
||||
}, BOTTOMSHEET_ANIMATION_DURATION);
|
||||
// BOTTOMSHEET_ANIMATION_DURATION is for allowing the current bottomsheet to close animatically before opening the new one.
|
||||
|
||||
@@ -25,7 +25,7 @@ type LineItem = {
|
||||
|
||||
export interface BaseNavigator {
|
||||
navigate(navigationRef: any, ctaData: CtaData): any;
|
||||
goBack(navigationRef: any): any;
|
||||
goBack(navigationRef: any, ctaData: CtaData): any;
|
||||
push(navigationRef: any, ctaData: CtaData): any;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
import { BackHandler } from "react-native";
|
||||
import { BackHandler, Platform } from "react-native";
|
||||
import {
|
||||
ActionMetaData,
|
||||
BaseActionTypes,
|
||||
GenericActionPayload,
|
||||
} from "../actions/GenericAction";
|
||||
import { BASE_SCREEN } from "../constants/ScreenNameConstants";
|
||||
import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent";
|
||||
import { BaseNavigator, NavigationType } from "../interface";
|
||||
import { ScreenActionHandler } from "../screen/ScreenActionHandler";
|
||||
import WidgetActionHandler from "../widgets/widget-actions/WidgetActionHandler";
|
||||
import {
|
||||
AnalyticsEventNameConstants,
|
||||
EVENT_NAMES,
|
||||
} from "../constants/AnalyticsEventsConstant";
|
||||
import { BASE_SCREEN } from "../constants/ScreenNameConstants";
|
||||
import { sendAsAnalyticsEvent } from "../hooks/useAnalyticsEvent";
|
||||
import { BaseNavigator } from "../interface";
|
||||
import { NativeDeeplinkNavigatorModule } from "../native-module/NativeModules";
|
||||
import { ScreenActionHandler } from "../screen/ScreenActionHandler";
|
||||
import WidgetActionHandler from "../widgets/widget-actions/WidgetActionHandler";
|
||||
import { OsTypeConstants } from "../constants";
|
||||
|
||||
export const CtaNavigator: BaseNavigator = {
|
||||
navigate: (navigationRef, ctaData) => {
|
||||
navigationRef?.navigate(BASE_SCREEN, { ctaData });
|
||||
},
|
||||
goBack: navigationRef => {
|
||||
goBack: (navigationRef, ctaData) => {
|
||||
if (navigationRef?.canGoBack()) {
|
||||
navigationRef?.goBack();
|
||||
} else if (Platform.OS === OsTypeConstants.IOS) {
|
||||
NativeDeeplinkNavigatorModule.navigateToNaviDeeplinkNavigator(
|
||||
JSON.stringify(ctaData),
|
||||
);
|
||||
} else {
|
||||
BackHandler.exitApp();
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export const globalHandleClick = (
|
||||
CtaNavigator.navigate(navigation, cta);
|
||||
break;
|
||||
case CtaType.GO_BACK:
|
||||
CtaNavigator.goBack(navigation);
|
||||
CtaNavigator.goBack(navigation, cta);
|
||||
break;
|
||||
default:
|
||||
NativeDeeplinkNavigatorModule.navigateToNaviDeeplinkNavigator(
|
||||
|
||||
Reference in New Issue
Block a user