TabLayout 기획변경으로 기능 추가 및 수정
This commit is contained in:
@@ -40,6 +40,10 @@ const TabItemBase = ({
|
|||||||
(ev) => {
|
(ev) => {
|
||||||
clearPressedJob.current.start(() => {
|
clearPressedJob.current.start(() => {
|
||||||
if (onClick) {
|
if (onClick) {
|
||||||
|
if (showSubTab) {
|
||||||
|
Spotlight.focus("activatedSub");
|
||||||
|
}
|
||||||
|
|
||||||
onClick({ index, target });
|
onClick({ index, target });
|
||||||
if (spotlightId) {
|
if (spotlightId) {
|
||||||
setLastFocusId(spotlightId);
|
setLastFocusId(spotlightId);
|
||||||
@@ -47,7 +51,7 @@ const TabItemBase = ({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[target, index, onClick]
|
[target, index, onClick, showSubTab]
|
||||||
);
|
);
|
||||||
|
|
||||||
const _onFocus = useCallback(() => {
|
const _onFocus = useCallback(() => {
|
||||||
@@ -99,7 +103,8 @@ const TabItemBase = ({
|
|||||||
<SpottableComponent
|
<SpottableComponent
|
||||||
className={classNames(
|
className={classNames(
|
||||||
css.tabItem,
|
css.tabItem,
|
||||||
(focused || opened) && css.focused,
|
focused && css.focused,
|
||||||
|
opened && css.opened,
|
||||||
!isSubItem && opened && showSubTab && css.arrow,
|
!isSubItem && opened && showSubTab && css.arrow,
|
||||||
mainSelected && css.selected,
|
mainSelected && css.selected,
|
||||||
selected && css.selected
|
selected && css.selected
|
||||||
|
|||||||
@@ -21,6 +21,14 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.opened {
|
||||||
|
color: #eee;
|
||||||
|
width: 402px;
|
||||||
|
z-index: 1;
|
||||||
|
margin-left: 30px;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
&.arrow {
|
&.arrow {
|
||||||
&::after {
|
&::after {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import React, { useCallback, useRef, useState } from "react";
|
import React, { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import compose from "ramda/src/compose";
|
import compose from "ramda/src/compose";
|
||||||
|
|
||||||
import { Job } from "@enact/core/util";
|
import { Job } from "@enact/core/util";
|
||||||
import { Marquee, MarqueeController } from "@enact/sandstone/Marquee";
|
import { Marquee, MarqueeController } from "@enact/sandstone/Marquee";
|
||||||
|
import Spotlight from "@enact/spotlight";
|
||||||
import Spottable from "@enact/spotlight/Spottable";
|
import Spottable from "@enact/spotlight/Spottable";
|
||||||
|
|
||||||
import css from "./TabItemSub.module.less";
|
import css from "./TabItemSub.module.less";
|
||||||
@@ -22,6 +23,8 @@ const TabItemBase = ({
|
|||||||
isSubItem,
|
isSubItem,
|
||||||
onFocus,
|
onFocus,
|
||||||
path,
|
path,
|
||||||
|
spotlightId,
|
||||||
|
setLastFocusId,
|
||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const [focused, setFocused] = useState(false);
|
const [focused, setFocused] = useState(false);
|
||||||
@@ -37,6 +40,9 @@ const TabItemBase = ({
|
|||||||
clearPressedJob.current.start(() => {
|
clearPressedJob.current.start(() => {
|
||||||
if (onClick) {
|
if (onClick) {
|
||||||
onClick({ index, target });
|
onClick({ index, target });
|
||||||
|
if (spotlightId) {
|
||||||
|
setLastFocusId(spotlightId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -48,10 +54,11 @@ const TabItemBase = ({
|
|||||||
if (onFocus) {
|
if (onFocus) {
|
||||||
onFocus(index);
|
onFocus(index);
|
||||||
}
|
}
|
||||||
}, [index]);
|
}, [index, onFocus]);
|
||||||
|
|
||||||
const _onBlur = useCallback(() => {
|
const _onBlur = useCallback(() => {
|
||||||
setFocused(false);
|
setFocused(false);
|
||||||
|
setLastFocusId(null);
|
||||||
}, [index]);
|
}, [index]);
|
||||||
|
|
||||||
const onKeyDown = useCallback(
|
const onKeyDown = useCallback(
|
||||||
@@ -111,6 +118,7 @@ const TabItemBase = ({
|
|||||||
onFocus={_onFocus}
|
onFocus={_onFocus}
|
||||||
onBlur={_onBlur}
|
onBlur={_onBlur}
|
||||||
onClick={_onClick}
|
onClick={_onClick}
|
||||||
|
spotlightId={spotlightId}
|
||||||
>
|
>
|
||||||
<div className={classNames(isSubItem && css.subWrap)}>
|
<div className={classNames(isSubItem && css.subWrap)}>
|
||||||
{!path && (
|
{!path && (
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
const [mainSelectedIndex, setMainSelectedIndex] = useState(-1);
|
const [mainSelectedIndex, setMainSelectedIndex] = useState(-1);
|
||||||
const [secondDepthReduce, setSecondDepthReduce] = useState(false);
|
const [secondDepthReduce, setSecondDepthReduce] = useState(false);
|
||||||
const [lastFocusId, setLastFocusId] = useState(null);
|
const [lastFocusId, setLastFocusId] = useState(null);
|
||||||
|
const [subTabLastFocusId, setSubTabLastFocusId] = useState(null);
|
||||||
const [tabs, setTabs] = useState([]);
|
const [tabs, setTabs] = useState([]);
|
||||||
const [tabFocused, setTabFocused] = useState([false, false, false]); //COLLABSED_MAIN, ACTIVATED_MAIN, ACTIVATED_SUB
|
const [tabFocused, setTabFocused] = useState([false, false, false]); //COLLABSED_MAIN, ACTIVATED_MAIN, ACTIVATED_SUB
|
||||||
const panelSwitching = useRef(null);
|
const panelSwitching = useRef(null);
|
||||||
@@ -216,7 +217,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
result =
|
result =
|
||||||
data?.shortFeaturedBrands &&
|
data?.shortFeaturedBrands &&
|
||||||
data.shortFeaturedBrands.map((item) => ({
|
data.shortFeaturedBrands.map((item) => ({
|
||||||
Id: item.patnrId,
|
id: item.patnrId,
|
||||||
path: item.patncLogoPath,
|
path: item.patncLogoPath,
|
||||||
target: [
|
target: [
|
||||||
{
|
{
|
||||||
@@ -230,6 +231,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
result =
|
result =
|
||||||
data?.mypage &&
|
data?.mypage &&
|
||||||
data.mypage.map((item) => ({
|
data.mypage.map((item) => ({
|
||||||
|
id: item.menuId,
|
||||||
title: item.menuNm,
|
title: item.menuNm,
|
||||||
target: [
|
target: [
|
||||||
{
|
{
|
||||||
@@ -240,7 +242,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//console.log("#data", data);
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -279,6 +281,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
title: subItem.title,
|
title: subItem.title,
|
||||||
path: subItem.path,
|
path: subItem.path,
|
||||||
target: subItem.target,
|
target: subItem.target,
|
||||||
|
spotlightId: `secondDetph-${subItem.id}`,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -339,9 +342,8 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTIVATED_SUB: {
|
case ACTIVATED_SUB: {
|
||||||
if (cursorVisible) {
|
if (!cursorVisible) {
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case EXTRA_AREA: {
|
case EXTRA_AREA: {
|
||||||
if (cursorVisible) {
|
if (cursorVisible) {
|
||||||
@@ -401,6 +403,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
dispatch(resetPanels());
|
dispatch(resetPanels());
|
||||||
deActivateTab();
|
deActivateTab();
|
||||||
Spotlight.focus(SpotlightIds.TBODY);
|
Spotlight.focus(SpotlightIds.TBODY);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (target) {
|
if (target) {
|
||||||
@@ -453,7 +456,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}, [tabActivated, tabs, mainSelectedIndex]);
|
}, [tabActivated, mainSelectedIndex]);
|
||||||
|
|
||||||
const backKeyHandler = useCallback(
|
const backKeyHandler = useCallback(
|
||||||
(ev) => {
|
(ev) => {
|
||||||
@@ -474,6 +477,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
} else {
|
} else {
|
||||||
Spotlight.focus("spotlight_home");
|
Spotlight.focus("spotlight_home");
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(gnbOpened(true));
|
dispatch(gnbOpened(true));
|
||||||
}
|
}
|
||||||
if (onTabActivated) {
|
if (onTabActivated) {
|
||||||
@@ -481,11 +485,17 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
}
|
}
|
||||||
}, [tabActivated, showTab, dispatch]);
|
}, [tabActivated, showTab, dispatch]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (tabActivated && showSubTab && subTabLastFocusId !== null) {
|
||||||
|
Spotlight.focus(subTabLastFocusId);
|
||||||
|
}
|
||||||
|
}, [tabActivated, mainSelectedIndex, subTabLastFocusId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSecondDepthReduce(false);
|
setSecondDepthReduce(false);
|
||||||
|
|
||||||
if (showSubTab) {
|
if (showSubTab) {
|
||||||
tabs[mainSelectedIndex]?.children.map((item) => {
|
tabs[mainSelectedIndex]?.children.forEach((item) => {
|
||||||
if (item.path) {
|
if (item.path) {
|
||||||
setSecondDepthReduce(true);
|
setSecondDepthReduce(true);
|
||||||
}
|
}
|
||||||
@@ -514,7 +524,17 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
<TabItem
|
<TabItem
|
||||||
key={"tabitem" + index}
|
key={"tabitem" + index}
|
||||||
expanded={false}
|
expanded={false}
|
||||||
selected={mainSelectedIndex === index}
|
mainSelected={
|
||||||
|
(panels.length === 0 && index === 3) ||
|
||||||
|
(Array.isArray(item.target) &&
|
||||||
|
item.target[0]?.name &&
|
||||||
|
panels[0]?.name === item.target[0]?.name)
|
||||||
|
}
|
||||||
|
selected={
|
||||||
|
Array.isArray(item.children[0]?.target) &&
|
||||||
|
item.children[0]?.target[0]?.name &&
|
||||||
|
panels[0]?.name === item.children[0]?.target?.[0].name
|
||||||
|
}
|
||||||
index={index}
|
index={index}
|
||||||
onClick={handleNavigation}
|
onClick={handleNavigation}
|
||||||
icons={item.icons}
|
icons={item.icons}
|
||||||
@@ -550,10 +570,10 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
tabs.map((item, index) => (
|
tabs.map((item, index) => (
|
||||||
<TabItem
|
<TabItem
|
||||||
{...item}
|
{...item}
|
||||||
|
key={"tabitemExpanded" + index}
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
spotlightId={item.spotlightId}
|
spotlightId={item.spotlightId}
|
||||||
setLastFocusId={setLastFocusId}
|
setLastFocusId={setLastFocusId}
|
||||||
key={"tabitemExpanded" + index}
|
|
||||||
onClick={handleNavigation}
|
onClick={handleNavigation}
|
||||||
deActivateTab={deActivateTab}
|
deActivateTab={deActivateTab}
|
||||||
showSubTab={showSubTab}
|
showSubTab={showSubTab}
|
||||||
@@ -598,8 +618,10 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
|
|||||||
<TabItemSub
|
<TabItemSub
|
||||||
{...item}
|
{...item}
|
||||||
key={"tabitemSubmenu" + index}
|
key={"tabitemSubmenu" + index}
|
||||||
|
spotlightId={item.spotlightId}
|
||||||
|
setLastFocusId={setSubTabLastFocusId}
|
||||||
onClick={onClickSubItem}
|
onClick={onClickSubItem}
|
||||||
expanded={true}
|
expanded={mainExpanded}
|
||||||
index={index}
|
index={index}
|
||||||
isSubItem={true}
|
isSubItem={true}
|
||||||
deActivateTab={deActivateTab}
|
deActivateTab={deActivateTab}
|
||||||
|
|||||||
Reference in New Issue
Block a user