126 lines
5.6 KiB
TypeScript
126 lines
5.6 KiB
TypeScript
// Metro module 15790 (f15791).
|
|
import { useRef, useState, useEffect, useCallback } from "react";
|
|
import { Pressable, StyleSheet, TouchableOpacity, View } from "react-native";
|
|
import { LaunchPadTypes } from "./LaunchPadConstants";
|
|
import { AnalyticEvents, ComponentActions } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import RouteManager from "../../routing/RouteManager";
|
|
import { ComponentDispatch } from "../../../utils/ComponentDispatchUtils";
|
|
import { useIsModalOpen } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
|
|
import useLaunchPadAnimatedStyles_native from "./useLaunchPadAnimatedStyles.native";
|
|
import useStateFromSharedValue from "../../reanimated/native/useStateFromSharedValue";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { setLaunchPadPullTabExclusionRect, clearLaunchPadPullTabExclusionRect } from "./LaunchPadPullTabCache";
|
|
import { triggerHapticFeedback, HapticFeedbackTypes } from "../../haptics/HapticUtils.native";
|
|
import useBackPressHandler from "../../routing/native/useBackPressHandler";
|
|
import useRefValue from "../../../hooks/useRefValue";
|
|
import ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import LaunchPadPullTab from "./LaunchPadPullTab";
|
|
import { AccessibilityView } from "../../../design/components/AccessibilityView/AccessibilityView.native";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { Freeze } from "../../../_bundle/Suspender";
|
|
import LaunchPad from "./LaunchPad";
|
|
const useStyles = createStyles({
|
|
modalWrapper: {
|
|
height: "100%",
|
|
width: "100%",
|
|
paddingTop: Module712.space.PX_8
|
|
},
|
|
a11yDismiss: {
|
|
position: "absolute",
|
|
top: 0,
|
|
width: "100%",
|
|
height: Module712.space.PX_8
|
|
}
|
|
});
|
|
export default function LaunchPadWrapper(props) {
|
|
let callback;
|
|
let updaters2;
|
|
const { launchPadType, gestureState, launchPadShown, launchPadSharedState, launchPadPullTabState, updaters } = props;
|
|
callback = void 0;
|
|
const styles = useStyles();
|
|
const isModalOpen = useIsModalOpen();
|
|
const launchPadAnimatedStyles_native = useLaunchPadAnimatedStyles_native({
|
|
launchPadSharedState,
|
|
launchPadShown,
|
|
gestureState
|
|
});
|
|
const { launchPadCoverStyles, launchPadStyles } = launchPadAnimatedStyles_native;
|
|
const stateFromSharedValue = useStateFromSharedValue(launchPadShown);
|
|
let c22445_3 = stateFromSharedValue;
|
|
const ref = useRef(!stateFromSharedValue);
|
|
const [, setState] = useState({});
|
|
useEffect(() => {
|
|
if (c22445_3) {
|
|
ref.current = false;
|
|
return void 0;
|
|
}
|
|
let c28157_0 = setTimeout(() => {
|
|
ref.current = true;
|
|
setState({});
|
|
}, 1000);
|
|
return () => clearTimeout(c28157_0);
|
|
}, [stateFromSharedValue]);
|
|
callback = useCallback(() => updaters.setLaunchPadPosition(0), [updaters]);
|
|
useEffect(() => {
|
|
if (c22445_3) {
|
|
AnalyticsUtils.track(AnalyticEvents.LAUNCHPAD_OPENED);
|
|
}
|
|
}, [stateFromSharedValue]);
|
|
useEffect(() => {
|
|
L5: {
|
|
if (launchPadType === LaunchPadTypes.PULL_TAB && !isModalOpen) {
|
|
setLaunchPadPullTabExclusionRect();
|
|
if (!c22445_3) {
|
|
break L5;
|
|
}
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
|
|
} else {
|
|
clearLaunchPadPullTabExclusionRect();
|
|
}
|
|
}
|
|
}, [launchPadType, stateFromSharedValue, isModalOpen]);
|
|
useEffect(() => () => clearLaunchPadPullTabExclusionRect(), [launchPadShown]);
|
|
useBackPressHandler(() => {
|
|
if (c22445_3) {
|
|
callback();
|
|
}
|
|
return c22445_3;
|
|
});
|
|
updaters2 = updaters;
|
|
useEffect(() => {
|
|
let hideLaunchPad2, c30919_2;
|
|
const showLaunchPad2 = function showLaunchPad() {
|
|
updaters2.setLaunchPadShown(true);
|
|
updaters2.setLaunchPadPosition(1);
|
|
};
|
|
hideLaunchPad2 = function hideLaunchPad() {
|
|
updaters2.setLaunchPadShown(false);
|
|
updaters2.setLaunchPadPosition(0);
|
|
};
|
|
c30919_2 = RouteManager.addRouteChangeListener(hideLaunchPad2);
|
|
ComponentDispatch.subscribe(ComponentActions.LAUNCH_PAD_SHOW, showLaunchPad2);
|
|
ComponentDispatch.subscribe(ComponentActions.LAUNCH_PAD_HIDE, hideLaunchPad2);
|
|
return () => {
|
|
c30919_2();
|
|
ComponentDispatch.unsubscribe(ComponentActions.LAUNCH_PAD_SHOW, showLaunchPad2);
|
|
ComponentDispatch.unsubscribe(ComponentActions.LAUNCH_PAD_HIDE, hideLaunchPad2);
|
|
};
|
|
}, [updaters]);
|
|
const refValue = useRefValue(ref);
|
|
return <View style={StyleSheet.absoluteFill} pointerEvents="box-none">
|
|
<ReanimatedRexport.View style={launchPadCoverStyles} pointerEvents="none" />
|
|
{launchPadType === LaunchPadTypes.PULL_TAB ? isModalOpen ? null : <LaunchPadPullTab gestureState={gestureState} launchPadSharedState={launchPadSharedState} launchPadPullTabState={launchPadPullTabState} updaters={updaters} /> : null}
|
|
<ReanimatedRexport.View style={launchPadStyles} pointerEvents={stateFromSharedValue ? void 0 : "none"}>
|
|
<AccessibilityView nativeID="launch-pad" style={styles.modalWrapper} onAccessibilityEscape={callback} accessibilityViewIsModal={stateFromSharedValue}>
|
|
<Pressable importantForAccessibility={stateFromSharedValue ? "yes" : "no"} accessibilityRole="button" accessibilityLabel={intl.string(t.WAI6xu)} onPress={callback} style={styles.a11yDismiss} />
|
|
<TouchableOpacity accessible={false} aria-hidden onPress={callback} style={StyleSheet.absoluteFillObject} />
|
|
<Freeze freeze={stateFromSharedValue ? !stateFromSharedValue : refValue}>
|
|
<LaunchPad visible={stateFromSharedValue} sharedState={launchPadSharedState} />
|
|
</Freeze>
|
|
</AccessibilityView>
|
|
</ReanimatedRexport.View>
|
|
</View>;
|
|
};
|