Accept modifiers in Surface
Bug: 143760114
Test: built and ran demos
Change-Id: Id4654795e48da442d0685212f04fce7e0f02fa20
diff --git a/ui/ui-material/api/0.1.0-dev03.txt b/ui/ui-material/api/0.1.0-dev03.txt
index 242833c..3a98b93 100644
--- a/ui/ui-material/api/0.1.0-dev03.txt
+++ b/ui/ui-material/api/0.1.0-dev03.txt
@@ -401,7 +401,7 @@
public final class SurfaceKt {
ctor public SurfaceKt();
- method public static void Surface(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
+ method public static void Surface(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
surface
}), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 0.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method public static androidx.compose.Ambient<androidx.ui.graphics.Color> getCurrentBackground();
diff --git a/ui/ui-material/api/current.txt b/ui/ui-material/api/current.txt
index 242833c..3a98b93 100644
--- a/ui/ui-material/api/current.txt
+++ b/ui/ui-material/api/current.txt
@@ -401,7 +401,7 @@
public final class SurfaceKt {
ctor public SurfaceKt();
- method public static void Surface(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
+ method public static void Surface(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
surface
}), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 0.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method public static androidx.compose.Ambient<androidx.ui.graphics.Color> getCurrentBackground();
diff --git a/ui/ui-material/api/public_plus_experimental_0.1.0-dev03.txt b/ui/ui-material/api/public_plus_experimental_0.1.0-dev03.txt
index 242833c..3a98b93 100644
--- a/ui/ui-material/api/public_plus_experimental_0.1.0-dev03.txt
+++ b/ui/ui-material/api/public_plus_experimental_0.1.0-dev03.txt
@@ -401,7 +401,7 @@
public final class SurfaceKt {
ctor public SurfaceKt();
- method public static void Surface(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
+ method public static void Surface(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
surface
}), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 0.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method public static androidx.compose.Ambient<androidx.ui.graphics.Color> getCurrentBackground();
diff --git a/ui/ui-material/api/public_plus_experimental_current.txt b/ui/ui-material/api/public_plus_experimental_current.txt
index 242833c..3a98b93 100644
--- a/ui/ui-material/api/public_plus_experimental_current.txt
+++ b/ui/ui-material/api/public_plus_experimental_current.txt
@@ -401,7 +401,7 @@
public final class SurfaceKt {
ctor public SurfaceKt();
- method public static void Surface(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
+ method public static void Surface(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
surface
}), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 0.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method public static androidx.compose.Ambient<androidx.ui.graphics.Color> getCurrentBackground();
diff --git a/ui/ui-material/api/restricted_0.1.0-dev03.txt b/ui/ui-material/api/restricted_0.1.0-dev03.txt
index 242833c..3a98b93 100644
--- a/ui/ui-material/api/restricted_0.1.0-dev03.txt
+++ b/ui/ui-material/api/restricted_0.1.0-dev03.txt
@@ -401,7 +401,7 @@
public final class SurfaceKt {
ctor public SurfaceKt();
- method public static void Surface(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
+ method public static void Surface(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
surface
}), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 0.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method public static androidx.compose.Ambient<androidx.ui.graphics.Color> getCurrentBackground();
diff --git a/ui/ui-material/api/restricted_current.txt b/ui/ui-material/api/restricted_current.txt
index 242833c..3a98b93 100644
--- a/ui/ui-material/api/restricted_current.txt
+++ b/ui/ui-material/api/restricted_current.txt
@@ -401,7 +401,7 @@
public final class SurfaceKt {
ctor public SurfaceKt();
- method public static void Surface(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
+ method public static void Surface(androidx.ui.core.Modifier modifier = Modifier.None, androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({
surface
}), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 0.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
method public static androidx.compose.Ambient<androidx.ui.graphics.Color> getCurrentBackground();
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Button.kt b/ui/ui-material/src/main/java/androidx/ui/material/Button.kt
index ae93094..83f21e6 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Button.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Button.kt
@@ -179,7 +179,12 @@
style: ButtonStyle = ContainedButtonStyle(),
children: @Composable() () -> Unit
) {
- Surface(style.shape, style.color, style.border, style.elevation) {
+ Surface(
+ shape = style.shape,
+ color = style.color,
+ border = style.border,
+ elevation = style.elevation
+ ) {
Ripple(bounded = true, color = style.rippleColor, enabled = onClick != null) {
Clickable(onClick = onClick) {
Container(constraints = ButtonConstraints, padding = style.paddings) {
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/surface/Surface.kt b/ui/ui-material/src/main/java/androidx/ui/material/surface/Surface.kt
index ef5eab3..5cc302d 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/surface/Surface.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/surface/Surface.kt
@@ -25,6 +25,7 @@
import androidx.ui.core.Dp
import androidx.ui.core.DrawShadow
import androidx.ui.core.Layout
+import androidx.ui.core.Modifier
import androidx.ui.core.Text
import androidx.ui.core.dp
import androidx.ui.core.ipx
@@ -60,6 +61,7 @@
* values use [CurrentTextStyleProvider] or provide direct styling to your components.
* @see textColorForBackground
*
+ * @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
* displayed if the [elevation] is greater than zero.
* @param color The background color. Use [Color.Transparent] to have no color.
@@ -69,13 +71,14 @@
*/
@Composable
fun Surface(
+ modifier: Modifier = Modifier.None,
shape: Shape = RectangleShape,
color: Color = +themeColor { surface },
border: Border? = null,
elevation: Dp = 0.dp,
children: @Composable() () -> Unit
) {
- SurfaceLayout {
+ SurfaceLayout(modifier) {
if (elevation > 0.dp) {
DrawShadow(shape = shape, elevation = elevation)
}
@@ -109,8 +112,8 @@
*/
// TODO("Andrey: Should be replaced with some basic layout implementation when we have it")
@Composable
-private fun SurfaceLayout(children: @Composable() () -> Unit) {
- Layout(children) { measurables, constraints ->
+private fun SurfaceLayout(modifier: Modifier = Modifier.None, children: @Composable() () -> Unit) {
+ Layout(children, modifier) { measurables, constraints ->
if (measurables.size > 1) {
throw IllegalStateException("Surface can have only one direct measurable child!")
}