[go: nahoru, domu]

Renames Ambients to match the Ambient to CompositionLocal rename

Deprecates existing ambients, replaces with the new Local* CompositionLocals.

Bug: b/178501597
Test: updateApi
Relnote: "Renamed Ambients to match the Ambient -> CompositionLocal rename. Ambients used to be named AmbientFoo, now CompositionLocals are named LocalFoo."
Change-Id: I2d55d1c5c38a08b04e72a569d3079db4feca1bf7
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 d0b7854..08f19f1 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
@@ -20,7 +20,7 @@
 import androidx.compose.foundation.text.InlineTextContent
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.Providers
-import androidx.compose.runtime.ambientOf
+import androidx.compose.runtime.compositionLocalOf
 import androidx.compose.runtime.structuralEqualityPolicy
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.graphics.Color
@@ -224,13 +224,29 @@
 }
 
 /**
- * Ambient containing the preferred [TextStyle] that will be used by [Text] components by default.
- * To set the value for this ambient, see [ProvideTextStyle] which will merge any missing
- * [TextStyle] properties with the existing [TextStyle] set in this ambient.
+ * CompositionLocal containing the preferred [TextStyle] that will be used by [Text] components by
+ * default. To set the value for this CompositionLocal, see [ProvideTextStyle] which will merge any
+ * missing [TextStyle] properties with the existing [TextStyle] set in this CompositionLocal.
  *
  * @see ProvideTextStyle
  */
-val AmbientTextStyle = ambientOf(structuralEqualityPolicy()) { TextStyle.Default }
+@Deprecated(
+    "Renamed to LocalTextStyle",
+    replaceWith = ReplaceWith(
+        "LocalTextStyle",
+        "androidx.compose.material.LocalTextStyle"
+    )
+)
+val AmbientTextStyle get() = LocalTextStyle
+
+/**
+ * CompositionLocal containing the preferred [TextStyle] that will be used by [Text] components by
+ * default. To set the value for this CompositionLocal, see [ProvideTextStyle] which will merge any
+ * missing [TextStyle] properties with the existing [TextStyle] set in this CompositionLocal.
+ *
+ * @see ProvideTextStyle
+ */
+val LocalTextStyle = compositionLocalOf(structuralEqualityPolicy()) { TextStyle.Default }
 
 // TODO: b/156598010 remove this and replace with fold definition on the backing Ambient
 /**