168 lines
7.8 KiB
TypeScript
168 lines
7.8 KiB
TypeScript
// Metro module 14634 (f14635).
|
|
import { useMemo, useCallback, useLayoutEffect } from "react";
|
|
import { View } from "react-native";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { CollectiblesMobileShopScreen } from "../CollectiblesShopConstants";
|
|
import { AnalyticEvents } from "../../../Constants";
|
|
import { RewardFilterTypes } from "../../quests/QuestConstants";
|
|
import { UserProfileSections } from "../../user_profile/Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { ShopIcon } from "../../../design/components/Icon/native/redesign/generated/ShopIcon";
|
|
import { Heading } from "../../../design/components/Text/native/Text";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { useFetchVirtualCurrencyBalance } from "../../virtual_currency/hooks/useFetchVirtualCurrencyBalance";
|
|
import { openCollectiblesShopMobile } from "../CollectiblesActionCreators";
|
|
import AnalyticsLocation from "../../app_analytics/AnalyticsLocation";
|
|
import { CheckmarkSmallIcon } from "../../../design/components/Icon/native/redesign/generated/CheckmarkSmallIcon";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import { openQuestHome } from "../../quests/native/QuestUtils.native";
|
|
import { QuestContent } from "../../quests/QuestTypes";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import showUserProfileActionSheet from "../../user_profile/native/showUserProfileActionSheet";
|
|
import { BalanceWidgetPillButton } from "../../virtual_currency/native/index";
|
|
import { IconButton } from "../../../design/components/Button/native/IconButton.native";
|
|
import { HeartIcon } from "../../../design/components/Icon/native/redesign/generated/HeartIcon";
|
|
import { ContextMenu } from "../../../design/components/ContextMenu/native/ContextMenu.native";
|
|
import { MenuIcon } from "../../../design/components/Icon/native/redesign/generated/MenuIcon";
|
|
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
|
|
let useStyles, CollectiblesShopHeaderRight;
|
|
const CollectiblesShopHeaderTitle = function CollectiblesShopHeaderTitle(props) {
|
|
const currentScreen3 = props.currentScreen;
|
|
const styles = useStyles();
|
|
return <View style={styles.headerTitleContainer}>
|
|
<ShopIcon size="md" color="icon-strong" />
|
|
<Heading variant="redesign/heading-18/bold" color="mobile-text-heading-primary" maxFontSizeMultiplier={2} lineClamp={1} style={styles.headerTitle}>
|
|
{currentScreen3 === CollectiblesMobileShopScreen.ORBS ? intl.string(t.ElYQFS) : intl.string(t.pWG4ze)}
|
|
</Heading>
|
|
</View>;
|
|
};
|
|
CollectiblesShopHeaderRight = function CollectiblesShopHeaderRight(props) {
|
|
let balance;
|
|
const currentScreen = props.currentScreen;
|
|
balance = void 0;
|
|
const styles = useStyles();
|
|
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), []);
|
|
balance = useFetchVirtualCurrencyBalance().balance;
|
|
const memo = useMemo(() => [{
|
|
label: intl.string(t["xNiB/O"]),
|
|
action: () => {
|
|
openCollectiblesShopMobile({
|
|
analyticsLocations: [AnalyticsLocation.COLLECTIBLES_SHOP_MOBILE_FEATURED_PAGE_MENU_ITEM],
|
|
analyticsSource: AnalyticsLocation.COLLECTIBLES_SHOP_MOBILE_FEATURED_PAGE_MENU_ITEM,
|
|
screen: CollectiblesMobileShopScreen.FEATURED_PAGE
|
|
});
|
|
},
|
|
trailingIndicator: currentScreen === CollectiblesMobileShopScreen.FEATURED_PAGE ? CheckmarkSmallIcon : void 0
|
|
}, {
|
|
label: intl.string(t.RSyoZu),
|
|
action: () => {
|
|
openCollectiblesShopMobile({
|
|
analyticsLocations: [AnalyticsLocation.COLLECTIBLES_SHOP_MOBILE_SHOP_ALL_MENU_ITEM],
|
|
analyticsSource: AnalyticsLocation.COLLECTIBLES_SHOP_MOBILE_SHOP_ALL_MENU_ITEM,
|
|
screen: CollectiblesMobileShopScreen.SHOP_ALL
|
|
});
|
|
},
|
|
trailingIndicator: currentScreen === CollectiblesMobileShopScreen.SHOP_ALL ? CheckmarkSmallIcon : void 0
|
|
}, {
|
|
label: intl.string(t.EBYkzk),
|
|
action: () => {
|
|
openCollectiblesShopMobile({
|
|
analyticsLocations: [AnalyticsLocation.COLLECTIBLES_SHOP_MOBILE_ORBS_MENU_ITEM],
|
|
analyticsSource: AnalyticsLocation.COLLECTIBLES_SHOP_MOBILE_ORBS_MENU_ITEM,
|
|
screen: CollectiblesMobileShopScreen.ORBS
|
|
});
|
|
},
|
|
trailingIndicator: currentScreen === CollectiblesMobileShopScreen.ORBS ? CheckmarkSmallIcon : void 0
|
|
}], [currentScreen]);
|
|
const callback = useCallback(() => {
|
|
ActionSheetActionCreators.openLazy(() => import("../../virtual_currency/native/BalanceWidgetActionSheet").then((result) => result.default), "BalanceWidgetActionSheet", {
|
|
balance,
|
|
primaryButtonConfig: {
|
|
buttonText: intl.string(t.SymzJC),
|
|
onButtonPress: () => {
|
|
AnalyticsUtils.track(AnalyticEvents.ORB_BALANCE_ACTION_SHEET_ACTION, {
|
|
type: "GO_TO_QUEST_HOME",
|
|
source: AnalyticsLocation.COLLECTIBLES_SHOP,
|
|
balance
|
|
});
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
openQuestHome({
|
|
mergeExistingRoutes: true,
|
|
filter: RewardFilterTypes.VIRTUAL_CURRENCY,
|
|
fromContent: QuestContent.ORBS_BALANCE_MENU
|
|
});
|
|
}
|
|
},
|
|
secondaryButtonConfig: {
|
|
buttonText: intl.string(t["/g10LC"]),
|
|
onButtonPress: () => {
|
|
AnalyticsUtils.track(AnalyticEvents.ORB_BALANCE_ACTION_SHEET_ACTION, {
|
|
type: "GO_BACK",
|
|
source: AnalyticsLocation.COLLECTIBLES_SHOP,
|
|
balance
|
|
});
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
}
|
|
},
|
|
source: AnalyticsLocation.COLLECTIBLES_SHOP
|
|
});
|
|
}, [balance]);
|
|
const callback2 = useCallback(() => {
|
|
if (stateFromStores?.id != null) {
|
|
AnalyticsUtils.track(AnalyticEvents.COLLECTIBLES_SHOP_ELEMENT_CLICKED, {
|
|
cta_name: "wishlist header button",
|
|
page_type: currentScreen
|
|
});
|
|
ModalActionCreators.popAll();
|
|
showUserProfileActionSheet({
|
|
userId: stateFromStores.id,
|
|
sourceAnalyticsLocations: [AnalyticsLocation.COLLECTIBLES_SHOP],
|
|
initialSection: UserProfileSections.WISHLIST
|
|
});
|
|
}
|
|
}, [currentScreen, stateFromStores?.id]);
|
|
return <View style={styles.headerRightContainer}>
|
|
<BalanceWidgetPillButton balance={balance} onPress={callback} />
|
|
{stateFromStores != null && <IconButton accessibilityLabel={intl.string(t["7lZ31J"])} variant="tertiary" size="sm" icon={<HeartIcon size="sm" color="redesign-button-tertiary-text" />} onPress={callback2} />}
|
|
<ContextMenu key={currentScreen} items={memo} align="below" title={intl.string(t.nSFuC0)} keyboardShouldPersistTaps="handled">
|
|
{(a0) => {
|
|
const { ref, ...rest } = a0;
|
|
return <IconButton ref={a0.ref} {...rest} variant="tertiary" accessibilityLabel={intl.string(t.nSFuC0)} size="sm" icon={<MenuIcon size="sm" color="redesign-button-tertiary-text" />} />;
|
|
}}
|
|
</ContextMenu>
|
|
</View>;
|
|
};
|
|
useStyles = createStyles({
|
|
headerTitleContainer: {
|
|
width: "100%",
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
marginTop: Module712.space.PX_8,
|
|
paddingLeft: Module712.space.PX_8,
|
|
gap: Module712.space.PX_8
|
|
},
|
|
headerTitle: {
|
|
flexShrink: 1
|
|
},
|
|
headerRightContainer: {
|
|
flexDirection: "row",
|
|
justifyContent: "flex-end",
|
|
alignItems: "center",
|
|
gap: Module712.space.PX_8,
|
|
marginTop: Module712.space.PX_8
|
|
}
|
|
});
|
|
export default function useCollectiblesShopHeader(r3 = {}) {
|
|
const currentScreen2 = r3.currentScreen;
|
|
const navigation = useNavigation();
|
|
useLayoutEffect(() => {
|
|
navigation.setOptions({
|
|
headerTitle: () => <CollectiblesShopHeaderTitle currentScreen={currentScreen2} />,
|
|
headerRight: () => <CollectiblesShopHeaderRight currentScreen={currentScreen2} />
|
|
});
|
|
}, [navigation, currentScreen2]);
|
|
};
|