[go: nahoru, domu]

Adds lint check for composable lambda parameters in composable functions

Composable functions with only one composable lambda parameter should use the name `content` and place this parameter at the end, so it can be used as a trailing lambda.

Also updates existing functions that do not follow these guidelines.

Bug: b/172469237
Test: ComposableLambdaParameterDetectorTest
Test: updateApi
Test: lintDebug
Relnote: """Added lint check for composable lambda parameter naming and position, to check for consistency with Compose guidelines.
Also migrated some APIs using `children` as the name for their trailing lambda to `content`, according to the lint check and guidance."""

Change-Id: Iec48e38a2896785b521814d95c9fb624d2807315
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Text.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Text.kt
index 3a5b772..d96a672 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Text.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Text.kt
@@ -236,12 +236,12 @@
 /**
  * This function is used to set the current value of [AmbientTextStyle], merging the given style
  * with the current style values for any missing attributes. Any [Text] components included in
- * this component's [children] will be styled with this style unless styled explicitly.
+ * this component's [content] will be styled with this style unless styled explicitly.
  *
  * @see AmbientTextStyle
  */
 @Composable
-fun ProvideTextStyle(value: TextStyle, children: @Composable () -> Unit) {
+fun ProvideTextStyle(value: TextStyle, content: @Composable () -> Unit) {
     val mergedStyle = AmbientTextStyle.current.merge(value)
-    Providers(AmbientTextStyle provides mergedStyle, children = children)
+    Providers(AmbientTextStyle provides mergedStyle, content = content)
 }