Migrates CompositionLocal usages away from the deprecated Ambient* named properties
Also fixes comments / documentation referring to `ambient`
Bug: b/178501597
Test: n/a
Change-Id: Idbc8f1870dd1af40b26cf81013ff456792b3197b
diff --git a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/ComplexInteractions.kt b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/ComplexInteractions.kt
index 5a44235..e596cbe44 100644
--- a/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/ComplexInteractions.kt
+++ b/compose/androidview/androidview/integration-tests/androidview-demos/src/main/java/androidx/compose/androidview/demos/ComplexInteractions.kt
@@ -38,8 +38,8 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientContext
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
@@ -56,7 +56,7 @@
@Composable
fun ComposeInAndroidInComposeEtcTargetingDemo() {
- val context = AmbientContext.current
+ val context = LocalContext.current
Column {
Text(
"In this demo, from the inside out, we have a Compose Button, wrapped in 2 Android " +
diff --git a/compose/animation/animation-core/src/androidMain/kotlin/androidx/compose/animation/core/AndroidAnimationClock.kt b/compose/animation/animation-core/src/androidMain/kotlin/androidx/compose/animation/core/AndroidAnimationClock.kt
index 918f9c5..f961f35 100644
--- a/compose/animation/animation-core/src/androidMain/kotlin/androidx/compose/animation/core/AndroidAnimationClock.kt
+++ b/compose/animation/animation-core/src/androidMain/kotlin/androidx/compose/animation/core/AndroidAnimationClock.kt
@@ -34,7 +34,7 @@
/**
* Default Choreographer based clock that pushes a new frame to all subscribers on each
* Choreographer tick, until all subscribers have unsubscribed. An instance of this clock will be
- * provided through [AnimationClockAmbient][androidx.compose.ui.platform.AnimationClockAmbient] at
+ * provided through [LocalAnimationClock][androidx.compose.ui.platform.LocalAnimationClock] at
* the root of the composition tree.
*
* If initialized from any other thread but the main thread, part of the initialization is done
diff --git a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt
index d7b4510..16038bb 100644
--- a/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt
+++ b/compose/animation/animation-core/src/commonMain/kotlin/androidx/compose/animation/core/Transition.kt
@@ -458,8 +458,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -533,8 +533,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -568,8 +568,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -599,8 +599,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -630,8 +630,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -661,8 +661,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -692,8 +692,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -723,8 +723,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
@@ -753,9 +753,10 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
- * [Transition] will start running again to ensure this animation reaches its new target smoothly.
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState),
+ * the [Transition] will start running again to ensure this animation reaches its new target
+ * smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
* each pair of initialState and targetState. [FiniteAnimationSpec] includes any non-infinite
@@ -784,8 +785,8 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
* [Transition] will start running again to ensure this animation reaches its new target smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
diff --git a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt
index 1a92a86..fb933a0 100644
--- a/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt
+++ b/compose/animation/animation/integration-tests/animation-demos/src/main/java/androidx/compose/animation/demos/AnimateContentSizeDemo.kt
@@ -31,8 +31,8 @@
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.AmbientTextStyle
import androidx.compose.material.Button
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -82,7 +82,7 @@
} else {
longText
},
- style = AmbientTextStyle.current.copy(color = Color.White)
+ style = LocalTextStyle.current.copy(color = Color.White)
)
}
}
@@ -101,7 +101,7 @@
} else {
longText
},
- style = AmbientTextStyle.current.copy(color = Color.White),
+ style = LocalTextStyle.current.copy(color = Color.White),
modifier = Modifier.animateContentSize()
)
}
@@ -123,7 +123,7 @@
} else {
"16 : 9"
},
- style = AmbientTextStyle.current.copy(color = Color.Black)
+ style = LocalTextStyle.current.copy(color = Color.Black)
)
}
}
diff --git a/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimationModifierSample.kt b/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimationModifierSample.kt
index 78b8aee..ba7059e 100644
--- a/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimationModifierSample.kt
+++ b/compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimationModifierSample.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.AmbientTextStyle
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -58,7 +58,7 @@
} else {
longText
},
- style = AmbientTextStyle.current.copy(color = Color.White)
+ style = LocalTextStyle.current.copy(color = Color.White)
)
}
}
diff --git a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt
index 8c48ac2..a069b0e 100644
--- a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt
+++ b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimatedVisibilityTest.kt
@@ -29,7 +29,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.unit.IntOffset
@@ -89,7 +89,7 @@
}
}
}
- density = AmbientDensity.current.density
+ density = LocalDensity.current.density
}
rule.runOnIdle {
@@ -199,7 +199,7 @@
}
}
}
- density = AmbientDensity.current.density
+ density = LocalDensity.current.density
}
rule.runOnIdle {
diff --git a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt
index 49ef8bd..997558f 100644
--- a/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt
+++ b/compose/animation/animation/src/androidAndroidTest/kotlin/androidx/compose/animation/AnimationModifierTest.kt
@@ -28,8 +28,8 @@
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasureResult
import androidx.compose.ui.layout.MeasureScope
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.junit4.createComposeRule
@@ -100,7 +100,7 @@
}
.size(width.dp, height.dp)
)
- density = AmbientDensity.current.density
+ density = LocalDensity.current.density
}
rule.runOnUiThread {
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedValueEffects.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedValueEffects.kt
index 4c34544..3ca2772 100644
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedValueEffects.kt
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedValueEffects.kt
@@ -33,7 +33,7 @@
import androidx.compose.runtime.setValue
import androidx.compose.runtime.structuralEqualityPolicy
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
/**
* The animatedValue effect creates an [AnimatedValue] and positionally memoizes it. When the
@@ -59,7 +59,7 @@
initVal: T,
converter: TwoWayConverter<T, V>,
visibilityThreshold: T? = null,
- clock: AnimationClockObservable = AmbientAnimationClock.current
+ clock: AnimationClockObservable = LocalAnimationClock.current
): AnimatedValue<T, V> = clock.asDisposableClock().let { disposableClock ->
remember(disposableClock) {
AnimatedValueModel(initVal, converter, disposableClock, visibilityThreshold)
@@ -85,7 +85,7 @@
fun animatedFloat(
initVal: Float,
visibilityThreshold: Float = Spring.DefaultDisplacementThreshold,
- clock: AnimationClockObservable = AmbientAnimationClock.current
+ clock: AnimationClockObservable = LocalAnimationClock.current
): AnimatedFloat = clock.asDisposableClock().let { disposableClock ->
remember(disposableClock) { AnimatedFloatModel(initVal, disposableClock, visibilityThreshold) }
}
@@ -108,7 +108,7 @@
)
fun animatedColor(
initVal: Color,
- clock: AnimationClockObservable = AmbientAnimationClock.current
+ clock: AnimationClockObservable = LocalAnimationClock.current
): AnimatedValue<Color, AnimationVector4D> = clock.asDisposableClock().let { disposableClock ->
remember(disposableClock) {
AnimatedValueModel(
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt
index 7772778..26a203d 100644
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/AnimatedVisibility.kt
@@ -27,7 +27,7 @@
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.util.fastForEach
@@ -255,7 +255,7 @@
}
}
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
val animations = remember(clock, enter, exit) {
// TODO: Should we delay changing enter/exit after on-going animations are finished?
TransitionAnimations(enter, exit, clock) {
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt
index ac40171..b13884b 100644
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/SingleValueAnimation.kt
@@ -47,7 +47,7 @@
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
import androidx.compose.ui.unit.Bounds
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
@@ -453,7 +453,7 @@
visibilityThreshold: T? = null,
endListener: ((T) -> Unit)? = null
): T {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
val anim = remember(clock, converter) {
AnimatedValueModel(target, converter, clock, visibilityThreshold)
}
diff --git a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
index 509501e..c58614d 100644
--- a/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
+++ b/compose/animation/animation/src/commonMain/kotlin/androidx/compose/animation/Transition.kt
@@ -39,9 +39,10 @@
* [targetValueByState] is used as a mapping from a target state to the target value of this
* animation. [Transition] will be using this mapping to determine what value to target this
* animation towards. __Note__ that [targetValueByState] is a composable function. This means the
- * mapping function could access states, ambient, themes, etc. If the targetValue changes outside
- * of a [Transition] run (i.e. when the [Transition] already reached its targetState), the
- * [Transition] will start running again to ensure this animation reaches its new target smoothly.
+ * mapping function could access states, CompositionLocals, themes, etc. If the targetValue changes
+ * outside of a [Transition] run (i.e. when the [Transition] already reached its targetState),
+ * the [Transition] will start running again to ensure this animation reaches its new target
+ * smoothly.
*
* An optional [transitionSpec] can be provided to specify (potentially different) animation for
* each pair of initialState and targetState. [FiniteAnimationSpec] includes any non-infinite
diff --git a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/RobolectricComposeTester.kt b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/RobolectricComposeTester.kt
index 9fe9099..8b74ce0 100644
--- a/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/RobolectricComposeTester.kt
+++ b/compose/compiler/compiler-hosted/integration-tests/src/test/java/androidx/compose/compiler/plugins/kotlin/RobolectricComposeTester.kt
@@ -27,7 +27,7 @@
import androidx.compose.runtime.ExperimentalComposeApi
import androidx.compose.runtime.Recomposer
import androidx.compose.ui.node.UiApplier
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
@@ -99,7 +99,7 @@
val realComposable: (Composer, Int) -> Unit = { composer, _ ->
startProviders.invoke(
composer,
- listOf(AmbientContext provides root.context).toTypedArray()
+ listOf(LocalContext provides root.context).toTypedArray()
)
composable(composer, 0)
endProviders.invoke(composer)
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/TestAmbient.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/TestAmbient.kt
index 9f29f4b..deaeeec 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/TestAmbient.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/popupexample/TestAmbient.kt
@@ -16,6 +16,6 @@
package androidx.compose.desktop.examples.popupexample
-import androidx.compose.runtime.staticAmbientOf
+import androidx.compose.runtime.staticCompositionLocalOf
-val AmbientTest = staticAmbientOf<Int>()
\ No newline at end of file
+val AmbientTest = staticCompositionLocalOf<Int>()
\ No newline at end of file
diff --git a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/vsynctest/Main.kt b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/vsynctest/Main.kt
index 59b3714..1195848 100644
--- a/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/vsynctest/Main.kt
+++ b/compose/desktop/desktop/samples/src/jvmMain/kotlin/androidx/compose/desktop/examples/vsynctest/Main.kt
@@ -29,7 +29,7 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntSize
private val frameLogCount = 1000
@@ -76,7 +76,7 @@
Window(size = IntSize(800, 200)) {
val window = AppWindowAmbient.current!!
- val width = (AmbientDensity.current.density * window.window.width).toInt()
+ val width = (LocalDensity.current.density * window.window.width).toInt()
val singleFrameMillis = remember {
1000 / window.window.graphicsConfiguration.device.displayMode.refreshRate
}
diff --git a/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt b/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt
index b3b2da8..5ac328d 100644
--- a/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt
+++ b/compose/foundation/foundation-layout/integration-tests/layout-demos/src/main/java/androidx/compose/foundation/layout/demos/RtlDemo.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
@@ -61,11 +61,11 @@
)
CustomLayout(false)
Text("WITH CONSTRAINTS", Modifier.align(Alignment.CenterHorizontally))
- Providers(AmbientLayoutDirection provides LayoutDirection.Ltr) {
- LayoutWithConstraints("LD: set LTR via ambient")
+ Providers(LocalLayoutDirection provides LayoutDirection.Ltr) {
+ LayoutWithConstraints("LD: set LTR via CompositionLocal")
}
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
- LayoutWithConstraints("LD: set RTL via ambient")
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
+ LayoutWithConstraints("LD: set RTL via CompositionLocal")
}
LayoutWithConstraints(text = "LD: locale")
Text("STACK EXAMPLE", Modifier.align(Alignment.CenterHorizontally))
@@ -109,7 +109,7 @@
Row {
Box(boxSize.background(Color.Red)) {}
Box(boxSize.background(Color.Green)) {}
- Providers(AmbientLayoutDirection provides LayoutDirection.Ltr) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Ltr) {
Row {
Box(boxSize.background(Color.Magenta)) {}
Box(boxSize.background(Color.Yellow)) {}
@@ -179,7 +179,7 @@
private fun LayoutWithConstraints(text: String) {
BoxWithConstraints {
val w = maxWidth / 3
- val color = if (AmbientLayoutDirection.current == LayoutDirection.Ltr) {
+ val color = if (LocalLayoutDirection.current == LayoutDirection.Ltr) {
Color.Red
} else {
Color.Magenta
diff --git a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RelativePaddingFromSamples.kt b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RelativePaddingFromSamples.kt
index 5709620..9a97218 100644
--- a/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RelativePaddingFromSamples.kt
+++ b/compose/foundation/foundation-layout/samples/src/main/java/androidx/compose/foundation/layout/samples/RelativePaddingFromSamples.kt
@@ -23,7 +23,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.FirstBaseline
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -34,7 +34,7 @@
// first line of text.
val distanceToBaseline = 30.sp
// We convert the 30.sp value to dps, which is required for the paddingFrom API.
- val distanceToBaselineDp = with(AmbientDensity.current) { distanceToBaseline.toDp() }
+ val distanceToBaselineDp = with(LocalDensity.current) { distanceToBaseline.toDp() }
// The result will be a layout with 30.sp distance from the top of the layout box to the
// baseline of the first line of text.
Text(
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt
index d77ad2f..28073d0 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxTest.kt
@@ -28,8 +28,8 @@
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.IntSize
@@ -258,7 +258,7 @@
val childPosition = Array(9) { Ref<Offset>() }
show {
Box(Modifier.wrapContentSize(Alignment.TopStart)) {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(
Modifier
.preferredSize(tripleSizeDp)
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxWithConstraintsTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxWithConstraintsTest.kt
index c540dd0..de52528 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxWithConstraintsTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/BoxWithConstraintsTest.kt
@@ -48,7 +48,7 @@
import androidx.compose.ui.layout.MeasureScope
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
@@ -643,7 +643,7 @@
Layout(
content = @Composable {
BoxWithConstraints {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
assertEquals(minWidthConstraint.toIntPx(), minWidth.toIntPx())
assertEquals(maxWidthConstraint.toIntPx(), maxWidth.toIntPx())
assertEquals(minHeightConstraint.toIntPx(), minHeight.toIntPx())
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/ConstraintLayoutTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/ConstraintLayoutTest.kt
index ae7cf66..6d4bdd0 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/ConstraintLayoutTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/ConstraintLayoutTest.kt
@@ -27,8 +27,8 @@
import androidx.compose.ui.layout.positionInParent
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.test.junit4.createComposeRule
@@ -538,7 +538,7 @@
val position = Array(3) { Ref<Offset>() }
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
ConstraintLayout(Modifier.fillMaxSize()) {
val (box0, box1, box2) = createRefs()
Box(
@@ -658,7 +658,7 @@
val position = Array(8) { 0f }
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
ConstraintLayout(Modifier.size(size)) {
val guidelines = arrayOf(
createGuidelineFromStart(offset),
@@ -758,7 +758,7 @@
val position = Array(4) { 0f }
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
ConstraintLayout(Modifier.size(size)) {
val (box1, box2) = createRefs()
val guideline1 = createGuidelineFromAbsoluteLeft(offset)
@@ -887,7 +887,7 @@
val position = Array(16) { 0f }
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
ConstraintLayout(Modifier.size(size)) {
val box = createRef()
val guideline = createGuidelineFromAbsoluteLeft(offset)
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutTest.kt
index 28b5cdc..818359c 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/LayoutTest.kt
@@ -35,7 +35,7 @@
import androidx.compose.ui.layout.Placeable
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.ViewRootForTest
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.unit.Constraints
@@ -213,7 +213,7 @@
modifier: Modifier = Modifier,
content: @Composable () -> Unit
) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
val pxConstraints = Constraints(constraints)
Layout(
content,
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt
index cbca1c0..dcb9e12 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/OffsetTest.kt
@@ -27,8 +27,8 @@
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
@@ -104,7 +104,7 @@
var positionX = 0
var positionY = 0
rule.setContent {
- Providers((AmbientLayoutDirection provides LayoutDirection.Rtl)) {
+ Providers((LocalLayoutDirection provides LayoutDirection.Rtl)) {
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
@@ -164,7 +164,7 @@
var positionX = 0
var positionY = 0
rule.setContent {
- Providers((AmbientLayoutDirection provides LayoutDirection.Rtl)) {
+ Providers((LocalLayoutDirection provides LayoutDirection.Rtl)) {
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
@@ -224,7 +224,7 @@
var positionX = 0
var positionY = 0
rule.setContent {
- Providers((AmbientLayoutDirection provides LayoutDirection.Rtl)) {
+ Providers((LocalLayoutDirection provides LayoutDirection.Rtl)) {
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
@@ -287,7 +287,7 @@
var positionX = 0
var positionY = 0
rule.setContent {
- Providers((AmbientLayoutDirection provides LayoutDirection.Rtl)) {
+ Providers((LocalLayoutDirection provides LayoutDirection.Rtl)) {
Box(
Modifier.testTag("box")
.wrapContentSize(Alignment.TopEnd)
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt
index 7df407d..0ae70ad 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/PaddingTest.kt
@@ -25,8 +25,8 @@
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.unit.Constraints
@@ -260,7 +260,7 @@
// ltr: P1 S P2 | S P3 | P1 S
// rtl: S P1 | P3 S | P2 S P1
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(Modifier.fillMaxSize()) {
Box(
Modifier.padding(start = padding1Dp, end = padding2Dp)
@@ -336,7 +336,7 @@
// ltr: P1 S P2 | S P3
// rtl: S P3 | P1 S P2
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(Modifier.fillMaxSize()) {
Box(
Modifier.absolutePadding(left = padding1Dp, right = padding2Dp)
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
index 3326100..c76adc2 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/RowColumnTest.kt
@@ -30,8 +30,8 @@
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.node.Ref
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.unit.Constraints
@@ -4022,7 +4022,7 @@
val drawLatch = CountDownLatch(2)
val childPosition = arrayOf(Offset.Zero, Offset.Zero)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(Modifier.fillMaxWidth()) {
Container(
Modifier.preferredSize(sizeDp).onGloballyPositioned { coordinates ->
@@ -4066,7 +4066,7 @@
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -4122,7 +4122,7 @@
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -4177,7 +4177,7 @@
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -4230,7 +4230,7 @@
val childLayoutCoordinates = arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -4280,7 +4280,7 @@
val drawLatch = CountDownLatch(2)
val childPosition = arrayOf(Offset.Zero, Offset.Zero)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
@@ -4327,7 +4327,7 @@
val rowSize = rowSizePx.toDp()
val latch = CountDownLatch(3)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column {
Row(
horizontalArrangement = Arrangement.spacedBy(space, Alignment.End),
@@ -4363,7 +4363,7 @@
val drawLatch = CountDownLatch(2)
val childPosition = arrayOf(Offset.Zero, Offset.Zero)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(Modifier.fillMaxWidth()) {
Container(
Modifier.preferredSize(sizeDp).onGloballyPositioned { coordinates ->
@@ -4408,7 +4408,7 @@
val drawLatch = CountDownLatch(2)
val childPosition = arrayOf(Offset.Zero, Offset.Zero)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(Modifier.fillMaxWidth()) {
Container(
Modifier.preferredSize(sizeDp)
@@ -4447,7 +4447,7 @@
val drawLatch = CountDownLatch(2)
val childPosition = arrayOf(Offset.Zero, Offset.Zero)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(Modifier.fillMaxWidth()) {
Container(
Modifier.preferredSize(sizeDp)
@@ -4555,7 +4555,7 @@
arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
Modifier
.fillMaxWidth()
@@ -4668,7 +4668,7 @@
arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -4797,7 +4797,7 @@
arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -4933,7 +4933,7 @@
arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -5065,7 +5065,7 @@
arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -5197,7 +5197,7 @@
arrayOfNulls<LayoutCoordinates?>(childPosition.size)
var parentLayoutCoordinates: LayoutCoordinates? = null
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Row(
modifier = Modifier
.fillMaxWidth()
@@ -5268,7 +5268,7 @@
val rowSize = rowSizePx.toDp()
val latch = CountDownLatch(3)
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column {
Row(
horizontalArrangement = Arrangement.Absolute.spacedBy(space, Alignment.End),
diff --git a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
index 2eddbde..891eaa9 100644
--- a/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
+++ b/compose/foundation/foundation-layout/src/androidAndroidTest/kotlin/androidx/compose/foundation/layout/SizeTest.kt
@@ -26,8 +26,8 @@
import androidx.compose.ui.node.Ref
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInParent
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.unit.Constraints
@@ -1417,7 +1417,7 @@
val childSize = Array(3) { Ref<IntSize>() }
val childPosition = Array(3) { Ref<Offset>() }
show {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize().wrapContentSize(Alignment.TopStart)) {
Box(
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
index 51a1925..78896f0 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/ListDemos.kt
@@ -49,8 +49,8 @@
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.integration.demos.common.ComposableDemo
-import androidx.compose.material.AmbientContentColor
-import androidx.compose.material.AmbientTextStyle
+import androidx.compose.material.LocalContentColor
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
@@ -63,8 +63,8 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -123,7 +123,7 @@
}
LazyColumn(Modifier.fillMaxWidth()) {
items((1..numItems).map { it + offset }) {
- Text("$it", style = AmbientTextStyle.current.copy(fontSize = 40.sp))
+ Text("$it", style = LocalTextStyle.current.copy(fontSize = 40.sp))
}
}
}
@@ -139,7 +139,7 @@
@Suppress("DEPRECATION")
FlowRow {
val buttonModifier = Modifier.padding(8.dp)
- val density = AmbientDensity.current
+ val density = LocalDensity.current
val coroutineScope = rememberCoroutineScope()
Button(
modifier = buttonModifier,
@@ -196,7 +196,7 @@
state = state
) {
items(1000) {
- Text("$it", style = AmbientTextStyle.current.copy(fontSize = 40.sp))
+ Text("$it", style = LocalTextStyle.current.copy(fontSize = 40.sp))
}
}
}
@@ -210,7 +210,7 @@
.background(Color(0xFF6200EE), RoundedCornerShape(4.dp))
.padding(horizontal = 16.dp, vertical = 8.dp)
) {
- Providers(AmbientContentColor provides Color.White, content = content)
+ Providers(LocalContentColor provides Color.White, content = content)
}
}
@@ -253,7 +253,7 @@
@Composable
private fun RtlListDemo() {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
LazyRow(Modifier.fillMaxWidth()) {
items(100) {
Text(
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt
index ca65435..ba0fbbd 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/ComposeInputField.kt
@@ -31,7 +31,7 @@
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.text.SoftwareKeyboardController
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
@@ -46,7 +46,7 @@
TagLine(tag = "LTR Layout")
}
item {
- Providers(AmbientLayoutDirection provides LayoutDirection.Ltr) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Ltr) {
Column(modifier = Modifier.fillMaxWidth()) {
TagLine(tag = "simple editing single line")
EditLine(singleLine = true)
@@ -61,7 +61,7 @@
TagLine(tag = "RTL Layout")
}
item {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Column(modifier = Modifier.fillMaxWidth()) {
TagLine(tag = "simple editing RTL")
EditLine()
diff --git a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TypefaceDemo.kt b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TypefaceDemo.kt
index 1d8f0b3..33b23a4 100644
--- a/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TypefaceDemo.kt
+++ b/compose/foundation/foundation/integration-tests/foundation-demos/src/main/java/androidx/compose/foundation/demos/text/TypefaceDemo.kt
@@ -19,7 +19,7 @@
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.Typeface
@@ -44,7 +44,7 @@
@Composable
fun TypefaceFromFontFamilyDemo() {
- val typeface = Typeface(AmbientContext.current, FontFamily.Cursive)
+ val typeface = Typeface(LocalContext.current, FontFamily.Cursive)
val fontFamily = FontFamily(typeface)
Text("Hello World", style = TextStyle(fontFamily = fontFamily))
}
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
index a620c11..9f5ff01 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/IndicationSamples.kt
@@ -17,8 +17,8 @@
package androidx.compose.foundation.samples
import androidx.annotation.Sampled
-import androidx.compose.foundation.AmbientIndication
import androidx.compose.foundation.InteractionState
+import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.clickable
import androidx.compose.foundation.indication
import androidx.compose.foundation.layout.Column
@@ -51,8 +51,8 @@
text = "I'm neighbour and I indicate when you click the other one",
modifier = Modifier
// this element doesn't have a click, but will show default indication from the
- // ambient as it accepts same interaction state
- .indication(interactionState, AmbientIndication.current())
+ // CompositionLocal as it accepts same interaction state
+ .indication(interactionState, LocalIndication.current())
.padding(10.dp)
)
}
diff --git a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
index f4fcf0b..0918e83 100644
--- a/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
+++ b/compose/foundation/foundation/samples/src/main/java/androidx/compose/foundation/samples/InteractionStateSample.kt
@@ -17,10 +17,10 @@
package androidx.compose.foundation.samples
import androidx.annotation.Sampled
-import androidx.compose.foundation.AmbientIndication
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Interaction
import androidx.compose.foundation.InteractionState
+import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.draggable
@@ -31,7 +31,7 @@
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.wrapContentSize
-import androidx.compose.material.AmbientTextStyle
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
@@ -72,14 +72,14 @@
.fillMaxSize()
.clickable(
interactionState = interactionState,
- indication = AmbientIndication.current()
+ indication = LocalIndication.current()
) { /* do nothing */ }
.then(draggable)
.border(BorderStroke(3.dp, color))
.padding(3.dp)
) {
Text(
- text, style = AmbientTextStyle.current.copy(textAlign = TextAlign.Center),
+ text, style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
modifier = Modifier.fillMaxSize().wrapContentSize()
)
}
@@ -98,7 +98,7 @@
val clickable = Modifier.clickable(
interactionState = interactionState,
- indication = AmbientIndication.current()
+ indication = LocalIndication.current()
) {
/* update some business state here */
}
@@ -136,7 +136,7 @@
val pressed = Interaction.Pressed in interactionState
Text(
text = if (pressed) "Pressed" else "Not pressed",
- style = AmbientTextStyle.current.copy(textAlign = TextAlign.Center),
+ style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
modifier = Modifier.fillMaxSize().wrapContentSize()
)
}
@@ -150,14 +150,14 @@
val dragged = Interaction.Dragged in interactionState
Text(
text = if (dragged) "Dragged" else "Not dragged",
- style = AmbientTextStyle.current.copy(textAlign = TextAlign.Center),
+ style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
modifier = Modifier.fillMaxSize().wrapContentSize()
)
}
}
Text(
text = text,
- style = AmbientTextStyle.current.copy(textAlign = TextAlign.Center),
+ style = LocalTextStyle.current.copy(textAlign = TextAlign.Center),
modifier = Modifier.fillMaxSize().wrapContentSize()
)
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt
index 484f51f..95ca719 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BackgroundTest.kt
@@ -32,9 +32,9 @@
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.SolidColor
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
@@ -183,7 +183,7 @@
fun background_rtl_initially() {
rule.setContent {
SemanticParent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(
Modifier.preferredSize(40f.toDp())
.background(Color.Magenta)
@@ -210,7 +210,7 @@
val direction = mutableStateOf(LayoutDirection.Ltr)
rule.setContent {
SemanticParent {
- Providers(AmbientLayoutDirection provides direction.value) {
+ Providers(LocalLayoutDirection provides direction.value) {
Box(
Modifier.preferredSize(40f.toDp())
.background(Color.Magenta)
@@ -267,7 +267,7 @@
@Composable
private fun SemanticParent(content: @Composable Density.() -> Unit) {
Box(Modifier.testTag(contentTag)) {
- AmbientDensity.current.content()
+ LocalDensity.current.content()
}
}
}
\ No newline at end of file
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt
index 37bde61..f228931 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/BorderTest.kt
@@ -35,9 +35,9 @@
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.SolidColor
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.graphics.toPixelMap
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createComposeRule
@@ -264,7 +264,7 @@
val direction = mutableStateOf(LayoutDirection.Ltr)
rule.setContent {
SemanticParent {
- Providers(AmbientLayoutDirection provides direction.value) {
+ Providers(LocalLayoutDirection provides direction.value) {
Box(
Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
.background(color = Color.Blue)
@@ -293,7 +293,7 @@
fun SemanticParent(content: @Composable Density.() -> Unit) {
Box {
Box(modifier = Modifier.testTag(testTag)) {
- AmbientDensity.current.content()
+ LocalDensity.current.content()
}
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt
index 14c436d..cb59aaa 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/CanvasTest.kt
@@ -29,7 +29,7 @@
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.toArgb
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.assertHeightIsEqualTo
import androidx.compose.ui.test.assertWidthIsEqualTo
import androidx.compose.ui.test.captureToImage
@@ -62,7 +62,7 @@
fun testCanvas() {
val strokeWidth = 5.0f
rule.setContent {
- val density = AmbientDensity.current.density
+ val density = LocalDensity.current.density
val containerSize = (containerSize * 2 / density).dp
val minWidth = (boxWidth / density).dp
val minHeight = (boxHeight / density).dp
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
index 208dd07..1b42081 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ImageTest.kt
@@ -55,7 +55,7 @@
import androidx.compose.testutils.assertPixels
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.toPixelMap
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.Role
@@ -113,7 +113,7 @@
@Test
fun testImage() {
rule.setContent {
- val size = (containerSize / AmbientDensity.current.density).dp
+ val size = (containerSize / LocalDensity.current.density).dp
Box(
Modifier.preferredSize(size)
.background(color = Color.White)
@@ -158,7 +158,7 @@
val subsectionWidth = imageWidth / 2
val subsectionHeight = imageHeight / 2
rule.setContent {
- val size = (containerSize / AmbientDensity.current.density).dp
+ val size = (containerSize / LocalDensity.current.density).dp
Box(
Modifier.preferredSize(size)
.background(color = Color.White)
@@ -257,7 +257,7 @@
val imageComposableWidth = imageWidth * 2
val imageComposableHeight = imageHeight * 2
rule.setContent {
- val density = AmbientDensity.current.density
+ val density = LocalDensity.current.density
val size = (containerSize * 2 / density).dp
Box(
Modifier.preferredSize(size)
@@ -319,7 +319,7 @@
val imageComposableHeight = imageHeight * 7
rule.setContent {
- val density = AmbientDensity.current
+ val density = LocalDensity.current
val size = (containerSize * 2 / density.density).dp
val ImageBitmap = ImageBitmap(imageWidth, imageHeight)
CanvasDrawScope().draw(
@@ -359,7 +359,7 @@
val imageComposableWidth = imageWidth * 2
val imageComposableHeight = imageHeight * 2
rule.setContent {
- val density = AmbientDensity.current.density
+ val density = LocalDensity.current.density
val size = (containerSize * 2 / density).dp
Box(
Modifier.preferredSize(size)
@@ -419,7 +419,7 @@
// used to wait until vector resource is loaded asynchronously
var vectorDrawn = false
rule.setContent {
- val density = AmbientDensity.current.density
+ val density = LocalDensity.current.density
val size = (boxWidth * 2 / density).dp
val minWidth = (boxWidth / density).dp
val minHeight = (boxHeight / density).dp
@@ -517,7 +517,7 @@
}
this
}
- val heightDp = asset.height / AmbientDensity.current.density
+ val heightDp = asset.height / LocalDensity.current.density
Image(
asset,
null,
@@ -596,7 +596,7 @@
fun testImageWithNoIntrinsicSizePainterFillsMaxConstraints() {
val testTag = "testTag"
rule.setContent {
- val sizeDp = with(AmbientDensity.current) { 50 / density }
+ val sizeDp = with(LocalDensity.current) { 50 / density }
Box(modifier = Modifier.size(sizeDp.dp)) {
Image(
painter = ColorPainter(Color.Red),
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
index 727fc31..c7f16ef 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollTest.kt
@@ -37,8 +37,8 @@
import androidx.compose.testutils.assertPixels
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
@@ -769,7 +769,7 @@
with(rule.density) {
rule.setContent {
val direction = if (isRtl) LayoutDirection.Rtl else LayoutDirection.Ltr
- Providers(AmbientLayoutDirection provides direction) {
+ Providers(LocalLayoutDirection provides direction) {
Box {
Row(
modifier = Modifier
@@ -856,7 +856,7 @@
}
} else {
val direction = if (isRtl) LayoutDirection.Rtl else LayoutDirection.Ltr
- Providers(AmbientLayoutDirection provides direction) {
+ Providers(LocalLayoutDirection provides direction) {
Row(
Modifier.testTag(scrollerTag)
.horizontalScroll(scrollState, reverseScrolling = isReversed)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
index b73bf05..a49a0f6 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/ScrollableTest.kt
@@ -40,8 +40,8 @@
import androidx.compose.ui.gesture.nestedscroll.NestedScrollSource
import androidx.compose.ui.gesture.nestedscroll.nestedScroll
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
-import androidx.compose.ui.platform.AmbientViewConfiguration
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
@@ -931,7 +931,7 @@
)
rule.setContent {
- touchSlop = AmbientViewConfiguration.current.touchSlop
+ touchSlop = LocalViewConfiguration.current.touchSlop
Box {
Box(
modifier = Modifier.preferredSize(300.dp)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt
index 46035f9..16e8944 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyArrangementsTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Providers
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertHeightIsEqualTo
import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo
@@ -320,7 +320,7 @@
fun composeRowWith(arrangement: Arrangement.Horizontal, layoutDirection: LayoutDirection) {
rule.setContent {
- Providers(AmbientLayoutDirection provides layoutDirection) {
+ Providers(LocalLayoutDirection provides layoutDirection) {
LazyRow(
horizontalArrangement = arrangement,
modifier = Modifier.size(containerSize)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
index 8bd7d3e..967740a 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyColumnTest.kt
@@ -43,7 +43,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.platform.AmbientViewConfiguration
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.ViewConfiguration
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.SemanticsNodeInteraction
@@ -1278,7 +1278,7 @@
composable: @Composable () -> Unit
) {
this.setContent {
- Providers(AmbientViewConfiguration provides FakeViewConfiguration) {
+ Providers(LocalViewConfiguration provides FakeViewConfiguration) {
composable()
}
}
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt
index 4b3898944..56d67f9 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyListsReverseLayoutTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Providers
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.compose.ui.test.assertTopPositionInRootIsEqualTo
@@ -365,7 +365,7 @@
@Test
fun row_rtl_emitTwoElementsAsOneItem_positionedReversed() {
rule.setContentWithTestViewConfiguration {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
LazyRow(
reverseLayout = true
) {
@@ -386,7 +386,7 @@
@Test
fun row_rtl_emitTwoItems_positionedReversed() {
rule.setContentWithTestViewConfiguration {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
LazyRow(
reverseLayout = true
) {
@@ -410,7 +410,7 @@
fun row_rtl_scrollForwardHalfWay() {
lateinit var state: LazyListState
rule.setContentWithTestViewConfiguration {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
LazyRow(
reverseLayout = true,
state = rememberLazyListState().also { state = it },
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
index 3c9af9c..3871525 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/lazy/LazyRowTest.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.assertHeightIsEqualTo
@@ -509,7 +509,7 @@
@Test
fun scrollsLeftInRtl() {
rule.setContentWithTestViewConfiguration {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(Modifier.preferredWidth(100.dp)) {
LazyRow(Modifier.testTag(LazyListTag)) {
items(4) {
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt
index 029a4f3..fde2278 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftKeyboardTest.kt
@@ -27,8 +27,8 @@
import androidx.compose.ui.focus.FocusManager
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
-import androidx.compose.ui.platform.AmbientFocusManager
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalFocusManager
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
@@ -56,7 +56,7 @@
// Arrange.
lateinit var view: View
rule.setContent {
- view = AmbientView.current
+ view = LocalView.current
CoreTextField(
value = TextFieldValue("Hello"),
>
@@ -78,7 +78,7 @@
val focusRequester = FocusRequester()
lateinit var view: View
rule.setContent {
- view = AmbientView.current
+ view = LocalView.current
CoreTextField(
value = TextFieldValue("Hello"),
>
@@ -101,8 +101,8 @@
lateinit var view: View
val focusRequester = FocusRequester()
rule.setContent {
- view = AmbientView.current
- focusManager = AmbientFocusManager.current
+ view = LocalView.current
+ focusManager = LocalFocusManager.current
CoreTextField(
value = TextFieldValue("Hello"),
>
@@ -127,7 +127,7 @@
// Arrange.
lateinit var view: View
rule.setContent {
- view = AmbientView.current
+ view = LocalView.current
CoreTextField(
value = TextFieldValue("Hello"),
>
@@ -156,7 +156,7 @@
val (focusRequester1, focusRequester2) = FocusRequester.createRefs()
lateinit var view: View
rule.setContent {
- view = AmbientView.current
+ view = LocalView.current
Column {
CoreTextField(
value = TextFieldValue("Hello"),
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
index fab4850..307508f 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/CoreTextFieldSoftWrapTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.runtime.Providers
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.text.InternalTextApi
import androidx.compose.ui.text.TextLayoutResult
@@ -67,7 +67,7 @@
var width: Int? = null
rule.setContent {
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
CoreTextField(
value = TextFieldValue(string),
>
@@ -104,7 +104,7 @@
var width: Int? = null
rule.setContent {
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
CoreTextField(
value = TextFieldValue(string),
>
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextLayoutDirectionTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextLayoutDirectionTest.kt
index e7196f5..1b292b8 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextLayoutDirectionTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/TextLayoutDirectionTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.foundation.text
import androidx.compose.runtime.Providers
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.text.InternalTextApi
import androidx.compose.ui.text.input.TextFieldValue
@@ -40,7 +40,7 @@
var layoutDirection: LayoutDirection? = null
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
@OptIn(InternalTextApi::class)
CoreTextField(
value = TextFieldValue("..."),
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt
index c8b4fee..73507fd 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionContainerTest.kt
@@ -38,8 +38,8 @@
import androidx.compose.ui.input.pointer.changedToUp
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientHapticFeedback
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
import androidx.compose.ui.test.click
@@ -273,8 +273,8 @@
val layoutDirection = if (isRtl) LayoutDirection.Rtl else LayoutDirection.Ltr
rule.setContent {
Providers(
- AmbientHapticFeedback provides hapticFeedback,
- AmbientLayoutDirection provides layoutDirection
+ LocalHapticFeedback provides hapticFeedback,
+ LocalLayoutDirection provides layoutDirection
) {
TestParent(Modifier.testTag("selectionContainer").gestureSpy(log)) {
SelectionContainer(
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt
index 7f99433..9a58fcf 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/text/selection/SelectionHandlePopupPositionTest.kt
@@ -26,8 +26,8 @@
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Placeable
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientLayoutDirection
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalLayoutDirection
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.ViewRootForTest
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.createComposeRule
@@ -165,7 +165,7 @@
rule.setContent {
// Get the compose view position on screen
- val composeView = AmbientView.current
+ val composeView = LocalView.current
val positionArray = IntArray(2)
composeView.getLocationOnScreen(positionArray)
composeViewAbsolutePos = IntOffset(
@@ -176,7 +176,7 @@
// Align the parent of the popup on the top left corner, this results in the global
// position of the parent to be (0, 0)
val layoutDirection = if (isRtl) LayoutDirection.Rtl else LayoutDirection.Ltr
- Providers(AmbientLayoutDirection provides layoutDirection) {
+ Providers(LocalLayoutDirection provides layoutDirection) {
SimpleLayout {
SimpleContainer(width = parentWidthDp, height = parentHeightDp) {}
SelectionHandle(
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/SoftwareKeyboardTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/SoftwareKeyboardTest.kt
index 5dd938f..e63050b 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/SoftwareKeyboardTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/SoftwareKeyboardTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientTextInputService
+import androidx.compose.ui.platform.LocalTextInputService
import androidx.compose.ui.test.hasSetTextAction
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.performClick
@@ -58,7 +58,7 @@
val onTextInputStarted: (SoftwareKeyboardController) -> Unit = mock()
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
val state = remember { mutableStateOf("") }
BasicTextField(
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt
index 6a53413..e720ef7 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldDefaultWidthTest.kt
@@ -25,7 +25,7 @@
import androidx.compose.runtime.Providers
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
@@ -194,7 +194,7 @@
style = FontStyle.Normal
)
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
androidx.compose.foundation.layout.Box {
BasicTextField(
value = text,
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldOnValueChangeTextFieldValueTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldOnValueChangeTextFieldValueTest.kt
index d4f13a5..b6d392b 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldOnValueChangeTextFieldValueTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldOnValueChangeTextFieldValueTest.kt
@@ -22,7 +22,7 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.platform.AmbientTextInputService
+import androidx.compose.ui.platform.LocalTextInputService
import androidx.compose.ui.test.click
import androidx.compose.ui.test.hasSetTextAction
import androidx.compose.ui.test.junit4.createComposeRule
@@ -74,7 +74,7 @@
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
val state = remember {
mutableStateOf(
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
index c864623..e15b40b 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldScrollTest.kt
@@ -44,8 +44,8 @@
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientViewConfiguration
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
@@ -396,7 +396,7 @@
var touchSlop = 0f
rule.setContent {
- touchSlop = AmbientViewConfiguration.current.touchSlop
+ touchSlop = LocalViewConfiguration.current.touchSlop
Column(
Modifier
.preferredSize(size)
diff --git a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
index fd8a3f6..0f6fffd 100644
--- a/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
+++ b/compose/foundation/foundation/src/androidAndroidTest/kotlin/androidx/compose/foundation/textfield/TextFieldTest.kt
@@ -51,8 +51,8 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientTextInputService
-import androidx.compose.ui.platform.AmbientTextToolbar
+import androidx.compose.ui.platform.LocalTextInputService
+import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.ui.platform.TextToolbar
import androidx.compose.ui.platform.TextToolbarStatus
import androidx.compose.ui.platform.testTag
@@ -123,7 +123,7 @@
rule.setContent {
val state = remember { mutableStateOf("") }
Providers(
- AmbientTextInputService provides inputService
+ LocalTextInputService provides inputService
) {
BasicTextField(
value = state.value,
@@ -162,7 +162,7 @@
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
TextFieldApp()
}
@@ -233,7 +233,7 @@
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
OnlyDigitsApp()
}
@@ -292,7 +292,7 @@
val onTextLayout: (TextLayoutResult) -> Unit = mock()
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
val state = remember { mutableStateOf("") }
BasicTextField(
@@ -615,7 +615,7 @@
var toolbar: TextToolbar? = null
rule.setContent {
- toolbar = AmbientTextToolbar.current
+ toolbar = LocalTextToolbar.current
BasicTextField(
modifier = Modifier.testTag(Tag),
value = value,
diff --git a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/DarkTheme.kt b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/DarkTheme.kt
index becda0f..8c959b0 100644
--- a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/DarkTheme.kt
+++ b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/DarkTheme.kt
@@ -19,7 +19,7 @@
import android.content.res.Configuration
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
-import androidx.compose.ui.platform.AmbientConfiguration
+import androidx.compose.ui.platform.LocalConfiguration
/**
* This function should be used to help build responsive UIs that follow the system setting, to
@@ -31,9 +31,9 @@
*
* It is also recommended to provide user accessible overrides in your application, so users can
* choose to force an always-light or always-dark theme. To do this, you should provide the current
- * theme value in an ambient or similar to components further down your hierarchy, only calling
- * this effect once at the top level if no user override has been set. This also helps avoid
- * multiple calls to this effect, which can be expensive as it queries system configuration.
+ * theme value in a CompositionLocal or similar to components further down your hierarchy, only
+ * calling this effect once at the top level if no user override has been set. This also helps
+ * avoid multiple calls to this effect, which can be expensive as it queries system configuration.
*
* For example, to draw a white rectangle when in dark theme, and a black rectangle when in light
* theme:
@@ -45,6 +45,6 @@
@Composable
@ReadOnlyComposable
fun isSystemInDarkTheme(): Boolean {
- val uiMode = AmbientConfiguration.current.uiMode
+ val uiMode = LocalConfiguration.current.uiMode
return (uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
}
diff --git a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingCalculator.kt b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingCalculator.kt
index 6bb3c64..30955a3 100644
--- a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingCalculator.kt
+++ b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingCalculator.kt
@@ -44,7 +44,7 @@
* Configuration for Android-feel flinging motion at the given density.
*
* @param friction scroll friction.
- * @param density density of the screen. Use [DensityAmbient] to get current density in composition.
+ * @param density density of the screen. Use LocalDensity to get current density in composition.
*/
internal class AndroidFlingCalculator(
private val friction: Float,
diff --git a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingConfig.kt b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingConfig.kt
index 2ed0f66..3d03ed5 100644
--- a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingConfig.kt
+++ b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/animation/AndroidFlingConfig.kt
@@ -19,13 +19,13 @@
import androidx.compose.animation.core.TargetAnimation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
@Composable
internal actual fun actualFlingConfig(adjustTarget: (Float) -> TargetAnimation?): FlingConfig {
// This function will internally update the calculation of fling decay when the density changes,
// but the reference to the returned FlingConfig will not change across calls.
- val density = AmbientDensity.current
+ val density = LocalDensity.current
return remember(density.density) {
val decayAnimation = FloatAndroidFlingDecaySpec(density)
FlingConfig(
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
index 6032f46..346a609 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Clickable.kt
@@ -38,7 +38,7 @@
* Add this modifier to the element to make it clickable within its bounds.
*
* This version has no [InteractionState] or [Indication] parameters, default indication from
- * [AmbientIndication] will be used. To specify [InteractionState] or [Indication], use another
+ * [LocalIndication] will be used. To specify [InteractionState] or [Indication], use another
* overload.
*
* @sample androidx.compose.foundation.samples.ClickableSample
@@ -80,7 +80,7 @@
>
>
role = role,
- indication = AmbientIndication.current(),
+ indication = LocalIndication.current(),
interactionState = remember { InteractionState() }
)
}
@@ -98,8 +98,8 @@
* pressed, using [Interaction.Pressed]. Only initial (first) press will be recorded and added to
* [InteractionState]
* @param indication indication to be shown when modified element is pressed. Be default,
- * indication from [AmbientIndication] will be used. Pass `null` to show no indication, or
- * current value from [AmbientIndication] to show theme default
+ * indication from [LocalIndication] will be used. Pass `null` to show no indication, or
+ * current value from [LocalIndication] to show theme default
* @param onClickLabel semantic / accessibility label for the [onClick] action
* @param role the type of user interface element. Accessibility services might use this
* to describe the element or do customizations
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
index 38ef30d..5d78137 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Indication.kt
@@ -37,7 +37,7 @@
* [indication] modifier.
*
* If you want to override default behaviour for [indication] for the whole subtree, consider
- * creating object of this factory and providing it in [AmbientIndication].
+ * creating object of this factory and providing it in [LocalIndication].
*/
@Stable
interface Indication {
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
index 65bc7c7..f51f945 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/Scroll.kt
@@ -55,8 +55,8 @@
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasureResult
import androidx.compose.ui.layout.MeasureScope
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.semantics.ScrollAxisRange
import androidx.compose.ui.semantics.horizontalScrollAxisRange
@@ -86,7 +86,7 @@
initial: Float = 0f,
interactionState: InteractionState? = null
): ScrollState {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
val config = defaultFlingConfig()
return rememberSaveable(
clock, config, interactionState,
@@ -436,7 +436,7 @@
)
}
}
- val isRtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val scrolling = Modifier.scrollable(
orientation = if (isVertical) Orientation.Vertical else Orientation.Horizontal,
// reverse scroll by default, to have "natural" gesture that goes reversed to layout
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
index 15a8e9a..2890e00 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Scrollable.kt
@@ -44,7 +44,7 @@
import androidx.compose.ui.gesture.nestedscroll.NestedScrollSource
import androidx.compose.ui.gesture.nestedscroll.nestedScroll
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Velocity
import kotlinx.coroutines.Job
@@ -68,7 +68,7 @@
interactionState: InteractionState? = null,
consumeScrollDelta: (Float) -> Float
): ScrollableController {
- val clocks = AmbientAnimationClock.current.asDisposableClock()
+ val clocks = LocalAnimationClock.current.asDisposableClock()
val flingConfig = defaultFlingConfig()
return remember(clocks, flingConfig, interactionState) {
ScrollableController(consumeScrollDelta, flingConfig, clocks, interactionState)
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Zoomable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Zoomable.kt
index c791a3b..6657e37 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Zoomable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Zoomable.kt
@@ -38,7 +38,7 @@
import androidx.compose.ui.input.pointer.consumeAllChanges
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.input.pointer.positionChanged
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.util.fastAny
import androidx.compose.ui.util.fastForEach
@@ -53,7 +53,7 @@
*/
@Composable
fun rememberZoomableController(onZoomDelta: (Float) -> Unit): ZoomableController {
- val clocks = AmbientAnimationClock.current.asDisposableClock()
+ val clocks = LocalAnimationClock.current.asDisposableClock()
return remember(clocks) { ZoomableController(clocks, onZoomDelta) }
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt
index e1bc857..48cc3f5 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyList.kt
@@ -29,7 +29,7 @@
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
import androidx.compose.ui.layout.SubcomposeLayout
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.LayoutDirection
@Composable
@@ -59,7 +59,7 @@
/** The factory defining the content for an item on the given position in the list */
itemContent: LazyItemScope.(Int) -> @Composable () -> Unit
) {
- val isRtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
// reverse scroll by default, to have "natural" gesture that goes reversed to layout
// if rtl and horizontal, do not reverse to make it right-to-left
val reverseScrollDirection = if (!isVertical && isRtl) reverseLayout else !reverseLayout
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
index 6b90307..6bcc913 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListState.kt
@@ -35,7 +35,7 @@
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.layout.Remeasurement
import androidx.compose.ui.layout.RemeasurementModifier
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
import kotlin.math.abs
/**
@@ -57,7 +57,7 @@
initialFirstVisibleItemScrollOffset: Int = 0,
interactionState: InteractionState? = null
): LazyListState {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
val config = defaultFlingConfig()
// Avoid creating a new instance every invocation
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Selectable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Selectable.kt
index 6c572d7..1e77f3a 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Selectable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Selectable.kt
@@ -16,10 +16,10 @@
package androidx.compose.foundation.selection
-import androidx.compose.foundation.AmbientIndication
import androidx.compose.foundation.Indication
import androidx.compose.foundation.Interaction
import androidx.compose.foundation.InteractionState
+import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.Strings
import androidx.compose.foundation.clickable
import androidx.compose.runtime.remember
@@ -40,7 +40,7 @@
* using [Modifier.toggleable]
*
* This version has no [InteractionState] or [Indication] parameters, default indication from
- * [AmbientIndication] will be used. To specify [InteractionState] or [Indication], use another
+ * [LocalIndication] will be used. To specify [InteractionState] or [Indication], use another
* overload.
*
* @sample androidx.compose.foundation.samples.SelectableSample
@@ -71,7 +71,7 @@
enabled = enabled,
role = role,
interactionState = remember { InteractionState() },
- indication = AmbientIndication.current(),
+ indication = LocalIndication.current(),
>
)
}
@@ -93,8 +93,8 @@
* @param interactionState [InteractionState] that will be updated when this element is
* pressed, using [Interaction.Pressed]
* @param indication indication to be shown when the modified element is pressed. By default,
- * the indication from [AmbientIndication] will be used. Set to `null` to show no indication, or
- * current value from [AmbientIndication] to show theme default
+ * the indication from [LocalIndication] will be used. Set to `null` to show no indication, or
+ * current value from [LocalIndication] to show theme default
* @param enabled whether or not this [selectable] will handle input events
* and appear enabled from a semantics perspective
* @param role the type of user interface element. Accessibility services might use this
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Toggleable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Toggleable.kt
index 504f56c..96c5ba2 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Toggleable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/selection/Toggleable.kt
@@ -16,10 +16,10 @@
package androidx.compose.foundation.selection
-import androidx.compose.foundation.AmbientIndication
import androidx.compose.foundation.Indication
import androidx.compose.foundation.Interaction
import androidx.compose.foundation.InteractionState
+import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.Strings
import androidx.compose.foundation.indication
import androidx.compose.runtime.DisposableEffect
@@ -45,7 +45,7 @@
* Configure component to make it toggleable via input and accessibility events
*
* This version has no [InteractionState] or [Indication] parameters, default indication from
- * [AmbientIndication] will be used. To specify [InteractionState] or [Indication], use another
+ * [LocalIndication] will be used. To specify [InteractionState] or [Indication], use another
* overload.
*
* @sample androidx.compose.foundation.samples.ToggleableSample
@@ -80,7 +80,7 @@
enabled = enabled,
role = role,
interactionState = remember { InteractionState() },
- indication = AmbientIndication.current()
+ indication = LocalIndication.current()
)
}
@@ -98,8 +98,8 @@
* @param interactionState [InteractionState] that will be updated when this toggleable is
* pressed, using [Interaction.Pressed]
* @param indication indication to be shown when modified element is pressed. Be default,
- * indication from [AmbientIndication] will be used. Pass `null` to show no indication, or
- * current value from [AmbientIndication] to show theme default
+ * indication from [LocalIndication] will be used. Pass `null` to show no indication, or
+ * current value from [LocalIndication] to show theme default
* @param enabled whether or not this [toggleable] will handle input events and appear
* enabled for semantics purposes
* * @param role the type of user interface element. Accessibility services might use this
@@ -144,7 +144,7 @@
* component and those can have different values.
*
* This version has no [InteractionState] or [Indication] parameters, default indication from
- * [AmbientIndication] will be used. To specify [InteractionState] or [Indication], use another
+ * [LocalIndication] will be used. To specify [InteractionState] or [Indication], use another
* overload.
*
* @sample androidx.compose.foundation.samples.TriStateToggleableSample
@@ -177,7 +177,7 @@
enabled,
role,
remember { InteractionState() },
- AmbientIndication.current(),
+ LocalIndication.current(),
onClick
)
}
@@ -200,8 +200,8 @@
* @param interactionState [InteractionState] that will be updated when this toggleable is
* pressed, using [Interaction.Pressed]
* @param indication indication to be shown when modified element is pressed. Be default,
- * indication from [AmbientIndication] will be used. Pass `null` to show no indication, or
- * current value from [AmbientIndication] to show theme default
+ * indication from [LocalIndication] will be used. Pass `null` to show no indication, or
+ * current value from [LocalIndication] to show theme default
* @param enabled whether or not this [triStateToggleable] will handle input events and
* appear enabled for semantics purposes
* @param role the type of user interface element. Accessibility services might use this
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
index 5208a22..30d1b08 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreText.kt
@@ -43,8 +43,8 @@
import androidx.compose.ui.layout.MeasureBlock
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInWindow
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientFontLoader
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalFontLoader
import androidx.compose.foundation.text.selection.LocalSelectionRegistrar
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.Selectable
@@ -108,8 +108,8 @@
// selection registrar, if no SelectionContainer is added ambient value will be null
val selectionRegistrar = LocalSelectionRegistrar.current
- val density = AmbientDensity.current
- val resourceLoader = AmbientFontLoader.current
+ val density = LocalDensity.current
+ val resourceLoader = LocalFontLoader.current
val selectionBackgroundColor = LocalTextSelectionColors.current.backgroundColor
val (placeholders, inlineComposables) = resolveInlineContent(text, inlineContent)
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
index 31bd8a4..41796d2 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/CoreTextField.kt
@@ -46,12 +46,12 @@
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientClipboardManager
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientFontLoader
-import androidx.compose.ui.platform.AmbientHapticFeedback
-import androidx.compose.ui.platform.AmbientTextInputService
-import androidx.compose.ui.platform.AmbientTextToolbar
+import androidx.compose.ui.platform.LocalClipboardManager
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalFontLoader
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.platform.LocalTextInputService
+import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.SimpleLayout
import androidx.compose.ui.semantics.copyText
@@ -181,11 +181,11 @@
val scope = currentRecomposeScope
val focusRequester = FocusRequester()
- // Ambients
+ // CompositionLocals
// If the text field is disabled or read-only, we should not deal with the input service
- val textInputService = if (!enabled || readOnly) null else AmbientTextInputService.current
- val density = AmbientDensity.current
- val resourceLoader = AmbientFontLoader.current
+ val textInputService = if (!enabled || readOnly) null else LocalTextInputService.current
+ val density = LocalDensity.current
+ val resourceLoader = LocalFontLoader.current
val selectionBackgroundColor = LocalTextSelectionColors.current.backgroundColor
// Scroll state
@@ -245,9 +245,9 @@
manager.>
manager.state = state
manager.value = value
- manager.clipboardManager = AmbientClipboardManager.current
- manager.textToolbar = AmbientTextToolbar.current
- manager.hapticFeedBack = AmbientHapticFeedback.current
+ manager.clipboardManager = LocalClipboardManager.current
+ manager.textToolbar = LocalTextToolbar.current
+ manager.hapticFeedBack = LocalHapticFeedback.current
manager.focusRequester = focusRequester
manager.editable = !readOnly
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
index a080669..f23a824 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/MaxLinesHeightModifier.kt
@@ -20,9 +20,9 @@
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientFontLoader
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalFontLoader
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.resolveDefaults
@@ -47,9 +47,9 @@
}
if (maxLines == Int.MAX_VALUE) return@composed Modifier
- val density = AmbientDensity.current
- val resourceLoader = AmbientFontLoader.current
- val layoutDirection = AmbientLayoutDirection.current
+ val density = LocalDensity.current
+ val resourceLoader = LocalFontLoader.current
+ val layoutDirection = LocalLayoutDirection.current
// Difference between the height of two lines paragraph and one line paragraph gives us
// an approximation of height of one line
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldScroll.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldScroll.kt
index bc86ec6..2dd5651 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldScroll.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldScroll.kt
@@ -39,8 +39,8 @@
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasureResult
import androidx.compose.ui.layout.MeasureScope
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextRange
@@ -67,7 +67,7 @@
}
) {
// do not reverse direction only in case of RTL in horizontal orientation
- val rtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val rtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val reverseDirection = scrollerPosition.orientation == Orientation.Vertical || !rtl
val controller = rememberScrollableController(
scrollerPosition,
@@ -130,7 +130,7 @@
interactionState: InteractionState? = null,
consumeScrollDelta: (Float) -> Float
): ScrollableController {
- val clocks = AmbientAnimationClock.current.asDisposableClock()
+ val clocks = LocalAnimationClock.current.asDisposableClock()
val flingConfig = defaultFlingConfig()
return remember(inputs, clocks, flingConfig, interactionState) {
ScrollableController(consumeScrollDelta, flingConfig, clocks, interactionState)
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldSize.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldSize.kt
index 74891fb..6c97389 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldSize.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/TextFieldSize.kt
@@ -21,9 +21,9 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.layout.layout
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientFontLoader
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalFontLoader
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.resolveDefaults
@@ -33,9 +33,9 @@
@Suppress("ModifierInspectorInfo")
internal fun Modifier.textFieldMinSize(style: TextStyle) = composed {
- val density = AmbientDensity.current
- val resourceLoader = AmbientFontLoader.current
- val layoutDirection = AmbientLayoutDirection.current
+ val density = LocalDensity.current
+ val resourceLoader = LocalFontLoader.current
+ val layoutDirection = LocalLayoutDirection.current
val minSizeState = remember { TextFieldSize(layoutDirection, density, resourceLoader, style) }
minSizeState.update(layoutDirection, density, resourceLoader, style)
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
index a70e8c6..87d6769 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionContainer.kt
@@ -26,9 +26,9 @@
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.gesture.dragGestureFilter
-import androidx.compose.ui.platform.AmbientClipboardManager
-import androidx.compose.ui.platform.AmbientHapticFeedback
-import androidx.compose.ui.platform.AmbientTextToolbar
+import androidx.compose.ui.platform.LocalClipboardManager
+import androidx.compose.ui.platform.LocalHapticFeedback
+import androidx.compose.ui.platform.LocalTextToolbar
import androidx.compose.ui.text.InternalTextApi
/**
@@ -87,9 +87,9 @@
val registrarImpl = remember { SelectionRegistrarImpl() }
val manager = remember { SelectionManager(registrarImpl) }
- manager.hapticFeedBack = AmbientHapticFeedback.current
- manager.clipboardManager = AmbientClipboardManager.current
- manager.textToolbar = AmbientTextToolbar.current
+ manager.hapticFeedBack = LocalHapticFeedback.current
+ manager.clipboardManager = LocalClipboardManager.current
+ manager.textToolbar = LocalTextToolbar.current
manager.>
manager.selection = selection
diff --git a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Scrollbar.kt b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Scrollbar.kt
index f92d0f0..7d88b50 100644
--- a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Scrollbar.kt
+++ b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/Scrollbar.kt
@@ -28,7 +28,7 @@
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
-import androidx.compose.runtime.staticAmbientOf
+import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.geometry.Offset
@@ -42,7 +42,7 @@
import androidx.compose.ui.input.pointer.pointerMoveFilter
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.MeasuringIntrinsicsMeasureBlocks
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.constrainHeight
@@ -57,7 +57,7 @@
* This value is typically set in some "Theme" composable function
* (DesktopTheme, MaterialTheme)
*/
-val ScrollbarStyleAmbient = staticAmbientOf { defaultScrollbarStyle() }
+val ScrollbarStyleAmbient = staticCompositionLocalOf { defaultScrollbarStyle() }
/**
* Defines visual style of scrollbars (thickness, shapes, colors, etc).
@@ -174,7 +174,7 @@
style: ScrollbarStyle,
interactionState: InteractionState,
isVertical: Boolean
-) = with(AmbientDensity.current) {
+) = with(LocalDensity.current) {
DisposableEffect(interactionState) {
onDispose {
interactionState.removeInteraction(Interaction.Dragged)
@@ -305,7 +305,7 @@
itemCount: Int,
averageItemSize: Dp
): ScrollbarAdapter {
- val averageItemSizePx = with(AmbientDensity.current) {
+ val averageItemSizePx = with(LocalDensity.current) {
averageItemSize.toPx()
}
return remember(scrollState, itemCount, averageItemSizePx) {
diff --git a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/animation/DesktopFlingConfig.kt b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/animation/DesktopFlingConfig.kt
index 1272c0e..a85753d 100644
--- a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/animation/DesktopFlingConfig.kt
+++ b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/animation/DesktopFlingConfig.kt
@@ -19,13 +19,13 @@
import androidx.compose.animation.core.TargetAnimation
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
@Composable
internal actual fun actualFlingConfig(adjustTarget: (Float) -> TargetAnimation?): FlingConfig {
// This function will internally update the calculation of fling decay when the density changes,
// but the reference to the returned FlingConfig will not change across calls.
- val density = AmbientDensity.current
+ val density = LocalDensity.current
return remember(density.density) {
val decayAnimation = DesktopFlingDecaySpec(density)
FlingConfig(
diff --git a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/gestures/DesktopScrollable.kt b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/gestures/DesktopScrollable.kt
index e1d7067..1d9ae3d 100644
--- a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/gestures/DesktopScrollable.kt
+++ b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/gestures/DesktopScrollable.kt
@@ -22,7 +22,7 @@
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
import androidx.compose.ui.input.mouse.MouseScrollUnit
import androidx.compose.ui.input.mouse.mouseScrollFilter
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.DesktopPlatform
import androidx.compose.ui.platform.DesktopPlatformAmbient
import androidx.compose.ui.unit.Density
@@ -44,7 +44,7 @@
scrollCallback: ScrollCallback,
orientation: Orientation
): Modifier = composed {
- val density = AmbientDensity.current
+ val density = LocalDensity.current
val desktopPlatform = DesktopPlatformAmbient.current
val config = PlatformScrollConfig(density, desktopPlatform)
diff --git a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelection.kt b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelection.kt
index 0c4d40f..6539630 100644
--- a/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelection.kt
+++ b/compose/foundation/foundation/src/desktopMain/kotlin/androidx/compose/foundation/text/selection/DesktopSelection.kt
@@ -114,7 +114,7 @@
}
}
- Providers(AmbientSelectionRegistrar provides registrarImpl) {
+ Providers(LocalSelectionRegistrar provides registrarImpl) {
Wrap(modifier) {
content()
}
diff --git a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/SuspendingGestureTestUtil.kt b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/SuspendingGestureTestUtil.kt
index c0ba66b..0fb20da 100644
--- a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/SuspendingGestureTestUtil.kt
+++ b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/SuspendingGestureTestUtil.kt
@@ -38,8 +38,8 @@
import androidx.compose.ui.input.pointer.PointerInputScope
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.materialize
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientViewConfiguration
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.ViewConfiguration
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.IntSize
@@ -96,8 +96,8 @@
withRunningRecomposer { recomposer ->
compose(recomposer) {
Providers(
- AmbientDensity provides Density(1f),
- AmbientViewConfiguration provides TestViewConfiguration()
+ LocalDensity provides Density(1f),
+ LocalViewConfiguration provides TestViewConfiguration()
) {
pointerInputFilter = currentComposer
.materialize(Modifier.pointerInput(gestureDetector)) as
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
index 4aee2ae..e234cd3 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/autofill/AndroidAutofillBenchmark.kt
@@ -26,8 +26,8 @@
import androidx.compose.ui.autofill.AutofillTree
import androidx.compose.ui.autofill.AutofillType
import androidx.compose.ui.geometry.Rect
-import androidx.compose.ui.platform.AmbientAutofillTree
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalAutofillTree
+import androidx.compose.ui.platform.LocalView
import androidx.test.annotation.UiThreadTest
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
@@ -55,8 +55,8 @@
@Before
fun setup() {
composeTestRule.setContent {
- autofillTree = AmbientAutofillTree.current
- composeView = AmbientView.current
+ autofillTree = LocalAutofillTree.current
+ composeView = LocalView.current
}
}
diff --git a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt
index f0e13d8..4b892f3 100644
--- a/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt
+++ b/compose/integration-tests/benchmark/src/androidTest/java/androidx/ui/pointerinput/ComposeTapIntegrationBenchmark.kt
@@ -27,7 +27,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.gesture.tapGestureFilter
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.unit.dp
import androidx.test.annotation.UiThreadTest
@@ -93,7 +93,7 @@
activityTestRule.runOnUiThreadIR {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
itemHeightDp = ItemHeightPx.toDp()
}
App()
diff --git a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
index 4136fb9..e5d7d45 100644
--- a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
+++ b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoApp.kt
@@ -50,7 +50,7 @@
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
@@ -178,7 +178,7 @@
private object AppBarIcons {
@Composable
fun Back(onClick: () -> Unit) {
- val icon = when (AmbientLayoutDirection.current) {
+ val icon = when (LocalLayoutDirection.current) {
LayoutDirection.Ltr -> Icons.Filled.ArrowBack
LayoutDirection.Rtl -> Icons.Filled.ArrowForward
}
diff --git a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt
index 412a4a3..4e37cde 100644
--- a/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt
+++ b/compose/integration-tests/demos/src/main/java/androidx/compose/integration/demos/DemoFilter.kt
@@ -26,11 +26,11 @@
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.verticalScroll
import androidx.compose.integration.demos.common.Demo
-import androidx.compose.material.AmbientContentColor
-import androidx.compose.material.AmbientTextStyle
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.ListItem
+import androidx.compose.material.LocalContentColor
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
@@ -115,8 +115,8 @@
modifier = modifier.focusRequester(focusRequester),
value = filterText,
>
- textStyle = AmbientTextStyle.current,
- cursorColor = AmbientContentColor.current
+ textStyle = LocalTextStyle.current,
+ cursorColor = LocalContentColor.current
)
DisposableEffect(focusRequester) {
focusRequester.requestFocus()
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/interoperability/Interoperability.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/interoperability/Interoperability.kt
index 589bddd..d43c673 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/interoperability/Interoperability.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/interoperability/Interoperability.kt
@@ -73,9 +73,9 @@
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.AbstractComposeView
-import androidx.compose.ui.platform.AmbientConfiguration
-import androidx.compose.ui.platform.AmbientContext
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
@@ -242,7 +242,7 @@
private object InteropSnippet8 {
@Composable
fun rememberCustomView(): CustomView {
- val context = AmbientContext.current
+ val context = LocalContext.current
return remember { CustomView(context).apply { /*...*/ } }
}
}
@@ -441,7 +441,7 @@
private object InteropSnippet1 {
@Composable
fun rememberCustomView(): CustomView {
- val context = AmbientContext.current
+ val context = LocalContext.current
return remember { CustomView(context).apply { /*...*/ } }
}
}
@@ -532,7 +532,7 @@
private object InteropSnippet6 {
@Composable
fun MyComposable() {
- val isPortrait = AmbientConfiguration.current.orientation == ORIENTATION_PORTRAIT
+ val isPortrait = LocalConfiguration.current.orientation == ORIENTATION_PORTRAIT
if (isPortrait) {
/* Portrait-displayed content */
} else {
@@ -675,7 +675,7 @@
onSystemEvent: (intent: Intent?) -> Unit
) {
// Grab the current context in this part of the UI tree
- val context = AmbientContext.current
+ val context = LocalContext.current
// Safely use the latest onSystemEvent lambda passed to the function
val currentOnSystemEvent by rememberUpdatedState(onSystemEvent)
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/navigation/Navigation.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/navigation/Navigation.kt
index 18ac649..6dc9a73 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/navigation/Navigation.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/navigation/Navigation.kt
@@ -32,7 +32,7 @@
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.core.app.TaskStackBuilder
import androidx.core.net.toUri
@@ -139,7 +139,7 @@
@Composable
private fun NavigationSnippet10() {
val id = "exampleId"
- val context = AmbientContext.current
+ val context = LocalContext.current
val deepLinkIntent = Intent(
Intent.ACTION_VIEW,
"https://example.com/$id".toUri(),
diff --git a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt
index c21ca48..0dfeb5a 100644
--- a/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt
+++ b/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/theming/Theming.kt
@@ -24,11 +24,11 @@
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.AmbientContentAlpha
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Colors
import androidx.compose.material.ContentAlpha
+import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Shapes
import androidx.compose.material.Surface
@@ -141,12 +141,12 @@
}
@Composable private fun ThemingSnippet7() {
- // By default, both Icon & Text use the combination of AmbientContentColor &
- // AmbientContentAlpha. De-emphasize content by setting content alpha
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
+ // By default, both Icon & Text use the combination of LocalContentColor &
+ // LocalContentAlpha. De-emphasize content by setting content alpha
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
Text(/*...*/)
}
- Providers(AmbientContentAlpha provides ContentAlpha.disabled) {
+ Providers(LocalContentAlpha provides ContentAlpha.disabled) {
Icon(/*...*/)
Text(/*...*/)
}
diff --git a/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/ImageVectorTest.kt b/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/ImageVectorTest.kt
index 3e0c8b2..aa37e05 100644
--- a/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/ImageVectorTest.kt
+++ b/compose/integration-tests/src/androidTest/java/androidx/ui/integration/test/ImageVectorTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.toArgb
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.test.captureToImage
@@ -91,7 +91,7 @@
val testTag = "testTag"
var insetRectSize: Int = 0
rule.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
insetRectSize = (10f * this.density).roundToInt()
}
val imageVector =
diff --git a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
index 330eb94..ee62674 100644
--- a/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
+++ b/compose/integration-tests/src/main/java/androidx/ui/integration/test/foundation/NestedScrollerTestCase.kt
@@ -38,7 +38,7 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import kotlinx.coroutines.runBlocking
import kotlin.random.Random
@@ -72,7 +72,7 @@
val playStoreColor = Color(red = 0x00, green = 0x00, blue = 0x80)
val content: @Composable RowScope.() -> Unit = {
repeat(6) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Column(Modifier.fillMaxHeight()) {
val color = remember {
val red = Random.nextInt(256)
diff --git a/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt b/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
index 7ad8cb3..231031d 100644
--- a/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
+++ b/compose/material/material-icons-extended/src/androidAndroidTest/kotlin/androidx/compose/material/icons/IconComparisonTest.kt
@@ -34,8 +34,8 @@
import androidx.compose.ui.graphics.vector.VectorGroup
import androidx.compose.ui.graphics.vector.VectorPath
import androidx.compose.ui.graphics.vector.rememberVectorPainter
-import androidx.compose.ui.platform.AmbientContext
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.vectorResource
@@ -207,7 +207,7 @@
*/
@Composable
private fun String.toImageVector(): ImageVector {
- val context = AmbientContext.current
+ val context = LocalContext.current
val resId = context.resources.getIdentifier(this, "drawable", context.packageName)
return vectorResource(resId)
}
@@ -281,7 +281,7 @@
// against in CI, on some devices using DP here causes there to be anti-aliasing issues.
// Using ipx directly ensures that we will always have a consistent layout / drawing
// story, so anti-aliasing should be identical.
- val layoutSize = with(AmbientDensity.current) {
+ val layoutSize = with(LocalDensity.current) {
Modifier.preferredSize(72.toDp())
}
Row(Modifier.align(Alignment.Center)) {
diff --git a/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt b/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt
index 37928a0..82c2e09 100644
--- a/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt
+++ b/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/Ripple.kt
@@ -58,7 +58,7 @@
* If you are using MaterialTheme in your hierarchy, a Ripple will be used as the default
* [Indication] inside components such as [androidx.compose.foundation.clickable] and
* [androidx.compose.foundation.indication]. You can also manually provide Ripples through
- * [androidx.compose.foundation.AmbientIndication] for the same effect if you are not using
+ * [androidx.compose.foundation.LocalIndication] for the same effect if you are not using
* MaterialTheme.
*
* You can also explicitly create a Ripple and provide it to components in order to change the
@@ -81,7 +81,7 @@
radius: Dp = Dp.Unspecified,
color: Color = Color.Unspecified
): Indication {
- val theme = AmbientRippleTheme.current
+ val theme = LocalRippleTheme.current
val scope = rememberCoroutineScope()
val resolvedColor = color.takeOrElse { theme.defaultColor() }
val colorState = remember { mutableStateOf(resolvedColor, structuralEqualityPolicy()) }
@@ -103,7 +103,7 @@
* If you are using MaterialTheme in your hierarchy, a Ripple will be used as the default
* [Indication] inside components such as [androidx.compose.foundation.clickable] and
* [androidx.compose.foundation.indication]. You can also manually provide Ripples through
- * [androidx.compose.foundation.AmbientIndication] for the same effect if you are not using
+ * [androidx.compose.foundation.LocalIndication] for the same effect if you are not using
* MaterialTheme.
*
* You can also explicitly create a Ripple and provide it to components in order to change the
diff --git a/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleTheme.kt b/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleTheme.kt
index 48ff691..e0b0f51 100644
--- a/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleTheme.kt
+++ b/compose/material/material-ripple/src/commonMain/kotlin/androidx/compose/material/ripple/RippleTheme.kt
@@ -26,7 +26,7 @@
/**
* Defines the appearance for Ripples. You can define a new theme and apply it using
- * [AmbientRippleTheme]. See [defaultRippleColor] and [defaultRippleAlpha] for default values
+ * [LocalRippleTheme]. See [defaultRippleColor] and [defaultRippleAlpha] for default values
* that can be used when creating your own [RippleTheme].
*
* @see rememberRipple
diff --git a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
index 91d0050..127b8c5 100644
--- a/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
+++ b/compose/material/material/integration-tests/material-demos/src/main/java/androidx/compose/material/demos/ColorPickerDemo.kt
@@ -39,7 +39,7 @@
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
-import androidx.compose.material.AmbientTextStyle
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
@@ -65,7 +65,7 @@
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.toPixelMap
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -165,7 +165,7 @@
*/
@Composable
private fun Magnifier(visible: Boolean, position: Offset, color: Color) {
- val offset = with(AmbientDensity.current) {
+ val offset = with(LocalDensity.current) {
Modifier.offset(
position.x.toDp() - MagnifierWidth / 2,
// Align with the center of the selection circle
@@ -244,7 +244,7 @@
Box(Modifier.weight(0.25f).fillMaxHeight().background(color))
// Add `#` and drop alpha characters
val text = "#" + Integer.toHexString(color.toArgb()).toUpperCase(Locale.ROOT).drop(2)
- val textStyle = AmbientTextStyle.current.copy(textAlign = TextAlign.Center)
+ val textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center)
Text(
text = text,
modifier = Modifier.weight(0.75f).padding(top = 10.dp, bottom = 20.dp),
diff --git a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/RallyAnimatedCircle.kt b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/RallyAnimatedCircle.kt
index 585e9d5..4fe42e6 100644
--- a/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/RallyAnimatedCircle.kt
+++ b/compose/material/material/integration-tests/material-studies/src/main/java/androidx/compose/material/studies/rally/RallyAnimatedCircle.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.Stroke
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
private const val DividerLengthInDegrees = 1.8f
@@ -45,7 +45,7 @@
proportions: List<Float>,
colors: List<Color>
) {
- val stroke = Stroke(5.dp.value * AmbientDensity.current.density)
+ val stroke = Stroke(5.dp.value * LocalDensity.current.density)
// Start animating when added to the tree
val states = remember { MutableTransitionState(0).apply { targetState = 1 } }
val transition = updateTransition(states)
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ContentAlphaSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ContentAlphaSamples.kt
index cfc3ef12..b9a4d1c 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ContentAlphaSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ContentAlphaSamples.kt
@@ -18,8 +18,8 @@
import androidx.annotation.Sampled
import androidx.compose.foundation.layout.Column
-import androidx.compose.material.AmbientContentAlpha
import androidx.compose.material.ContentAlpha
+import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Providers
@@ -34,16 +34,16 @@
"No content alpha applied - uses the default content alpha set by MaterialTheme - " +
"87% alpha"
)
- Providers(AmbientContentAlpha provides 1.00f) {
+ Providers(LocalContentAlpha provides 1.00f) {
Text("1.00f alpha applied - 100% alpha")
}
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
Text("High content alpha applied - 87% alpha")
}
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
Text("Medium content alpha applied - 60% alpha")
}
- Providers(AmbientContentAlpha provides ContentAlpha.disabled) {
+ Providers(LocalContentAlpha provides ContentAlpha.disabled) {
Text("Disabled content alpha applied - 38% alpha")
}
}
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ElevationSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ElevationSamples.kt
index 6b0bb22..066fa1c 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ElevationSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ElevationSamples.kt
@@ -17,7 +17,7 @@
package androidx.compose.material.samples
import androidx.annotation.Sampled
-import androidx.compose.material.AmbientAbsoluteElevation
+import androidx.compose.material.LocalAbsoluteElevation
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
@@ -28,10 +28,10 @@
fun AbsoluteElevationSample() {
Surface(elevation = 4.dp) {
// This will equal 4.dp
- val elevation = AmbientAbsoluteElevation.current
+ val elevation = LocalAbsoluteElevation.current
Surface(elevation = 2.dp) {
// This will equal 6.dp (4 + 2)
- val elevation = AmbientAbsoluteElevation.current
+ val elevation = LocalAbsoluteElevation.current
}
}
}
\ No newline at end of file
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ListSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ListSamples.kt
index 61a4171..a181467 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ListSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/ListSamples.kt
@@ -21,12 +21,12 @@
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.selection.toggleable
-import androidx.compose.material.AmbientContentColor
import androidx.compose.material.Checkbox
import androidx.compose.material.Divider
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.ListItem
+import androidx.compose.material.LocalContentColor
import androidx.compose.material.Switch
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@@ -105,7 +105,7 @@
Image(
icon24x24,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -116,7 +116,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -127,7 +127,7 @@
Image(
icon56x56,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -138,7 +138,7 @@
Image(
icon56x56,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
},
modifier = Modifier.clickable { }
@@ -155,7 +155,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
},
trailing = { Icon(vectorIcon, contentDescription = "Localized description") }
@@ -186,7 +186,7 @@
Image(
icon24x24,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -198,7 +198,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -211,7 +211,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -254,7 +254,7 @@
Image(
icon24x24,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -294,7 +294,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -305,7 +305,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -316,7 +316,7 @@
Image(
icon24x24,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -350,7 +350,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
@@ -362,7 +362,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
},
modifier = Modifier.clickable { }
@@ -400,7 +400,7 @@
Image(
icon40x40,
contentDescription = null,
- colorFilter = ColorFilter.tint(AmbientContentColor.current)
+ colorFilter = ColorFilter.tint(LocalContentColor.current)
)
}
)
diff --git a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt
index 1ca2897..f00c727 100644
--- a/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt
+++ b/compose/material/material/samples/src/main/java/androidx/compose/material/samples/SwipeableSamples.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -48,7 +48,7 @@
val squareSize = 50.dp
val swipeableState = rememberSwipeableState("A")
- val sizePx = with(AmbientDensity.current) { (width - squareSize).toPx() }
+ val sizePx = with(LocalDensity.current) { (width - squareSize).toPx() }
val anchors = mapOf(0f to "A", sizePx / 2 to "B", sizePx to "C")
Box(
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt
index 375d93d..5ef6c01 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AlertDialogTest.kt
@@ -51,7 +51,7 @@
>
modifier = Modifier.border(10.dp, Color.Blue),
text = {
- contentColor = AmbientContentColor.current
+ contentColor = LocalContentColor.current
Text("Text")
},
confirmButton = {},
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AppBarTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AppBarTest.kt
index 39baeaf..993d1b3 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AppBarTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/AppBarTest.kt
@@ -153,7 +153,7 @@
TopAppBar(
title = {
Text("App Bar Title")
- textStyle = AmbientTextStyle.current
+ textStyle = LocalTextStyle.current
h6Style = MaterialTheme.typography.h6
}
)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
index 0faf064..c1b5602 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ButtonTest.kt
@@ -235,7 +235,7 @@
fun containedButtonPropagateDefaultTextStyle() {
rule.setMaterialContent {
Button( {
- assertThat(AmbientTextStyle.current).isEqualTo(MaterialTheme.typography.button)
+ assertThat(LocalTextStyle.current).isEqualTo(MaterialTheme.typography.button)
}
}
}
@@ -244,7 +244,7 @@
fun outlinedButtonPropagateDefaultTextStyle() {
rule.setMaterialContent {
OutlinedButton( {
- assertThat(AmbientTextStyle.current).isEqualTo(MaterialTheme.typography.button)
+ assertThat(LocalTextStyle.current).isEqualTo(MaterialTheme.typography.button)
}
}
}
@@ -253,7 +253,7 @@
fun textButtonPropagateDefaultTextStyle() {
rule.setMaterialContent {
TextButton( {
- assertThat(AmbientTextStyle.current).isEqualTo(MaterialTheme.typography.button)
+ assertThat(LocalTextStyle.current).isEqualTo(MaterialTheme.typography.button)
}
}
}
@@ -314,7 +314,7 @@
rule.setMaterialContent {
>
Button( {
- content = AmbientContentColor.current
+ content = LocalContentColor.current
}
}
@@ -328,7 +328,7 @@
rule.setMaterialContent {
primary = MaterialTheme.colors.primary
OutlinedButton( {
- content = AmbientContentColor.current
+ content = LocalContentColor.current
}
}
@@ -342,7 +342,7 @@
rule.setMaterialContent {
primary = MaterialTheme.colors.primary
TextButton( {
- content = AmbientContentColor.current
+ content = LocalContentColor.current
}
}
@@ -485,7 +485,7 @@
>
disabledAlpha = ContentAlpha.disabled
Button( enabled = false) {
- content = AmbientContentColor.current.copy(alpha = AmbientContentAlpha.current)
+ content = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
}
}
@@ -501,7 +501,7 @@
>
disabledAlpha = ContentAlpha.disabled
OutlinedButton( enabled = false) {
- content = AmbientContentColor.current.copy(alpha = AmbientContentAlpha.current)
+ content = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
}
}
@@ -517,7 +517,7 @@
>
disabledAlpha = ContentAlpha.disabled
TextButton( enabled = false) {
- content = AmbientContentColor.current.copy(alpha = AmbientContentAlpha.current)
+ content = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ContentAlphaTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ContentAlphaTest.kt
index e6fbd29..f9b5fb2 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ContentAlphaTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ContentAlphaTest.kt
@@ -57,7 +57,7 @@
Surface {
val >
- assertThat(AmbientContentColor.current).isEqualTo(onSurface)
+ assertThat(LocalContentColor.current).isEqualTo(onSurface)
}
}
}
@@ -68,8 +68,8 @@
rule.setContent {
MaterialTheme(colors) {
Surface {
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
- assertThat(AmbientContentAlpha.current)
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
+ assertThat(LocalContentAlpha.current)
.isEqualTo(ReducedContrastHighContentAlpha)
}
}
@@ -82,8 +82,8 @@
rule.setContent {
MaterialTheme(colors) {
Surface {
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
- assertThat(AmbientContentAlpha.current)
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
+ assertThat(LocalContentAlpha.current)
.isEqualTo(ReducedContrastMediumContentAlpha)
}
}
@@ -96,8 +96,8 @@
rule.setContent {
MaterialTheme(colors) {
Surface {
- Providers(AmbientContentAlpha provides ContentAlpha.disabled) {
- assertThat(AmbientContentAlpha.current)
+ Providers(LocalContentAlpha provides ContentAlpha.disabled) {
+ assertThat(LocalContentAlpha.current)
.isEqualTo(ReducedContrastDisabledContentAlpha)
}
}
@@ -112,7 +112,7 @@
Surface(color = colors.primary) {
val >
- assertThat(AmbientContentColor.current).isEqualTo(onPrimary)
+ assertThat(LocalContentColor.current).isEqualTo(onPrimary)
}
}
}
@@ -123,8 +123,8 @@
rule.setContent {
MaterialTheme(colors) {
Surface(color = colors.primary) {
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
- assertThat(AmbientContentAlpha.current)
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
+ assertThat(LocalContentAlpha.current)
.isEqualTo(HighContrastHighContentAlpha)
}
}
@@ -137,8 +137,8 @@
rule.setContent {
MaterialTheme(colors) {
Surface(color = colors.primary) {
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
- assertThat(AmbientContentAlpha.current)
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
+ assertThat(LocalContentAlpha.current)
.isEqualTo(HighContrastMediumContentAlpha)
}
}
@@ -151,8 +151,8 @@
rule.setContent {
MaterialTheme(colors) {
Surface(color = colors.primary) {
- Providers(AmbientContentAlpha provides ContentAlpha.disabled) {
- assertThat(AmbientContentAlpha.current)
+ Providers(LocalContentAlpha provides ContentAlpha.disabled) {
+ assertThat(LocalContentAlpha.current)
.isEqualTo(HighContrastDisabledContentAlpha)
}
}
@@ -165,7 +165,7 @@
rule.setContent {
MaterialTheme(colors) {
Surface(contentColor = Color.Yellow) {
- assertThat(AmbientContentColor.current).isEqualTo(Color.Yellow)
+ assertThat(LocalContentColor.current).isEqualTo(Color.Yellow)
}
}
}
@@ -177,13 +177,13 @@
MaterialTheme(colors) {
val contentColor = Color(0.9f, 0.9f, 0.9f)
Surface(contentColor = contentColor) {
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
val expectedAlpha = if (colors.isLight) {
HighContrastHighContentAlpha
} else {
ReducedContrastHighContentAlpha
}
- assertThat(AmbientContentAlpha.current).isEqualTo(expectedAlpha)
+ assertThat(LocalContentAlpha.current).isEqualTo(expectedAlpha)
}
}
}
@@ -196,13 +196,13 @@
MaterialTheme(colors) {
val contentColor = Color(0.9f, 0.9f, 0.9f)
Surface(contentColor = contentColor) {
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
val expectedAlpha = if (colors.isLight) {
HighContrastMediumContentAlpha
} else {
ReducedContrastMediumContentAlpha
}
- assertThat(AmbientContentAlpha.current).isEqualTo(expectedAlpha)
+ assertThat(LocalContentAlpha.current).isEqualTo(expectedAlpha)
}
}
}
@@ -215,13 +215,13 @@
MaterialTheme(colors) {
val contentColor = Color(0.9f, 0.9f, 0.9f)
Surface(contentColor = contentColor) {
- Providers(AmbientContentAlpha provides ContentAlpha.disabled) {
+ Providers(LocalContentAlpha provides ContentAlpha.disabled) {
val expectedAlpha = if (colors.isLight) {
HighContrastDisabledContentAlpha
} else {
ReducedContrastDisabledContentAlpha
}
- assertThat(AmbientContentAlpha.current).isEqualTo(expectedAlpha)
+ assertThat(LocalContentAlpha.current).isEqualTo(expectedAlpha)
}
}
}
@@ -234,13 +234,13 @@
MaterialTheme(colors) {
val contentColor = Color(0.1f, 0.1f, 0.1f)
Surface(contentColor = contentColor) {
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
val expectedAlpha = if (colors.isLight) {
ReducedContrastHighContentAlpha
} else {
HighContrastHighContentAlpha
}
- assertThat(AmbientContentAlpha.current).isEqualTo(expectedAlpha)
+ assertThat(LocalContentAlpha.current).isEqualTo(expectedAlpha)
}
}
}
@@ -253,13 +253,13 @@
MaterialTheme(colors) {
val contentColor = Color(0.1f, 0.1f, 0.1f)
Surface(contentColor = contentColor) {
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
val expectedAlpha = if (colors.isLight) {
ReducedContrastMediumContentAlpha
} else {
HighContrastMediumContentAlpha
}
- assertThat(AmbientContentAlpha.current).isEqualTo(expectedAlpha)
+ assertThat(LocalContentAlpha.current).isEqualTo(expectedAlpha)
}
}
}
@@ -272,13 +272,13 @@
MaterialTheme(colors) {
val contentColor = Color(0.1f, 0.1f, 0.1f)
Surface(contentColor = contentColor) {
- Providers(AmbientContentAlpha provides ContentAlpha.disabled) {
+ Providers(LocalContentAlpha provides ContentAlpha.disabled) {
val expectedAlpha = if (colors.isLight) {
ReducedContrastDisabledContentAlpha
} else {
HighContrastDisabledContentAlpha
}
- assertThat(AmbientContentAlpha.current).isEqualTo(expectedAlpha)
+ assertThat(LocalContentAlpha.current).isEqualTo(expectedAlpha)
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt
index 2389196..94dca3c 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/DrawerTest.kt
@@ -24,7 +24,7 @@
import androidx.compose.runtime.Providers
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.SemanticsActions
import androidx.compose.ui.test.SemanticsMatcher
@@ -435,7 +435,7 @@
rule.setMaterialContent {
drawerState = rememberDrawerState(DrawerValue.Closed)
// emulate click on the screen
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(Modifier.testTag("Drawer")) {
ModalDrawerLayout(
drawerState = drawerState,
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt
index 829ad05..270f0fc 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ElevationOverlayTest.kt
@@ -25,7 +25,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.compositeOver
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createComposeRule
@@ -158,7 +158,7 @@
rule.setContent {
// Turn off overlay behavior
- Providers(AmbientElevationOverlay provides null) {
+ Providers(LocalElevationOverlay provides null) {
TestSurface(elevation!!, colors)
}
}
@@ -183,7 +183,7 @@
}
rule.setContent {
- Providers(AmbientElevationOverlay provides customOverlay) {
+ Providers(LocalElevationOverlay provides customOverlay) {
TestSurface(elevation!!, lightColors())
}
}
@@ -210,7 +210,7 @@
MaterialTheme(colors) {
Box {
Surface(elevation = elevation) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
// Make the surface size small so we compare less pixels
Box(
Modifier.preferredSize(
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt
index ab97ef7..84eb806 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/IconTest.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.graphics.painter.ImagePainter
import androidx.compose.ui.graphics.vector.ImageVector
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsProperties
@@ -90,7 +90,7 @@
val height = 24.dp
rule
.setMaterialContentForSizeAssertions {
- val image = with(AmbientDensity.current) {
+ val image = with(LocalDensity.current) {
ImageBitmap(width.toIntPx(), height.toIntPx())
}
@@ -107,7 +107,7 @@
rule
.setMaterialContentForSizeAssertions {
- val image = with(AmbientDensity.current) {
+ val image = with(LocalDensity.current) {
ImageBitmap(width.toIntPx(), height.toIntPx())
}
@@ -137,7 +137,7 @@
rule
.setMaterialContentForSizeAssertions {
- val image = with(AmbientDensity.current) {
+ val image = with(LocalDensity.current) {
ImageBitmap(width.toIntPx(), height.toIntPx())
}
@@ -156,7 +156,7 @@
val testTag = "testTag"
rule.setMaterialContentForSizeAssertions {
val image: ImageBitmap
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
image = createBitmapWithColor(
this,
width.toIntPx(),
@@ -179,7 +179,7 @@
val testTag = "testTag"
rule.setMaterialContentForSizeAssertions {
val image: ImageBitmap
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
image = createBitmapWithColor(
this,
width.toIntPx(),
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
index 8b7a31b..e862134 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MaterialRippleThemeTest.kt
@@ -27,8 +27,8 @@
import androidx.compose.foundation.layout.preferredHeight
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.shape.RoundedCornerShape
-import androidx.compose.material.ripple.AmbientRippleTheme
import androidx.compose.material.ripple.ExperimentalRippleApi
+import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material.ripple.RippleAlpha
import androidx.compose.material.ripple.RippleTheme
import androidx.compose.material.ripple.rememberRipple
@@ -436,7 +436,7 @@
rule.setContent {
MaterialTheme {
- Providers(AmbientRippleTheme provides rippleTheme) {
+ Providers(LocalRippleTheme provides rippleTheme) {
Surface(contentColor = contentColor) {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
RippleBox(interactionState, rememberRipple())
@@ -475,7 +475,7 @@
rule.setContent {
MaterialTheme {
- Providers(AmbientRippleTheme provides rippleTheme) {
+ Providers(LocalRippleTheme provides rippleTheme) {
Surface(contentColor = contentColor) {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
RippleBox(interactionState, rememberRipple())
@@ -514,7 +514,7 @@
rule.setContent {
MaterialTheme {
- Providers(AmbientRippleTheme provides rippleTheme) {
+ Providers(LocalRippleTheme provides rippleTheme) {
Surface(contentColor = Color.Black) {
Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
RippleBox(interactionState, rememberRipple())
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt
index 664def2..95fbbee 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/MenuTest.kt
@@ -26,7 +26,7 @@
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.hasAnyDescendant
@@ -102,7 +102,7 @@
@Test
fun menu_hasExpectedSize() {
rule.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
DropdownMenu(
expanded = true,
toggle = {
@@ -308,12 +308,12 @@
expanded = true
) {
DropdownMenuItem( {
- enabledContentColor = AmbientContentColor.current
- .copy(alpha = AmbientContentAlpha.current)
+ enabledContentColor = LocalContentColor.current
+ .copy(alpha = LocalContentAlpha.current)
}
DropdownMenuItem(enabled = false, {
- disabledContentColor = AmbientContentColor.current
- .copy(alpha = AmbientContentAlpha.current)
+ disabledContentColor = LocalContentColor.current
+ .copy(alpha = LocalContentAlpha.current)
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
index 9600b81..c0207f6 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/ScaffoldScreenshotTest.kt
@@ -30,7 +30,7 @@
import androidx.compose.runtime.Providers
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.captureToImage
@@ -653,7 +653,7 @@
val layoutDirection = if (rtl) LayoutDirection.Rtl else LayoutDirection.Ltr
- Providers(AmbientLayoutDirection provides layoutDirection) {
+ Providers(LocalLayoutDirection provides layoutDirection) {
Box(
Modifier
.fillMaxSize(0.5f)
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderTest.kt
index 2fcc47f..8cd2d38 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SliderTest.kt
@@ -20,8 +20,8 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.platform.AmbientLayoutDirection
-import androidx.compose.ui.platform.AmbientViewConfiguration
+import androidx.compose.ui.platform.LocalLayoutDirection
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.ProgressBarRangeInfo
import androidx.compose.ui.semantics.SemanticsActions
@@ -175,7 +175,7 @@
var slop = 0f
rule.setMaterialContent {
- slop = AmbientViewConfiguration.current.touchSlop
+ slop = LocalViewConfiguration.current.touchSlop
Slider(
modifier = Modifier.testTag(tag),
value = state.value,
@@ -236,8 +236,8 @@
var slop = 0f
rule.setMaterialContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
- slop = AmbientViewConfiguration.current.touchSlop
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
+ slop = LocalViewConfiguration.current.touchSlop
Slider(
modifier = Modifier.testTag(tag),
value = state.value,
@@ -270,7 +270,7 @@
val state = mutableStateOf(0f)
rule.setMaterialContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Slider(
modifier = Modifier.testTag(tag),
value = state.value,
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceContentColorTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceContentColorTest.kt
index 7e6a086..19e6b98 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceContentColorTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceContentColorTest.kt
@@ -37,7 +37,7 @@
rule.setContent {
MaterialTheme {
Surface(color = MaterialTheme.colors.primary) {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(MaterialTheme.colors.onPrimary)
}
}
@@ -49,7 +49,7 @@
rule.setContent {
MaterialTheme {
Surface(color = MaterialTheme.colors.secondary) {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(MaterialTheme.colors.onSecondary)
}
}
@@ -61,7 +61,7 @@
rule.setContent {
MaterialTheme {
Surface(color = MaterialTheme.colors.background) {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(MaterialTheme.colors.onBackground)
}
}
@@ -73,7 +73,7 @@
rule.setContent {
MaterialTheme {
Surface(color = MaterialTheme.colors.surface) {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(MaterialTheme.colors.onSurface)
}
}
@@ -85,7 +85,7 @@
rule.setContent {
MaterialTheme {
Surface(color = Color.Yellow) {
- assertThat(AmbientContentColor.current).isEqualTo(Color.Black)
+ assertThat(LocalContentColor.current).isEqualTo(Color.Black)
}
}
}
@@ -100,7 +100,7 @@
// This surface should inherit the parent contentColor, as yellow is not part
// of the theme
Surface(color = Color.Yellow) {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(MaterialTheme.colors.onSurface)
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
index 59074a7..9fb4a61 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SurfaceTest.kt
@@ -80,14 +80,14 @@
}
@Test
- fun absoluteElevationAmbientIsSet() {
+ fun absoluteElevationCompositionLocalIsSet() {
var outerElevation: Dp? = null
var innerElevation: Dp? = null
rule.setMaterialContent {
Surface(elevation = 2.dp) {
- outerElevation = AmbientAbsoluteElevation.current
+ outerElevation = LocalAbsoluteElevation.current
Surface(elevation = 4.dp) {
- innerElevation = AmbientAbsoluteElevation.current
+ innerElevation = LocalAbsoluteElevation.current
}
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt
index c78d22d..018fc22 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeToDismissTest.kt
@@ -22,7 +22,7 @@
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.runtime.Providers
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.compose.ui.test.junit4.createComposeRule
@@ -222,7 +222,7 @@
fun swipeToDismiss_dismissBySwipe_toEnd_rtl() {
val dismissState = DismissState(DismissValue.Default, clock)
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
SwipeToDismiss(
modifier = Modifier.testTag(swipeToDismissTag),
state = dismissState,
@@ -246,7 +246,7 @@
fun swipeToDismiss_dismissBySwipe_toStart_rtl() {
val dismissState = DismissState(DismissValue.Default, clock)
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
SwipeToDismiss(
modifier = Modifier.testTag(swipeToDismissTag),
state = dismissState,
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
index c2ca766..f879050 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwipeableTest.kt
@@ -38,8 +38,8 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.gesture.nestedscroll.nestedScroll
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
-import androidx.compose.ui.platform.AmbientViewConfiguration
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
@@ -1136,7 +1136,7 @@
val state = SwipeableState("A", clock)
var slop = 0f
setSwipeableContent {
- slop = AmbientViewConfiguration.current.touchSlop
+ slop = LocalViewConfiguration.current.touchSlop
Modifier.swipeable(
state = state,
anchors = mapOf(0f to "A", 100f to "B"),
@@ -1215,7 +1215,7 @@
val state = SwipeableState("A", clock)
var slop = 0f
setSwipeableContent {
- slop = AmbientViewConfiguration.current.touchSlop
+ slop = LocalViewConfiguration.current.touchSlop
Modifier.swipeable(
state = state,
anchors = mapOf(0f to "A", 100f to "B"),
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
index b73619e..15d9955 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchScreenshotTest.kt
@@ -27,7 +27,7 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.captureToImage
@@ -84,7 +84,7 @@
fun switchTest_checked_rtl() {
rule.setMaterialContent {
Box(wrapperModifier) {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Switch(checked = true, })
}
}
@@ -120,7 +120,7 @@
fun switchTest_unchecked_rtl() {
rule.setMaterialContent {
Box(wrapperModifier) {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Switch(checked = false, })
}
}
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchTest.kt
index 330f3ba..b61d926 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/SwitchTest.kt
@@ -22,7 +22,7 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.semantics.SemanticsProperties
@@ -187,7 +187,7 @@
rule.setMaterialContent {
// Box is needed because otherwise the control will be expanded to fill its parent
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box {
Switch(
modifier = Modifier.testTag(defaultSwitchTag),
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt
index d4bc695..6abdcc4 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldScreenshotTest.kt
@@ -20,16 +20,16 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
-import androidx.compose.material.AmbientContentColor
import androidx.compose.material.GOLDEN_MATERIAL
+import androidx.compose.material.LocalContentColor
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material.setMaterialContent
import androidx.compose.runtime.Providers
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.SemanticsNodeInteraction
@@ -127,7 +127,7 @@
@Test
fun outlinedTextField_focused_rtl() {
rule.setMaterialContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(Modifier.semantics(mergeDescendants = true) {}.testTag(TextFieldTag)) {
OutlinedTextField(
value = "",
@@ -183,7 +183,7 @@
@Test
fun outlinedTextField_textColor_fallbackToContentColor() {
rule.setMaterialContent {
- Providers(AmbientContentColor provides Color.Magenta) {
+ Providers(LocalContentColor provides Color.Magenta) {
OutlinedTextField(
value = "Hello, world!",
>
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
index 238014e..72c99a2 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/OutlinedTextFieldTest.kt
@@ -24,9 +24,9 @@
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.KeyboardOptions
-import androidx.compose.material.AmbientContentAlpha
-import androidx.compose.material.AmbientContentColor
-import androidx.compose.material.AmbientTextStyle
+import androidx.compose.material.LocalContentAlpha
+import androidx.compose.material.LocalContentColor
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
@@ -48,7 +48,7 @@
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientTextInputService
+import androidx.compose.ui.platform.LocalTextInputService
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertWidthIsEqualTo
@@ -468,8 +468,8 @@
placeholder = {
Text("placeholder")
assertThat(
- AmbientContentColor.current.copy(
- alpha = AmbientContentAlpha.current
+ LocalContentColor.current.copy(
+ alpha = LocalContentAlpha.current
)
)
.isEqualTo(
@@ -477,7 +477,7 @@
alpha = 0.6f
)
)
- assertThat(AmbientTextStyle.current)
+ assertThat(LocalTextStyle.current)
.isEqualTo(MaterialTheme.typography.subtitle1)
}
)
@@ -610,7 +610,7 @@
label = {},
isErrorValue = false,
leadingIcon = {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(
MaterialTheme.colors.onSurface.copy(
IconColorAlpha
@@ -618,7 +618,7 @@
)
},
trailingIcon = {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(
MaterialTheme.colors.onSurface.copy(
IconColorAlpha
@@ -638,7 +638,7 @@
label = {},
isErrorValue = true,
leadingIcon = {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(
MaterialTheme.colors.onSurface.copy(
IconColorAlpha
@@ -646,7 +646,7 @@
)
},
trailingIcon = {
- assertThat(AmbientContentColor.current).isEqualTo(MaterialTheme.colors.error)
+ assertThat(LocalContentColor.current).isEqualTo(MaterialTheme.colors.error)
}
)
}
@@ -658,7 +658,7 @@
val textInputService = mock<TextInputService>()
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
var text = remember { mutableStateOf("") }
OutlinedTextField(
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt
index fec6fd4..42e842f 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldScreenshotTest.kt
@@ -20,16 +20,16 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
-import androidx.compose.material.AmbientContentColor
import androidx.compose.material.GOLDEN_MATERIAL
+import androidx.compose.material.LocalContentColor
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.setMaterialContent
import androidx.compose.runtime.Providers
import androidx.compose.testutils.assertAgainstGolden
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.SemanticsNodeInteraction
@@ -126,7 +126,7 @@
@Test
fun textField_focused_rtl() {
rule.setMaterialContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box(Modifier.semantics(mergeDescendants = true) {}.testTag(TextFieldTag)) {
TextField(
value = "",
@@ -178,7 +178,7 @@
@Test
fun textField_textColor_fallbackToContentColor() {
rule.setMaterialContent {
- Providers(AmbientContentColor provides Color.Green) {
+ Providers(LocalContentColor provides Color.Green) {
TextField(
value = "Hello, world!",
>
diff --git a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
index bf96756..8308f6d 100644
--- a/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
+++ b/compose/material/material/src/androidAndroidTest/kotlin/androidx/compose/material/textfield/TextFieldTest.kt
@@ -30,9 +30,9 @@
import androidx.compose.foundation.layout.preferredSize
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.KeyboardOptions
-import androidx.compose.material.AmbientContentAlpha
-import androidx.compose.material.AmbientContentColor
-import androidx.compose.material.AmbientTextStyle
+import androidx.compose.material.LocalContentAlpha
+import androidx.compose.material.LocalContentColor
+import androidx.compose.material.LocalTextStyle
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextField
@@ -56,8 +56,8 @@
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientTextInputService
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalTextInputService
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertHeightIsEqualTo
@@ -219,7 +219,7 @@
val (focusRequester, parentFocusRequester) = FocusRequester.createRefs()
lateinit var hostView: View
rule.setMaterialContent {
- hostView = AmbientView.current
+ hostView = LocalView.current
Box {
TextField(
modifier = Modifier
@@ -250,7 +250,7 @@
lateinit var softwareKeyboardController: SoftwareKeyboardController
lateinit var hostView: View
rule.setMaterialContent {
- hostView = AmbientView.current
+ hostView = LocalView.current
Box {
TextField(
modifier = Modifier
@@ -615,8 +615,8 @@
placeholder = {
Text("placeholder")
assertThat(
- AmbientContentColor.current.copy(
- alpha = AmbientContentAlpha.current
+ LocalContentColor.current.copy(
+ alpha = LocalContentAlpha.current
)
)
.isEqualTo(
@@ -624,7 +624,7 @@
alpha = 0.6f
)
)
- assertThat(AmbientTextStyle.current)
+ assertThat(LocalTextStyle.current)
.isEqualTo(MaterialTheme.typography.subtitle1)
}
)
@@ -764,7 +764,7 @@
label = {},
isErrorValue = false,
leadingIcon = {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(
MaterialTheme.colors.onSurface.copy(
IconColorAlpha
@@ -772,7 +772,7 @@
)
},
trailingIcon = {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(
MaterialTheme.colors.onSurface.copy(
IconColorAlpha
@@ -792,7 +792,7 @@
label = {},
isErrorValue = true,
leadingIcon = {
- assertThat(AmbientContentColor.current)
+ assertThat(LocalContentColor.current)
.isEqualTo(
MaterialTheme.colors.onSurface.copy(
IconColorAlpha
@@ -800,7 +800,7 @@
)
},
trailingIcon = {
- assertThat(AmbientContentColor.current).isEqualTo(MaterialTheme.colors.error)
+ assertThat(LocalContentColor.current).isEqualTo(MaterialTheme.colors.error)
}
)
}
@@ -812,7 +812,7 @@
val textInputService = mock<TextInputService>()
rule.setContent {
Providers(
- AmbientTextInputService provides textInputService
+ LocalTextInputService provides textInputService
) {
val text = remember { mutableStateOf("") }
TextField(
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AlertDialog.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AlertDialog.kt
index 593921c..f53ba81 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AlertDialog.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AlertDialog.kt
@@ -159,7 +159,7 @@
AlertDialogBaselineLayout(
title = title?.let {
@Composable {
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
val textStyle = MaterialTheme.typography.subtitle1
ProvideTextStyle(textStyle, title)
}
@@ -167,7 +167,7 @@
},
text = text?.let {
@Composable {
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
val textStyle = MaterialTheme.typography.body2
ProvideTextStyle(textStyle, text)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
index 83f4c7a..0aa591f 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/AppBar.kt
@@ -86,7 +86,7 @@
} else {
Row(TitleIconModifier, verticalAlignment = Alignment.CenterVertically) {
Providers(
- AmbientContentAlpha provides ContentAlpha.high,
+ LocalContentAlpha provides ContentAlpha.high,
content = navigationIcon
)
}
@@ -97,11 +97,11 @@
verticalAlignment = Alignment.CenterVertically
) {
ProvideTextStyle(value = MaterialTheme.typography.h6) {
- Providers(AmbientContentAlpha provides ContentAlpha.high, content = title)
+ Providers(LocalContentAlpha provides ContentAlpha.high, content = title)
}
}
- Providers(AmbientContentAlpha provides ContentAlpha.medium) {
+ Providers(LocalContentAlpha provides ContentAlpha.medium) {
Row(
Modifier.fillMaxHeight(),
horizontalArrangement = Arrangement.End,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt
index e9a32e6..30beb88 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BackdropScaffold.kt
@@ -47,8 +47,8 @@
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.SubcomposeLayout
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
@@ -182,7 +182,7 @@
@ExperimentalMaterialApi
fun rememberBackdropScaffoldState(
initialValue: BackdropValue,
- clock: AnimationClockObservable = AmbientAnimationClock.current,
+ clock: AnimationClockObservable = LocalAnimationClock.current,
animationSpec: AnimationSpec<Float> = SwipeableDefaults.AnimationSpec,
confirmStateChange: (BackdropValue) -> Boolean = { true },
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }
@@ -290,8 +290,8 @@
backLayerContent: @Composable () -> Unit,
frontLayerContent: @Composable () -> Unit
) {
- val peekHeightPx = with(AmbientDensity.current) { peekHeight.toPx() }
- val headerHeightPx = with(AmbientDensity.current) { headerHeight.toPx() }
+ val peekHeightPx = with(LocalDensity.current) { peekHeight.toPx() }
+ val headerHeightPx = with(LocalDensity.current) { headerHeight.toPx() }
val backLayer = @Composable {
if (persistentAppBar) {
@@ -414,7 +414,7 @@
val animationProgress by animateFloatAsState(
targetValue = if (target == Revealed) 0f else 2f, animationSpec = TweenSpec()
)
- val animationSlideOffset = with(AmbientDensity.current) { AnimationSlideOffset.toPx() }
+ val animationSlideOffset = with(LocalDensity.current) { AnimationSlideOffset.toPx() }
val appBarFloat = (animationProgress - 1).coerceIn(0f, 1f)
val contentFloat = (1 - animationProgress).coerceIn(0f, 1f)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
index 48b2cd5..8b2f2f4 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomNavigation.kt
@@ -146,7 +146,7 @@
label: @Composable (() -> Unit)? = null,
alwaysShowLabels: Boolean = true,
interactionState: InteractionState = remember { InteractionState() },
- selectedContentColor: Color = AmbientContentColor.current,
+ selectedContentColor: Color = LocalContentColor.current,
unselectedContentColor: Color = selectedContentColor.copy(alpha = ContentAlpha.medium)
) {
val styledLabel: @Composable (() -> Unit)? = label?.let {
@@ -191,15 +191,15 @@
}
/**
- * Transition that animates [AmbientContentColor] between [inactiveColor] and [activeColor], depending
+ * Transition that animates [LocalContentColor] between [inactiveColor] and [activeColor], depending
* on [selected]. This component also provides the animation fraction as a parameter to [content],
* to allow animating the position of the icon and the scale of the label alongside this color
* animation.
*
- * @param activeColor [AmbientContentColor] when this item is [selected]
- * @param inactiveColor [AmbientContentColor] when this item is not [selected]
+ * @param activeColor [LocalContentColor] when this item is [selected]
+ * @param inactiveColor [LocalContentColor] when this item is not [selected]
* @param selected whether this item is selected
- * @param content the content of the [BottomNavigationItem] to animate [AmbientContentColor] for,
+ * @param content the content of the [BottomNavigationItem] to animate [LocalContentColor] for,
* where the animationProgress is the current progress of the animation from 0f to 1f.
*/
@Composable
@@ -217,8 +217,8 @@
val color = lerp(inactiveColor, activeColor, animationProgress)
Providers(
- AmbientContentColor provides color.copy(alpha = 1f),
- AmbientContentAlpha provides color.alpha,
+ LocalContentColor provides color.copy(alpha = 1f),
+ LocalContentAlpha provides color.alpha,
) {
content(animationProgress)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
index dae899a..534787c 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/BottomSheetScaffold.kt
@@ -45,8 +45,8 @@
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import kotlin.math.roundToInt
@@ -172,7 +172,7 @@
animationSpec: AnimationSpec<Float> = SwipeableDefaults.AnimationSpec,
confirmStateChange: (BottomSheetValue) -> Boolean = { true }
): BottomSheetState {
- val disposableClock = AmbientAnimationClock.current.asDisposableClock()
+ val disposableClock = LocalAnimationClock.current.asDisposableClock()
return rememberSaveable(
disposableClock,
saver = BottomSheetState.Saver(
@@ -301,7 +301,7 @@
) {
BoxWithConstraints(modifier) {
val fullHeight = constraints.maxHeight.toFloat()
- val peekHeightPx = with(AmbientDensity.current) { sheetPeekHeight.toPx() }
+ val peekHeightPx = with(LocalDensity.current) { sheetPeekHeight.toPx() }
var bottomSheetHeight by remember { mutableStateOf(fullHeight) }
val swipeable = Modifier
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
index d812c41..8953539 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Button.kt
@@ -122,7 +122,7 @@
indication = null
)
) {
- Providers(AmbientContentAlpha provides contentColor.alpha) {
+ Providers(LocalContentAlpha provides contentColor.alpha) {
ProvideTextStyle(
value = MaterialTheme.typography.button
) {
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Colors.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Colors.kt
index 4ab9313..b1c7b34 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Colors.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Colors.kt
@@ -266,16 +266,16 @@
* [backgroundColor] is [Colors.primary], this will return [Colors.onPrimary].
*
* If [backgroundColor] does not match a background color in the theme, this will return
- * the current value of [AmbientContentColor] as a best-effort color.
+ * the current value of [LocalContentColor] as a best-effort color.
*
* @return the matching content color for [backgroundColor]. If [backgroundColor] is not present in
- * the theme's [Colors], then returns the current value of [AmbientContentColor].
+ * the theme's [Colors], then returns the current value of [LocalContentColor].
*
* @see Colors.contentColorFor
*/
@Composable
fun contentColorFor(backgroundColor: Color) =
- MaterialTheme.colors.contentColorFor(backgroundColor).takeOrElse { AmbientContentColor.current }
+ MaterialTheme.colors.contentColorFor(backgroundColor).takeOrElse { LocalContentColor.current }
/**
* Updates the internal values of the given [Colors] with values from the [other] [Colors]. This
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt
index 775caaa..fe75875 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ContentAlpha.kt
@@ -23,7 +23,7 @@
/**
* Default alpha levels used by Material components.
*
- * See [AmbientContentAlpha].
+ * See [LocalContentAlpha].
*/
object ContentAlpha {
/**
@@ -74,7 +74,7 @@
/*@FloatRange(from = 0.0, to = 1.0)*/
lowContrastAlpha: Float
): Float {
- val contentColor = AmbientContentColor.current
+ val contentColor = LocalContentColor.current
val lightTheme = MaterialTheme.colors.isLight
return if (lightTheme) {
if (contentColor.luminance() > 0.5) highContrastAlpha else lowContrastAlpha
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
index 228edb0..c30b65e 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Drawer.kt
@@ -41,9 +41,9 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.semantics.dismiss
import androidx.compose.ui.semantics.paneTitle
import androidx.compose.ui.semantics.semantics
@@ -285,7 +285,7 @@
initialValue: DrawerValue,
confirmStateChange: (DrawerValue) -> Boolean = { true }
): DrawerState {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
return rememberSaveable(
clock,
saver = DrawerState.Saver(clock, confirmStateChange)
@@ -305,7 +305,7 @@
initialValue: BottomDrawerValue,
confirmStateChange: (BottomDrawerValue) -> Boolean = { true }
): BottomDrawerState {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
return rememberSaveable(
clock,
saver = BottomDrawerState.Saver(clock, confirmStateChange)
@@ -366,7 +366,7 @@
val maxValue = 0f
val anchors = mapOf(minValue to DrawerValue.Closed, maxValue to DrawerValue.Open)
- val isRtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val blockClicks = if (drawerState.isOpen) {
Modifier.pointerInput { detectTapGestures {} }
} else {
@@ -394,7 +394,7 @@
color = scrimColor
)
Surface(
- modifier = with(AmbientDensity.current) {
+ modifier = with(LocalDensity.current) {
Modifier
.preferredSizeIn(
minWidth = modalDrawerConstraints.minWidth.toDp(),
@@ -525,7 +525,7 @@
color = scrimColor
)
Surface(
- modifier = with(AmbientDensity.current) {
+ modifier = with(LocalDensity.current) {
Modifier.preferredSizeIn(
minWidth = modalDrawerConstraints.minWidth.toDp(),
minHeight = modalDrawerConstraints.minHeight.toDp(),
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ElevationOverlay.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ElevationOverlay.kt
index dd2304b..eab76f1 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ElevationOverlay.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ElevationOverlay.kt
@@ -62,7 +62,7 @@
* the Material specification for
* [Dark Theme](https://material.io/design/color/dark-theme.html#properties).
*
- * See [AmbientElevationOverlay] to provide your own [ElevationOverlay]. You can provide `null`
+ * See [LocalElevationOverlay] to provide your own [ElevationOverlay]. You can provide `null`
* to have no ElevationOverlay applied.
*/
interface ElevationOverlay {
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
index d658936..f608625 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/FloatingActionButton.kt
@@ -95,7 +95,7 @@
contentColor = contentColor,
elevation = elevation.elevation(interactionState).value
) {
- Providers(AmbientContentAlpha provides contentColor.alpha) {
+ Providers(LocalContentAlpha provides contentColor.alpha) {
ProvideTextStyle(MaterialTheme.typography.button) {
Box(
modifier = Modifier
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt
index e050dc5..2eeb8a2 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Icon.kt
@@ -38,7 +38,7 @@
import androidx.compose.ui.unit.dp
/**
- * Icon component that draws [imageVector] using [tint], defaulting to [AmbientContentColor]. For a
+ * Icon component that draws [imageVector] using [tint], defaulting to [LocalContentColor]. For a
* clickable icon, see [IconButton].
*
* @param imageVector [ImageVector] to draw inside this Icon
@@ -55,7 +55,7 @@
imageVector: ImageVector,
contentDescription: String?,
modifier: Modifier = Modifier,
- tint: Color = AmbientContentColor.current.copy(alpha = AmbientContentAlpha.current)
+ tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
) {
Icon(
painter = rememberVectorPainter(imageVector),
@@ -66,7 +66,7 @@
}
/**
- * Icon component that draws [bitmap] using [tint], defaulting to [AmbientContentColor]. For a
+ * Icon component that draws [bitmap] using [tint], defaulting to [LocalContentColor]. For a
* clickable icon, see [IconButton].
*
* @param bitmap [ImageBitmap] to draw inside this Icon
@@ -83,7 +83,7 @@
bitmap: ImageBitmap,
contentDescription: String?,
modifier: Modifier = Modifier,
- tint: Color = AmbientContentColor.current
+ tint: Color = LocalContentColor.current
) {
val painter = remember(bitmap) { ImagePainter(bitmap) }
Icon(
@@ -95,7 +95,7 @@
}
/**
- * Icon component that draws a [painter] using [tint], defaulting to [AmbientContentColor]. For a
+ * Icon component that draws a [painter] using [tint], defaulting to [LocalContentColor]. For a
* clickable icon, see [IconButton].
*
* @param painter [Painter] to draw inside this Icon
@@ -112,7 +112,7 @@
painter: Painter,
contentDescription: String?,
modifier: Modifier = Modifier,
- tint: Color = AmbientContentColor.current.copy(alpha = AmbientContentAlpha.current)
+ tint: Color = LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
) {
// TODO: consider allowing developers to override the intrinsic size, and specify their own
// size that this icon will be forced to take up.
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
index 40b52dc..46c3cc0 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ListItem.kt
@@ -416,7 +416,7 @@
): @Composable (() -> Unit)? {
if (icon == null) return null
return {
- Providers(AmbientContentAlpha provides contentAlpha) {
+ Providers(LocalContentAlpha provides contentAlpha) {
ProvideTextStyle(textStyle, icon)
}
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTextSelectionColors.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTextSelectionColors.kt
index 30b7151..aea6370 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTextSelectionColors.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTextSelectionColors.kt
@@ -41,7 +41,7 @@
// text shouldn't be selectable / is noted as disabled for accessibility purposes.
val textColorWithLowestAlpha = colors.contentColorFor(backgroundColor)
.takeOrElse {
- AmbientContentColor.current
+ LocalContentColor.current
}.copy(
alpha = ContentAlpha.medium
)
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt
index dc027db..3ee4e75 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/MaterialTheme.kt
@@ -16,10 +16,10 @@
package androidx.compose.material
-import androidx.compose.foundation.AmbientIndication
import androidx.compose.foundation.Indication
-import androidx.compose.material.ripple.AmbientRippleTheme
+import androidx.compose.foundation.LocalIndication
import androidx.compose.material.ripple.ExperimentalRippleApi
+import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material.ripple.RippleTheme
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
@@ -73,9 +73,9 @@
val selectionColors = rememberTextSelectionColors(rememberedColors)
Providers(
LocalColors provides rememberedColors,
- AmbientContentAlpha provides ContentAlpha.high,
- AmbientIndication provides indicationFactory,
- AmbientRippleTheme provides MaterialRippleTheme,
+ LocalContentAlpha provides ContentAlpha.high,
+ LocalIndication provides indicationFactory,
+ LocalRippleTheme provides MaterialRippleTheme,
LocalShapes provides shapes,
LocalTextSelectionColors provides selectionColors,
LocalTypography provides typography
@@ -123,13 +123,13 @@
private object MaterialRippleTheme : RippleTheme {
@Composable
override fun defaultColor() = RippleTheme.defaultRippleColor(
- contentColor = AmbientContentColor.current,
+ contentColor = LocalContentColor.current,
lightTheme = MaterialTheme.colors.isLight
)
@Composable
override fun rippleAlpha() = RippleTheme.defaultRippleAlpha(
- contentColor = AmbientContentColor.current,
+ contentColor = LocalContentColor.current,
lightTheme = MaterialTheme.colors.isLight
)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
index 50c6d03..653f21f 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Menu.kt
@@ -46,7 +46,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.IntBounds
@@ -107,7 +107,7 @@
if (expandedStates.currentState || expandedStates.targetState) {
val transformOriginState = remember { mutableStateOf(TransformOrigin.Center) }
- val density = AmbientDensity.current
+ val density = LocalDensity.current
val popupPositionProvider = DropdownMenuPositionProvider(
dropdownOffset,
density
@@ -236,7 +236,7 @@
val typography = MaterialTheme.typography
ProvideTextStyle(typography.subtitle1) {
val contentAlpha = if (enabled) ContentAlpha.high else ContentAlpha.disabled
- Providers(AmbientContentAlpha provides contentAlpha, content = content)
+ Providers(LocalContentAlpha provides contentAlpha, content = content)
}
}
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt
index 7d32d81..2b5a608 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ModalBottomSheet.kt
@@ -42,7 +42,7 @@
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.SubcomposeLayout
-import androidx.compose.ui.platform.AmbientAnimationClock
+import androidx.compose.ui.platform.LocalAnimationClock
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
@@ -164,7 +164,7 @@
/**
* Create a [ModalBottomSheetState] and [remember] it against the [clock]. If a clock is not
- * specified, the default animation clock will be used, as provided by [AnimationClockAmbient].
+ * specified, the default animation clock will be used, as provided by [LocalAnimationClock].
*
* @param initialValue The initial value of the state.
* @param clock The animation clock that will be used to drive the animations.
@@ -175,7 +175,7 @@
@ExperimentalMaterialApi
fun rememberModalBottomSheetState(
initialValue: ModalBottomSheetValue,
- clock: AnimationClockObservable = AmbientAnimationClock.current,
+ clock: AnimationClockObservable = LocalAnimationClock.current,
animationSpec: AnimationSpec<Float> = SwipeableDefaults.AnimationSpec,
confirmStateChange: (ModalBottomSheetValue) -> Boolean = { true }
): ModalBottomSheetState {
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt
index 2f919c026..3d90bb6 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/OutlinedTextField.kt
@@ -75,7 +75,7 @@
* field can not be modified, however, a user can focus it and copy text from it. Read-only text
* fields are usually used to display pre-filled forms that user can not edit
* @param textStyle the style to be applied to the input text. The default [textStyle] uses the
- * [AmbientTextStyle] defined by the theme
+ * [LocalTextStyle] defined by the theme
* @param label the optional label to be displayed inside the text field container. The default
* text style for internal [Text] is [Typography.caption] when the text field is in focus and
* [Typography.subtitle1] when the text field is not in focus
@@ -125,7 +125,7 @@
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
- textStyle: TextStyle = AmbientTextStyle.current,
+ textStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
@@ -200,7 +200,7 @@
* field can not be modified, however, a user can focus it and copy text from it. Read-only text
* fields are usually used to display pre-filled forms that user can not edit
* @param textStyle the style to be applied to the input text. The default [textStyle] uses the
- * [AmbientTextStyle] defined by the theme
+ * [LocalTextStyle] defined by the theme
* @param label the optional label to be displayed inside the text field container. The default
* text style for internal [Text] is [Typography.caption] when the text field is in focus and
* [Typography.subtitle1] when the text field is not in focus
@@ -250,7 +250,7 @@
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
- textStyle: TextStyle = AmbientTextStyle.current,
+ textStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt
index 5966f96..d662254 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/ProgressIndicator.kt
@@ -41,7 +41,7 @@
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.drawscope.Stroke
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
@@ -220,7 +220,7 @@
color: Color = MaterialTheme.colors.primary,
strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth
) {
- val stroke = with(AmbientDensity.current) {
+ val stroke = with(LocalDensity.current) {
Stroke(width = strokeWidth.toPx(), cap = StrokeCap.Butt)
}
Canvas(
@@ -249,7 +249,7 @@
color: Color = MaterialTheme.colors.primary,
strokeWidth: Dp = ProgressIndicatorDefaults.StrokeWidth
) {
- val stroke = with(AmbientDensity.current) {
+ val stroke = with(LocalDensity.current) {
Stroke(width = strokeWidth.toPx(), cap = StrokeCap.Square)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
index 1569c81..1de7725 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Slider.kt
@@ -58,9 +58,9 @@
import androidx.compose.ui.graphics.PointMode
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.setProgress
import androidx.compose.ui.unit.LayoutDirection
@@ -126,7 +126,7 @@
activeTickColor: Color = MaterialTheme.colors.onPrimary.copy(alpha = TickColorAlpha),
inactiveTickColor: Color = activeTrackColor.copy(alpha = TickColorAlpha)
) {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
val position = remember(valueRange, steps) {
SliderPosition(value, valueRange, steps, clock, onValueChange)
}
@@ -135,7 +135,7 @@
BoxWithConstraints(
modifier.sliderSemantics(value, position, onValueChange, valueRange, steps)
) {
- val isRtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val maxPx = constraints.maxWidth.toFloat()
val minPx = 0f
position.setBounds(minPx, maxPx)
@@ -223,7 +223,7 @@
interactionState: InteractionState,
modifier: Modifier
) {
- val widthDp = with(AmbientDensity.current) {
+ val widthDp = with(LocalDensity.current) {
width.toDp()
}
Box(modifier.then(DefaultSliderConstraints)) {
@@ -233,7 +233,7 @@
val trackStrokeWidth: Float
val thumbPx: Float
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
trackStrokeWidth = TrackHeight.toPx()
thumbPx = ThumbRadius.toPx()
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt
index 156dcc2..d625679 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Snackbar.kt
@@ -91,7 +91,7 @@
color = backgroundColor,
contentColor = contentColor
) {
- Providers(AmbientContentAlpha provides ContentAlpha.high) {
+ Providers(LocalContentAlpha provides ContentAlpha.high) {
val textStyle = MaterialTheme.typography.body2
ProvideTextStyle(value = textStyle) {
when {
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Surface.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Surface.kt
index 0acf4fb..536e75b 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Surface.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Surface.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.graphicsLayer
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -48,9 +48,9 @@
* 3) Borders: If [shape] has a border, then it will also be drawn.
*
* 4) Background: Surface fills the shape specified by [shape] with the [color]. If [color] is
- * [Colors.surface], the [ElevationOverlay] from [AmbientElevationOverlay] will be used to apply
+ * [Colors.surface], the [ElevationOverlay] from [LocalElevationOverlay] will be used to apply
* an overlay - by default this will only occur in dark theme. The color of the overlay depends
- * on the [elevation] of this Surface, and the [AmbientAbsoluteElevation] set by any parent
+ * on the [elevation] of this Surface, and the [LocalAbsoluteElevation] set by any parent
* surfaces. This ensures that a Surface never appears to have a lower elevation overlay than its
* ancestors, by summing the elevation of all previous Surfaces.
*
@@ -68,7 +68,7 @@
* To modify these default style values used by text, use [ProvideTextStyle] or explicitly
* pass a new [TextStyle] to your text.
*
- * To manually retrieve the content color inside a surface, use [AmbientContentColor].
+ * To manually retrieve the content color inside a surface, use [LocalContentColor].
*
* @param modifier Modifier to be applied to the layout corresponding to the surface
* @param shape Defines the surface's shape as well its shadow. A shadow is only
@@ -91,9 +91,9 @@
elevation: Dp = 0.dp,
content: @Composable () -> Unit
) {
- val elevationPx = with(AmbientDensity.current) { elevation.toPx() }
- val elevationOverlay = AmbientElevationOverlay.current
- val absoluteElevation = AmbientAbsoluteElevation.current + elevation
+ val elevationPx = with(LocalDensity.current) { elevation.toPx() }
+ val elevationOverlay = LocalElevationOverlay.current
+ val absoluteElevation = LocalAbsoluteElevation.current + elevation
val backgroundColor = if (color == MaterialTheme.colors.surface && elevationOverlay != null) {
elevationOverlay.apply(color, absoluteElevation)
} else {
@@ -110,8 +110,8 @@
propagateMinConstraints = true
) {
Providers(
- AmbientContentColor provides contentColor,
- AmbientAbsoluteElevation provides absoluteElevation,
+ LocalContentColor provides contentColor,
+ LocalAbsoluteElevation provides absoluteElevation,
content = content
)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/SwipeToDismiss.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/SwipeToDismiss.kt
index a1449a4..afe8f8b 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/SwipeToDismiss.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/SwipeToDismiss.kt
@@ -37,8 +37,8 @@
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.LayoutDirection
import kotlin.math.roundToInt
@@ -169,7 +169,7 @@
initialValue: DismissValue = Default,
confirmStateChange: (DismissValue) -> Boolean = { true }
): DismissState {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
return rememberSaveable(
clock,
saver = DismissState.Saver(clock, confirmStateChange)
@@ -202,7 +202,7 @@
dismissContent: @Composable RowScope.() -> Unit
) = BoxWithConstraints(modifier) {
val width = constraints.maxWidth.toFloat()
- val isRtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
val anchors = mutableMapOf(0f to Default)
if (StartToEnd in directions) anchors += width to DismissedToEnd
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt
index 2d4f98a..0edf551 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Swipeable.kt
@@ -49,8 +49,8 @@
import androidx.compose.ui.gesture.nestedscroll.NestedScrollConnection
import androidx.compose.ui.gesture.nestedscroll.NestedScrollSource
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
-import androidx.compose.ui.platform.AmbientAnimationClock
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalAnimationClock
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
@@ -411,7 +411,7 @@
animationSpec: AnimationSpec<Float> = AnimationSpec,
confirmStateChange: (newValue: T) -> Boolean = { true }
): SwipeableState<T> {
- val clock = AmbientAnimationClock.current.asDisposableClock()
+ val clock = LocalAnimationClock.current.asDisposableClock()
return rememberSaveable(
clock,
saver = SwipeableState.Saver(
@@ -532,7 +532,7 @@
require(anchors.values.distinct().count() == anchors.size) {
"You cannot have two anchors mapped to the same state."
}
- val density = AmbientDensity.current
+ val density = LocalDensity.current
DisposableEffect(anchors) {
state.anchors = anchors
state.thresholds = { a, b ->
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
index 79e179e..13a27c6 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Switch.kt
@@ -46,8 +46,8 @@
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.graphics.drawscope.DrawScope
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.LayoutDirection
@@ -82,9 +82,9 @@
colors: SwitchColors = SwitchDefaults.colors()
) {
val minBound = 0f
- val maxBound = with(AmbientDensity.current) { ThumbPathLength.toPx() }
+ val maxBound = with(LocalDensity.current) { ThumbPathLength.toPx() }
val swipeableState = rememberSwipeableStateFor(checked, onCheckedChange, AnimationSpec)
- val isRtl = AmbientLayoutDirection.current == LayoutDirection.Rtl
+ val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
Box(
modifier
.toggleable(
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
index cc0695a..944dd2c 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/Tab.kt
@@ -93,7 +93,7 @@
text: @Composable (() -> Unit)? = null,
icon: @Composable (() -> Unit)? = null,
interactionState: InteractionState = remember { InteractionState() },
- selectedContentColor: Color = AmbientContentColor.current,
+ selectedContentColor: Color = LocalContentColor.current,
unselectedContentColor: Color = selectedContentColor.copy(alpha = ContentAlpha.medium)
) {
val styledText: @Composable (() -> Unit)? = text?.let {
@@ -145,7 +145,7 @@
modifier: Modifier = Modifier,
enabled: Boolean = true,
interactionState: InteractionState = remember { InteractionState() },
- selectedContentColor: Color = AmbientContentColor.current,
+ selectedContentColor: Color = LocalContentColor.current,
unselectedContentColor: Color = selectedContentColor.copy(alpha = ContentAlpha.medium),
content: @Composable ColumnScope.() -> Unit
) {
@@ -196,7 +196,7 @@
fun Divider(
modifier: Modifier = Modifier,
thickness: Dp = DividerThickness,
- color: Color = AmbientContentColor.current.copy(alpha = DividerOpacity)
+ color: Color = LocalContentColor.current.copy(alpha = DividerOpacity)
) {
androidx.compose.material.Divider(modifier = modifier, thickness = thickness, color = color)
}
@@ -213,7 +213,7 @@
fun Indicator(
modifier: Modifier = Modifier,
height: Dp = IndicatorHeight,
- color: Color = AmbientContentColor.current
+ color: Color = LocalContentColor.current
) {
Box(
modifier
@@ -274,7 +274,7 @@
/**
* Transition defining how the tint color for a tab animates, when a new tab is selected. This
- * component uses [AmbientContentColor] to provide an interpolated value between [activeColor]
+ * component uses [LocalContentColor] to provide an interpolated value between [activeColor]
* and [inactiveColor] depending on the animation status.
*/
@Composable
@@ -304,8 +304,8 @@
if (it) activeColor else inactiveColor
}
Providers(
- AmbientContentColor provides color.copy(alpha = 1f),
- AmbientContentAlpha provides color.alpha,
+ LocalContentColor provides color.copy(alpha = 1f),
+ LocalContentAlpha provides color.alpha,
content = content
)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt
index 055ce90..ab23f0f 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TabRow.kt
@@ -333,7 +333,7 @@
fun Divider(
modifier: Modifier = Modifier,
thickness: Dp = DividerThickness,
- color: Color = AmbientContentColor.current.copy(alpha = DividerOpacity)
+ color: Color = LocalContentColor.current.copy(alpha = DividerOpacity)
) {
androidx.compose.material.Divider(modifier = modifier, thickness = thickness, color = color)
}
@@ -350,7 +350,7 @@
fun Indicator(
modifier: Modifier = Modifier,
height: Dp = IndicatorHeight,
- color: Color = AmbientContentColor.current
+ color: Color = LocalContentColor.current
) {
Box(
modifier
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 08f19f1..32471d6 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
@@ -40,8 +40,8 @@
/**
* High level element that displays text and provides semantics / accessibility information.
*
- * The default [style] uses the [AmbientTextStyle] provided by the [MaterialTheme] / components. If
- * you are setting your own style, you may want to consider first retrieving [AmbientTextStyle],
+ * The default [style] uses the [LocalTextStyle] provided by the [MaterialTheme] / components. If
+ * you are setting your own style, you may want to consider first retrieving [LocalTextStyle],
* and using [TextStyle.copy] to keep any theme defined attributes, only modifying the specific
* attributes you want to override.
*
@@ -53,14 +53,14 @@
* from [style] will be used instead.
*
* Additionally, for [color], if [color] is not set, and [style] does not have a color, then
- * [AmbientContentColor] will be used with an alpha of [AmbientContentAlpha]- this allows this
+ * [LocalContentColor] will be used with an alpha of [LocalContentAlpha]- this allows this
* [Text] or element containing this [Text] to adapt to different background colors and still
* maintain contrast and accessibility.
*
* @param text The text to be displayed.
* @param modifier [Modifier] to apply to this layout node.
* @param color [Color] to apply to the text. If [Color.Unspecified], and [style] has no color set,
- * this will be [AmbientContentColor].
+ * this will be [LocalContentColor].
* @param fontSize The size of glyphs to use when painting the text. See [TextStyle.fontSize].
* @param fontStyle The typeface variant to use when drawing the letters (e.g., italic).
* See [TextStyle.fontStyle].
@@ -101,7 +101,7 @@
softWrap: Boolean = true,
maxLines: Int = Int.MAX_VALUE,
onTextLayout: (TextLayoutResult) -> Unit = {},
- style: TextStyle = AmbientTextStyle.current
+ style: TextStyle = LocalTextStyle.current
) {
Text(
AnnotatedString(text),
@@ -127,8 +127,8 @@
/**
* High level element that displays text and provides semantics / accessibility information.
*
- * The default [style] uses the [AmbientTextStyle] provided by the [MaterialTheme] / components. If
- * you are setting your own style, you may want to consider first retrieving [AmbientTextStyle],
+ * The default [style] uses the [LocalTextStyle] provided by the [MaterialTheme] / components. If
+ * you are setting your own style, you may want to consider first retrieving [LocalTextStyle],
* and using [TextStyle.copy] to keep any theme defined attributes, only modifying the specific
* attributes you want to override.
*
@@ -140,14 +140,14 @@
* from [style] will be used instead.
*
* Additionally, for [color], if [color] is not set, and [style] does not have a color, then
- * [AmbientContentColor] will be used with an alpha of [AmbientContentAlpha]- this allows this
+ * [LocalContentColor] will be used with an alpha of [LocalContentAlpha]- this allows this
* [Text] or element containing this [Text] to adapt to different background colors and still
* maintain contrast and accessibility.
*
* @param text The text to be displayed.
* @param modifier [Modifier] to apply to this layout node.
* @param color [Color] to apply to the text. If [Color.Unspecified], and [style] has no color set,
- * this will be [AmbientContentColor].
+ * this will be [LocalContentColor].
* @param fontSize The size of glyphs to use when painting the text. See [TextStyle.fontSize].
* @param fontStyle The typeface variant to use when drawing the letters (e.g., italic).
* See [TextStyle.fontStyle].
@@ -191,11 +191,11 @@
maxLines: Int = Int.MAX_VALUE,
inlineContent: Map<String, InlineTextContent> = mapOf(),
onTextLayout: (TextLayoutResult) -> Unit = {},
- style: TextStyle = AmbientTextStyle.current
+ style: TextStyle = LocalTextStyle.current
) {
val textColor = color.takeOrElse {
style.color.takeOrElse {
- AmbientContentColor.current.copy(alpha = AmbientContentAlpha.current)
+ LocalContentColor.current.copy(alpha = LocalContentAlpha.current)
}
}
val mergedStyle = style.merge(
@@ -248,16 +248,16 @@
*/
val LocalTextStyle = compositionLocalOf(structuralEqualityPolicy()) { TextStyle.Default }
-// TODO: b/156598010 remove this and replace with fold definition on the backing Ambient
+// TODO: b/156598010 remove this and replace with fold definition on the backing CompositionLocal
/**
- * This function is used to set the current value of [AmbientTextStyle], merging the given style
+ * This function is used to set the current value of [LocalTextStyle], merging the given style
* with the current style values for any missing attributes. Any [Text] components included in
* this component's [content] will be styled with this style unless styled explicitly.
*
- * @see AmbientTextStyle
+ * @see LocalTextStyle
*/
@Composable
fun ProvideTextStyle(value: TextStyle, content: @Composable () -> Unit) {
- val mergedStyle = AmbientTextStyle.current.merge(value)
- Providers(AmbientTextStyle provides mergedStyle, content = content)
+ val mergedStyle = LocalTextStyle.current.merge(value)
+ Providers(LocalTextStyle provides mergedStyle, content = content)
}
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
index 81a2d4e..4b0f67f 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextField.kt
@@ -102,7 +102,7 @@
* field can not be modified, however, a user can focus it and copy text from it. Read-only text
* fields are usually used to display pre-filled forms that user can not edit
* @param textStyle the style to be applied to the input text. The default [textStyle] uses the
- * [AmbientTextStyle] defined by the theme
+ * [LocalTextStyle] defined by the theme
* @param label the optional label to be displayed inside the text field container. The default
* text style for internal [Text] is [Typography.caption] when the text field is in focus and
* [Typography.subtitle1] when the text field is not in focus
@@ -154,7 +154,7 @@
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
- textStyle: TextStyle = AmbientTextStyle.current,
+ textStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
@@ -234,7 +234,7 @@
* field can not be modified, however, a user can focus it and copy text from it. Read-only text
* fields are usually used to display pre-filled forms that user can not edit
* @param textStyle the style to be applied to the input text. The default [textStyle] uses the
- * [AmbientTextStyle] defined by the theme
+ * [LocalTextStyle] defined by the theme
* @param label the optional label to be displayed inside the text field container. The default
* text style for internal [Text] is [Typography.caption] when the text field is in focus and
* [Typography.subtitle1] when the text field is not in focus
@@ -286,7 +286,7 @@
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
- textStyle: TextStyle = AmbientTextStyle.current,
+ textStyle: TextStyle = LocalTextStyle.current,
label: @Composable (() -> Unit)? = null,
placeholder: @Composable (() -> Unit)? = null,
leadingIcon: @Composable (() -> Unit)? = null,
diff --git a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
index 4dc2446..f76c448 100644
--- a/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
+++ b/compose/material/material/src/commonMain/kotlin/androidx/compose/material/TextFieldImpl.kt
@@ -96,8 +96,8 @@
// TODO(soboleva): b/171305338 provide colors object and apply alpha there instead
// If color is not provided via the text style, use content color as a default
val textColor = textStyle.color.takeOrElse {
- AmbientContentColor.current
- }.copy(alpha = if (enabled) AmbientContentAlpha.current else ContentAlpha.disabled)
+ LocalContentColor.current
+ }.copy(alpha = if (enabled) LocalContentAlpha.current else ContentAlpha.disabled)
val mergedTextStyle = textStyle.merge(TextStyle(color = textColor))
val keyboardController: Ref<SoftwareKeyboardController> = remember { Ref() }
@@ -253,15 +253,15 @@
content: @Composable () -> Unit
) {
val colorAndEmphasis = @Composable {
- Providers(AmbientContentColor provides contentColor) {
+ Providers(LocalContentColor provides contentColor) {
if (contentAlpha != null) {
Providers(
- AmbientContentAlpha provides contentAlpha,
+ LocalContentAlpha provides contentAlpha,
content = content
)
} else {
Providers(
- AmbientContentAlpha provides contentColor.alpha,
+ LocalContentAlpha provides contentColor.alpha,
content = content
)
}
diff --git a/compose/runtime/runtime-livedata/src/androidTest/java/androidx/compose/runtime/livedata/LiveDataAdapterTest.kt b/compose/runtime/runtime-livedata/src/androidTest/java/androidx/compose/runtime/livedata/LiveDataAdapterTest.kt
index 46b3d0c..f752298 100644
--- a/compose/runtime/runtime-livedata/src/androidTest/java/androidx/compose/runtime/livedata/LiveDataAdapterTest.kt
+++ b/compose/runtime/runtime-livedata/src/androidTest/java/androidx/compose/runtime/livedata/LiveDataAdapterTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import androidx.compose.ui.platform.AmbientLifecycleOwner
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
@@ -88,7 +88,7 @@
var realValue: String? = null
val lifecycleOwner = rule.runOnUiThread { RegistryOwner() }
rule.setContent {
- Providers(AmbientLifecycleOwner provides lifecycleOwner) {
+ Providers(LocalLifecycleOwner provides lifecycleOwner) {
realValue = liveData.observeAsState().value
}
}
@@ -112,7 +112,7 @@
var emit by mutableStateOf(false)
val lifecycleOwner = rule.runOnUiThread { RegistryOwner() }
rule.setContent {
- Providers(AmbientLifecycleOwner provides lifecycleOwner) {
+ Providers(LocalLifecycleOwner provides lifecycleOwner) {
if (emit) {
liveData.observeAsState()
}
@@ -138,7 +138,7 @@
var realValue: String? = null
val lifecycleOwner = rule.runOnUiThread { RegistryOwner() }
rule.setContent {
- Providers(AmbientLifecycleOwner provides lifecycleOwner) {
+ Providers(LocalLifecycleOwner provides lifecycleOwner) {
realValue = liveData.observeAsState().value
}
}
@@ -176,7 +176,7 @@
}
}
rule.setContent {
- Providers(AmbientLifecycleOwner provides lifecycleOwner) {
+ Providers(LocalLifecycleOwner provides lifecycleOwner) {
realValue = liveData.observeAsState(null).value
}
}
@@ -195,7 +195,7 @@
}
}
rule.setContent {
- Providers(AmbientLifecycleOwner provides lifecycleOwner) {
+ Providers(LocalLifecycleOwner provides lifecycleOwner) {
realValue = liveData.observeAsState().value!!
}
}
diff --git a/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt b/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt
index 33678db..456d449 100644
--- a/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt
+++ b/compose/runtime/runtime-livedata/src/main/java/androidx/compose/runtime/livedata/LiveDataAdapter.kt
@@ -21,7 +21,7 @@
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
-import androidx.compose.ui.platform.AmbientLifecycleOwner
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
@@ -53,7 +53,7 @@
*/
@Composable
fun <R, T : R> LiveData<T>.observeAsState(initial: R): State<R> {
- val lifecycleOwner = AmbientLifecycleOwner.current
+ val lifecycleOwner = LocalLifecycleOwner.current
val state = remember { mutableStateOf(initial) }
DisposableEffect(this, lifecycleOwner) {
val observer = Observer<T> { state.value = it }
diff --git a/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/BaseComposeTest.kt b/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/BaseComposeTest.kt
index 21005f4..ed0aa81 100644
--- a/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/BaseComposeTest.kt
+++ b/compose/runtime/runtime/integration-tests/src/androidAndroidTest/kotlin/androidx/compose/runtime/BaseComposeTest.kt
@@ -25,7 +25,7 @@
import androidx.activity.ComponentActivity
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.ui.node.UiApplier
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.setContent
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@@ -138,7 +138,7 @@
private fun initialComposition(composable: @Composable () -> Unit) {
activity.show {
Providers(
- AmbientContext provides activity
+ LocalContext provides activity
) {
composable()
}
diff --git a/compose/test-utils/src/commonMain/kotlin/androidx/compose/testutils/ComposeTestCase.kt b/compose/test-utils/src/commonMain/kotlin/androidx/compose/testutils/ComposeTestCase.kt
index 553fcc1..ed01647 100644
--- a/compose/test-utils/src/commonMain/kotlin/androidx/compose/testutils/ComposeTestCase.kt
+++ b/compose/test-utils/src/commonMain/kotlin/androidx/compose/testutils/ComposeTestCase.kt
@@ -54,7 +54,7 @@
/**
* This method should emit content that is supposed to be measured. Any other helper containers,
- * ambients and themes should be set in [ContentWrappers].
+ * CompositionLocals and themes should be set in [ContentWrappers].
*
* The lifecycle rules for this method are same as for [Content]
*/
@@ -66,7 +66,7 @@
*
* In "first" benchmarks this method's content is set up before the content from
* [MeasuredContent] gets introduced to be measured. This helps to avoid measuring helper
- * containers or ambients setups.
+ * containers or CompositionLocal setups.
*
* The lifecycle rules for this method are same as for [Content]
*/
diff --git a/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/StateRestorationTester.kt b/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/StateRestorationTester.kt
index e2a50bc..7602ef9 100644
--- a/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/StateRestorationTester.kt
+++ b/compose/ui/ui-test-junit4/src/androidMain/kotlin/androidx/compose/ui/test/junit4/StateRestorationTester.kt
@@ -80,7 +80,7 @@
private fun InjectRestorationRegistry(content: @Composable (RestorationRegistry) -> Unit) {
val original = requireNotNull(LocalSaveableStateRegistry.current) {
"StateRestorationTester requires composeTestRule.setContent() to provide " +
- "an SaveableStateRegistry implementation via LocalSaveableStateRegistry"
+ "a SaveableStateRegistry implementation via LocalSaveableStateRegistry"
}
val restorationRegistry = remember { RestorationRegistry(original) }
Providers(LocalSaveableStateRegistry provides restorationRegistry) {
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt
index 830cce9..febc6ad 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/LayoutCoordinatesHelperTest.kt
@@ -25,7 +25,7 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.unit.dp
import androidx.test.filters.MediumTest
@@ -81,7 +81,7 @@
var parentCoordinates: LayoutCoordinates? = null
var childCoordinates: LayoutCoordinates? = null
rule.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(Modifier.preferredWidth(40.toDp()), contentAlignment = Alignment.Center) {
Column(
Modifier.preferredWidth(20.toDp())
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt
index 694fdb9..3566122 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/ScrollToTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.scrollBy
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Constraints
@@ -83,7 +83,7 @@
columnHeight: Int,
content: @Composable () -> Unit
) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Layout(
content,
modifier.size(crossAxisSize.toDp(), columnHeight.toDp()),
@@ -99,7 +99,7 @@
rowWidth: Int,
content: @Composable () -> Unit
) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Layout(
content,
modifier.size(rowWidth.toDp(), crossAxisSize.toDp()),
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt
index 6450e46..fdd652e 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/PositionsTest.kt
@@ -24,7 +24,7 @@
import androidx.compose.foundation.verticalScroll
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.bottom
import androidx.compose.ui.test.bottomCenter
@@ -123,7 +123,7 @@
private fun testPositionsInViewport(isVertical: Boolean, reverseScrollDirection: Boolean) {
rule.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
if (isVertical) {
Column(
Modifier.size(100.toDp())
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt
index 312c1ca..5986aaa 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/gesturescope/SendSwipeTest.kt
@@ -31,8 +31,8 @@
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientViewConfiguration
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.ViewConfiguration
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.bottomCenter
@@ -172,8 +172,8 @@
animationClock = MockAnimationClock()
)
rule.setContent {
- Providers(AmbientViewConfiguration provides FakeViewConfiguration) {
- with(AmbientDensity.current) {
+ Providers(LocalViewConfiguration provides FakeViewConfiguration) {
+ with(LocalDensity.current) {
// Scrollable with a viewport the size of 10 boxes
Column(
Modifier
diff --git a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt
index 93c724e..eb655d8 100644
--- a/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt
+++ b/compose/ui/ui-test/src/androidAndroidTest/kotlin/androidx/compose/ui/test/util/ClickableTestBox.kt
@@ -22,7 +22,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.util.ClickableTestBox.defaultColor
import androidx.compose.ui.test.util.ClickableTestBox.defaultSize
@@ -42,7 +42,7 @@
color: Color = defaultColor,
tag: String = defaultTag
) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
modifier = modifier.testTag(tag).size(width.toDp(), height.toDp()).background(color)
)
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt
index aec5e08..b222896 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/BoundsTest.kt
@@ -28,7 +28,7 @@
import androidx.compose.runtime.resetSourceInfo
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -138,7 +138,7 @@
Inspectable(slotTableRecord) {
key(value) {
BoxWithConstraints {
- requireNotNull(AmbientDensity.current)
+ requireNotNull(LocalDensity.current)
Text("Hello")
}
}
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/ModifierInfoTest.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/ModifierInfoTest.kt
index 51b3d3a..eabdb59 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/ModifierInfoTest.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/ModifierInfoTest.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.layout.LayoutModifier
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.node.OwnedLayer
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import org.junit.Assert.assertEquals
@@ -47,7 +47,7 @@
val slotTableRecord = CompositionDataRecord.create()
show {
Inspectable(slotTableRecord) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
val px10 = 10f.toDp()
val px5 = 5f.toDp()
Box {
diff --git a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/SimpleComposablePreview.kt b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/SimpleComposablePreview.kt
index 34f29e8..679b4a1 100644
--- a/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/SimpleComposablePreview.kt
+++ b/compose/ui/ui-tooling/src/androidTest/java/androidx/compose/ui/tooling/SimpleComposablePreview.kt
@@ -21,7 +21,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.saveable.LocalSaveableStateRegistry
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientLifecycleOwner
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.Lifecycle
@@ -70,7 +70,7 @@
@Preview
@Composable
private fun LifecyclePreview() {
- val lifecycleState = AmbientLifecycleOwner.current.lifecycle.currentState
+ val lifecycleState = LocalLifecycleOwner.current.lifecycle.currentState
if (lifecycleState != Lifecycle.State.RESUMED) throw IllegalArgumentException(
"Lifecycle state is not resumed. $lifecycleState"
)
diff --git a/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/Inspectable.kt b/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/Inspectable.kt
index 40e1889..94dba74 100644
--- a/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/Inspectable.kt
+++ b/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/Inspectable.kt
@@ -22,7 +22,7 @@
import androidx.compose.runtime.Providers
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.tooling.LocalInspectionTables
-import androidx.compose.ui.platform.InspectionMode
+import androidx.compose.ui.platform.LocalInspectionMode
import java.util.Collections
import java.util.WeakHashMap
@@ -62,7 +62,7 @@
val store = (compositionDataRecord as CompositionDataRecordImpl).store
store.add(currentComposer.compositionData)
Providers(
- InspectionMode provides true,
+ LocalInspectionMode provides true,
LocalInspectionTables provides store,
content = content
)
@@ -74,7 +74,7 @@
*/
@Composable
fun InInspectionModeOnly(content: @Composable () -> Unit) {
- if (InspectionMode.current) {
+ if (LocalInspectionMode.current) {
content()
}
}
diff --git a/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt b/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt
index 92237c6..fea9ba0 100644
--- a/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt
+++ b/compose/ui/ui-tooling/src/main/java/androidx/compose/ui/tooling/preview/ComposeViewAdapter.kt
@@ -37,8 +37,8 @@
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
-import androidx.compose.ui.platform.AmbientFontLoader
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalFontLoader
import androidx.compose.ui.platform.ViewRootForTest
import androidx.compose.ui.tooling.CompositionDataRecord
import androidx.compose.ui.tooling.Group
@@ -384,7 +384,7 @@
// We need to replace the FontResourceLoader to avoid using ResourcesCompat.
// ResourcesCompat can not load fonts within Layoutlib and, since Layoutlib always runs
// the latest version, we do not need it.
- Providers(AmbientFontLoader provides LayoutlibFontResourceLoader(context)) {
+ Providers(LocalFontLoader provides LayoutlibFontResourceLoader(context)) {
Inspectable(slotTableRecord, content)
}
}
diff --git a/compose/ui/ui-unit/samples/src/main/java/androidx/compose/ui/unit/samples/DensitySample.kt b/compose/ui/ui-unit/samples/src/main/java/androidx/compose/ui/unit/samples/DensitySample.kt
index 983599c..801540d 100644
--- a/compose/ui/ui-unit/samples/src/main/java/androidx/compose/ui/unit/samples/DensitySample.kt
+++ b/compose/ui/ui-unit/samples/src/main/java/androidx/compose/ui/unit/samples/DensitySample.kt
@@ -18,12 +18,12 @@
import androidx.annotation.Sampled
import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
@Sampled
@Composable
@Suppress("UNUSED_VARIABLE")
fun WithDensitySample() {
- val sizeInPx = with(AmbientDensity.current) { 16.dp.toPx() }
+ val sizeInPx = with(LocalDensity.current) { 16.dp.toPx() }
}
diff --git a/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt b/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt
index c7b8e9e..2138973 100644
--- a/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt
+++ b/compose/ui/ui-viewbinding/src/androidTest/java/androidx/compose/ui/viewinterop/AndroidViewBindingTest.kt
@@ -25,7 +25,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createComposeRule
@@ -94,7 +94,7 @@
val size = 50.dp
val density = Density(3f)
val sizeIpx = with(density) { size.toIntPx() }
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
AndroidViewBinding(
TestLayoutBinding::inflate,
Modifier.size(size).onGloballyPositioned {
diff --git a/compose/ui/ui-viewbinding/src/main/java/androidx/compose/ui/viewinterop/AndroidViewBinding.kt b/compose/ui/ui-viewbinding/src/main/java/androidx/compose/ui/viewinterop/AndroidViewBinding.kt
index 508137c..59bd320 100644
--- a/compose/ui/ui-viewbinding/src/main/java/androidx/compose/ui/viewinterop/AndroidViewBinding.kt
+++ b/compose/ui/ui-viewbinding/src/main/java/androidx/compose/ui/viewinterop/AndroidViewBinding.kt
@@ -26,8 +26,8 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.materialize
import androidx.compose.ui.node.UiApplier
-import androidx.compose.ui.platform.AmbientContext
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
import androidx.viewbinding.ViewBinding
/**
@@ -53,9 +53,9 @@
modifier: Modifier = Modifier,
update: T.() -> Unit = {}
) {
- val context = AmbientContext.current
+ val context = LocalContext.current
val materialized = currentComposer.materialize(modifier)
- val density = AmbientDensity.current
+ val density = LocalDensity.current
ComposeNode<ViewBindingHolder<T>, UiApplier>(
factory = { ViewBindingHolder<T>(context).also { it.bindingBlock = bindingBlock } },
update = {
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt
index 9ec65f5..628069c 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/autofill/ExplicitAutofillTypesDemo.kt
@@ -39,8 +39,8 @@
import androidx.compose.ui.graphics.toComposeRect
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientAutofill
-import androidx.compose.ui.platform.AmbientAutofillTree
+import androidx.compose.ui.platform.LocalAutofill
+import androidx.compose.ui.platform.LocalAutofillTree
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
@@ -51,7 +51,7 @@
Column {
val nameState = remember { mutableStateOf("Enter name here") }
val emailState = remember { mutableStateOf("Enter email here") }
- val autofill = AmbientAutofill.current
+ val autofill = LocalAutofill.current
val labelStyle = MaterialTheme.typography.subtitle1
val textStyle = MaterialTheme.typography.h6
@@ -118,7 +118,7 @@
) {
val autofillNode = AutofillNode( autofillTypes = autofillTypes)
- val autofillTree = AmbientAutofillTree.current
+ val autofillTree = LocalAutofillTree.current
autofillTree += autofillNode
Box(
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt
index b871bfd..7c17291 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInDialogDemo.kt
@@ -31,7 +31,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color.Companion.LightGray
import androidx.compose.ui.graphics.Color.Companion.White
-import androidx.compose.ui.platform.AmbientWindowInfo
+import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
@@ -41,7 +41,7 @@
var showDialog by remember { mutableStateOf(false) }
var mainText by remember { mutableStateOf(TextFieldValue("Enter Value")) }
var dialogText by remember { mutableStateOf(TextFieldValue("Enter Value")) }
- val windowInfo = AmbientWindowInfo.current
+ val windowInfo = LocalWindowInfo.current
Column(Modifier.background(if (windowInfo.isWindowFocused) White else LightGray)) {
Text("Click the button to show the dialog. Click outside the dialog to dismiss it.")
@@ -70,6 +70,6 @@
@Composable
private fun FocusStatus() {
- val windowInfo = AmbientWindowInfo.current
+ val windowInfo = LocalWindowInfo.current
Text("Status: Window ${if (windowInfo.isWindowFocused) "is" else "is not"} focused.")
}
\ No newline at end of file
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt
index a48d3d7..2388878 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusInPopupDemo.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color.Companion.LightGray
import androidx.compose.ui.graphics.Color.Companion.White
-import androidx.compose.ui.platform.AmbientWindowInfo
+import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Popup
@@ -42,7 +42,7 @@
var showPopup by remember { mutableStateOf(false) }
var mainText by remember { mutableStateOf(TextFieldValue("Enter Value")) }
var popupText by remember { mutableStateOf(TextFieldValue("Enter Value")) }
- val windowInfo = AmbientWindowInfo.current
+ val windowInfo = LocalWindowInfo.current
Column(Modifier.background(if (windowInfo.isWindowFocused) White else LightGray)) {
Text("Click the button to show the popup. Click outside the popup to dismiss it.")
@@ -75,6 +75,6 @@
@Composable
private fun FocusStatus() {
- val windowInfo = AmbientWindowInfo.current
+ val windowInfo = LocalWindowInfo.current
Text("Status: Window ${if (windowInfo.isWindowFocused) "is" else "is not"} focused.")
}
\ No newline at end of file
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt
index 2d02b59..3d721f2 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/focus/FocusManagerMoveFocusDemo.kt
@@ -51,7 +51,7 @@
import androidx.compose.ui.graphics.Color.Companion.Black
import androidx.compose.ui.graphics.Color.Companion.Green
import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.ui.platform.AmbientFocusManager
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -59,7 +59,7 @@
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun FocusManagerMoveFocusDemo() {
- val focusManager = AmbientFocusManager.current
+ val focusManager = LocalFocusManager.current
Column {
Text(
text = "Use the buttons to move focus",
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt
index e1bacaf..f75c9bc 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/DragScaleGestureDetectorDemo.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerInput
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
/**
@@ -44,7 +44,7 @@
val offset = remember { mutableStateOf(Offset.Zero) }
val (offsetX, offsetY) =
- with(AmbientDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
+ with(LocalDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
Column {
Text("Demonstrates combining dragging with scaling.")
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt
index 8410b39..d6ba962 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/LongPressDragGestureDetectorDemo.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.gesture.LongPressDragObserver
import androidx.compose.ui.gesture.longPressDragGestureFilter
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
/**
@@ -67,7 +67,7 @@
}
val (offsetX, offsetY) =
- with(AmbientDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
+ with(LocalDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
Column {
Text("Demonstrates dragging that only begins once a long press has occurred!")
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt
index 52197f7..d9fd67b 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/RawDragGestureDetectorDemo.kt
@@ -32,7 +32,7 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.gesture.DragObserver
import androidx.compose.ui.gesture.rawDragGestureFilter
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
/**
@@ -50,7 +50,7 @@
}
val (offsetX, offsetY) =
- with(AmbientDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
+ with(LocalDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
Column {
Text("Demonstrates dragging that starts immediately (no slop or anything else).")
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
index e63b42f..c49fd8f 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/ScrollGestureFilterDemo.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.gesture.scrollGestureFilter
import androidx.compose.ui.gesture.scrollorientationlocking.Orientation
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -70,7 +70,7 @@
val color = remember { mutableStateOf(idleColor) }
val offsetPx = remember { mutableStateOf(0f) }
- val offsetDp = with(AmbientDensity.current) {
+ val offsetDp = with(LocalDensity.current) {
offsetPx.value.toDp()
}
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt
index 3a9635c..e5f74fa 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/TouchSlopDragGestureDetectorDemo.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.gesture.DragObserver
import androidx.compose.ui.gesture.dragGestureFilter
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
/**
@@ -105,7 +105,7 @@
}
val (offsetX, offsetY) =
- with(AmbientDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
+ with(LocalDensity.current) { offset.value.x.toDp() to offset.value.y.toDp() }
Column {
Text(
diff --git a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt
index 2ae219a..96222e02 100644
--- a/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt
+++ b/compose/ui/ui/integration-tests/ui-demos/src/main/java/androidx/compose/ui/demos/gestures/VerticalScrollerInDrawerLayoutDemo.kt
@@ -47,7 +47,7 @@
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.IntOffset
@@ -81,7 +81,7 @@
private fun DrawerLayout(drawerWidth: Dp, content: @Composable ColumnScope.() -> Unit) {
val minOffset =
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
-drawerWidth.toPx()
}
diff --git a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt
index 5500315..a21be08d 100644
--- a/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt
+++ b/compose/ui/ui/samples/src/main/java/androidx/compose/ui/samples/AndroidViewSample.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.graphics.nativeCanvas
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat
@@ -56,7 +56,7 @@
@Sampled
@Composable
fun AndroidDrawableInDrawScopeSample() {
- val drawable = ContextCompat.getDrawable(AmbientContext.current, R.drawable.sample_drawable)
+ val drawable = ContextCompat.getDrawable(LocalContext.current, R.drawable.sample_drawable)
Box(
modifier = Modifier.size(100.dp)
.drawBehind {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt
index 9a187f8..775a03d 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AccessibilityIteratorsTest.kt
@@ -26,7 +26,7 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.AccessibilityIterators
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
@@ -426,8 +426,8 @@
): TextLayoutResult {
var textLayoutResult: TextLayoutResult? = null
rule.setContent {
- // TODO(yingleiw): use predefined DensityAmbient.current when b/163142237 is fixed.
- with(AmbientDensity.current) {
+ // TODO(yingleiw): use predefined LocalDensity.current when b/163142237 is fixed.
+ with(LocalDensity.current) {
BasicText(
style = TextStyle(
fontSize = fontSize,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
index d503b0f..348e85d 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidComposeViewAccessibilityDelegateCompatTest.kt
@@ -25,9 +25,9 @@
import androidx.activity.ComponentActivity
import androidx.compose.ui.node.InnerPlaceable
import androidx.compose.ui.node.LayoutNode
-import androidx.compose.ui.platform.AmbientClipboardManager
import androidx.compose.ui.platform.AndroidComposeView
import androidx.compose.ui.platform.AndroidComposeViewAccessibilityDelegateCompat
+import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.semantics.ProgressBarRangeInfo
import androidx.compose.ui.semantics.ScrollAxisRange
import androidx.compose.ui.semantics.SemanticsModifierCore
@@ -112,7 +112,7 @@
accessibilityDelegate.accessibilityForceEnabledForTesting = true
}
rule.setContent {
- AmbientClipboardManager.current.setText(AnnotatedString("test"))
+ LocalClipboardManager.current.setText(AnnotatedString("test"))
}
info = AccessibilityNodeInfoCompat.obtain()
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
index 4eca29f..2063bff 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/AndroidLayoutDrawTest.kt
@@ -82,11 +82,11 @@
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.node.Owner
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.AndroidComposeView
import androidx.compose.ui.platform.AndroidOwnerExtraAssertionsRule
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.RenderNodeApi23
import androidx.compose.ui.platform.RenderNodeApi29
import androidx.compose.ui.platform.ViewCompositionStrategy
@@ -1999,7 +1999,7 @@
val layoutDirection = Ref<LayoutDirection>()
activityTestRule.runOnUiThreadIR {
activity.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
FixedSize(
size = 50,
modifier = Modifier.drawBehind {
@@ -2032,7 +2032,7 @@
}
activityTestRule.runOnUiThreadIR {
activity.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
FixedSize(
size = 50,
modifier = layoutModifier
@@ -2820,7 +2820,7 @@
var zIndex by mutableStateOf(0f)
activityTestRule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
FixedSize(
size = 30,
modifier = Modifier.background(color = Color.Blue).drawLatchModifier()
@@ -3044,7 +3044,7 @@
ViewCompositionStrategy.DisposeOnLifecycleDestroyed(activity)
)
view.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier
.background(Color.Blue)
@@ -3088,7 +3088,7 @@
activityTestRule.runOnUiThread {
view = ComposeView(activity)
view.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier
.background(Color.Blue)
@@ -3346,7 +3346,7 @@
activity.setContent {
FixedSize(30, Modifier.background(Color.Blue)) {
FixedSize(30, Modifier.graphicsLayer()) {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Canvas(Modifier.size(10.toDp())) {
drawRect(color)
drawLatch.countDown()
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/autofill/AndroidAutoFillTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/autofill/AndroidAutoFillTest.kt
index 8119ae9..ecc7b203 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/autofill/AndroidAutoFillTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/autofill/AndroidAutoFillTest.kt
@@ -24,9 +24,9 @@
import androidx.compose.testutils.fake.FakeViewStructure
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.geometry.Rect
-import androidx.compose.ui.platform.AmbientAutofill
-import androidx.compose.ui.platform.AmbientAutofillTree
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalAutofill
+import androidx.compose.ui.platform.LocalAutofillTree
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
@@ -51,27 +51,27 @@
@Before
fun setup() {
rule.setContent {
- ownerView = AmbientView.current
- autofill = AmbientAutofill.current
- autofillTree = AmbientAutofillTree.current
+ ownerView = LocalView.current
+ autofill = LocalAutofill.current
+ autofillTree = LocalAutofillTree.current
}
}
@SdkSuppress(maxSdkVersion = 25)
@Test
- fun autofillAmbient_belowApi26_isNull() {
+ fun autofillCompositionLocal_belowApi26_isNull() {
assertThat(autofill).isNull()
}
@SdkSuppress(minSdkVersion = 26)
@Test
- fun autofillAmbient_isNotNull() {
+ fun autofillCompositionLocal_isNotNull() {
assertThat(autofill).isNotNull()
}
@SdkSuppress(minSdkVersion = 26)
@Test
- fun autofillAmbient_returnsAnInstanceOfAndroidAutofill() {
+ fun autofillCompositionLocal_returnsAnInstanceOfAndroidAutofill() {
assertThat(autofill).isInstanceOf(AndroidAutofill::class.java)
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ClipDrawTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ClipDrawTest.kt
index b27892f..ea70e78 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ClipDrawTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ClipDrawTest.kt
@@ -40,7 +40,7 @@
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.padding
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.runOnUiThreadIR
import androidx.compose.ui.test.TestActivity
@@ -485,7 +485,7 @@
rule.runOnUiThreadIR {
activity.setContent {
- Providers(AmbientLayoutDirection provides direction.value) {
+ Providers(LocalLayoutDirection provides direction.value) {
AtLeastSize(
size = 30,
modifier = Modifier.fillColor(Color.Green)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawModifierTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawModifierTest.kt
index ea680c0..fc75a60 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawModifierTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/DrawModifierTest.kt
@@ -33,8 +33,8 @@
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.toArgb
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.SemanticsNodeInteraction
@@ -275,7 +275,7 @@
var layoutDirection by mutableStateOf(LayoutDirection.Ltr)
var realLayoutDirection: LayoutDirection? = null
rule.setContent {
- Providers(AmbientLayoutDirection provides layoutDirection) {
+ Providers(LocalLayoutDirection provides layoutDirection) {
AtLeastSize(
size = 10,
modifier = Modifier.drawWithCache {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt
index e330766..919897f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/GraphicsLayerTest.kt
@@ -46,7 +46,7 @@
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.layout.positionInWindow
import androidx.compose.ui.padding
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.captureToImage
@@ -298,7 +298,7 @@
var coords1: LayoutCoordinates? = null
var coords2: LayoutCoordinates? = null
rule.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.size(25.toDp())
.graphicsLayer(
@@ -460,7 +460,7 @@
var testDpConversion = 0f
var testFontScaleConversion = 0f
rule.setContent {
- density = AmbientDensity.current
+ density = LocalDensity.current
// Verify that the current density is passed to the graphics layer
// implementation and that density dependent methods are consuming it
Box(
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt
index 381020a..b33c285 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/PainterModifierTest.kt
@@ -60,9 +60,9 @@
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasureResult
import androidx.compose.ui.layout.MeasureScope
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.testTag
@@ -494,8 +494,8 @@
var composableWidth = 0f
var composableHeight = 0f
rule.setContent {
- composableWidth = composableWidthPx / AmbientDensity.current.density
- composableHeight = composableHeightPx / AmbientDensity.current.density
+ composableWidth = composableWidthPx / LocalDensity.current.density
+ composableHeight = composableHeightPx / LocalDensity.current.density
// Because the painter is told to fit inside the constraints, the width should
// match that of the provided fixed width and the height should match that of the
// composable as no scaling is being done
@@ -540,8 +540,8 @@
modifier = Modifier
.testTag(testTag)
.background(color = Color.Gray)
- .width((boxWidth / AmbientDensity.current.density).dp)
- .height((boxHeight / AmbientDensity.current.density).dp)
+ .width((boxWidth / LocalDensity.current.density).dp)
+ .height((boxHeight / LocalDensity.current.density).dp)
.paint(ImagePainter(srcImage), contentScale = ContentScale.FillHeight)
)
}
@@ -585,8 +585,8 @@
modifier = Modifier
.testTag(testTag)
.background(color = Color.Gray)
- .width((boxWidth / AmbientDensity.current.density).dp)
- .height((boxHeight / AmbientDensity.current.density).dp)
+ .width((boxWidth / LocalDensity.current.density).dp)
+ .height((boxHeight / LocalDensity.current.density).dp)
.paint(ImagePainter(srcImage), contentScale = ContentScale.FillBounds)
)
}
@@ -608,12 +608,12 @@
val vectorWidth = 100
val vectorHeight = 200
rule.setContent {
- val vectorWidthDp = (vectorWidth / AmbientDensity.current.density).dp
- val vectorHeightDp = (vectorHeight / AmbientDensity.current.density).dp
+ val vectorWidthDp = (vectorWidth / LocalDensity.current.density).dp
+ val vectorHeightDp = (vectorHeight / LocalDensity.current.density).dp
Box(
modifier = Modifier.background(color = Color.Gray)
- .width((boxWidth / AmbientDensity.current.density).dp)
- .height((boxHeight / AmbientDensity.current.density).dp)
+ .width((boxWidth / LocalDensity.current.density).dp)
+ .height((boxHeight / LocalDensity.current.density).dp)
.paint(
rememberVectorPainter(
defaultWidth = vectorWidthDp,
@@ -679,7 +679,7 @@
) {
val p = TestPainter(containerWidth, containerHeight)
val layoutDirection = if (rtl) LayoutDirection.Rtl else LayoutDirection.Ltr
- Providers(AmbientLayoutDirection provides layoutDirection) {
+ Providers(LocalLayoutDirection provides layoutDirection) {
AtLeastSize(
modifier = Modifier.background(Color.White)
.paint(p, alpha = alpha, colorFilter = colorFilter),
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ShadowTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ShadowTest.kt
index 65d53ce..3419f1a 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ShadowTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/draw/ShadowTest.kt
@@ -31,8 +31,8 @@
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.graphics.graphicsLayer
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.InspectableValue
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.ValueElement
import androidx.compose.ui.platform.isDebugInspectorInfoEnabled
import androidx.compose.ui.platform.setContent
@@ -168,7 +168,7 @@
rule.runOnUiThreadIR {
activity.setContent {
AtLeastSize(size = 12, modifier = Modifier.background(Color.White)) {
- val elevation = with(AmbientDensity.current) { 4.dp.toPx() }
+ val elevation = with(LocalDensity.current) { 4.dp.toPx() }
AtLeastSize(
size = 10,
modifier = Modifier.graphicsLayer(
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/CustomFocusTraversalTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/CustomFocusTraversalTest.kt
index 8bf3664..57e720e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/CustomFocusTraversalTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/CustomFocusTraversalTest.kt
@@ -31,7 +31,7 @@
import androidx.compose.ui.input.key.Key.Companion.DirectionRight
import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.nativeKeyCode
-import androidx.compose.ui.platform.AmbientFocusManager
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performKeyPress
@@ -64,7 +64,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(
Modifier
@@ -111,7 +111,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(
Modifier
@@ -159,7 +159,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Column {
Box(
Modifier
@@ -207,7 +207,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Column {
Box(
Modifier
@@ -255,7 +255,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(
Modifier
@@ -303,7 +303,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(
Modifier
@@ -342,7 +342,7 @@
}
}
- // TODO(b/176847718): Verify that this test works correctly when the AmbientLayoutDirection
+ // TODO(b/176847718): Verify that this test works correctly when the LocalLayoutDirection
// changes.
@Test
fun focusOrder_start() {
@@ -353,7 +353,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(
Modifier
@@ -392,7 +392,7 @@
}
}
- // TODO(b/176847718): Verify that this test works correctly when the AmbientLayoutDirection
+ // TODO(b/176847718): Verify that this test works correctly when the LocalLayoutDirection
// changes.
@Test
fun focusOrder_end() {
@@ -403,7 +403,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(
Modifier
@@ -452,7 +452,7 @@
val (item1, item3, item4) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(Modifier.focusOrder { next = item4 }) {
Box(
@@ -508,7 +508,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(Modifier.focusOrder { next = FocusRequester.Default }) {
Box(
@@ -559,7 +559,7 @@
val (item1, item3) = FocusRequester.createRefs()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Row {
Box(Modifier.focusOrder { }) {
Box(
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusChangedCountTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusChangedCountTest.kt
index 0ac562c..61f5624 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusChangedCountTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusChangedCountTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusState.Inactive
import androidx.compose.ui.focus.FocusState.Active
-import androidx.compose.ui.platform.AmbientFocusManager
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -122,7 +122,7 @@
val focusRequester = FocusRequester()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Box(
modifier = Modifier
.onFocusChanged { focusStates.add(it) }
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusEventCountTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusEventCountTest.kt
index a141dbf..a1ee37e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusEventCountTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusEventCountTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusState.Inactive
import androidx.compose.ui.focus.FocusState.Active
-import androidx.compose.ui.platform.AmbientFocusManager
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -128,7 +128,7 @@
val focusRequester = FocusRequester()
lateinit var focusManager: FocusManager
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
Box(
modifier = Modifier
.onFocusEvent { focusStates.add(it) }
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusManagerAmbientTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusManagerCompositionLocalTest.kt
similarity index 94%
rename from compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusManagerAmbientTest.kt
rename to compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusManagerCompositionLocalTest.kt
index befabec..da8e12d 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusManagerAmbientTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusManagerCompositionLocalTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.ui.focus.FocusState.Active
import androidx.compose.ui.focus.FocusState.ActiveParent
import androidx.compose.ui.focus.FocusState.Inactive
-import androidx.compose.ui.platform.AmbientFocusManager
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -32,7 +32,7 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
-class FocusManagerAmbientTest {
+class FocusManagerCompositionLocalTest {
@get:Rule
val rule = createComposeRule()
@@ -43,7 +43,7 @@
lateinit var focusRequester: FocusRequester
var focusState = Inactive
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
focusRequester = FocusRequester()
Box(
modifier = Modifier
@@ -73,7 +73,7 @@
var parentFocusState = Inactive
var grandparentFocusState = Inactive
rule.setFocusableContent {
- focusManager = AmbientFocusManager.current
+ focusManager = LocalFocusManager.current
focusRequester = FocusRequester()
Box(
modifier = Modifier
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusRequesterTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusRequesterTest.kt
index f88d22f..2817d61 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusRequesterTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/FocusRequesterTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusState.Active
import androidx.compose.ui.focus.FocusState.Inactive
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -259,7 +259,7 @@
var focusState = Inactive
val (focusRequester1, focusRequester2) = FocusRequester.createRefs()
rule.setFocusableContent {
- hostView = AmbientView.current
+ hostView = LocalView.current
Column(
modifier = Modifier.onFocusChanged { focusState = it }
) {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/OwnerFocusTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/OwnerFocusTest.kt
index 8a8ff4f..b171637 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/OwnerFocusTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/focus/OwnerFocusTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusState.Active
import androidx.compose.ui.focus.FocusState.Inactive
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
@@ -46,7 +46,7 @@
lateinit var ownerView: View
val focusRequester = FocusRequester()
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(
modifier = Modifier
.focusRequester(focusRequester)
@@ -73,7 +73,7 @@
var focusState = Inactive
val focusRequester = FocusRequester()
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(
modifier = Modifier
.onFocusChanged { focusState = it }
@@ -101,7 +101,7 @@
var focusState = Inactive
val focusRequester = FocusRequester()
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(
modifier = Modifier
.onFocusChanged { focusState = it }
@@ -128,7 +128,7 @@
var focusState = Inactive
val focusRequester = FocusRequester()
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(
modifier = Modifier
.onFocusChanged { focusState = it }
@@ -158,7 +158,7 @@
var focusState = Inactive
val focusRequester = FocusRequester()
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(
modifier = Modifier
.onFocusChanged { focusState = it }
@@ -188,7 +188,7 @@
var didViewFocusChange = false
lateinit var ownerView: View
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(Modifier.testTag(nonClickable))
}
rule.runOnIdle {
@@ -218,7 +218,7 @@
var didViewFocusChange = false
lateinit var ownerView: View
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(Modifier.testTag(nonClickable))
}
rule.runOnIdle { assertThat(ownerView.isFocused).isFalse() }
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/TouchSlopDragGestureFilterTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/TouchSlopDragGestureFilterTest.kt
index 6c82d04..573343a 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/TouchSlopDragGestureFilterTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/gesture/TouchSlopDragGestureFilterTest.kt
@@ -22,7 +22,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.test.TestActivity
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -265,7 +265,7 @@
activityTestRule.runOnUiThreadIR {
activity.setContent {
Box {
- touchSlop = with(AmbientDensity.current) { TouchSlop.toPx() }
+ touchSlop = with(LocalDensity.current) { TouchSlop.toPx() }
Layout(
modifier = Modifier.dragGestureFilter(
dragObserver,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorInvalidationTestCase.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorInvalidationTestCase.kt
index 39fc20b..126ab5e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorInvalidationTestCase.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorInvalidationTestCase.kt
@@ -25,7 +25,7 @@
import androidx.compose.ui.draw.paint
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.loadVectorResource
import androidx.compose.ui.test.R
@@ -48,7 +48,7 @@
vectorState = state
val imageVector = loadVectorResource(state.value)
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
imageVector.resource.resource?.let {
val width = it.defaultWidth
vectorSize = width.toIntPx()
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
index 3847526..3bb8f81 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/graphics/vector/VectorTest.kt
@@ -39,7 +39,7 @@
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.ContentScale
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.createComposeRule
@@ -326,7 +326,7 @@
tintColor: Color = Color.Unspecified
): VectorPainter {
val sizePx = size.toFloat()
- val sizeDp = (size / AmbientDensity.current.density).dp
+ val sizeDp = (size / LocalDensity.current.density).dp
return rememberVectorPainter(
defaultWidth = sizeDp,
defaultHeight = sizeDp,
@@ -352,7 +352,7 @@
alignment: Alignment = Alignment.Center
) {
val sizePx = size.toFloat()
- val sizeDp = (size / AmbientDensity.current.density).dp
+ val sizeDp = (size / LocalDensity.current.density).dp
val background = Modifier.paint(
rememberVectorPainter(
defaultWidth = sizeDp,
@@ -405,7 +405,7 @@
alignment: Alignment = Alignment.Center
) {
val sizePx = size.toFloat()
- val sizeDp = (size / AmbientDensity.current.density).dp
+ val sizeDp = (size / LocalDensity.current.density).dp
val background = Modifier.paint(
rememberVectorPainter(
defaultWidth = sizeDp,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/key/AndroidProcessKeyInputTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/key/AndroidProcessKeyInputTest.kt
index 91f9ae1..750100f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/key/AndroidProcessKeyInputTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/key/AndroidProcessKeyInputTest.kt
@@ -29,7 +29,7 @@
import androidx.compose.ui.input.key.Key.Companion.A
import androidx.compose.ui.input.key.KeyEventType.KeyDown
import androidx.compose.ui.input.key.KeyEventType.KeyUp
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
@@ -62,7 +62,7 @@
var receivedKeyEvent: KeyEvent? = null
val focusRequester = FocusRequester()
rule.setFocusableContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
Box(
modifier = Modifier
.focusRequester(focusRequester)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt
index 3d6a2c6..6614cf7 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/ClipPointerInputTest.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.gesture.PointerCoords
import androidx.compose.ui.gesture.PointerProperties
import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.runOnUiThreadIR
import androidx.compose.ui.test.TestActivity
@@ -223,7 +223,7 @@
rule.runOnUiThreadIR {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
val children = @Composable {
Child(Modifier.offset((-1f).toDp(), (-1f).toDp()).then(loggingPim1))
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
index d492eac..e8cce0f 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/LayerTouchTransformTest.kt
@@ -34,7 +34,7 @@
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.layout.Layout
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.down
@@ -87,11 +87,11 @@
val latchDrawModifier = Modifier.drawBehind { latch?.countDown() }
- val containerDp = (200.0f / AmbientDensity.current.density).dp
- val boxDp = (50.0f / AmbientDensity.current.density).dp
+ val containerDp = (200.0f / LocalDensity.current.density).dp
+ val boxDp = (50.0f / LocalDensity.current.density).dp
- val offsetX = (270.0f / AmbientDensity.current.density).dp
- val offsetY = (120.0f / AmbientDensity.current.density).dp
+ val offsetX = (270.0f / LocalDensity.current.density).dp
+ val offsetY = (120.0f / LocalDensity.current.density).dp
Box(Modifier.testTag(testTag)) {
SimpleLayout(
modifier = Modifier.fillMaxSize().offset(offsetX, offsetY)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterAndroidViewOffsetsTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterAndroidViewOffsetsTest.kt
index 190561d..0e3ba43 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterAndroidViewOffsetsTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterAndroidViewOffsetsTest.kt
@@ -26,8 +26,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.unit.dp
@@ -90,7 +90,7 @@
)
setPadding(3, 13, 0, 0)
setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
// Box is "three"
Box(
Modifier.padding(start = (2f / density).dp, top = (12f / density).dp)
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt
index ab8ec19..00fcd3d 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/input/pointer/PointerInteropFilterComposeHookupTest.kt
@@ -25,8 +25,8 @@
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -63,7 +63,7 @@
val parent = ComposeView(activity).apply {
setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
modifier = Modifier
.spyGestureFilter {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/LayoutDensityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/LayoutDensityTest.kt
index 06d73c6..4571566 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/LayoutDensityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/LayoutDensityTest.kt
@@ -20,7 +20,7 @@
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.unit.Density
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -38,14 +38,14 @@
val rule = createComposeRule()
@Test
- fun layoutReadsAmbientDensity() {
- var ambientDensity by mutableStateOf(5f)
- var ambientFontScale by mutableStateOf(7f)
+ fun layoutReadsCompositionLocalDensity() {
+ var localDensity by mutableStateOf(5f)
+ var localFontScale by mutableStateOf(7f)
var measureScopeDensity = 0f
var measureScopeFontScale = 0f
rule.setContent {
- Providers(AmbientDensity provides Density(ambientDensity, ambientFontScale)) {
+ Providers(LocalDensity provides Density(localDensity, localFontScale)) {
Layout({}) { _, _ ->
measureScopeDensity = density
measureScopeFontScale = fontScale
@@ -55,15 +55,15 @@
}
rule.runOnIdle {
- Assert.assertEquals(ambientDensity, measureScopeDensity)
- Assert.assertEquals(ambientFontScale, measureScopeFontScale)
- ambientDensity = 9f
- ambientFontScale = 11f
+ Assert.assertEquals(localDensity, measureScopeDensity)
+ Assert.assertEquals(localFontScale, measureScopeFontScale)
+ localDensity = 9f
+ localFontScale = 11f
}
rule.runOnIdle {
- Assert.assertEquals(ambientDensity, measureScopeDensity)
- Assert.assertEquals(ambientFontScale, measureScopeFontScale)
+ Assert.assertEquals(localDensity, measureScopeDensity)
+ Assert.assertEquals(localFontScale, measureScopeFontScale)
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
index 8d0b574..8024c086 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnGloballyPositionedTest.kt
@@ -37,8 +37,8 @@
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.padding
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.runOnUiThreadIR
import androidx.compose.ui.test.TestActivity
@@ -399,7 +399,7 @@
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
DelayedMeasure(50) {
Box(Modifier.size(25.toDp())) {
Box(
@@ -445,7 +445,7 @@
val positionedLatch = CountDownLatch(1)
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.fillMaxSize()
.padding(start = paddingLeftPx.toDp(), top = paddingTopPx.toDp())
@@ -474,7 +474,7 @@
val positionedLatch = CountDownLatch(2)
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.padding(start = firstPaddingPx.toDp()).then(
Modifier.onGloballyPositioned {
@@ -575,7 +575,7 @@
var positionedLatch = CountDownLatch(1)
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box {
Box(
Modifier.onGloballyPositioned {
@@ -608,7 +608,7 @@
var positionedLatch = CountDownLatch(1)
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box {
Offset(left) {
Box(Modifier.size(10.toDp())) {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt
index 186a2b0..50a78e1 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/OnSizeChangedTest.kt
@@ -23,7 +23,7 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.test.TestActivity
import androidx.compose.ui.unit.IntSize
@@ -64,7 +64,7 @@
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.padding(10.toDp()).onSizeChanged {
changedSize = it
@@ -100,7 +100,7 @@
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.padding(10.toDp())
.onSizeChanged {
@@ -136,7 +136,7 @@
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.padding(sizePx.toDp()).onSizeChanged {
changedSize = it
@@ -169,7 +169,7 @@
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(
Modifier.padding(10.toDp()).onSizeChanged {
changedSize = it
@@ -208,7 +208,7 @@
rule.runOnUiThread {
activity.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
val mod = if (addModifier) Modifier.onSizeChanged {
changedSize2 = it
latch2.countDown()
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
index 7ea1393..04ee7f2 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/RtlLayoutTest.kt
@@ -27,7 +27,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.node.Ref
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.runOnUiThreadIR
import androidx.compose.ui.test.TestActivity
@@ -178,7 +178,7 @@
layout(100, 100) {}
}
}
- Providers(AmbientLayoutDirection provides direction.value) {
+ Providers(LocalLayoutDirection provides direction.value) {
Layout(children) { measurables, constraints ->
layout(100, 100) {
measurables.first().measure(constraints).placeRelative(0, 0)
@@ -203,7 +203,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Layout(content = {}) { _, _ ->
resultLayoutDirection.value = layoutDirection
latch.countDown()
@@ -225,7 +225,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
@OptIn(ExperimentalLayout::class)
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Layout(
content = {},
modifier = Modifier.preferredWidth(IntrinsicSize.Max),
@@ -256,10 +256,10 @@
activityTestRule.runOnUiThread {
activity.setContent {
- val initialLayoutDirection = AmbientLayoutDirection.current
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ val initialLayoutDirection = LocalLayoutDirection.current
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Box {
- Providers(AmbientLayoutDirection provides initialLayoutDirection) {
+ Providers(LocalLayoutDirection provides initialLayoutDirection) {
Layout({}) { _, _ ->
resultLayoutDirection.value = layoutDirection
latch.countDown()
@@ -280,7 +280,7 @@
absolutePositioning: Boolean,
testLayoutDirection: LayoutDirection
) {
- Providers(AmbientLayoutDirection provides testLayoutDirection) {
+ Providers(LocalLayoutDirection provides testLayoutDirection) {
Layout(
content = {
FixedSize(size, modifier = Modifier.saveLayoutInfo(position[0], countDownLatch))
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
index f08b696..5bfa9ee 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/layout/SubcomposeLayoutTest.kt
@@ -32,9 +32,9 @@
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asAndroidBitmap
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.AndroidOwnerExtraAssertionsRule
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertHeightIsEqualTo
import androidx.compose.ui.test.assertIsDisplayed
@@ -461,7 +461,7 @@
val size = 50.dp
val density = Density(3f)
val sizeIpx = with(density) { size.toIntPx() }
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
SubcomposeLayout(
Modifier.size(size).onGloballyPositioned {
assertThat(it.size).isEqualTo(IntSize(sizeIpx, sizeIpx))
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/node/HotReloadTests.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/node/HotReloadTests.kt
index e0421da..1c8015a 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/node/HotReloadTests.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/node/HotReloadTests.kt
@@ -27,7 +27,7 @@
import androidx.compose.runtime.ComposeNode
import androidx.compose.runtime.simulateHotReload
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.contentDescription
@@ -66,7 +66,7 @@
var value = "First value"
@Composable fun text(text: String, id: Int = -1) {
- val context = AmbientContext.current
+ val context = LocalContext.current
ComposeNode<TextView, UiApplier>(
factory = { TextView(context) },
update = {
@@ -77,7 +77,7 @@
}
@Composable fun column(content: @Composable () -> Unit) {
- val context = AmbientContext.current
+ val context = LocalContext.current
ComposeNode<LinearLayout, UiApplier>(
factory = { LinearLayout(context) },
update = {},
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInAppCompatActivityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInAppCompatActivityTest.kt
index f1b0d20..3374eb9 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInAppCompatActivityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInAppCompatActivityTest.kt
@@ -17,8 +17,8 @@
package androidx.compose.ui.owners
import androidx.appcompat.app.AppCompatActivity
-import androidx.compose.ui.platform.AmbientLifecycleOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.setContent
import androidx.lifecycle.LifecycleOwner
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -54,7 +54,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
@@ -72,7 +72,7 @@
val view = ComposeView(activity)
activity.setContentView(view)
view.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInComponentActivityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInComponentActivityTest.kt
index da001b6..6f2a166 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInComponentActivityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInComponentActivityTest.kt
@@ -17,8 +17,8 @@
package androidx.compose.ui.owners
import androidx.activity.ComponentActivity
-import androidx.compose.ui.platform.AmbientLifecycleOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.setContent
import androidx.lifecycle.LifecycleOwner
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -54,7 +54,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
@@ -72,7 +72,7 @@
val view = ComposeView(activity)
activity.setContentView(view)
view.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInFragmentTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInFragmentTest.kt
index 0142e37..3e11511 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInFragmentTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/LifecycleOwnerInFragmentTest.kt
@@ -19,8 +19,8 @@
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.compose.ui.platform.AmbientLifecycleOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentContainerView
@@ -80,7 +80,7 @@
savedInstanceState: Bundle?
) = ComposeView(requireContext()).apply {
setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInAppCompatActivityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInAppCompatActivityTest.kt
index d038d6e..d2c50f5 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInAppCompatActivityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInAppCompatActivityTest.kt
@@ -17,8 +17,8 @@
package androidx.compose.ui.owners
import androidx.appcompat.app.AppCompatActivity
-import androidx.compose.ui.platform.AmbientSavedStateRegistryOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalSavedStateRegistryOwner
import androidx.compose.ui.platform.setContent
import androidx.savedstate.SavedStateRegistryOwner
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -54,7 +54,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- owner = AmbientSavedStateRegistryOwner.current
+ owner = LocalSavedStateRegistryOwner.current
latch.countDown()
}
}
@@ -72,7 +72,7 @@
val view = ComposeView(activity)
activity.setContentView(view)
view.setContent {
- owner = AmbientSavedStateRegistryOwner.current
+ owner = LocalSavedStateRegistryOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInComponentActivityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInComponentActivityTest.kt
index fd42773..90538ec 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInComponentActivityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInComponentActivityTest.kt
@@ -17,8 +17,8 @@
package androidx.compose.ui.owners
import androidx.activity.ComponentActivity
-import androidx.compose.ui.platform.AmbientSavedStateRegistryOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalSavedStateRegistryOwner
import androidx.compose.ui.platform.setContent
import androidx.savedstate.SavedStateRegistryOwner
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -54,7 +54,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- owner = AmbientSavedStateRegistryOwner.current
+ owner = LocalSavedStateRegistryOwner.current
latch.countDown()
}
}
@@ -72,7 +72,7 @@
val view = ComposeView(activity)
activity.setContentView(view)
view.setContent {
- owner = AmbientSavedStateRegistryOwner.current
+ owner = LocalSavedStateRegistryOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInFragmentTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInFragmentTest.kt
index 09691f9..59b7685 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInFragmentTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/owners/SavedStateRegistryOwnerInFragmentTest.kt
@@ -19,8 +19,8 @@
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.compose.ui.platform.AmbientSavedStateRegistryOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalSavedStateRegistryOwner
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentContainerView
@@ -80,7 +80,7 @@
savedInstanceState: Bundle?
) = ComposeView(requireContext()).apply {
setContent {
- owner = AmbientSavedStateRegistryOwner.current
+ owner = LocalSavedStateRegistryOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/AndroidViewCompatTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/AndroidViewCompatTest.kt
index 2d40db5..49277a5 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/AndroidViewCompatTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/AndroidViewCompatTest.kt
@@ -408,7 +408,7 @@
var size by mutableStateOf(20)
rule.setContent {
Box(Modifier.graphicsLayer().fillMaxSize()) {
- val context = AmbientContext.current
+ val context = LocalContext.current
val view = remember { View(context) }
AndroidView({ view }, Modifier.testTag("view"))
view.layoutParams = ViewGroup.LayoutParams(size, size)
@@ -438,7 +438,7 @@
rule.setContent {
Box(Modifier.onGloballyPositioned { outer = it.positionInWindow() }) {
- val paddingDp = with(AmbientDensity.current) { padding.toDp() }
+ val paddingDp = with(LocalDensity.current) { padding.toDp() }
Box(Modifier.padding(paddingDp)) {
AndroidView(::ComposeView) {
it.setContent {
@@ -478,7 +478,7 @@
view.setContent {
Box {
- val paddingDp = with(AmbientDensity.current) { padding.toDp() }
+ val paddingDp = with(LocalDensity.current) { padding.toDp() }
Box(Modifier.padding(paddingDp)) {
AndroidView(::ComposeView) {
it.setContent {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/WindowInfoAmbientTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/WindowInfoCompositionLocalTest.kt
similarity index 93%
rename from compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/WindowInfoAmbientTest.kt
rename to compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/WindowInfoCompositionLocalTest.kt
index accdec5..f6f5dc0 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/WindowInfoAmbientTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/platform/WindowInfoCompositionLocalTest.kt
@@ -33,7 +33,7 @@
@MediumTest
@RunWith(AndroidJUnit4::class)
-class WindowInfoAmbientTest {
+class WindowInfoCompositionLocalTest {
@get:Rule
val rule = createComposeRule()
@@ -45,7 +45,7 @@
val windowFocusGain = CountDownLatch(1)
rule.setContent {
BasicText("Main Window")
- windowInfo = AmbientWindowInfo.current
+ windowInfo = LocalWindowInfo.current
@Suppress("DEPRECATION")
WindowFocusObserver { if (it) windowFocusGain.countDown() }
}
@@ -68,12 +68,12 @@
val showPopup = mutableStateOf(false)
rule.setContent {
BasicText("Main Window")
- mainWindowInfo = AmbientWindowInfo.current
+ mainWindowInfo = LocalWindowInfo.current
WindowFocusObserver { if (!it) mainWindowFocusLoss.countDown() }
if (showPopup.value) {
Popup(isFocusable = true, showPopup.value = false }) {
BasicText("Popup Window")
- popupWindowInfo = AmbientWindowInfo.current
+ popupWindowInfo = LocalWindowInfo.current
WindowFocusObserver { if (it) popupFocusGain.countDown() }
}
}
@@ -99,7 +99,7 @@
val showPopup = mutableStateOf(false)
rule.setContent {
BasicText(text = "Main Window")
- mainWindowInfo = AmbientWindowInfo.current
+ mainWindowInfo = LocalWindowInfo.current
WindowFocusObserver { if (it) mainWindowFocusGain.countDown() }
if (showPopup.value) {
Popup(isFocusable = true, showPopup.value = false }) {
@@ -132,12 +132,12 @@
val showDialog = mutableStateOf(false)
rule.setContent {
BasicText("Main Window")
- mainWindowInfo = AmbientWindowInfo.current
+ mainWindowInfo = LocalWindowInfo.current
WindowFocusObserver { if (!it) mainWindowFocusLoss.countDown() }
if (showDialog.value) {
Dialog( showDialog.value = false }) {
BasicText("Popup Window")
- dialogWindowInfo = AmbientWindowInfo.current
+ dialogWindowInfo = LocalWindowInfo.current
WindowFocusObserver { if (it) dialogFocusGain.countDown() }
}
}
@@ -163,7 +163,7 @@
val showDialog = mutableStateOf(false)
rule.setContent {
BasicText(text = "Main Window")
- mainWindowInfo = AmbientWindowInfo.current
+ mainWindowInfo = LocalWindowInfo.current
WindowFocusObserver { if (it) mainWindowFocusGain.countDown() }
if (showDialog.value) {
Dialog( showDialog.value = false }) {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ColorResourcesTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ColorResourcesTest.kt
index 8de8d7e..4f7e4e3 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ColorResourcesTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ColorResourcesTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.runtime.Providers
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.R
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -41,7 +41,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(colorResource(R.color.color_resource))
.isEqualTo(Color(0x12345678))
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/FontResourcesTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/FontResourcesTest.kt
index bbf6e70..c09aa7e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/FontResourcesTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/FontResourcesTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.res
import androidx.compose.runtime.Providers
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
@@ -49,7 +49,7 @@
var syncLoadedTypeface: Typeface? = null
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
// async API
result = loadFontResource(
@@ -77,7 +77,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
loadFontResource(
fontFamily = Font(R.font.sample_font).toFontFamily(),
pendingFontFamily = Font(R.font.sample_font).toFontFamily(),
@@ -92,7 +92,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
loadFontResource(
fontFamily = Font(R.font.sample_font).toFontFamily(),
pendingFontFamily = FontFamily.Serif,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/PrimitiveResourcesTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/PrimitiveResourcesTest.kt
index e836941..d5e84d3 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/PrimitiveResourcesTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/PrimitiveResourcesTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.res
import androidx.compose.runtime.Providers
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.R
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.unit.dp
@@ -41,7 +41,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(integerResource(R.integer.integer_value)).isEqualTo(123)
}
}
@@ -52,7 +52,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(integerArrayResource(R.array.integer_array))
.isEqualTo(intArrayOf(234, 345))
}
@@ -64,7 +64,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(booleanResource(R.bool.boolean_value)).isTrue()
}
}
@@ -75,7 +75,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(dimensionResource(R.dimen.dimension_value)).isEqualTo(32.dp)
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ResourcesTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ResourcesTest.kt
index ab7dc0b..11df6ee 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ResourcesTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/ResourcesTest.kt
@@ -21,7 +21,7 @@
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.graphics.imageFromResource
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.R
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -70,7 +70,7 @@
var res: DeferredResource<ImageBitmap>? = null
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
res = loadResourceInternal(
key = "random key string",
pendingResource = pendingImage,
@@ -133,7 +133,7 @@
var res: DeferredResource<ImageBitmap>? = null
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
res = loadResourceInternal(
key = "random key string",
pendingResource = pendingImage,
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/StringResourcesTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/StringResourcesTest.kt
index 8bcbfcc..2016bb2 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/StringResourcesTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/res/StringResourcesTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.res
import androidx.compose.runtime.Providers
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.R
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -53,7 +53,7 @@
fun stringResource_not_localized_defaultLocale() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(stringResource(R.string.not_localized)).isEqualTo(NotLocalizedText)
}
}
@@ -70,7 +70,7 @@
)
rule.setContent {
- Providers(AmbientContext provides spanishContext) {
+ Providers(LocalContext provides spanishContext) {
assertThat(stringResource(R.string.not_localized)).isEqualTo(NotLocalizedText)
}
}
@@ -80,7 +80,7 @@
fun stringResource_localized_defaultLocale() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(stringResource(R.string.localized))
.isEqualTo(DefaultLocalizedText)
}
@@ -98,7 +98,7 @@
)
rule.setContent {
- Providers(AmbientContext provides spanishContext) {
+ Providers(LocalContext provides spanishContext) {
assertThat(stringResource(R.string.localized))
.isEqualTo(SpanishLocalizedText)
}
@@ -109,7 +109,7 @@
fun stringResource_not_localized_format_defaultLocale() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(stringResource(R.string.not_localized_format, FormatValue))
.isEqualTo(NotLocalizedFormatText)
}
@@ -127,7 +127,7 @@
)
rule.setContent {
- Providers(AmbientContext provides spanishContext) {
+ Providers(LocalContext provides spanishContext) {
assertThat(stringResource(R.string.not_localized_format, FormatValue))
.isEqualTo(NotLocalizedFormatText)
}
@@ -138,7 +138,7 @@
fun stringResource_localized_format_defaultLocale() {
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(stringResource(R.string.localized_format, FormatValue))
.isEqualTo(DefaultLocalizedFormatText)
}
@@ -156,7 +156,7 @@
)
rule.setContent {
- Providers(AmbientContext provides spanishContext) {
+ Providers(LocalContext provides spanishContext) {
assertThat(stringResource(R.string.localized_format, FormatValue))
.isEqualTo(SpanishLocalizedFormatText)
}
@@ -168,7 +168,7 @@
val context = InstrumentationRegistry.getInstrumentation().targetContext
rule.setContent {
- Providers(AmbientContext provides context) {
+ Providers(LocalContext provides context) {
assertThat(stringArrayResource(R.array.string_array))
.isEqualTo(arrayOf("string1", "string2"))
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt
index 951a5e1..2a7ed45 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/AndroidViewTest.kt
@@ -38,8 +38,8 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.R
@@ -330,7 +330,7 @@
val size = 50.dp
val density = Density(3f)
val sizeIpx = with(density) { size.toIntPx() }
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
AndroidView(
{ FrameLayout(it) },
Modifier.size(size).onGloballyPositioned {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/EditTextInteropTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/EditTextInteropTest.kt
index 5b07d5e..b0eb458 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/EditTextInteropTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/EditTextInteropTest.kt
@@ -20,7 +20,7 @@
import android.view.View
import android.widget.EditText
import androidx.activity.ComponentActivity
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.text.InternalTextApi
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -43,7 +43,7 @@
lateinit var editText: EditText
lateinit var ownerView: View
rule.setContent {
- ownerView = AmbientView.current
+ ownerView = LocalView.current
AndroidView({
EditText(it).apply { width = 500; editText = this }
})
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInAppCompatActivityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInAppCompatActivityTest.kt
index 548434f8..dcc2d01 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInAppCompatActivityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInAppCompatActivityTest.kt
@@ -17,8 +17,8 @@
package androidx.compose.ui.viewinterop
import androidx.appcompat.app.AppCompatActivity
-import androidx.compose.ui.platform.AmbientLifecycleOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.setContent
import androidx.lifecycle.LifecycleOwner
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -54,7 +54,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
@@ -72,7 +72,7 @@
val view = ComposeView(activity)
activity.setContentView(view)
view.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInComponentActivityTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInComponentActivityTest.kt
index 5a5d8b2..ddd0f03 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInComponentActivityTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelInComponentActivityTest.kt
@@ -17,8 +17,8 @@
package androidx.compose.ui.viewinterop
import androidx.activity.ComponentActivity
-import androidx.compose.ui.platform.AmbientLifecycleOwner
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.platform.setContent
import androidx.lifecycle.LifecycleOwner
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -54,7 +54,7 @@
activityTestRule.runOnUiThread {
activity.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
@@ -72,7 +72,7 @@
val view = ComposeView(activity)
activity.setContentView(view)
view.setContent {
- owner = AmbientLifecycleOwner.current
+ owner = LocalLifecycleOwner.current
latch.countDown()
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelTest.kt
index 57b10df..4347258 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/viewinterop/ViewModelTest.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.viewinterop
import androidx.compose.runtime.Providers
-import androidx.compose.ui.platform.AmbientViewModelStoreOwner
+import androidx.compose.ui.platform.LocalViewModelStoreOwner
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.lifecycle.HasDefaultViewModelProviderFactory
import androidx.lifecycle.ViewModel
@@ -42,7 +42,7 @@
fun viewModelCreatedViaDefaultFactory() {
val owner = FakeViewModelStoreOwner()
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
viewModel<TestViewModel>()
}
}
@@ -55,7 +55,7 @@
val owner = FakeViewModelStoreOwner()
var createdInComposition: Any? = null
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
createdInComposition = viewModel<TestViewModel>()
}
}
@@ -70,7 +70,7 @@
val owner = FakeViewModelStoreOwner()
var createdInComposition: Any? = null
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
createdInComposition = viewModel<TestViewModel>()
}
}
@@ -85,7 +85,7 @@
val owner = FakeViewModelStoreOwner()
var createdInComposition: Any? = null
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
createdInComposition = viewModel<TestViewModel>(key = "test")
}
}
@@ -100,7 +100,7 @@
val owner = FakeViewModelStoreOwner()
val customFactory = FakeViewModelProviderFactory()
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
viewModel<TestViewModel>(factory = customFactory)
}
}
@@ -113,7 +113,7 @@
val owner = FakeViewModelStoreOwner()
val customFactory = FakeViewModelProviderFactory()
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
viewModel<TestViewModel>(factory = customFactory)
}
}
@@ -127,7 +127,7 @@
var createdInComposition: Any? = null
val customFactory = FakeViewModelProviderFactory()
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
createdInComposition = viewModel<TestViewModel>()
}
}
@@ -143,7 +143,7 @@
var createdInComposition: Any? = null
val customFactory = FakeViewModelProviderFactory()
rule.setContent {
- Providers(AmbientViewModelStoreOwner provides owner) {
+ Providers(LocalViewModelStoreOwner provides owner) {
createdInComposition = viewModel<TestViewModel>(key = "test")
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt
index 027e5c4..6ea928c 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogScreenshotTest.kt
@@ -25,7 +25,7 @@
import androidx.compose.ui.background
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.isDialog
import androidx.compose.ui.test.junit4.createComposeRule
@@ -71,7 +71,7 @@
fun dialogWithElevation() {
rule.setContent {
Dialog( {
- val elevation = with(AmbientDensity.current) { 16.dp.toPx() }
+ val elevation = with(LocalDensity.current) { 16.dp.toPx() }
Box(
Modifier
.graphicsLayer(
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogUiTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogUiTest.kt
index d5261f5..211e801 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogUiTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/DialogUiTest.kt
@@ -256,7 +256,7 @@
}
@Test
- fun dialog_preservesAmbients() {
+ fun dialog_preservesCompositionLocals() {
val compositionLocal = compositionLocalOf<Float>()
var value = 0f
rule.setContent {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt
index a0de7cc..d33a19e 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupAlignmentTest.kt
@@ -23,8 +23,8 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.onGloballyPositioned
-import androidx.compose.ui.platform.AmbientLayoutDirection
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalLayoutDirection
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.unit.IntBounds
import androidx.compose.ui.unit.IntOffset
@@ -307,7 +307,7 @@
rule.setContent {
// Get the compose view position on screen
- val composeView = AmbientView.current
+ val composeView = LocalView.current
val positionArray = IntArray(2)
composeView.getLocationOnScreen(positionArray)
composeViewAbsolutePos = IntOffset(
@@ -319,7 +319,7 @@
// position of the parent to be (0, 0)
TestAlign {
val layoutDirection = if (isRtl) LayoutDirection.Rtl else LayoutDirection.Ltr
- Providers(AmbientLayoutDirection provides layoutDirection) {
+ Providers(LocalLayoutDirection provides layoutDirection) {
SimpleContainer(width = parentWidthDp, height = parentHeightDp) {
PopupTestTag(testTag) {
Popup(alignment = alignment, offset = offset) {
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
index 2415022..146b0fc 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PopupTest.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.node.Owner
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.getUnclippedBoundsInRoot
@@ -205,7 +205,7 @@
}
@Test
- fun preservesAmbients() {
+ fun preservesCompositionLocals() {
val compositionLocal = compositionLocalOf<Float>()
var value = 0f
rule.setContent {
@@ -224,9 +224,9 @@
fun preservesLayoutDirection() {
var value = LayoutDirection.Ltr
rule.setContent {
- Providers(AmbientLayoutDirection provides LayoutDirection.Rtl) {
+ Providers(LocalLayoutDirection provides LayoutDirection.Rtl) {
Popup {
- value = AmbientLayoutDirection.current
+ value = LocalLayoutDirection.current
}
}
}
diff --git a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt
index c1c0f14..a201006 100644
--- a/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt
+++ b/compose/ui/ui/src/androidAndroidTest/kotlin/androidx/compose/ui/window/PositionInWindowTest.kt
@@ -26,7 +26,7 @@
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInWindow
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -65,7 +65,7 @@
window.attributes = layoutParams
}
rule.setContent {
- with(AmbientDensity.current) {
+ with(LocalDensity.current) {
Box(Modifier.size(size.toDp()).onGloballyPositioned { coordinates = it })
}
}
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidAmbients.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidAmbients.kt
index 99178a5..6f0bbfc 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidAmbients.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidAmbients.kt
@@ -148,7 +148,10 @@
@Composable
@OptIn(ExperimentalComposeUiApi::class, InternalAnimationApi::class)
-internal fun ProvideAndroidAmbients(owner: AndroidComposeView, content: @Composable () -> Unit) {
+internal fun ProvideAndroidCompositionLocals(
+ owner: AndroidComposeView,
+ content: @Composable () -> Unit
+) {
val view = owner
val context = view.context
val scope = rememberCoroutineScope()
@@ -181,15 +184,15 @@
}
Providers(
- AmbientConfiguration provides configuration,
- AmbientContext provides context,
- AmbientLifecycleOwner provides viewTreeOwners.lifecycleOwner,
- AmbientSavedStateRegistryOwner provides viewTreeOwners.savedStateRegistryOwner,
+ LocalConfiguration provides configuration,
+ LocalContext provides context,
+ LocalLifecycleOwner provides viewTreeOwners.lifecycleOwner,
+ LocalSavedStateRegistryOwner provides viewTreeOwners.savedStateRegistryOwner,
LocalSaveableStateRegistry provides saveableStateRegistry,
- AmbientView provides owner.view,
- AmbientViewModelStoreOwner provides viewTreeOwners.viewModelStoreOwner
+ LocalView provides owner.view,
+ LocalViewModelStoreOwner provides viewTreeOwners.viewModelStoreOwner
) {
- ProvideCommonAmbients(
+ ProvideCommonCompositionLocals(
owner = owner,
animationClock = rootAnimationClock,
uriHandler = uriHandler,
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt
index 626a971..b5d7ce0 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/AndroidComposeView.kt
@@ -179,15 +179,15 @@
// private val ownerScope = CoroutineScope(Dispatchers.Main.immediate + Job())
/**
- * Used for updating the ConfigurationAmbient when configuration changes - consume the
- * configuration ambient instead of changing this observer if you are writing a component
- * that adapts to configuration changes.
+ * Used for updating LocalConfiguration when configuration changes - consume LocalConfiguration
+ * instead of changing this observer if you are writing a component that adapts to
+ * configuration changes.
*/
var configurationChangeObserver: (Configuration) -> Unit = {}
private val _autofill = if (autofillSupported()) AndroidAutofill(this, autofillTree) else null
- // Used as an ambient for performing autofill.
+ // Used as a CompositionLocal for performing autofill.
override val autofill: Autofill? get() = _autofill
private var observationClearRequested = false
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
index 9692706..52130e6 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
@@ -93,7 +93,7 @@
* Composes the given composable into the given view.
*
* The new composition can be logically "linked" to an existing one, by providing a
- * [parent]. This will ensure that invalidations and ambients will flow through
+ * [parent]. This will ensure that invalidations and CompositionLocals will flow through
* the two compositions as if they were not separate.
*
* Note that this [ViewGroup] should have an unique id for the saved instance state mechanism to
@@ -196,7 +196,7 @@
LaunchedEffect(owner) { owner.boundsUpdatesEventLoop() }
Providers(LocalInspectionTables provides inspectionTable) {
- ProvideAndroidAmbients(owner, content)
+ ProvideAndroidCompositionLocals(owner, content)
}
}
}
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ColorResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ColorResources.kt
index 8bc1caf..9a6108e 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ColorResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ColorResources.kt
@@ -20,7 +20,7 @@
import androidx.annotation.ColorRes
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
/**
* Load a color resource.
@@ -30,7 +30,7 @@
*/
@Composable
fun colorResource(@ColorRes id: Int): Color {
- val context = AmbientContext.current
+ val context = LocalContext.current
return if (Build.VERSION.SDK_INT >= 23) {
Color(context.resources.getColor(id, context.theme))
} else {
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/FontResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/FontResources.kt
index ffef346..c2092de 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/FontResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/FontResources.kt
@@ -20,7 +20,7 @@
import android.util.TypedValue
import androidx.annotation.GuardedBy
import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.Typeface
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontListFontFamily
@@ -46,7 +46,7 @@
*/
@Composable
fun fontResource(fontFamily: FontFamily): Typeface {
- return fontResourceFromContext(AmbientContext.current, fontFamily)
+ return fontResourceFromContext(LocalContext.current, fontFamily)
}
internal fun fontResourceFromContext(context: Context, fontFamily: FontFamily): Typeface {
@@ -84,7 +84,7 @@
pendingFontFamily: FontFamily? = null,
failedFontFamily: FontFamily? = null
): DeferredResource<Typeface> {
- val context = AmbientContext.current
+ val context = LocalContext.current
val pendingTypeface = if (pendingFontFamily == null) {
null
} else if (!pendingFontFamily.canLoadSynchronously) {
@@ -137,7 +137,7 @@
pendingTypeface: Typeface? = null,
failedTypeface: Typeface? = null
): DeferredResource<Typeface> {
- val context = AmbientContext.current
+ val context = LocalContext.current
if (fontFamily.canLoadSynchronously) {
val typeface = synchronized(cacheLock) {
syncLoadedTypefaces.getOrPut(fontFamily) {
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ImageResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ImageResources.kt
index b8ad9f3..dc1e877 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ImageResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/ImageResources.kt
@@ -22,7 +22,7 @@
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.imageFromResource
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.util.trace
/**
@@ -37,7 +37,7 @@
*/
@Composable
fun imageResource(@DrawableRes id: Int): ImageBitmap {
- val context = AmbientContext.current
+ val context = LocalContext.current
val value = remember { TypedValue() }
context.resources.getValue(id, value, true)
// We use the file path as a key of the request cache.
@@ -64,7 +64,7 @@
pendingImage: ImageBitmap? = null,
failedImage: ImageBitmap? = null
): DeferredResource<ImageBitmap> {
- val context = AmbientContext.current
+ val context = LocalContext.current
val res = context.resources
val value = remember { TypedValue() }
res.getValue(id, value, true)
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PainterResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PainterResources.kt
index d8af23f..e2b2e26f 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PainterResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PainterResources.kt
@@ -31,7 +31,7 @@
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.graphics.vector.VectorPainter
import androidx.compose.ui.graphics.vector.compat.seekToStartTag
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
/**
* Create a [Painter] from an Android resource id. This can load either an instance of
@@ -55,7 +55,7 @@
*/
@Composable
fun painterResource(@DrawableRes id: Int): Painter {
- val context = AmbientContext.current
+ val context = LocalContext.current
val res = context.resources
val value = remember { TypedValue() }
res.getValue(id, value, true)
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PrimitiveResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PrimitiveResources.kt
index 4011080..6c2fb81 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PrimitiveResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/PrimitiveResources.kt
@@ -21,8 +21,8 @@
import androidx.annotation.DimenRes
import androidx.annotation.IntegerRes
import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.AmbientContext
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
/**
@@ -33,7 +33,7 @@
*/
@Composable
fun integerResource(@IntegerRes id: Int): Int {
- val context = AmbientContext.current
+ val context = LocalContext.current
return context.resources.getInteger(id)
}
@@ -45,7 +45,7 @@
*/
@Composable
fun integerArrayResource(@ArrayRes id: Int): IntArray {
- val context = AmbientContext.current
+ val context = LocalContext.current
return context.resources.getIntArray(id)
}
@@ -57,7 +57,7 @@
*/
@Composable
fun booleanResource(@BoolRes id: Int): Boolean {
- val context = AmbientContext.current
+ val context = LocalContext.current
return context.resources.getBoolean(id)
}
@@ -69,8 +69,8 @@
*/
@Composable
fun dimensionResource(@DimenRes id: Int): Dp {
- val context = AmbientContext.current
- val density = AmbientDensity.current
+ val context = LocalContext.current
+ val density = LocalDensity.current
val pxValue = context.resources.getDimension(id)
return Dp(pxValue / density.density)
}
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/StringResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/StringResources.kt
index bb7e61a..70e41c5 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/StringResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/StringResources.kt
@@ -20,8 +20,8 @@
import androidx.annotation.ArrayRes
import androidx.annotation.StringRes
import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.AmbientConfiguration
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalConfiguration
+import androidx.compose.ui.platform.LocalContext
/**
* Load a string resource.
@@ -66,6 +66,6 @@
*/
@Composable
private fun resources(): Resources {
- AmbientConfiguration.current
- return AmbientContext.current.resources
+ LocalConfiguration.current
+ return LocalContext.current.resources
}
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/VectorResources.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/VectorResources.kt
index 3fd252b..5730588 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/VectorResources.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/res/VectorResources.kt
@@ -28,7 +28,7 @@
import androidx.compose.ui.graphics.vector.compat.isAtEnd
import androidx.compose.ui.graphics.vector.compat.parseCurrentVectorNode
import androidx.compose.ui.graphics.vector.compat.seekToStartTag
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.util.trace
import org.xmlpull.v1.XmlPullParserException
@@ -44,7 +44,7 @@
*/
@Composable
fun vectorResource(@DrawableRes id: Int): ImageVector {
- val context = AmbientContext.current
+ val context = LocalContext.current
val res = context.resources
val theme = context.theme
return remember(id) {
@@ -72,7 +72,7 @@
pendingResource: ImageVector? = null,
failedResource: ImageVector? = null
): DeferredResource<ImageVector> {
- val context = AmbientContext.current
+ val context = LocalContext.current
val res = context.resources
val theme = context.theme
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/AndroidView.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/AndroidView.kt
index 1b8095c..fec0dcc 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/AndroidView.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/AndroidView.kt
@@ -24,8 +24,8 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.materialize
import androidx.compose.ui.node.UiApplier
-import androidx.compose.ui.platform.AmbientContext
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalDensity
/**
* Composes an Android [View] obtained from [viewBlock]. The [viewBlock] block will be called
@@ -49,9 +49,9 @@
modifier: Modifier = Modifier,
update: (T) -> Unit = NoOpUpdate
) {
- val context = AmbientContext.current
+ val context = LocalContext.current
val materialized = currentComposer.materialize(modifier)
- val density = AmbientDensity.current
+ val density = LocalDensity.current
ComposeNode<ViewBlockHolder<T>, UiApplier>(
factory = { ViewBlockHolder(context) },
update = {
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/EmitView.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/EmitView.kt
index 7cf7d64..5686ab9 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/EmitView.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/EmitView.kt
@@ -22,7 +22,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ComposeNode
import androidx.compose.ui.node.UiApplier
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
@Suppress("ComposableNaming")
@Composable
@@ -35,7 +35,7 @@
ctor: (Context) -> T,
update: (T) -> Unit
) {
- val context = AmbientContext.current
+ val context = LocalContext.current
ComposeNode<T, UiApplier>(
factory = { ctor(context) },
update = {
@@ -56,7 +56,7 @@
update: (T) -> Unit,
children: @Composable () -> Unit
) {
- val context = AmbientContext.current
+ val context = LocalContext.current
ComposeNode<T, UiApplier>(
factory = { ctor(context) },
update = {
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/ViewModel.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/ViewModel.kt
index ffacdc6..5e8c29794 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/ViewModel.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/viewinterop/ViewModel.kt
@@ -17,7 +17,7 @@
package androidx.compose.ui.viewinterop
import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.AmbientViewModelStoreOwner
+import androidx.compose.ui.platform.LocalViewModelStoreOwner
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
@@ -57,7 +57,7 @@
modelClass: Class<T>,
key: String? = null,
factory: ViewModelProvider.Factory? = null
-): T = AmbientViewModelStoreOwner.current.get(modelClass, key, factory)
+): T = LocalViewModelStoreOwner.current.get(modelClass, key, factory)
private fun <T : ViewModel> ViewModelStoreOwner.get(
javaClass: Class<T>,
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt
index 6779455..d888b1e 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidDialog.kt
@@ -41,8 +41,8 @@
import androidx.compose.ui.R
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.platform.AbstractComposeView
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.semantics.dialog
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Density
@@ -110,8 +110,8 @@
properties: DialogProperties?,
content: @Composable () -> Unit
) {
- val view = AmbientView.current
- val density = AmbientDensity.current
+ val view = LocalView.current
+ val density = LocalDensity.current
val composition = rememberCompositionReference()
val currentContent by rememberUpdatedState(content)
val dialog = remember(view, density) {
diff --git a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt
index e6d5ef0..ecd1e6c 100644
--- a/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt
+++ b/compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/window/AndroidPopup.kt
@@ -46,8 +46,8 @@
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.layout.positionInWindow
import androidx.compose.ui.platform.AbstractComposeView
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientView
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.semantics.popup
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.unit.Density
@@ -122,8 +122,8 @@
properties: PopupProperties?,
content: @Composable () -> Unit
) {
- val view = AmbientView.current
- val density = AmbientDensity.current
+ val view = LocalView.current
+ val density = LocalDensity.current
val testTag = LocalPopupTestTag.current
val parentComposition = rememberCompositionReference()
val currentContent by rememberUpdatedState(content)
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/autofill/Autofill.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/autofill/Autofill.kt
index 32bdaca..981a975 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/autofill/Autofill.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/autofill/Autofill.kt
@@ -22,9 +22,9 @@
/**
* Autofill API.
*
- * This interface is available to all composables via an ambient. The composable can then request
- * or cancel autofill as required. For instance, the [TextField] can call [requestAutofillForNode]
- * when it gains focus, and [cancelAutofillForNode] when it loses focus.
+ * This interface is available to all composables via a CompositionLocal. The composable can then
+ * request or cancel autofill as required. For instance, the [TextField] can call
+ * [requestAutofillForNode] when it gains focus, and [cancelAutofillForNode] when it loses focus.
*/
@ExperimentalComposeUiApi
interface Autofill {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/draw/Shadow.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/draw/Shadow.kt
index b8a8cfd..892199b 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/draw/Shadow.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/draw/Shadow.kt
@@ -22,7 +22,7 @@
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.graphicsLayer
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -61,7 +61,7 @@
}
) {
graphicsLayer(
- shadowElevation = with(AmbientDensity.current) { elevation.toPx() },
+ shadowElevation = with(LocalDensity.current) { elevation.toPx() },
shape = shape,
clip = clip
)
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/gesture/DragSlopExceededGestureFilter.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/gesture/DragSlopExceededGestureFilter.kt
index 141b8ec..7e28580 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/gesture/DragSlopExceededGestureFilter.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/gesture/DragSlopExceededGestureFilter.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.input.pointer.PointerInputFilter
import androidx.compose.ui.input.pointer.changedToUpIgnoreConsumed
import androidx.compose.ui.input.pointer.positionChange
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.IntSize
import kotlin.math.abs
@@ -69,7 +69,7 @@
properties["orientation"] = orientation
}
) {
- val touchSlop = with(AmbientDensity.current) { TouchSlop.toPx() }
+ val touchSlop = with(LocalDensity.current) { TouchSlop.toPx() }
val filter = remember {
DragSlopExceededGestureFilter(touchSlop)
}
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt
index 95807e3..b1bd0a7 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/graphics/vector/VectorPainter.kt
@@ -30,7 +30,7 @@
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.graphics.painter.Painter
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp
/**
@@ -66,7 +66,7 @@
tintBlendMode: BlendMode = BlendMode.SrcIn,
content: @Composable (viewportWidth: Float, viewportHeight: Float) -> Unit
): VectorPainter {
- val density = AmbientDensity.current
+ val density = LocalDensity.current
val widthPx = with(density) { defaultWidth.toPx() }
val heightPx = with(density) { defaultHeight.toPx() }
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt
index 8fc5e32..fc8fa7e 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/input/pointer/SuspendingPointerInputFilter.kt
@@ -21,8 +21,8 @@
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientViewConfiguration
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalViewConfiguration
import androidx.compose.ui.platform.ViewConfiguration
import androidx.compose.ui.platform.debugInspectorInfo
import androidx.compose.ui.unit.Density
@@ -133,8 +133,8 @@
this.properties["block"] = block
}
) {
- val density = AmbientDensity.current
- val viewConfiguration = AmbientViewConfiguration.current
+ val density = LocalDensity.current
+ val viewConfiguration = LocalViewConfiguration.current
remember(density) { SuspendingPointerInputFilter(viewConfiguration, density) }.apply {
LaunchedEffect(this) {
block()
@@ -152,7 +152,7 @@
* a LayoutNode.
*
* [SuspendingPointerInputFilter] implements the [PointerInputScope] used to offer the
- * [Modifier.pointerInput] DSL and carries the [Density] from [AmbientDensity] at the point of
+ * [Modifier.pointerInput] DSL and carries the [Density] from [LocalDensity] at the point of
* the modifier's materialization. Even if this value were returned to the [PointerInputFilter]
* callbacks, we would still need the value at composition time in order for [Modifier.pointerInput]
* to begin its internal [LaunchedEffect] for the provided code block.
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/Layout.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/Layout.kt
index 7277de7..34c0b46 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/Layout.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/Layout.kt
@@ -31,8 +31,8 @@
import androidx.compose.ui.node.LayoutEmitHelper
import androidx.compose.ui.node.LayoutNode
import androidx.compose.ui.node.MeasureBlocks
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.simpleIdentityToString
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
@@ -225,8 +225,8 @@
modifier: Modifier = Modifier
) {
@OptIn(ExperimentalComposeApi::class)
- val density = AmbientDensity.current
- val layoutDirection = AmbientLayoutDirection.current
+ val density = LocalDensity.current
+ val layoutDirection = LocalLayoutDirection.current
ComposeNode<LayoutNode, Applier<Any>>(
factory = LayoutEmitHelper.constructor,
update = {
@@ -262,8 +262,8 @@
) {
val measureBlocks = remember(measureBlock) { MeasuringIntrinsicsMeasureBlocks(measureBlock) }
val materialized = currentComposer.materialize(modifier)
- val density = AmbientDensity.current
- val layoutDirection = AmbientLayoutDirection.current
+ val density = LocalDensity.current
+ val layoutDirection = LocalLayoutDirection.current
@OptIn(ExperimentalComposeApi::class)
ComposeNode<LayoutNode, Applier<Any>>(
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
index d2777f9..abe490a2 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/SubcomposeLayout.kt
@@ -32,8 +32,8 @@
import androidx.compose.ui.node.LayoutNode
import androidx.compose.ui.node.LayoutNode.LayoutState
import androidx.compose.ui.node.MeasureBlocks
-import androidx.compose.ui.platform.AmbientDensity
-import androidx.compose.ui.platform.AmbientLayoutDirection
+import androidx.compose.ui.platform.LocalDensity
+import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.platform.subcomposeInto
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.LayoutDirection
@@ -67,8 +67,8 @@
state.compositionRef = rememberCompositionReference()
val materialized = currentComposer.materialize(modifier)
- val density = AmbientDensity.current
- val layoutDirection = AmbientLayoutDirection.current
+ val density = LocalDensity.current
+ val layoutDirection = LocalLayoutDirection.current
ComposeNode<LayoutNode, Applier<Any>>(
factory = LayoutEmitHelper.constructor,
update = {
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
index 67963a8..eebbda9 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/Owner.kt
@@ -73,7 +73,8 @@
val autofillTree: AutofillTree
/**
- * The [Autofill] class can be used to perform autofill operations. It is used as an ambient.
+ * The [Autofill] class can be used to perform autofill operations. It is used as a
+ * CompositionLocal.
*/
@get:ExperimentalComposeUiApi
@ExperimentalComposeUiApi
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/Ambients.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/Ambients.kt
index cd8e880..28afa80 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/Ambients.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/Ambients.kt
@@ -303,27 +303,27 @@
@ExperimentalComposeUiApi
@Composable
-internal fun ProvideCommonAmbients(
+internal fun ProvideCommonCompositionLocals(
owner: Owner,
animationClock: AnimationClockObservable,
uriHandler: UriHandler,
content: @Composable () -> Unit
) {
Providers(
- AmbientAnimationClock provides animationClock,
- AmbientAutofill provides owner.autofill,
- AmbientAutofillTree provides owner.autofillTree,
- AmbientClipboardManager provides owner.clipboardManager,
- AmbientDensity provides owner.density,
- AmbientFocusManager provides owner.focusManager,
- AmbientFontLoader provides owner.fontLoader,
- AmbientHapticFeedback provides owner.hapticFeedBack,
- AmbientLayoutDirection providesDefault owner.layoutDirection,
- AmbientTextInputService provides owner.textInputService,
- AmbientTextToolbar provides owner.textToolbar,
- AmbientUriHandler provides uriHandler,
- AmbientViewConfiguration provides owner.viewConfiguration,
- AmbientWindowInfo provides owner.windowInfo,
+ LocalAnimationClock provides animationClock,
+ LocalAutofill provides owner.autofill,
+ LocalAutofillTree provides owner.autofillTree,
+ LocalClipboardManager provides owner.clipboardManager,
+ LocalDensity provides owner.density,
+ LocalFocusManager provides owner.focusManager,
+ LocalFontLoader provides owner.fontLoader,
+ LocalHapticFeedback provides owner.hapticFeedBack,
+ LocalLayoutDirection providesDefault owner.layoutDirection,
+ LocalTextInputService provides owner.textInputService,
+ LocalTextToolbar provides owner.textToolbar,
+ LocalUriHandler provides uriHandler,
+ LocalViewConfiguration provides owner.viewConfiguration,
+ LocalWindowInfo provides owner.windowInfo,
content = content
)
}
\ No newline at end of file
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/WindowInfo.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/WindowInfo.kt
index 9de325c..88db96d 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/WindowInfo.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/WindowInfo.kt
@@ -43,7 +43,7 @@
@OptIn(ExperimentalComposeApi::class)
@Composable
internal fun WindowFocusObserver(onWindowFocusChanged: (isWindowFocused: Boolean) -> Unit) {
- val windowInfo = AmbientWindowInfo.current
+ val windowInfo = LocalWindowInfo.current
val callback = rememberUpdatedState(onWindowFocusChanged)
LaunchedEffect(windowInfo) {
snapshotFlow { windowInfo.isWindowFocused }.collect { callback.value(it) }
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt
index a7adf1f..58a9e7b 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/desktop/AppWindow.kt
@@ -18,7 +18,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionReference
import androidx.compose.runtime.Providers
-import androidx.compose.runtime.ambientOf
+import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.platform.Keyboard
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
@@ -34,7 +34,7 @@
import javax.swing.SwingUtilities
import javax.swing.WindowConstants
-val AppWindowAmbient = ambientOf<AppWindow?>()
+val AppWindowAmbient = compositionLocalOf<AppWindow?>()
/**
* Opens a window with the given content.
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwners.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwners.kt
index eb9c39a..8abbef1 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwners.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopOwners.kt
@@ -18,8 +18,8 @@
import androidx.compose.animation.core.MonotonicFrameAnimationClock
import androidx.compose.runtime.BroadcastFrameClock
import androidx.compose.runtime.Recomposer
+import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.runtime.snapshots.Snapshot
-import androidx.compose.runtime.staticAmbientOf
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.mouse.MouseScrollEvent
import androidx.compose.ui.input.pointer.PointerId
@@ -36,7 +36,7 @@
import java.awt.event.MouseEvent
import androidx.compose.ui.input.key.KeyEvent as ComposeKeyEvent
-internal val DesktopOwnersAmbient = staticAmbientOf<DesktopOwners>()
+internal val DesktopOwnersAmbient = staticCompositionLocalOf<DesktopOwners>()
@OptIn(ExperimentalCoroutinesApi::class)
internal class DesktopOwners(
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopPlatform.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopPlatform.kt
index 8bd07f7..02326b9 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopPlatform.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopPlatform.kt
@@ -16,9 +16,9 @@
package androidx.compose.ui.platform
-import androidx.compose.runtime.staticAmbientOf
+import androidx.compose.runtime.staticCompositionLocalOf
-val DesktopPlatformAmbient = staticAmbientOf(DesktopPlatform::Current)
+val DesktopPlatformAmbient = staticCompositionLocalOf(DesktopPlatform::Current)
enum class DesktopPlatform {
Linux,
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopSelectionClipboard.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopSelectionClipboard.kt
index b5cff56..98f1c41 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopSelectionClipboard.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/DesktopSelectionClipboard.kt
@@ -16,12 +16,12 @@
package androidx.compose.ui.platform
-import androidx.compose.runtime.staticAmbientOf
+import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.plus
import androidx.compose.ui.text.AnnotatedString
-val SelectionTrackerAmbient = staticAmbientOf<SelectionTracker>()
+val SelectionTrackerAmbient = staticCompositionLocalOf<SelectionTracker>()
class SelectionTracker {
var getSelectedText: (() -> AnnotatedString?)? = null
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/Wrapper.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
index 6bdeac6..7db20a6 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/platform/Wrapper.kt
@@ -59,7 +59,7 @@
DesktopOwnersAmbient provides owner.container,
SelectionTrackerAmbient provides owner.selectionTracker
) {
- ProvideCommonAmbients(
+ ProvideCommonCompositionLocals(
owner = owner,
animationClock = owner.container.animationClock,
uriHandler = DesktopUriHandler(),
diff --git a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/res/DesktopXmlVectorResources.kt b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/res/DesktopXmlVectorResources.kt
index a1d365d..a1a9faa 100644
--- a/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/res/DesktopXmlVectorResources.kt
+++ b/compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/res/DesktopXmlVectorResources.kt
@@ -19,7 +19,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.vector.ImageVector
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.vector.parseVectorRoot
import androidx.compose.ui.unit.Density
import org.xml.sax.InputSource
@@ -86,7 +86,7 @@
*/
@Composable
fun vectorXmlResource(inputSource: InputSource): ImageVector {
- val density = AmbientDensity.current
+ val density = LocalDensity.current
return remember(inputSource, density) {
loadVectorXmlResource(inputSource, density)
}
diff --git a/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/DesktopPopupTest.kt b/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/DesktopPopupTest.kt
index eb141b3..e3e1a48 100644
--- a/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/DesktopPopupTest.kt
+++ b/compose/ui/ui/src/desktopTest/kotlin/androidx/compose/ui/window/DesktopPopupTest.kt
@@ -21,8 +21,8 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.setValue
-import androidx.compose.runtime.staticAmbientOf
-import androidx.compose.ui.platform.AmbientDensity
+import androidx.compose.runtime.staticCompositionLocalOf
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.unit.Density
@@ -37,7 +37,7 @@
@Test
fun `pass ambients to popup`() {
- val ambient = staticAmbientOf<Int>()
+ val ambient = staticCompositionLocalOf<Int>()
var actualAmbientValue = 0
@@ -81,9 +81,9 @@
var densityInsidePopup = 0f
rule.setContent {
- Providers(AmbientDensity provides density) {
+ Providers(LocalDensity provides density) {
Popup {
- densityInsidePopup = AmbientDensity.current.density
+ densityInsidePopup = LocalDensity.current.density
}
}
}
diff --git a/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt b/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt
index bcd1417..eac32a3 100644
--- a/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt
+++ b/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavGraphBuilderTest.kt
@@ -17,7 +17,7 @@
package androidx.navigation.compose
import android.net.Uri
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.core.net.toUri
import androidx.navigation.NavDeepLinkRequest
@@ -45,7 +45,7 @@
val key = "key"
val arg = "myarg"
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(ComposeNavigator())
NavHost(navController, startDestination = firstRoute) {
@@ -67,7 +67,7 @@
val key = "key"
val defaultArg = "default"
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(ComposeNavigator())
NavHost(navController, startDestination = firstRoute) {
@@ -92,7 +92,7 @@
val uriString = "https://www.example.com"
val deeplink = NavDeepLinkRequest.Builder.fromUri(Uri.parse(uriString)).build()
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(ComposeNavigator())
NavHost(navController, startDestination = firstRoute) {
@@ -115,7 +115,7 @@
fun testNavigationNestedStart() {
lateinit var navController: TestNavHostController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(ComposeNavigator())
NavHost(navController, startDestination = firstRoute) {
@@ -136,7 +136,7 @@
fun testNavigationNestedInGraph() {
lateinit var navController: TestNavHostController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(ComposeNavigator())
NavHost(navController, startDestination = firstRoute) {
diff --git a/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostControllerTest.kt b/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostControllerTest.kt
index 5ba5c48..48fa470 100644
--- a/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostControllerTest.kt
+++ b/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostControllerTest.kt
@@ -18,7 +18,7 @@
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
@@ -47,7 +47,7 @@
fun testCurrentBackStackEntrySetGraph() {
var currentBackStackEntry: State<NavBackStackEntry?> = mutableStateOf(null)
composeTestRule.setContent {
- val navController = TestNavHostController(AmbientContext.current)
+ val navController = TestNavHostController(LocalContext.current)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
test(FIRST_DESTINATION)
@@ -66,7 +66,7 @@
var currentBackStackEntry: State<NavBackStackEntry?> = mutableStateOf(null)
lateinit var navController: NavController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
test(FIRST_DESTINATION)
@@ -94,7 +94,7 @@
var currentBackStackEntry: State<NavBackStackEntry?> = mutableStateOf(null)
lateinit var navController: TestNavHostController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
test(FIRST_DESTINATION)
@@ -120,7 +120,7 @@
lateinit var navController: NavController
val navigator = TestNavigator()
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(navigator)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
@@ -156,7 +156,7 @@
lateinit var navController: NavController
val navigator = TestNavigator()
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.navigatorProvider.addNavigator(navigator)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
@@ -195,7 +195,7 @@
fun testGetBackStackEntry() {
lateinit var navController: NavController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
test(FIRST_DESTINATION)
@@ -224,7 +224,7 @@
fun testGetBackStackEntryNoEntryFound() {
lateinit var navController: NavController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
navController.graph = navController.createGraph(startDestination = FIRST_DESTINATION) {
test(FIRST_DESTINATION)
diff --git a/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt b/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
index dc344d4..2b61132 100644
--- a/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
+++ b/navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
@@ -28,7 +28,7 @@
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@@ -55,7 +55,7 @@
fun testSingleDestinationSet() {
lateinit var navController: NavHostController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
NavHost(navController, startDestination = "first") {
test("first")
@@ -71,7 +71,7 @@
fun testNavigate() {
lateinit var navController: NavHostController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
NavHost(navController, startDestination = "first") {
test("first")
@@ -149,7 +149,7 @@
fun testPop() {
lateinit var navController: TestNavHostController
composeTestRule.setContent {
- navController = TestNavHostController(AmbientContext.current)
+ navController = TestNavHostController(LocalContext.current)
NavHost(navController, startDestination = "first") {
test("first")
@@ -175,7 +175,7 @@
lateinit var state: MutableState<String>
composeTestRule.setContent {
state = remember { mutableStateOf("first") }
- val context = AmbientContext.current
+ val context = LocalContext.current
navController = remember { TestNavHostController(context) }
NavHost(navController, startDestination = state.value) {
diff --git a/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt b/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
index 13ed100..166dbec 100644
--- a/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
+++ b/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
@@ -24,9 +24,9 @@
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.SaveableStateHolder
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
-import androidx.compose.ui.platform.AmbientContext
-import androidx.compose.ui.platform.AmbientLifecycleOwner
-import androidx.compose.ui.platform.AmbientViewModelStoreOwner
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalLifecycleOwner
+import androidx.compose.ui.platform.LocalViewModelStoreOwner
import androidx.compose.ui.viewinterop.viewModel
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
@@ -80,9 +80,9 @@
*/
@Composable
public fun NavHost(navController: NavHostController, graph: NavGraph) {
- var context = AmbientContext.current
- val lifecycleOwner = AmbientLifecycleOwner.current
- val viewModelStore = AmbientViewModelStoreOwner.current.viewModelStore
+ var context = LocalContext.current
+ val lifecycleOwner = LocalLifecycleOwner.current
+ val viewModelStore = LocalViewModelStoreOwner.current.viewModelStore
val rememberedGraph = remember { graph }
// on successful recompose we setup the navController with proper inputs
@@ -124,8 +124,8 @@
// while in the scope of the composable, we provide the navBackStackEntry as the
// ViewModelStoreOwner and LifecycleOwner
Providers(
- AmbientViewModelStoreOwner provides currentNavBackStackEntry,
- AmbientLifecycleOwner provides currentNavBackStackEntry
+ LocalViewModelStoreOwner provides currentNavBackStackEntry,
+ LocalLifecycleOwner provides currentNavBackStackEntry
) {
saveableStateHolder.SaveableStateProvider {
destination.content(currentNavBackStackEntry)
diff --git a/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHostController.kt b/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHostController.kt
index 7d7533a..08c66a0 100644
--- a/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHostController.kt
+++ b/navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHostController.kt
@@ -26,7 +26,7 @@
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.core.net.toUri
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
@@ -76,7 +76,7 @@
*/
@Composable
public fun rememberNavController(): NavHostController {
- val context = AmbientContext.current
+ val context = LocalContext.current
return rememberSaveable(saver = NavControllerSaver(context)) {
createNavController(context)
}
diff --git a/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/PagingRoomSample.kt b/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/PagingRoomSample.kt
index 93dea17..780a5ac 100644
--- a/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/PagingRoomSample.kt
+++ b/paging/paging-compose/integration-tests/paging-demos/src/main/java/androidx/paging/compose/demos/room/PagingRoomSample.kt
@@ -23,7 +23,7 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
-import androidx.compose.ui.platform.AmbientContext
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.sp
import androidx.paging.Pager
import androidx.paging.PagingConfig
@@ -35,7 +35,7 @@
@Composable
fun PagingRoomDemo() {
- val context = AmbientContext.current
+ val context = LocalContext.current
val dao: UserDao = AppDatabase.getInstance(context).userDao()
val scope = rememberCoroutineScope()