Skip to content

Commit 27fe258

Browse files
committed
Optimize PaddingValues copy
Avoid nullable parameters in this function and we can let local direction as the default param.
1 parent e2d0daa commit 27fe258

File tree

1 file changed

+10
-9
lines changed
  • app/src/main/java/com/google/android/samples/socialite/ui/chat

1 file changed

+10
-9
lines changed

Diff for: app/src/main/java/com/google/android/samples/socialite/ui/chat/ChatScreen.kt

+10-9
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,18 @@ private fun ChatContent(
229229
}
230230
}
231231

232+
@Composable
232233
private fun PaddingValues.copy(
233-
layoutDirection: LayoutDirection,
234-
start: Dp? = null,
235-
top: Dp? = null,
236-
end: Dp? = null,
237-
bottom: Dp? = null,
234+
layoutDirection: LayoutDirection = LocalLayoutDirection.current,
235+
start: Dp = calculateStartPadding(layoutDirection),
236+
top: Dp = calculateTopPadding(),
237+
end: Dp = calculateEndPadding(layoutDirection),
238+
bottom: Dp = calculateBottomPadding(),
238239
) = PaddingValues(
239-
start = start ?: calculateStartPadding(layoutDirection),
240-
top = top ?: calculateTopPadding(),
241-
end = end ?: calculateEndPadding(layoutDirection),
242-
bottom = bottom ?: calculateBottomPadding(),
240+
start = start,
241+
top = top,
242+
end = end,
243+
bottom = bottom,
243244
)
244245

245246
@OptIn(ExperimentalMaterial3Api::class)

0 commit comments

Comments
 (0)