150 lines
6.8 KiB
TypeScript
150 lines
6.8 KiB
TypeScript
// Metro module 7954 (f7955).
|
|
import * as Module19 from "react";
|
|
import { useEffect, useMemo, useCallback } from "react";
|
|
import AccessibilityStore from "../../a11y/AccessibilityStore";
|
|
import { CollectiblesMobileShopScreen } from "../../collectibles/CollectiblesShopConstants";
|
|
import { MEDIA_PICKER_SEND_BUTTON_SPRING } from "../../media_keyboard/native/MediaKeyboardConstants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import useCollectiblesData from "../../collectibles/hooks/useCollectiblesData";
|
|
import ReanimatedRexport, { useSharedValue, useAnimatedStyle, useAnimatedProps } from "../../reanimated/ReanimatedRexport";
|
|
import * as _spring from "../../../design/animation/reanimated/spring/spring";
|
|
import PremiumUtils from "../../../utils/PremiumUtils";
|
|
import { isPremiumCollectiblesProduct, isPremiumCollectiblesPurchase } from "../../collectibles/CollectiblesUtils";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { triggerHapticFeedback, HapticFeedbackTypes } from "../../haptics/HapticUtils.native";
|
|
import { navigateToNitroManagement } from "./EditCollectiblesActionCreators";
|
|
import { openCollectiblesShopMobile } from "../../collectibles/CollectiblesActionCreators";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
const useStyles = createStyles({
|
|
buttonRowContainer: {
|
|
flexGrow: 0,
|
|
flexDirection: "row",
|
|
justifyContent: "flex-end",
|
|
paddingHorizontal: 12,
|
|
height: 48
|
|
},
|
|
buttonContainer: {
|
|
position: "absolute",
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
marginLeft: 24,
|
|
marginRight: 24,
|
|
flexDirection: "column",
|
|
justifyContent: "flex-end"
|
|
}
|
|
});
|
|
const __initData = {
|
|
code: "function EditCollectiblesCTAButtonTsx1(){const{shouldShowButton,APPLY_BUTTON_BOUNCE_DISTANCE,APPLY_BUTTON_SCALE_TRANSITION,reducedMotion,withSpring,MEDIA_PICKER_SEND_BUTTON_SPRING}=this.__closure;const targetTranslateY=shouldShowButton.get()?0:APPLY_BUTTON_BOUNCE_DISTANCE;const targetScale=shouldShowButton.get()?1:APPLY_BUTTON_SCALE_TRANSITION;return{transform:[{translateY:reducedMotion?targetTranslateY:withSpring(targetTranslateY,MEDIA_PICKER_SEND_BUTTON_SPRING)},{scale:reducedMotion?targetScale:withSpring(targetScale,MEDIA_PICKER_SEND_BUTTON_SPRING)}]};}"
|
|
};
|
|
const __initData2 = {
|
|
code: "function EditCollectiblesCTAButtonTsx2(){const{shouldShowButton}=this.__closure;return{pointerEvents:shouldShowButton.get()?'box-none':'none'};}"
|
|
};
|
|
const __initData3 = {
|
|
code: "function EditCollectiblesCTAButtonTsx3(){const{shouldShowButton,reducedMotion,withSpring,MEDIA_PICKER_SEND_BUTTON_SPRING}=this.__closure;const targetOpacity=shouldShowButton.get()?1:0;return{opacity:reducedMotion?targetOpacity:withSpring(targetOpacity,{...MEDIA_PICKER_SEND_BUTTON_SPRING,overshootClamping:true})};}"
|
|
};
|
|
const r38 = Module19.memo(function({ user, currentSkuId, selectedSkuId, isTryItOut: isTryItOut2, onApply, analyticsLocations, analyticsSource }) {
|
|
let sharedValue, isTryItOut, c16125_9;
|
|
sharedValue = void 0;
|
|
isTryItOut = void 0;
|
|
c16125_9 = void 0;
|
|
const styles = useStyles();
|
|
const bottom = useSafeAreaInsets_native().bottom;
|
|
const stateFromStores = useStateFromStores([AccessibilityStore], () => AccessibilityStore.useReducedMotion);
|
|
const collectiblesData = useCollectiblesData(selectedSkuId);
|
|
const { product, purchase } = collectiblesData;
|
|
sharedValue = useSharedValue(false);
|
|
useEffect(() => {
|
|
sharedValue.set(selectedSkuId !== currentSkuId);
|
|
}, [selectedSkuId, currentSkuId, sharedValue]);
|
|
const O = function O() {
|
|
const r0 = sharedValue.get() ? 0 : 60;
|
|
const r1 = sharedValue.get() ? 1 : 0.9;
|
|
return {
|
|
transform: [{
|
|
translateY: stateFromStores ? r0 : _spring.withSpring(r0, MEDIA_PICKER_SEND_BUTTON_SPRING)
|
|
}, {
|
|
scale: stateFromStores ? r1 : _spring.withSpring(r1, MEDIA_PICKER_SEND_BUTTON_SPRING)
|
|
}]
|
|
};
|
|
};
|
|
O.__closure = {
|
|
shouldShowButton: sharedValue,
|
|
APPLY_BUTTON_BOUNCE_DISTANCE: 60,
|
|
APPLY_BUTTON_SCALE_TRANSITION: 0.9,
|
|
reducedMotion: stateFromStores,
|
|
withSpring: _spring.withSpring,
|
|
MEDIA_PICKER_SEND_BUTTON_SPRING
|
|
};
|
|
O.__workletHash = 15594859424201;
|
|
O.__initData = __initData;
|
|
const animatedStyle = useAnimatedStyle(O);
|
|
const M = function M() {
|
|
return {
|
|
pointerEvents: sharedValue.get() ? "box-none" : "none"
|
|
};
|
|
};
|
|
M.__closure = {
|
|
shouldShowButton: sharedValue
|
|
};
|
|
M.__workletHash = 16151141699021;
|
|
M.__initData = __initData2;
|
|
const animatedProps = useAnimatedProps(M);
|
|
const R = function R() {
|
|
const r0 = sharedValue.get() ? 1 : 0;
|
|
return {
|
|
opacity: stateFromStores ? r0 : _spring.withSpring(r0, {
|
|
...MEDIA_PICKER_SEND_BUTTON_SPRING,
|
|
overshootClamping: true
|
|
})
|
|
};
|
|
};
|
|
R.__closure = {
|
|
shouldShowButton: sharedValue,
|
|
reducedMotion: stateFromStores,
|
|
withSpring: _spring.withSpring,
|
|
MEDIA_PICKER_SEND_BUTTON_SPRING
|
|
};
|
|
R.__workletHash = 13351061137085;
|
|
R.__initData = __initData3;
|
|
const animatedStyle2 = useAnimatedStyle(R);
|
|
const canUseCollectibles = PremiumUtils.canUseCollectibles(user);
|
|
let r81 = isPremiumCollectiblesProduct(product) || isPremiumCollectiblesPurchase(purchase);
|
|
const r85 = canUseCollectibles ? !canUseCollectibles : isPremiumCollectiblesPurchase(purchase);
|
|
isTryItOut = selectedSkuId == null || purchase != null && !r85 || (r81 ? isTryItOut2 : r81);
|
|
if (r81) {
|
|
r81 = !canUseCollectibles;
|
|
}
|
|
if (r81) {
|
|
r81 = !isTryItOut2;
|
|
}
|
|
c16125_9 = r81;
|
|
const memo = useMemo(() => isTryItOut ? intl.string(t.Jh8fJz) : c16125_9 ? PremiumUtils.isPremium(user) ? intl.string(t.KXLX7l) : intl.string(t.mr4K7D) : intl.string(t.fYfGgK), [isTryItOut, r81, user]);
|
|
return <ReanimatedRexport.View style={[styles.buttonContainer, animatedStyle2]} animatedProps={animatedProps}>
|
|
<ReanimatedRexport.View style={[styles.buttonRowContainer, animatedStyle, {
|
|
marginBottom: bottom
|
|
}]} pointerEvents="box-none">
|
|
<Button variant={r81 ? "active" : "primary"} onPress={useCallback(() => {
|
|
if (isTryItOut) {
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_MEDIUM);
|
|
onApply();
|
|
} else if (c16125_9) {
|
|
navigateToNitroManagement();
|
|
} else {
|
|
openCollectiblesShopMobile({
|
|
analyticsLocations,
|
|
analyticsSource,
|
|
initialProductSkuId: selectedSkuId,
|
|
screen: CollectiblesMobileShopScreen.SHOP_ALL
|
|
});
|
|
}
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
}, [isTryItOut, onApply, r81, analyticsLocations, analyticsSource, selectedSkuId])} size="md" text={memo} grow />
|
|
</ReanimatedRexport.View>
|
|
</ReanimatedRexport.View>;
|
|
});
|
|
export default r38;
|