NTP-17996 | RN Changes for iOS (#14059)
This commit is contained in:
@@ -4,6 +4,8 @@ import { StyledLottie } from "../styled-lottie/StyledLottie";
|
||||
|
||||
import {
|
||||
NativeEventEmitter,
|
||||
NativeModules,
|
||||
Platform,
|
||||
ViewStyle,
|
||||
useWindowDimensions,
|
||||
} from "react-native";
|
||||
@@ -24,9 +26,10 @@ import { GenericActionPayload } from "../../../App/common/actions/GenericAction"
|
||||
import { NativeEventNameConstants } from "../../../App/common/constants/EventNameConstants";
|
||||
import { CtaData } from "../../../App/common/interface";
|
||||
import { FabWidgetData } from "../../../App/common/interface/widgets/widgetData/FabWidgetData";
|
||||
import { FAB_HEIGHT, styles } from "./FABStyle";
|
||||
import { StyledImage } from "../../StyledImage";
|
||||
import { getTextWithHtmlSpace } from "../../../App/common/utilities/MiscUtils";
|
||||
import { StyledImage } from "../../StyledImage";
|
||||
import { FAB_HEIGHT, styles } from "./FABStyle";
|
||||
import { OsTypeConstants } from "../../../App/common/constants";
|
||||
|
||||
const FAB = ({
|
||||
widgetData,
|
||||
@@ -37,7 +40,7 @@ const FAB = ({
|
||||
widgetData: FabWidgetData;
|
||||
handleActions: (
|
||||
value: any | undefined | null,
|
||||
actionPayloadList: GenericActionPayload | undefined
|
||||
actionPayloadList: GenericActionPayload | undefined,
|
||||
) => void;
|
||||
handleClick?: (cta: CtaData) => void;
|
||||
scrollStyle?: ViewStyle;
|
||||
@@ -45,18 +48,21 @@ const FAB = ({
|
||||
const [enabled, setEnabled] = useState(true);
|
||||
const { height } = useWindowDimensions();
|
||||
useEffect(() => {
|
||||
const nativeEventListener = new NativeEventEmitter();
|
||||
const nativeEventListener =
|
||||
Platform.OS === OsTypeConstants.ANDROID
|
||||
? new NativeEventEmitter()
|
||||
: new NativeEventEmitter(NativeModules.DeviceEventEmitterModule);
|
||||
let reloadPageEventListener = nativeEventListener.addListener(
|
||||
NativeEventNameConstants.reloadPage,
|
||||
(event) => {
|
||||
event => {
|
||||
if (event === true) {
|
||||
setEnabled(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
return () => {
|
||||
nativeEventListener.removeAllListeners(
|
||||
NativeEventNameConstants.reloadPage
|
||||
NativeEventNameConstants.reloadPage,
|
||||
);
|
||||
setEnabled(true);
|
||||
};
|
||||
@@ -86,7 +92,7 @@ const FAB = ({
|
||||
const maxY = 0;
|
||||
fabPositionY.value = clamp(newY, minY, maxY);
|
||||
},
|
||||
onEnd: (_) => {},
|
||||
onEnd: _ => {},
|
||||
});
|
||||
|
||||
const animatedRootStyles = useAnimatedStyle(() => {
|
||||
@@ -96,7 +102,7 @@ const FAB = ({
|
||||
});
|
||||
|
||||
const isDraggable = widgetData?.properties?.isDraggable ?? true;
|
||||
const buttonText = getTextWithHtmlSpace(widgetData?.buttonTitle?.text)
|
||||
const buttonText = getTextWithHtmlSpace(widgetData?.buttonTitle?.text);
|
||||
|
||||
const fabContent = (
|
||||
<Animated.View style={[styles.rootStyles, animatedRootStyles]}>
|
||||
|
||||
Reference in New Issue
Block a user