150 lines
5.7 KiB
TypeScript
150 lines
5.7 KiB
TypeScript
// Metro module 11924 (f11925).
|
|
import { useCallback, useMemo } from "react";
|
|
import { Pressable, View } from "react-native";
|
|
import { IGDB_ATTRIBUTION_LINK } from "../../../content_inventory/ContentInventoryConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import Linking from "../../../../lib/native/Linking";
|
|
import { getGenreText } from "../../../../utils/SKUUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { GameCompanyRole } from "../../../../flow/Server";
|
|
import { dateFormat } from "../../../../utils/DateUtils";
|
|
import { GameUpdatePlatformIcon } from "../../../game_update/native/GameUpdatePlatformIcon";
|
|
import getGameProfileWebsiteData from "../utils/getGameProfileWebsiteData";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
let useStyles;
|
|
const GameProfileWebsiteButton = function GameProfileWebsiteButton(props) {
|
|
const { icon, action, title, trackAction, url } = props;
|
|
return <Pressable accessibilityRole="button" accessibilityLabel={title} onPress={useCallback(() => {
|
|
Linking.openURL(url);
|
|
trackAction(action);
|
|
}, [trackAction, action, url])} hitSlop={Module712.space.PX_4}>{icon}</Pressable>;
|
|
};
|
|
useStyles = createStyles({
|
|
container: {
|
|
gap: Module712.space.PX_8
|
|
},
|
|
headerText: {
|
|
paddingHorizontal: Module712.space.PX_8
|
|
},
|
|
detailsContainer: {
|
|
borderRadius: Module712.radii.lg,
|
|
borderWidth: 1,
|
|
borderColor: Module712.colors.BORDER_SUBTLE,
|
|
overflow: "hidden",
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
|
|
},
|
|
detailsRow: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
justifyContent: "space-between",
|
|
padding: Module712.space.PX_12
|
|
},
|
|
detailsRowValue: {
|
|
flexDirection: "column",
|
|
flexShrink: 1,
|
|
paddingLeft: Module712.space.PX_32
|
|
},
|
|
detailsRowBottomBorder: {
|
|
borderBottomWidth: 1,
|
|
borderBottomColor: Module712.colors.BORDER_SUBTLE
|
|
},
|
|
platformsContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_12
|
|
},
|
|
linksContainer: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_12
|
|
}
|
|
});
|
|
export default function GameProfileDetails(props) {
|
|
const { game, trackAction: trackAction2 } = props;
|
|
const styles = useStyles();
|
|
const memo = useMemo(() => {
|
|
if (game == null) {
|
|
return [];
|
|
}
|
|
const value = game == null ? void 0 : game.genres.map(getGenreText).join(", ");
|
|
const r26 = value != null && value !== "";
|
|
const r28 = [];
|
|
if (r26) {
|
|
r28.push({
|
|
label: game.genres.length !== 1 ? intl.string(t.pDgwYB) : intl.string(t.mjFKqn),
|
|
value
|
|
});
|
|
}
|
|
const r59 = game == null ? void 0 : game.getCompanyByRole(GameCompanyRole.PUBLISHER);
|
|
const value2 = r59.map((item) => item.name).join(", ");
|
|
if (value2 != null && value2 !== "") {
|
|
r28.push({
|
|
label: r59.length !== 1 ? intl.string(t.Hc7Enk) : intl.string(t["4Byy/G"]),
|
|
value: value2
|
|
});
|
|
}
|
|
const r108 = game == null ? void 0 : game.getCompanyByRole(GameCompanyRole.DEVELOPER);
|
|
const value3 = r108.map((item) => item.name).join(", ");
|
|
if (value3 != null && value3 !== "") {
|
|
r28.push({
|
|
label: r108.length !== 1 ? intl.string(t.KATEJB) : intl.string(t.na3PT0),
|
|
value: value3
|
|
});
|
|
}
|
|
const firstReleaseDate = game?.firstReleaseDate;
|
|
if (firstReleaseDate != null && firstReleaseDate !== "") {
|
|
r28.push({
|
|
label: intl.string(t.H3mPDT),
|
|
value: dateFormat(new Date(firstReleaseDate), "LL")
|
|
});
|
|
}
|
|
const platforms = game?.platforms;
|
|
if (platforms != null && platforms.length > 0) {
|
|
r28.push({
|
|
label: game.platforms.length !== 1 ? intl.string(t.PNqxNe) : intl.string(t["UxAag+"]),
|
|
value: <View style={styles.platformsContainer}>
|
|
{platforms.map((a0) => <GameUpdatePlatformIcon key={a0} platform={a0} size="md" color={Module712.colors.ICON_SUBTLE} />)}
|
|
</View>
|
|
});
|
|
}
|
|
const r237 = game == null;
|
|
let r238 = void 0;
|
|
if (!r237) {
|
|
const websites = game.websites;
|
|
r238 = websites == null ? void 0 : websites.map((website) => getGameProfileWebsiteData(website, Module712.colors.ICON_SUBTLE)).filter((item) => item != null);
|
|
}
|
|
if (r238 == null) {
|
|
r238 = [];
|
|
}
|
|
if (r238 != null && r238.length > 0) {
|
|
r28.push({
|
|
label: intl.string(t["Oj3o1/"]),
|
|
value: <View style={styles.linksContainer}>
|
|
{r238.map(({ title, icon, action: action2, url: url2 }) => <GameProfileWebsiteButton key={url2} icon={icon} action={action2} title={title} url={url2} trackAction={trackAction2} />)}
|
|
</View>
|
|
});
|
|
}
|
|
if (r28.length > 0) {
|
|
r28.push({
|
|
label: intl.string(t["BwQ+9e"]),
|
|
value: intl.format(t.XPFZVl, {
|
|
igdbLink: IGDB_ATTRIBUTION_LINK
|
|
})
|
|
});
|
|
}
|
|
return r28;
|
|
}, [styles.linksContainer, styles.platformsContainer, game, trackAction2]);
|
|
return memo.length !== 0 ? <View style={styles.container}>
|
|
<Text variant="heading-sm/semibold" color="mobile-text-heading-primary" style={styles.headerText}>
|
|
{intl.string(t["7OjmmH"])}
|
|
</Text>
|
|
<View style={styles.detailsContainer}>
|
|
{memo.map((item, index) => <View key={item.label} style={[styles.detailsRow, memo.length > 1 ? index < memo.length - 1 ? styles.detailsRowBottomBorder : null : null]}>
|
|
<Text variant="text-sm/medium" color="text-subtle" lineClamp={1}>{item.label}</Text>
|
|
{typeof item.value === "string" ? <Text variant="text-sm/normal" color="text-subtle" lineClamp={1} style={styles.detailsRowValue}>{item.value}</Text> : item.value}
|
|
</View>)}
|
|
</View>
|
|
</View> : null;
|
|
};
|