298 lines
12 KiB
TypeScript
298 lines
12 KiB
TypeScript
// Metro module 8481 (f8482).
|
|
import { useState, useRef, useCallback, useMemo, useEffect } from "react";
|
|
import { ActivityIndicator, View } from "react-native";
|
|
import GameProfileStore from "../../GameProfileStore";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import { useBottomSheetRef } from "../../../../design/components/Sheet/native/useBottomSheetRef";
|
|
import useOpenExternalUrlFromGameProfile from "../../hooks/useOpenExternalUrlFromGameProfile";
|
|
import Linking from "../../../../lib/native/Linking";
|
|
import { generateViewId, getGuildIdAndVerifiedFromInvite, trackGameProfileAction, trackGameProfileOpen, GameProfileTypes, trackGameProfileClose } from "../../GameProfileAnalyticUtils";
|
|
import { useGame } from "../../../games/hooks/useGame";
|
|
import useGameProfileObscured from "../../hooks/useGameProfileObscured";
|
|
import * as _ReanimatedRexport from "../../../reanimated/ReanimatedRexport";
|
|
import ReanimatedRexport, { useSharedValue, useAnimatedReaction, useAnimatedStyle } from "../../../reanimated/ReanimatedRexport";
|
|
import useInAppBrowserReturn from "../hooks/useInAppBrowserReturn";
|
|
import * as _timing from "../../../../design/animation/reanimated/timing/timing";
|
|
import { useGameProfileStoreWebsites } from "../../hooks/useGameProfileStoreWebsites";
|
|
import getGameProfileStoreWebsiteData from "../utils/getGameProfileStoreWebsiteData";
|
|
import ActionSheetActionCreators, { showActionSheet } from "../../../action_sheet/native/ActionSheetActionCreators";
|
|
import GameProfileStoreLinksActionSheet, { ACTION_SHEET_KEY } from "./GameProfileStoreLinksActionSheet";
|
|
import { GameProfileSimilarGamesMobileExperiment } from "../../SimilarGamesExperiments";
|
|
import { BottomSheet } from "../../../../design/components/Sheet/native/BottomSheet.native";
|
|
import { BottomSheetScrollView } from "../../../../_bundle/Module5245";
|
|
import ObscuredSurface from "../../../safety_common/native/ObscuredSurface";
|
|
import GameProfileView from "./GameProfileView";
|
|
import GameProfileNavigationHeader from "./GameProfileNavigationHeader";
|
|
import { ActionSheetHeaderBar } from "../../../../design/components/Sheet/native/ActionSheetHeaderBar.native";
|
|
let useStyles, __initData, __initData2, __initData3, __initData4, __initData5;
|
|
const GetButton = function GetButton(props) {
|
|
const onPress = props.onPress;
|
|
return <Button variant="primary" size="sm" text={intl.string(t.l8JeHg)} onPress={onPress} accessibilityLabel={intl.string(t.Vsxqmz)} />;
|
|
};
|
|
useStyles = createStyles({
|
|
loadingContainer: {
|
|
flex: 1,
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
minHeight: 300,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST
|
|
},
|
|
scrollView: {
|
|
flex: 1,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST
|
|
},
|
|
stickyHeader: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
right: 0
|
|
}
|
|
});
|
|
__initData = {
|
|
code: "function GameProfileScreenTsx1(){const{heroHeaderHeight,scrollY,STICKY_HEADER_HEIGHT}=this.__closure;return heroHeaderHeight.get()>0&&scrollY.get()>=heroHeaderHeight.get()-STICKY_HEADER_HEIGHT;}"
|
|
};
|
|
__initData2 = {
|
|
code: "function GameProfileScreenTsx2(isVisible,wasVisible){const{stickyHeaderVisible,withTiming}=this.__closure;if(isVisible!==wasVisible){stickyHeaderVisible.set(withTiming(isVisible?1:0,{duration:150}));}}"
|
|
};
|
|
__initData3 = {
|
|
code: "function GameProfileScreenTsx3(){const{interpolate,stickyHeaderVisible,STICKY_HEADER_HEIGHT}=this.__closure;return{transform:[{translateY:interpolate(stickyHeaderVisible.get(),[0,1],[-1*STICKY_HEADER_HEIGHT,0])}]};}"
|
|
};
|
|
__initData4 = {
|
|
code: "function GameProfileScreenTsx4(){const{scrollY,storeLinksSectionBottomY,STICKY_HEADER_HEIGHT}=this.__closure;return scrollY.get()>storeLinksSectionBottomY.get()-STICKY_HEADER_HEIGHT;}"
|
|
};
|
|
__initData5 = {
|
|
code: "function GameProfileScreenTsx5(shouldShow,prevShouldShow){const{runOnJS,setShowGetButton}=this.__closure;if(shouldShow!==prevShouldShow){runOnJS(setShowGetButton)(shouldShow);}}"
|
|
};
|
|
export default function GameProfileScreen(props) {
|
|
let ref, ref2, state2, name, sharedValue, ref3, sharedValue2, sharedValue3, sharedValue4, state3, setState, gameProfileStoreWebsites, memo, ref4, ref5, callback, callback2;
|
|
const { gameId, source, sourceUserId, initialScrollOffset = 0 } = props;
|
|
let c16611_3 = initialScrollOffset;
|
|
ref = void 0;
|
|
ref2 = void 0;
|
|
state2 = void 0;
|
|
name = void 0;
|
|
sharedValue = void 0;
|
|
ref3 = void 0;
|
|
sharedValue2 = void 0;
|
|
sharedValue3 = void 0;
|
|
sharedValue4 = void 0;
|
|
state3 = void 0;
|
|
setState = void 0;
|
|
gameProfileStoreWebsites = void 0;
|
|
memo = void 0;
|
|
ref4 = void 0;
|
|
ref5 = void 0;
|
|
callback = void 0;
|
|
callback2 = void 0;
|
|
const styles = useStyles();
|
|
const bottomSheetRef2 = useBottomSheetRef();
|
|
const { bottomSheetRef, bottomSheetClose } = bottomSheetRef2;
|
|
const openExternalUrlFromGameProfile = useOpenExternalUrlFromGameProfile(Linking.openURL);
|
|
let c16611_4 = openExternalUrlFromGameProfile;
|
|
const [state] = useState(() => generateViewId());
|
|
ref = useRef(null);
|
|
ref2 = useRef(0);
|
|
const game = useGame(gameId);
|
|
const { data, isLoading } = game;
|
|
const gameProfileObscured = useGameProfileObscured(data);
|
|
let onGuildInviteResolved;
|
|
[state2, onGuildInviteResolved] = useState(null);
|
|
name = data?.name;
|
|
sharedValue = useSharedValue(0);
|
|
const callback3 = useCallback((a0) => {
|
|
const current = a0.nativeEvent.contentOffset.y;
|
|
sharedValue.set(current);
|
|
ref2.current = current;
|
|
}, [sharedValue]);
|
|
ref3 = useRef(false);
|
|
const callback4 = useCallback(() => {
|
|
if (c16611_3 > 0 && !ref3.current) {
|
|
ref3.current = true;
|
|
const current = ref.current;
|
|
if (current != null) {
|
|
current.scrollTo({
|
|
y: c16611_3,
|
|
animated: false
|
|
});
|
|
}
|
|
}
|
|
}, [initialScrollOffset]);
|
|
useInAppBrowserReturn({
|
|
gameId: data?.id,
|
|
scrollOffsetRef: ref2
|
|
});
|
|
sharedValue2 = useSharedValue(0);
|
|
sharedValue3 = useSharedValue(0);
|
|
const U = () => sharedValue2.get() > 0 && sharedValue.get() >= sharedValue2.get() - 56;
|
|
U.__closure = {
|
|
heroHeaderHeight: sharedValue2,
|
|
scrollY: sharedValue,
|
|
STICKY_HEADER_HEIGHT: 56
|
|
};
|
|
U.__workletHash = 15395308691297;
|
|
U.__initData = __initData;
|
|
const j = function j(a0, a1) {
|
|
if (a0 !== a1) {
|
|
sharedValue3.set(_timing.withTiming(a0 ? 1 : 0, {
|
|
duration: 150
|
|
}));
|
|
}
|
|
};
|
|
j.__closure = {
|
|
stickyHeaderVisible: sharedValue3,
|
|
withTiming: _timing.withTiming
|
|
};
|
|
j.__workletHash = 3161097061646;
|
|
j.__initData = __initData2;
|
|
useAnimatedReaction(U, j);
|
|
const q = function q() {
|
|
return {
|
|
transform: [{
|
|
translateY: _ReanimatedRexport.interpolate(sharedValue3.get(), [0, 1], [-56, 0])
|
|
}]
|
|
};
|
|
};
|
|
q.__closure = {
|
|
interpolate: _ReanimatedRexport.interpolate,
|
|
stickyHeaderVisible: sharedValue3,
|
|
STICKY_HEADER_HEIGHT: 56
|
|
};
|
|
q.__workletHash = 16452163547712;
|
|
q.__initData = __initData3;
|
|
const animatedStyle = useAnimatedStyle(q);
|
|
sharedValue4 = useSharedValue(Infinity);
|
|
[state3, setState] = useState(false);
|
|
const X = () => sharedValue.get() > sharedValue4.get() - 56;
|
|
X.__closure = {
|
|
scrollY: sharedValue,
|
|
storeLinksSectionBottomY: sharedValue4,
|
|
STICKY_HEADER_HEIGHT: 56
|
|
};
|
|
X.__workletHash = 14521195063038;
|
|
X.__initData = __initData4;
|
|
const Q = function Q(a0, a1) {
|
|
if (a0 !== a1) {
|
|
_ReanimatedRexport.runOnJS(setState)(a0);
|
|
}
|
|
};
|
|
Q.__closure = {
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
setShowGetButton: setState
|
|
};
|
|
Q.__workletHash = 15045914286853;
|
|
Q.__initData = __initData5;
|
|
useAnimatedReaction(X, Q);
|
|
gameProfileStoreWebsites = useGameProfileStoreWebsites(data);
|
|
memo = useMemo(() => gameProfileStoreWebsites.map(getGameProfileStoreWebsiteData).filter((item) => item != null), [gameProfileStoreWebsites]);
|
|
ref4 = useRef(void 0);
|
|
ref5 = useRef(null);
|
|
useEffect(() => {
|
|
ref4.current = name;
|
|
}, [name]);
|
|
useEffect(() => {
|
|
ref5.current = state2;
|
|
}, [state2]);
|
|
callback = useCallback((a0, a1) => {
|
|
const guildIdAndVerifiedFromInvite = getGuildIdAndVerifiedFromInvite(ref5.current);
|
|
const { guildId, isVerified } = guildIdAndVerifiedFromInvite;
|
|
let current = ref4.current;
|
|
if (current == null) {
|
|
current = "";
|
|
}
|
|
trackGameProfileAction({
|
|
gameName: current,
|
|
gameId,
|
|
action: a0,
|
|
similarGameId: a1,
|
|
viewId: state,
|
|
guildId,
|
|
isVerified,
|
|
source
|
|
});
|
|
}, [gameId, state, source]);
|
|
callback2 = useCallback(() => {
|
|
if (memo.length === 1) {
|
|
const [r31] = memo;
|
|
callback(r31.action);
|
|
c16611_4(r31.url);
|
|
} else if (memo.length > 1) {
|
|
let current = ref4.current;
|
|
if (current == null) {
|
|
current = "";
|
|
}
|
|
showActionSheet({
|
|
key: ACTION_SHEET_KEY,
|
|
content: <GameProfileStoreLinksActionSheet gameName={current} websiteButtons={memo} trackAction={callback} />,
|
|
stackingBehavior: "stack"
|
|
});
|
|
}
|
|
}, [memo, callback, openExternalUrlFromGameProfile]);
|
|
useEffect(() => {
|
|
let current = ref4.current;
|
|
if (current == null) {
|
|
current = "";
|
|
}
|
|
trackGameProfileOpen({
|
|
source,
|
|
viewId: state,
|
|
gameId,
|
|
gameName: current,
|
|
authorId: sourceUserId,
|
|
profileType: GameProfileTypes.FullProfile
|
|
});
|
|
}, [gameId, source, sourceUserId, state]);
|
|
useEffect(() => () => {
|
|
let similarGames;
|
|
const guildIdAndVerifiedFromInvite = getGuildIdAndVerifiedFromInvite(ref5.current);
|
|
const { guildId, isVerified } = guildIdAndVerifiedFromInvite;
|
|
const enabled = GameProfileSimilarGamesMobileExperiment.getConfig({
|
|
location: "GameProfileScreenClose"
|
|
}).enabled;
|
|
let current = ref4.current;
|
|
if (current == null) {
|
|
current = "";
|
|
}
|
|
if (enabled) {
|
|
let r34 = GameProfileStore.getSimilarGames(gameId);
|
|
if (r34 == null) {
|
|
r34 = [];
|
|
}
|
|
similarGames = r34;
|
|
} else {
|
|
similarGames = [];
|
|
}
|
|
trackGameProfileClose({
|
|
viewId: state,
|
|
gameId,
|
|
gameName: current,
|
|
playedFriendIds: [],
|
|
playedFriendsData: [],
|
|
similarGames,
|
|
guildId,
|
|
isVerified
|
|
});
|
|
}, [gameId, source, sourceUserId, state]);
|
|
const callback5 = useCallback((a0) => {
|
|
sharedValue2.set(a0);
|
|
}, [sharedValue2]);
|
|
const callback6 = useCallback((a0) => {
|
|
sharedValue4.set(a0);
|
|
}, [sharedValue4]);
|
|
return <BottomSheet ref={bottomSheetRef} startExpanded scrollable handleDisabled onExpand={callback4}>
|
|
{!isLoading && data != null ? <BottomSheetScrollView ref={ref} style={styles.scrollView} onScroll={callback3}>
|
|
<ObscuredSurface obscured={gameProfileObscured}>
|
|
<GameProfileView game={data} invite={state2} viewId={state} source={source} trackAction={callback} onGuildInviteResolved={onGuildInviteResolved} closeModal={() => ActionSheetActionCreators.hideAllActionSheets()} scrollY={sharedValue} websiteButtons={memo} onStoreLinksMeasured={callback6} onHeaderHeightMeasured={callback5} scrollOffsetRef={ref2} />
|
|
</ObscuredSurface>
|
|
</BottomSheetScrollView> : <View style={styles.loadingContainer}>
|
|
<ActivityIndicator animating size="large" />
|
|
</View>}
|
|
<ReanimatedRexport.View style={[styles.stickyHeader, animatedStyle]} pointerEvents="box-none">
|
|
<GameProfileNavigationHeader game={data} headerRight={useMemo(() => memo.length > 0 ? state3 ? () => <GetButton onPress={callback2} /> : void 0 : void 0, [memo, state3, callback2])} />
|
|
</ReanimatedRexport.View>
|
|
<ActionSheetHeaderBar variant="overlay" onPress={bottomSheetClose} />
|
|
</BottomSheet>;
|
|
};
|