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 28, 2024
1 parent e2d0daa commit 27fe258
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,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 27fe258

Please sign in to comment.