Created
November 16, 2020 13:17
-
-
Save followthemoney1/4688990e6de9ce7a92498e9ed644ff53 to your computer and use it in GitHub Desktop.
medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rowsList.asMap().entries.forEach((rows) { | |
//нам нужно определить пересекается ли текущий элемент с элементом который слева или же сверху, если пересекается, | |
//тогда текущий элемент мы двигаем вниз или справо в зависимости | |
//mark: left | |
if (currentRow.iRow != 0) { | |
calcOverflowLeft(rowsList.elementAt(currentRow.iRow - 1), currentRow); | |
} | |
//mark: top | |
if (currentRow.iColumn != 0) { | |
calcOverflowTop( | |
suggestionMatrix[currentRow.iColumn - 1] | |
.elementAt(currentRow.iRow), | |
currentRow); | |
} | |
//mark: left top first | |
if (currentRow.iRow != 0 && | |
currentRow.iRow + 1 < rowsList.length && | |
currentRow.iColumn >= 1) { | |
caclLeftTopElementOverflow( | |
suggestionMatrix[iColumn - 1].elementAt(currentRow.iRow), | |
rowsList.elementAt(currentRow.iRow + 1)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
caclLeftTopElementOverflow( | |
SuggestionCategory prev, SuggestionCategory current) { | |
final currentYStartPosition = current.y; | |
final prevYEndPosition = prev.y + prev.height; | |
final currentXStartPosition = current.x; | |
final prevXEndPosition = prev.x + prev.width; | |
if (prevYEndPosition >= currentYStartPosition && prev.isExpanded) { | |
current.y += (prev.y + prev.height) - current.y; | |
} | |
} | |
void calcOverflowLeft(SuggestionCategory prev, SuggestionCategory current) { | |
final currentStartPosition = current.x; | |
final prevEndPosition = prev.x + prev.width; | |
if (prevEndPosition > currentStartPosition) { | |
current.x += prevEndPosition - currentStartPosition; | |
} else if (prevEndPosition < currentStartPosition) { | |
current.x -= currentStartPosition - prevEndPosition; | |
} else if (prevEndPosition != currentStartPosition) { | |
print( | |
"prevEndPosition = $prevEndPosition currentStartPosition=$currentStartPosition"); | |
} | |
} | |
void calcOverflowTop(SuggestionCategory prev, SuggestionCategory current) { | |
final currentStartPosition = current.y; | |
final prevEndPosition = prev.y + prev.height; | |
if (prevEndPosition > currentStartPosition) { | |
current.y += prevEndPosition - currentStartPosition; | |
} else if (prevEndPosition < currentStartPosition) { | |
current.y -= currentStartPosition - prevEndPosition; | |
} else if (prevEndPosition != currentStartPosition) { | |
print( | |
"prevEndPosition = $prevEndPosition currentStartPosition=$currentStartPosition"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment