214 lines
8.8 KiB
TypeScript
214 lines
8.8 KiB
TypeScript
// Metro module 9824 (f9825).
|
|
import { useCallback, useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import BadgeDirectoryStore from "../../../badges/BadgeDirectoryStore";
|
|
import { getNextTierForProgress, getRemainingGiftsToNextTier, getTierForProgress } from "../../gifting/GiftingBadgeConstants";
|
|
import { ContentDismissActionType } from "../../../dismissible_content/DismissibleContentConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import useSafeAreaInsets_native from "../../../safe_area/useSafeAreaInsets.native";
|
|
import ModalActionCreators from "../../../../actions/ModalActionCreators";
|
|
import { getRootNavigationRef } from "../../../main_tabs_v2/RootNavigationRef.native";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
import { GiftIcon } from "../../../../design/components/Icon/native/redesign/generated/GiftIcon";
|
|
import { intl } from "../../../../intl/index.native";
|
|
import GiftingBadge_messages from "../../gifting/GiftingBadge.messages";
|
|
import GiftingBadgeProgress from "../../gifting/native/views/GiftingBadgeProgress";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { triggerHapticFeedback } from "../../../haptics/HapticUtils.native";
|
|
import HapticFeedbackTypes from "../../../haptics/HapticFeedbackTypes";
|
|
import GiftingBadgeIcon from "../../gifting/native/views/GiftingBadgeIcon";
|
|
import GiftingBadgeLevelUpProgress from "../../gifting/native/views/GiftingBadgeLevelUpProgress";
|
|
import { UNSAFE_markDismissibleContentAsDismissed } from "../../../dismissible_content/DismissibleContentUnsafeUtils";
|
|
import { DismissibleContent } from "../../../../_bundle/Module1358";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { BadgeId } from "../../../../_bundle/Module8106";
|
|
let useStyles, InProgressScreen, LevelUpScreen;
|
|
const PostPurchaseFooter = function PostPurchaseFooter(props) {
|
|
const onSendGift = props.onSendGift;
|
|
const styles = useStyles(useSafeAreaInsets_native().bottom);
|
|
const callback2 = useCallback(() => {
|
|
ModalActionCreators.pop();
|
|
onSendGift();
|
|
}, [onSendGift]);
|
|
const callback = useCallback(() => {
|
|
ModalActionCreators.pop();
|
|
const rootNavigationRef = getRootNavigationRef();
|
|
if (rootNavigationRef != null) {
|
|
rootNavigationRef.navigate("you");
|
|
}
|
|
}, []);
|
|
return <View style={styles.footer}>
|
|
<Button grow variant="primary" icon={<GiftIcon size="sm" color={Module712.colors.CONTROL_PRIMARY_TEXT_DEFAULT} />} text={intl.string(GiftingBadge_messages.g86YiI)} onPress={callback2} />
|
|
<Button grow variant="secondary" text={intl.string(GiftingBadge_messages["sa/cfM"])} onPress={callback} />
|
|
</View>;
|
|
};
|
|
InProgressScreen = function InProgressScreen(props) {
|
|
const { progress, title, progressBarTitle, description, currentTier, nextTier, onSendGift: onSendGift2 } = props;
|
|
const styles = useStyles(useSafeAreaInsets_native().bottom);
|
|
return <View style={styles.screenContainer}>
|
|
<View style={styles.content}>
|
|
<View style={styles.progressWrapper}>
|
|
<GiftingBadgeProgress progress={progress} currentTier={currentTier} nextTier={nextTier} iconSize={48} title={progressBarTitle} />
|
|
</View>
|
|
<View style={styles.messageSection}>
|
|
<Text variant="heading-xxl/bold" style={styles.centerText}>{title}</Text>
|
|
<Text variant="text-md/medium" color="text-subtle" style={styles.centerText}>{description}</Text>
|
|
</View>
|
|
</View>
|
|
<PostPurchaseFooter onSendGift={onSendGift2} />
|
|
</View>;
|
|
};
|
|
LevelUpScreen = function LevelUpScreen(props) {
|
|
const { simulatedProgress, currentTier, newTier, nextTier, giftsToNextTier, onSendGift: onSendGift2 } = props;
|
|
const styles = useStyles(useSafeAreaInsets_native().bottom);
|
|
useEffect(() => {
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_HEAVY);
|
|
}, []);
|
|
const r45 = [<View style={styles.levelUpIconWrapper}>
|
|
{newTier.simple_icon_url != null && <GiftingBadgeIcon icon={newTier.simple_icon_url} size={140} />}
|
|
</View>, ,];
|
|
const r53 = [<GiftingBadgeLevelUpProgress progress={simulatedProgress} currentTier={currentTier} newTier={newTier} style={styles.levelUpProgress} />, ,];
|
|
let name = newTier.name;
|
|
if (name == null) {
|
|
name = "";
|
|
}
|
|
const r69 = [<Text variant="heading-xxl/bold" style={styles.centerText}>
|
|
{intl.format(GiftingBadge_messages.k8MmO8, {
|
|
tierName: name
|
|
})}
|
|
</Text>, ,];
|
|
let r70 = nextTier != null && giftsToNextTier != null && giftsToNextTier > 0;
|
|
if (r70) {
|
|
const r82 = GiftingBadge_messages["6QVlxw"];
|
|
let name2 = nextTier.name;
|
|
if (name2 == null) {
|
|
name2 = "";
|
|
}
|
|
r70 = <Text variant="text-md/normal" color="text-subtle" style={styles.centerText}>
|
|
{intl.format(r82, {
|
|
count: giftsToNextTier,
|
|
nextTierName: name2
|
|
})}
|
|
</Text>;
|
|
}
|
|
r69[1] = r70;
|
|
r53[1] = <View style={styles.messageSection}>{r69}</View>;
|
|
r45[1] = <View style={styles.levelUpBody}>{r53}</View>;
|
|
return <View style={styles.screenContainer}>
|
|
<View style={styles.content}>{r45}</View>
|
|
<PostPurchaseFooter onSendGift={onSendGift2} />
|
|
</View>;
|
|
};
|
|
useStyles = createStyles((a0) => ({
|
|
screenContainer: {
|
|
flex: 1
|
|
},
|
|
content: {
|
|
flex: 1,
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
padding: Module712.space.PX_16
|
|
},
|
|
progressWrapper: {
|
|
padding: Module712.space.PX_16,
|
|
width: "100%",
|
|
marginBottom: Module712.space.PX_24
|
|
},
|
|
messageSection: {
|
|
gap: Module712.space.PX_12,
|
|
alignItems: "center",
|
|
width: "100%",
|
|
paddingHorizontal: Module712.space.PX_16
|
|
},
|
|
centerText: {
|
|
textAlign: "center"
|
|
},
|
|
levelUpIconWrapper: {
|
|
paddingVertical: 26,
|
|
paddingHorizontal: 74,
|
|
marginBottom: Module712.space.PX_48
|
|
},
|
|
levelUpBody: {
|
|
gap: Module712.space.PX_12,
|
|
alignItems: "center",
|
|
width: "100%"
|
|
},
|
|
levelUpProgress: {
|
|
maxWidth: 260
|
|
},
|
|
footer: {
|
|
width: "100%",
|
|
gap: Module712.space.PX_12,
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingBottom: Module712.space.PX_16 + a0
|
|
}
|
|
}));
|
|
export default function GiftBadgePostPurchase(props) {
|
|
let r100, props2;
|
|
const { currentProgress, onSendGift: onSendGift2 } = props;
|
|
useEffect(() => {
|
|
UNSAFE_markDismissibleContentAsDismissed(DismissibleContent.NEW_GIFTING_BADGES_COACHMARK, {
|
|
dismissAction: ContentDismissActionType.INDIRECT_ACTION
|
|
});
|
|
}, []);
|
|
const stateFromStores = useStateFromStores([BadgeDirectoryStore], () => BadgeDirectoryStore.getBadgeById(BadgeId.GIFTING)?.tiers);
|
|
if (stateFromStores == null) {
|
|
return null;
|
|
}
|
|
const tierForProgress2 = getTierForProgress(stateFromStores, currentProgress);
|
|
const simulatedProgress = currentProgress + 1;
|
|
const tierForProgress = getTierForProgress(stateFromStores, simulatedProgress);
|
|
const key = tierForProgress?.key;
|
|
const key2 = tierForProgress2?.key;
|
|
const nextTierForProgress = getNextTierForProgress(stateFromStores, simulatedProgress);
|
|
const remainingGiftsToNextTier = getRemainingGiftsToNextTier(stateFromStores, simulatedProgress);
|
|
if (key !== key2 && tierForProgress != null) {
|
|
r100 = <LevelUpScreen simulatedProgress={simulatedProgress} currentTier={tierForProgress2} newTier={tierForProgress} nextTier={nextTierForProgress} giftsToNextTier={remainingGiftsToNextTier} onSendGift={onSendGift2} />;
|
|
} else {
|
|
if (remainingGiftsToNextTier === 1) {
|
|
let nextTier = nextTierForProgress?.name;
|
|
if (nextTier == null) {
|
|
nextTier = "";
|
|
}
|
|
const r81 = {
|
|
title: intl.formatToPlainString(GiftingBadge_messages.KjdBPz, {
|
|
nextTier
|
|
}),
|
|
description: intl.string(GiftingBadge_messages.oqDrEM),
|
|
progressBarTitle: intl.string(GiftingBadge_messages["Ka5s+Q"]),
|
|
progress: simulatedProgress,
|
|
currentTier: null,
|
|
nextTier: null,
|
|
onSendGift: null
|
|
};
|
|
let currentTier = tierForProgress;
|
|
if (currentTier == null) {
|
|
currentTier = void 0;
|
|
}
|
|
r81.currentTier = currentTier;
|
|
let nextTier2 = nextTierForProgress;
|
|
if (nextTier2 == null) {
|
|
nextTier2 = void 0;
|
|
}
|
|
r81.nextTier = nextTier2;
|
|
r81.onSendGift = onSendGift2;
|
|
props2 = r81;
|
|
} else {
|
|
props2 = {
|
|
title: intl.string(GiftingBadge_messages["/rBQud"]),
|
|
description: intl.string(GiftingBadge_messages.DDQMlx),
|
|
progressBarTitle: tierForProgress2?.name != null ? intl.formatToPlainString(GiftingBadge_messages.bwyQt8, {
|
|
tierName: tierForProgress2?.name
|
|
}) : "",
|
|
progress: simulatedProgress,
|
|
currentTier: tierForProgress == null ? void 0 : tierForProgress,
|
|
nextTier: nextTierForProgress == null ? void 0 : nextTierForProgress,
|
|
onSendGift: onSendGift2
|
|
};
|
|
}
|
|
r100 = <InProgressScreen {...props2} />;
|
|
}
|
|
return r100;
|
|
};
|