Files
shoptime/com.twin.app.shoptime/src/views/PlayerPanel/PlayerTabContents/TabContainer.jsx
yonghyon 7806dc839a [SHOPTIME-3648] Player / Featured Show / 방송 전환 시 현재 방송 배경 이미지가 아주 잠깐 노출됨
원인 : Featured Show 선택시 해당 리스트를 재구성하는 과정에서 index 가
한번 더 변경되어 이전 Thumbnail url 을 로드함
대책 : Featured Show 인덱스 선택시 리스트 재구성하지 않도록 수정
2024-10-21 14:06:13 +09:00

164 lines
4.3 KiB
JavaScript

import React, { useCallback, useEffect, useState } from "react";
import classNames from "classnames";
import Spotlight from "@enact/spotlight";
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
import TButtonTab, {
LIST_TYPE,
} from "../../../components/TButtonTab/TButtonTab";
import { LOG_MENU } from "../../../utils/Config";
import { $L } from "../../../utils/helperMethods";
import css from "./TabContainer.module.less";
import FeaturedShowContents from "./TabContents/FeaturedShowContents";
import LiveChannelContents from "./TabContents/LiveChannelContents";
import ShopNowContents from "./TabContents/ShopNowContents";
import YouMayLikeContents from "./TabContents/YouMayLikeContents";
const Container = SpotlightContainerDecorator(
{ enterTo: "last-focused" },
"div"
);
export default function TabContainer({
panelInfo,
playListInfo,
shopNowInfo,
selectedIndex,
setSelectedIndex,
liveChannelInfos,
videoVerticalVisible,
handleItemFocus,
prevChannelIndex,
currentTime,
}) {
const [tab, setTab] = useState(0);
const tabList = [
$L("SHOP NOW"),
panelInfo?.shptmBanrTpNm === "LIVE"
? $L("LIVE CHANNEL")
: $L("FEATURED SHOWS"),
];
const handleItemClick = useCallback(
({ index }) => {
if (index === tab) return;
if (index === 0) {
setTimeout(() => {
Spotlight.focus("playVideoShopNowBox");
});
}
if (index === 1) {
setTimeout(() => {
Spotlight.focus(`tabChannel-video-${prevChannelIndex}`);
});
}
setTab(index);
},
[tab, prevChannelIndex]
);
useEffect(() => {
let nowMenu;
if (tab === 0) {
nowMenu = LOG_MENU.FULL_SHOP_NOW;
}
if (tab === 1) {
const isLive = panelInfo?.shptmBanrTpNm === "LIVE";
nowMenu = isLive
? LOG_MENU.FULL_LIVE_CHANNELS
: LOG_MENU.FULL_FEATURED_SHOWS;
}
if (nowMenu) {
handleItemFocus(nowMenu);
}
}, [handleItemFocus, panelInfo?.shptmBanrTpNm, tab]);
const _handleItemFocus = useCallback(
(nowMenu) => {
if (handleItemFocus) {
handleItemFocus(nowMenu);
}
},
[handleItemFocus]
);
const onSpotlightIndicatorUpButton = useCallback(
(e) => {
if (videoVerticalVisible) {
e.stopPropagation();
e.preventDefault();
Spotlight.focus("spotlightId-video-contaienr");
}
},
[videoVerticalVisible]
);
return (
<Container
className={classNames(
css.tabContainer,
videoVerticalVisible && css.vertical
)}
>
<TButtonTab
contents={tabList}
className={css.tTab}
onItemClick={handleItemClick}
selectedIndex={tab}
listType={LIST_TYPE.small}
onSpotlightLeft={onSpotlightIndicatorUpButton}
/>
{tab === 0 && (
<ShopNowContents
shopNowInfo={shopNowInfo}
playListInfo={playListInfo && playListInfo[selectedIndex]}
videoVerticalVisible={videoVerticalVisible}
panelInfo={panelInfo}
tabIndex={tab}
handleItemFocus={_handleItemFocus}
/>
)}
{panelInfo?.shptmBanrTpNm === "VOD" && tab === 1 && (
<FeaturedShowContents
featuredShowsInfos={playListInfo}
currentVideoInfo={playListInfo[selectedIndex]}
setSelectedIndex={setSelectedIndex}
selectedIndex={selectedIndex}
videoVerticalVisible={videoVerticalVisible}
currentVideoShowId={playListInfo[selectedIndex]?.showId}
tabIndex={tab}
handleItemFocus={_handleItemFocus}
/>
)}
{panelInfo?.shptmBanrTpNm === "LIVE" && tab === 1 && liveChannelInfos && (
<LiveChannelContents
selectedIndex={selectedIndex}
setSelectedIndex={setSelectedIndex}
videoVerticalVisible={videoVerticalVisible}
liveInfos={playListInfo}
tabIndex={tab}
handleItemFocus={_handleItemFocus}
currentTime={currentTime}
/>
)}
{shopNowInfo && shopNowInfo.length < 3 && tab === 0 && (
<YouMayLikeContents
shopNowInfo={shopNowInfo}
handleItemFocus={_handleItemFocus}
playListInfo={playListInfo && playListInfo[selectedIndex]}
/>
)}
</Container>
);
}