Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Nov 25, 2023
1 parent 426706b commit 535e6da
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,19 @@ public fun <T> BasicLazyTree(
)

val backgroundShape by derivedStateOf {
val upperCorners = flattenedTree.getOrNull(index - 1)?.id?.let {
val hasRoundedTopCorners = flattenedTree.getOrNull(index - 1)?.id?.let {
it !in treeState.delegate.selectedKeys
} ?: false
val bottomCorners = flattenedTree.getOrNull(index + 1)?.id?.let {
val hasRoundedBottomCorners = flattenedTree.getOrNull(index + 1)?.id?.let {
it !in treeState.delegate.selectedKeys
} ?: false
val topCornerSize = computerCornerSize(hasRoundedTopCorners, elementBackgroundCornerSize)
val bottomCornerSize = computerCornerSize(hasRoundedBottomCorners, elementBackgroundCornerSize)
RoundedCornerShape(
topStart = if (upperCorners) elementBackgroundCornerSize else CornerSize(0.dp),
topEnd = if (upperCorners) elementBackgroundCornerSize else CornerSize(0.dp),
bottomEnd = if (bottomCorners) elementBackgroundCornerSize else CornerSize(0.dp),
bottomStart = if (bottomCorners) elementBackgroundCornerSize else CornerSize(0.dp),
topStart = topCornerSize,
topEnd = topCornerSize,
bottomEnd = bottomCornerSize,
bottomStart = bottomCornerSize,
)
}
Row(
Expand Down Expand Up @@ -213,6 +215,11 @@ public fun <T> BasicLazyTree(
}
}

private fun computerCornerSize(
isRounded: Boolean,
cornerSize: CornerSize,
) = if (isRounded) cornerSize else CornerSize(0.dp)

private fun Modifier.elementBackground(
state: TreeElementState,
selectedFocused: Color,
Expand Down

0 comments on commit 535e6da

Please sign in to comment.