Skip to content

Commit

Permalink
Optimize PaddingValues copy
Browse files Browse the repository at this point in the history
Avoid nullable parameters in this function and we can let local direction as the default param.
  • Loading branch information
Goooler committed Mar 26, 2024
1 parent abd564e commit 14053d0
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,18 @@ private fun ChatContent(
}
}

@Composable
private fun PaddingValues.copy(
layoutDirection: LayoutDirection,
start: Dp? = null,
top: Dp? = null,
end: Dp? = null,
bottom: Dp? = null,
layoutDirection: LayoutDirection = LocalLayoutDirection.current,
start: Dp = calculateStartPadding(layoutDirection),
top: Dp = calculateTopPadding(),
end: Dp = calculateEndPadding(layoutDirection),
bottom: Dp = calculateBottomPadding(),
) = PaddingValues(
start = start ?: calculateStartPadding(layoutDirection),
top = top ?: calculateTopPadding(),
end = end ?: calculateEndPadding(layoutDirection),
bottom = bottom ?: calculateBottomPadding(),
start = start,
top = top,
end = end,
bottom = bottom,
)

@OptIn(ExperimentalMaterial3Api::class)
Expand Down

0 comments on commit 14053d0

Please sign in to comment.