150 lines
6.1 KiB
TypeScript
150 lines
6.1 KiB
TypeScript
// Metro module 14145 (f14146).
|
|
import { useMemo, useRef, useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useQuestTaskDetails, useTaskPlatformScreen } from "../../hooks/QuestHooks";
|
|
import * as _QuestTaskUtils from "../../utils/QuestTaskUtils";
|
|
import { hasStreamOnDesktopTask, getDefaultInGameTask } from "../../utils/QuestTaskUtils";
|
|
import { useHasWatchVideoOnMobileTasks } from "../QuestHooks.native";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { getDefaultRewardNameWithArticle } from "../../utils/QuestRewardUtils";
|
|
import * as _QuestUtils from "../../utils/QuestUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { QuestBottomSheetStep } from "./QuestBottomSheet";
|
|
import { TaskPlatformScreen } from "../../QuestTypes";
|
|
import { useActionSheetPressHandler } from "../QuestDock/QuestDockHooks";
|
|
import { useIsScreenReaderEnabled } from "../../../a11y/native/useIsScreenReaderEnabled.native";
|
|
import { setAccessibilityFocus } from "../../../a11y/native/setAccessibilityFocus.android";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
|
|
import { MoreHorizontalIcon } from "../../../../design/components/Icon/native/redesign/generated/MoreHorizontalIcon";
|
|
const useStyles = createStyles({
|
|
container: {
|
|
display: "flex",
|
|
gap: 6,
|
|
paddingHorizontal: Module712.space.PX_16,
|
|
paddingTop: Module712.space.PX_8
|
|
},
|
|
containerWithActionSheet: {
|
|
alignItems: "center",
|
|
flexDirection: "row",
|
|
paddingHorizontal: Module712.space.PX_8
|
|
},
|
|
title: {
|
|
textAlign: "center"
|
|
},
|
|
titleWithActionSheet: {
|
|
textAlign: "left",
|
|
flex: 1
|
|
},
|
|
actionSheetButton: {
|
|
flexGrow: 0,
|
|
flexShrink: 0
|
|
}
|
|
});
|
|
export default function QuestBottomSheetHeader(props) {
|
|
const { quest: quest2, step: step2 } = props;
|
|
let withActionSheet = props.withActionSheet;
|
|
if (withActionSheet === void 0) {
|
|
withActionSheet = false;
|
|
}
|
|
let isScreenReaderEnabled, ref;
|
|
let hasWatchVideoOnMobileTasks, defaultRewardNameWithArticle, isSponsoredPlayQuest;
|
|
props.location;
|
|
isScreenReaderEnabled = void 0;
|
|
ref = void 0;
|
|
const styles = useStyles();
|
|
const actionSheetPressHandler = useActionSheetPressHandler(quest2);
|
|
const quest = quest2;
|
|
const step = step2;
|
|
hasWatchVideoOnMobileTasks = void 0;
|
|
defaultRewardNameWithArticle = void 0;
|
|
isSponsoredPlayQuest = void 0;
|
|
const r32 = quest.userStatus?.completedAt != null;
|
|
let c20945_2 = r32;
|
|
const gameTitle = quest.config.messages.gameTitle;
|
|
const questTaskDetails = useQuestTaskDetails(quest);
|
|
const hasWatchVideoTasks = _QuestTaskUtils.hasWatchVideoTasks(quest);
|
|
const isInGameQuest = _QuestTaskUtils.isInGameQuest(quest);
|
|
const [r23] = useTaskPlatformScreen(quest, questTaskDetails);
|
|
let c20945_6 = r23;
|
|
const targetMinutes = questTaskDetails.targetMinutes;
|
|
const memo = useMemo(() => hasStreamOnDesktopTask({
|
|
quest
|
|
}), [quest]);
|
|
hasWatchVideoOnMobileTasks = useHasWatchVideoOnMobileTasks(quest.config);
|
|
defaultRewardNameWithArticle = getDefaultRewardNameWithArticle(quest.config, useStateFromStores([UserStore], () => UserStore.getCurrentUser()));
|
|
isSponsoredPlayQuest = _QuestUtils.isSponsoredPlayQuest(quest);
|
|
const memo2 = useMemo(() => {
|
|
let r56;
|
|
if (c20945_2) {
|
|
return intl.string(t["ij5E/5"]);
|
|
}
|
|
if (hasWatchVideoTasks) {
|
|
return hasWatchVideoOnMobileTasks ? intl.formatToPlainString(t.ttFsLj, {
|
|
reward: defaultRewardNameWithArticle
|
|
}) : intl.formatToPlainString(t.IpoqqA, {
|
|
questReward: defaultRewardNameWithArticle
|
|
});
|
|
}
|
|
if (isInGameQuest) {
|
|
const defaultInGameTask = getDefaultInGameTask(quest.config);
|
|
if (defaultInGameTask != null) {
|
|
return defaultInGameTask.messages.taskDescription;
|
|
}
|
|
}
|
|
L17: {
|
|
if (step === QuestBottomSheetStep.TASK_SELECT) {
|
|
r56 = intl.string(t.drVw4T);
|
|
} else if (step === QuestBottomSheetStep.CONSOLE_CONNECT) {
|
|
r56 = intl.string(t.svdwbA);
|
|
} else if (isSponsoredPlayQuest) {
|
|
r56 = intl.formatToPlainString(t["2GJLK2"], {
|
|
targetMinutes,
|
|
rewardNameWithArticle: defaultRewardNameWithArticle
|
|
});
|
|
} else {
|
|
if (c20945_6 === TaskPlatformScreen.DESKTOP && memo) {
|
|
r56 = intl.formatToPlainString(t["hkJ+Gs"], {
|
|
gameTitle,
|
|
questReward: defaultRewardNameWithArticle,
|
|
streamingDurationRequirement: targetMinutes
|
|
});
|
|
break L17;
|
|
}
|
|
r56 = intl.formatToPlainString(t.NIimTt, {
|
|
gameTitle,
|
|
rewardNameWithArticle: defaultRewardNameWithArticle,
|
|
targetMinutes
|
|
});
|
|
}
|
|
}
|
|
return r56;
|
|
}, [r32, hasWatchVideoTasks, step, r23, memo, gameTitle, defaultRewardNameWithArticle, targetMinutes, hasWatchVideoOnMobileTasks, isInGameQuest, isSponsoredPlayQuest, quest.config]);
|
|
isScreenReaderEnabled = useIsScreenReaderEnabled();
|
|
ref = useRef(null);
|
|
useEffect(() => {
|
|
let r1 = isScreenReaderEnabled;
|
|
if (isScreenReaderEnabled) {
|
|
r1 = ref.current != null;
|
|
}
|
|
if (r1) {
|
|
setAccessibilityFocus({
|
|
ref,
|
|
delay: 100
|
|
});
|
|
}
|
|
}, [isScreenReaderEnabled]);
|
|
const style = [styles.container, withActionSheet ? styles.containerWithActionSheet : withActionSheet];
|
|
const r102 = [memo2 != null && <Text ref={ref} variant="redesign/heading-18/bold" color="mobile-text-heading-primary" accessibilityRole="header" style={[styles.title, withActionSheet ? styles.titleWithActionSheet : withActionSheet]}>{memo2}</Text>, ,];
|
|
if (withActionSheet) {
|
|
withActionSheet = <PressableOpacity accessibilityRole="button" accessibilityLabel={intl.string(t["UKOtz+"])} onPress={actionSheetPressHandler} style={styles.actionSheetButton}>
|
|
<MoreHorizontalIcon color={Module712.colors.INTERACTIVE_TEXT_DEFAULT} />
|
|
</PressableOpacity>;
|
|
}
|
|
r102[1] = withActionSheet;
|
|
return <View style={style}>{r102}</View>;
|
|
};
|