228 lines
9.6 KiB
TypeScript
228 lines
9.6 KiB
TypeScript
// Metro module 8521 (f8522).
|
|
import { useCallback } from "react";
|
|
import { Image as Image2, Pressable, View } from "react-native";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import useOpenExternalUrlFromGameProfile from "../../hooks/useOpenExternalUrlFromGameProfile";
|
|
import Linking from "../../../../lib/native/Linking";
|
|
import { calculateSteamReviewScoreDescription } from "../../../game_detection/calculateSteamReviewScoreDescription";
|
|
import * as _GameProfileReviewUtils from "../../GameProfileReviewUtils";
|
|
import { getSteamReviewScoreDescriptionColor, getSteamReviewScoreDescriptionIntl } from "../../GameProfileReviewUtils";
|
|
import { GameProfileTrackActionActions } from "../../GameProfileAnalyticUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { SteamNeutralIcon } from "../../../../design/components/Icon/native/redesign/generated/SteamNeutralIcon";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { SteamReviewScoreDescription } from "../../../game_detection/GameDetectionTypes";
|
|
import { getOpenCriticTierText, getOpenCriticCircleRatingColor, getOpenCriticTierImage } from "../../hooks/useGameProfileOpenCritic";
|
|
import OpenCriticRatingCircle from "./OpenCriticRatingCircle";
|
|
import { useSteamWebsiteUrl } from "../../hooks/useSteamWebsiteUrl";
|
|
import { SteamReleaseStatus } from "../../../../_bundle/Module8492";
|
|
let useStyles, OpenCriticReview;
|
|
const SteamReviewRow = function SteamReviewRow(props) {
|
|
const url = props.url;
|
|
let showBorderBottom = props.showBorderBottom;
|
|
const { trackAction, title, rating, ratingCount, isRecentRating } = props;
|
|
const styles = useStyles();
|
|
const openExternalUrlFromGameProfile = useOpenExternalUrlFromGameProfile(Linking.openURL);
|
|
let c16625_2 = openExternalUrlFromGameProfile;
|
|
const r11 = calculateSteamReviewScoreDescription(rating, ratingCount, isRecentRating);
|
|
const steamReviewScoreDescriptionColor = getSteamReviewScoreDescriptionColor(r11);
|
|
const props2 = {
|
|
onPress: useCallback(() => {
|
|
trackAction(GameProfileTrackActionActions.SteamReviews);
|
|
c16625_2(url);
|
|
}, [openExternalUrlFromGameProfile, url, trackAction]),
|
|
accessibilityRole: "link",
|
|
accessibilityLabel: intl.string(t.YNC5Di),
|
|
style: null,
|
|
children: null
|
|
};
|
|
const style = [styles.reviewRow, ,];
|
|
if (showBorderBottom) {
|
|
showBorderBottom = styles.reviewRowNotLast;
|
|
}
|
|
style[1] = showBorderBottom;
|
|
props2.style = style;
|
|
props2.children = [<View style={styles.steamNameContainer}>
|
|
<SteamNeutralIcon size="sm" color={Module712.colors.ICON_STRONG} />
|
|
<Text variant="heading-sm/medium" color="mobile-text-heading-primary">{title}</Text>
|
|
</View>, <View style={styles.steamRatingContainer}>
|
|
<Text variant="text-sm/medium" color={steamReviewScoreDescriptionColor}>
|
|
{getSteamReviewScoreDescriptionIntl(r11)}
|
|
</Text>
|
|
{ratingCount != null && r11 !== SteamReviewScoreDescription.NO_USER_REVIEWS && <Text variant="text-sm/medium" color="text-subtle">
|
|
{intl.format(t.sgIoin, {
|
|
rating_count: ratingCount.toLocaleString()
|
|
}).toString()}
|
|
</Text>}
|
|
</View>];
|
|
return <Pressable {...props2} />;
|
|
};
|
|
OpenCriticReview = function OpenCriticReview(props) {
|
|
const { game, url: url2, trackAction: trackAction2 } = props;
|
|
const styles = useStyles();
|
|
let r30 = game.reviews?.opencritic;
|
|
if (r30 == null) {
|
|
r30 = {
|
|
topCriticRating: void 0,
|
|
topCriticRatingCount: void 0,
|
|
tier: void 0
|
|
};
|
|
}
|
|
const tier = r30.tier;
|
|
let topCriticRating = r30.topCriticRating;
|
|
if (topCriticRating == null) {
|
|
topCriticRating = -1;
|
|
}
|
|
let topCriticRatingCount = r30.topCriticRatingCount;
|
|
if (topCriticRatingCount == null) {
|
|
topCriticRatingCount = -1;
|
|
}
|
|
const openExternalUrlFromGameProfile = useOpenExternalUrlFromGameProfile(Linking.openURL);
|
|
let c16626_2 = openExternalUrlFromGameProfile;
|
|
const callback = useCallback(() => {
|
|
trackAction2(GameProfileTrackActionActions.OpenCriticReviews);
|
|
c16626_2(url2);
|
|
}, [openExternalUrlFromGameProfile, url2, trackAction2]);
|
|
const accessibilityLabel = tier != null ? getOpenCriticTierText(tier) : "";
|
|
const r45 = tier != null ? getOpenCriticCircleRatingColor(tier) : {
|
|
foregroundColor: "",
|
|
backgroundColor: ""
|
|
};
|
|
const { foregroundColor, backgroundColor } = r45;
|
|
const props2 = {
|
|
onPress: callback,
|
|
accessibilityRole: "link",
|
|
accessibilityLabel: intl.string(t.aLNBAw),
|
|
style: styles.reviewRow,
|
|
children: null
|
|
};
|
|
const children = [<Text variant="heading-sm/medium" color="mobile-text-heading-primary">
|
|
{intl.string(t["UxvER+"])}
|
|
</Text>, ,];
|
|
const r89 = [tier != null ? <View style={styles.opencriticTopCriticContainer} accessibilityLabel={accessibilityLabel} accessibilityRole="image">
|
|
<Image2 source={{
|
|
uri: getOpenCriticTierImage(tier)
|
|
}} style={styles.opencriticTopCriticImage} accessible accessibilityLabel={accessibilityLabel} />
|
|
</View> : null, tier != null ? topCriticRating > 0 ? topCriticRatingCount > 0 ? <View style={[styles.opencriticTopCriticContainer, {
|
|
backgroundColor
|
|
}]} accessibilityLabel={intl.string(t.Ub4YR1)} accessibilityRole="image">
|
|
<OpenCriticRatingCircle rating={topCriticRating} strokeColor={foregroundColor} size={32} />
|
|
<View style={styles.opencriticTopCriticRatingContainer}>
|
|
<Text variant="text-xs/bold" color="text-overlay-light">
|
|
{Math.floor(topCriticRating)}
|
|
</Text>
|
|
</View>
|
|
</View> : null : null : null, topCriticRating <= 0 ? tier == null ? <Text variant="text-xs/medium" color={getSteamReviewScoreDescriptionColor(SteamReviewScoreDescription.NO_USER_REVIEWS)}>
|
|
{intl.string(t["0xYzpO"])}
|
|
</Text> : null : topCriticRatingCount <= 0 ? tier == null ? <Text variant="text-xs/medium" color={getSteamReviewScoreDescriptionColor(SteamReviewScoreDescription.NO_USER_REVIEWS)}>
|
|
{intl.string(t["0xYzpO"])}
|
|
</Text> : null : null];
|
|
children[1] = <View style={styles.opencriticRightContainer}>{r89}</View>;
|
|
props2.children = children;
|
|
return <Pressable {...props2} />;
|
|
};
|
|
useStyles = createStyles({
|
|
container: {
|
|
gap: Module712.space.PX_8
|
|
},
|
|
headerText: {
|
|
paddingHorizontal: Module712.space.PX_8
|
|
},
|
|
reviewContainer: {
|
|
borderRadius: Module712.radii.lg,
|
|
borderWidth: 1,
|
|
borderColor: Module712.colors.BORDER_SUBTLE,
|
|
overflow: "hidden"
|
|
},
|
|
reviewRow: {
|
|
height: 56,
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "space-between",
|
|
padding: Module712.space.PX_12
|
|
},
|
|
reviewRowNotLast: {
|
|
borderBottomWidth: 1,
|
|
borderBottomColor: Module712.colors.BACKGROUND_MOD_SUBTLE
|
|
},
|
|
steamNameContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_8
|
|
},
|
|
steamRatingContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "flex-end",
|
|
flexShrink: 1,
|
|
paddingLeft: Module712.space.PX_32,
|
|
gap: Module712.space.PX_4
|
|
},
|
|
opencriticRightContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_12
|
|
},
|
|
opencriticTopCriticContainer: {
|
|
width: 32,
|
|
height: 32,
|
|
borderRadius: Module712.radii.round,
|
|
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
|
|
alignItems: "center",
|
|
justifyContent: "center"
|
|
},
|
|
opencriticTopCriticImage: {
|
|
width: 32,
|
|
height: 32
|
|
},
|
|
opencriticTopCriticRatingContainer: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 1,
|
|
right: 0,
|
|
bottom: 0,
|
|
alignItems: "center",
|
|
justifyContent: "center"
|
|
}
|
|
});
|
|
export default function GameProfileReviews(props) {
|
|
let r68;
|
|
const { game, trackAction: trackAction3 } = props;
|
|
const styles = useStyles();
|
|
const steamWebsiteUrl = useSteamWebsiteUrl(game?.id);
|
|
const opencriticUrl = game?.opencriticUrl;
|
|
if (game == null) {
|
|
return null;
|
|
}
|
|
const r4 = game.steamReleaseStatus !== SteamReleaseStatus.RETIRED_ABANDONED && steamWebsiteUrl != null;
|
|
const steam = game.reviews?.steam;
|
|
const r48 = calculateSteamReviewScoreDescription(steam?.recentRating, steam?.recentRatingCount, true);
|
|
const r3 = r4 ? r48 !== SteamReviewScoreDescription.NO_USER_REVIEWS : r4;
|
|
const canShowLocalizedSteamReview = _GameProfileReviewUtils.canShowLocalizedSteamReview(steam);
|
|
const r57 = steam == null;
|
|
const rating = canShowLocalizedSteamReview ? r57 ? void 0 : steam.localizedRating : r57 ? void 0 : steam.rating;
|
|
const r59 = steam == null;
|
|
const ratingCount = canShowLocalizedSteamReview ? r59 ? void 0 : steam.localizedRatingCount : r59 ? void 0 : steam.ratingCount;
|
|
const r25 = canShowLocalizedSteamReview ? t["aWb+V4"] : t["8e4LiB"];
|
|
const showBorderBottom = game.reviews?.opencritic != null && opencriticUrl != null;
|
|
L55: {
|
|
if (!r4 && !r3) {
|
|
r68 = null;
|
|
if (!showBorderBottom) {
|
|
break L55;
|
|
}
|
|
}
|
|
r68 = <View style={styles.container}>
|
|
<Text variant="heading-sm/semibold" color="mobile-text-heading-primary" style={styles.headerText}>
|
|
{intl.string(t.GaAQXP)}
|
|
</Text>
|
|
<View style={styles.reviewContainer}>
|
|
{r3 ? steamWebsiteUrl != null ? <SteamReviewRow url={steamWebsiteUrl} showBorderBottom={r4 || showBorderBottom} trackAction={trackAction3} title={intl.string(t.MQGNsN)} rating={steam?.recentRating} ratingCount={steam?.recentRatingCount} isRecentRating /> : null : null}
|
|
{r4 ? steamWebsiteUrl != null ? <SteamReviewRow url={steamWebsiteUrl} showBorderBottom={showBorderBottom} trackAction={trackAction3} title={intl.string(r25)} rating={rating} ratingCount={ratingCount} isRecentRating={false} /> : null : null}
|
|
{showBorderBottom ? opencriticUrl != null ? <OpenCriticReview game={game} url={opencriticUrl} trackAction={trackAction3} /> : null : null}
|
|
</View>
|
|
</View>;
|
|
}
|
|
return r68;
|
|
};
|