回退 'Pull Request !49040 : List多列模式支持方向键Z字形走焦'

This commit is contained in:
yeyinglong 2024-11-21 10:59:25 +00:00 committed by Gitee
parent 67fc6cf82b
commit ec22a43c0c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 25 additions and 7 deletions

View File

@ -1094,8 +1094,27 @@ WeakPtr<FocusHub> ListPattern::GetNextFocusNode(FocusStep step, const WeakPtr<Fo
moveStep = -curListItemGroupPara.lanes;
nextIndexInGroup = curIndexInGroup + moveStep;
}
} else if ((step == FocusStep::TAB) ||
(isVertical && (step == FocusStep::RIGHT)) || (!isVertical && step == FocusStep::DOWN)) {
} else if ((isVertical && (step == FocusStep::RIGHT)) || (!isVertical && step == FocusStep::DOWN)) {
moveStep = 1;
if (((curIndexInGroup == -1) && ((curIndex - (lanes_ - 1)) % lanes_ != 0)) ||
((curIndexInGroup != -1) &&
((curIndexInGroup - (curListItemGroupPara.lanes - 1)) % curListItemGroupPara.lanes == 0))) {
nextIndex = curIndex + moveStep;
nextIndexInGroup = -1;
} else if ((curIndexInGroup != -1) &&
((curIndexInGroup - (curListItemGroupPara.lanes - 1)) % curListItemGroupPara.lanes != 0)) {
nextIndexInGroup = curIndexInGroup + moveStep;
}
} else if ((isVertical && step == FocusStep::LEFT) || (!isVertical && step == FocusStep::UP)) {
moveStep = -1;
if (((curIndexInGroup == -1) && (curIndex % lanes_ != 0)) ||
((curIndexInGroup != -1) && (curIndexInGroup % curListItemGroupPara.lanes == 0))) {
nextIndex = curIndex + moveStep;
nextIndexInGroup = -1;
} else if ((curIndexInGroup != -1) && (curIndexInGroup % curListItemGroupPara.lanes != 0)) {
nextIndexInGroup = curIndexInGroup + moveStep;
}
} else if (step == FocusStep::TAB) {
moveStep = 1;
if ((curIndexInGroup == -1) || (curIndexInGroup >= curListItemGroupPara.itemEndIndex)) {
nextIndex = curIndex + moveStep;
@ -1103,8 +1122,7 @@ WeakPtr<FocusHub> ListPattern::GetNextFocusNode(FocusStep step, const WeakPtr<Fo
} else {
nextIndexInGroup = curIndexInGroup + moveStep;
}
} else if ((step == FocusStep::SHIFT_TAB) ||
(isVertical && step == FocusStep::LEFT) || (!isVertical && step == FocusStep::UP)) {
} else if (step == FocusStep::SHIFT_TAB) {
moveStep = -1;
if ((curIndexInGroup == -1) || (curIndexInGroup <= 0)) {
nextIndex = curIndex + moveStep;

View File

@ -326,7 +326,7 @@ HWTEST_F(ListCommonTestNg, FocusStep003, TestSize.Level1)
*/
int32_t currentIndex = 2;
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::NONE, currentIndex, NULL_VALUE));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::LEFT, currentIndex, 1));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::LEFT, currentIndex, NULL_VALUE));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::UP, currentIndex, 0));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::RIGHT, currentIndex, 3));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::DOWN, currentIndex, 4));
@ -344,7 +344,7 @@ HWTEST_F(ListCommonTestNg, FocusStep003, TestSize.Level1)
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::NONE, currentIndex, NULL_VALUE));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::LEFT, currentIndex, 2));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::UP, currentIndex, 1));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::RIGHT, currentIndex, 4));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::RIGHT, currentIndex, NULL_VALUE));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::DOWN, currentIndex, 5));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::LEFT_END, currentIndex, 0));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::UP_END, currentIndex, 0));
@ -375,7 +375,7 @@ HWTEST_F(ListCommonTestNg, FocusStep004, TestSize.Level1)
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::LEFT, currentIndex, 1));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::UP, currentIndex, 2));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::RIGHT, currentIndex, 5));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::DOWN, currentIndex, 4));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::DOWN, currentIndex, NULL_VALUE));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::LEFT_END, currentIndex, 0));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::UP_END, currentIndex, 0));
EXPECT_TRUE(IsEqualNextFocusNode(FocusStep::RIGHT_END, currentIndex, 5));