[go: nahoru, domu]

Modifier.drawBackground -> Modifier.background

This CL renamed drawBackground modifier to just background for better readability.

While renaming API, this CL also cuts unnecessary APIs from this modifiers that might confuse users, like alpha in color version or fill type, as background always fills

Relnote: Modifier.drawBackground has been renamed to Modifier.background
Fixes: 159612389
Test: renamed and should pass
Change-Id: I1367723fce0e07418ed4ab391fe20c69aa092f53
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
index 01d845c..a6f4e69 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
@@ -25,8 +25,8 @@
 import androidx.ui.core.onPositioned
 import androidx.ui.core.testTag
 import androidx.ui.foundation.Box
+import androidx.ui.foundation.background
 import androidx.ui.foundation.clickable
-import androidx.ui.foundation.drawBackground
 import androidx.ui.geometry.Offset
 import androidx.ui.graphics.Color
 import androidx.ui.layout.fillMaxSize
@@ -341,10 +341,10 @@
             Box(Modifier.testTag("Drawer")) {
                 ModalDrawerLayout(drawerState.value, { drawerState.value = it },
                     drawerContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Magenta))
+                        Box(Modifier.fillMaxSize().background(color = Color.Magenta))
                     },
                     bodyContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Red))
+                        Box(Modifier.fillMaxSize().background(color = Color.Red))
                     })
             }
         }
@@ -372,10 +372,10 @@
             Box(Modifier.testTag("Drawer").rtl) {
                 ModalDrawerLayout(drawerState.value, { drawerState.value = it },
                     drawerContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Magenta))
+                        Box(Modifier.fillMaxSize().background(color = Color.Magenta))
                     },
                     bodyContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Red))
+                        Box(Modifier.fillMaxSize().background(color = Color.Red))
                     })
             }
         }
@@ -403,10 +403,10 @@
             Box(Modifier.testTag("Drawer")) {
                 BottomDrawerLayout(drawerState.value, { drawerState.value = it },
                     drawerContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Magenta))
+                        Box(Modifier.fillMaxSize().background(color = Color.Magenta))
                     },
                     bodyContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Red))
+                        Box(Modifier.fillMaxSize().background(color = Color.Red))
                     })
             }
         }
@@ -434,10 +434,10 @@
             Box(Modifier.testTag("Drawer")) {
                 BottomDrawerLayout(drawerState.value, { drawerState.value = it },
                     drawerContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Magenta))
+                        Box(Modifier.fillMaxSize().background(Color.Magenta))
                     },
                     bodyContent = {
-                        Box(Modifier.fillMaxSize().drawBackground(Color.Red))
+                        Box(Modifier.fillMaxSize().background(Color.Red))
                     })
             }
         }
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
index 61d01e3..10e6c73 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
@@ -27,9 +27,9 @@
 import androidx.ui.core.testTag
 import androidx.ui.foundation.Box
 import androidx.ui.foundation.Text
+import androidx.ui.foundation.background
 import androidx.ui.foundation.clickable
 import androidx.ui.foundation.contentColor
-import androidx.ui.foundation.drawBackground
 import androidx.ui.graphics.Color
 import androidx.ui.layout.preferredSize
 import androidx.ui.layout.size
@@ -69,7 +69,7 @@
             DropdownMenu(
                 expanded = expanded,
                 toggle = {
-                    Box(Modifier.size(20.dp).drawBackground(Color.Blue))
+                    Box(Modifier.size(20.dp).background(color = Color.Blue))
                 },
                 >
             ) {
@@ -103,7 +103,7 @@
                 DropdownMenu(
                     expanded = true,
                     toggle = {
-                        Box(Modifier.size(20.toDp()).drawBackground(Color.Blue))
+                        Box(Modifier.size(20.toDp()).background(color = Color.Blue))
                     },
                     >
                 ) {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
index 695b856..83552b8 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
@@ -31,7 +31,7 @@
 import androidx.ui.foundation.Box
 import androidx.ui.foundation.Icon
 import androidx.ui.foundation.Text
-import androidx.ui.foundation.drawBackground
+import androidx.ui.foundation.background
 import androidx.ui.geometry.Offset
 import androidx.ui.graphics.Color
 import androidx.ui.layout.DpConstraints
@@ -118,7 +118,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(50.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             ) {
@@ -126,7 +126,7 @@
                     .onPositioned { contentPosition = it.localToGlobal(Offset.Zero) }
                     .fillMaxWidth()
                     .preferredHeight(50.dp)
-                    .drawBackground(Color.Blue)
+                    .background(Color.Blue)
                 )
             }
         }
@@ -150,7 +150,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(50.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             ) {
@@ -161,7 +161,7 @@
                     }
                     .fillMaxWidth()
                     .preferredHeight(50.dp)
-                    .drawBackground(Color.Blue)
+                    .background(color = Color.Blue)
                 )
             }
         }
@@ -186,7 +186,7 @@
                             }
                             .fillMaxWidth()
                             .preferredHeight(50.dp)
-                            .drawBackground(Color.Blue)
+                            .background(color = Color.Blue)
                         )
                     }
                 ) {
@@ -194,7 +194,7 @@
                         Modifier
                             .fillMaxWidth()
                             .preferredHeight(50.dp)
-                            .drawBackground(Color.Blue)
+                            .background(color = Color.Blue)
                     )
                 }
             }
@@ -239,7 +239,7 @@
                             }
                             .fillMaxWidth()
                             .preferredHeight(50.dp)
-                            .drawBackground(Color.Blue)
+                            .background(color = Color.Blue)
                         )
                     }
                 ) {
@@ -247,7 +247,7 @@
                         Modifier
                             .fillMaxWidth()
                             .preferredHeight(50.dp)
-                            .drawBackground(Color.Blue)
+                            .background(color = Color.Blue)
                     )
                 }
             }
@@ -290,7 +290,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(100.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             ) {
@@ -329,7 +329,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(100.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             ) {
@@ -355,13 +355,13 @@
                         Box(
                             Modifier.size(10.dp)
                                 .drawShadow(4.dp)
-                                .drawBackground(Color.White)
+                                .background(color = Color.White)
                         )
                     }
                 ) {
                     Box(
                         Modifier.size(10.dp)
-                            .drawBackground(Color.White)
+                            .background(color = Color.White)
                     )
                 }
             }
@@ -429,7 +429,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(100.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             } else {
@@ -466,7 +466,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(100.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             } else {
@@ -505,7 +505,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(100.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             ) {
@@ -537,7 +537,7 @@
                         }
                         .fillMaxWidth()
                         .preferredHeight(100.dp)
-                        .drawBackground(Color.Red)
+                        .background(color = Color.Red)
                     )
                 }
             ) {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
index 2c9bf07..f3864a7 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
@@ -23,7 +23,7 @@
 import androidx.ui.core.DensityAmbient
 import androidx.ui.core.Modifier
 import androidx.ui.core.testTag
-import androidx.ui.foundation.drawBackground
+import androidx.ui.foundation.background
 import androidx.ui.geometry.Offset
 import androidx.ui.graphics.Color
 import androidx.ui.graphics.compositeOver
@@ -266,7 +266,7 @@
                 thumbStrokeWidth = TrackHeight.toIntPx()
                 thumbPx = ThumbRadius.toIntPx()
             }
-            Slider(modifier = Modifier.testTag(sliderTag).drawBackground(Color.Gray),
+            Slider(modifier = Modifier.testTag(sliderTag).background(color = Color.Gray),
                 color = Color.Green,
                 value = 0.5f,
                 >
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
index f10e94b..7682e92 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
@@ -24,7 +24,7 @@
 import androidx.ui.core.testTag
 import androidx.ui.core.zIndex
 import androidx.ui.foundation.Box
-import androidx.ui.foundation.drawBackground
+import androidx.ui.foundation.background
 import androidx.ui.graphics.Color
 import androidx.ui.graphics.RectangleShape
 import androidx.ui.layout.Stack
@@ -109,7 +109,7 @@
                 .preferredSize(10.dp, 10.dp)
                 .semantics(mergeAllDescendants = true) {}
                 .testTag("stack")) {
-                Box(Modifier.fillMaxSize().drawBackground(Color.Green).zIndex(3f))
+                Box(Modifier.fillMaxSize().background(color = Color.Green).zIndex(3f))
                 Surface(color = Color.Yellow, elevation = 2.dp) {
                     Box(Modifier.fillMaxSize())
                 }
@@ -134,7 +134,7 @@
                 .preferredSize(10.dp, 10.dp)
                 .semantics(mergeAllDescendants = true) {}
                 .testTag("stack")) {
-                Box(Modifier.fillMaxSize().drawBackground(Color.Green).zIndex(1f))
+                Box(Modifier.fillMaxSize().background(color = Color.Green).zIndex(1f))
                 Surface(color = Color.Yellow, elevation = 2.dp) {
                     Box(Modifier.fillMaxSize())
                 }
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
index be7c851..7528721 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
@@ -25,7 +25,7 @@
 import androidx.ui.foundation.Box
 import androidx.ui.foundation.Icon
 import androidx.ui.foundation.Text
-import androidx.ui.foundation.drawBackground
+import androidx.ui.foundation.background
 import androidx.ui.graphics.Color
 import androidx.ui.layout.fillMaxWidth
 import androidx.ui.layout.preferredHeight
@@ -109,10 +109,11 @@
 
             val indicatorContainer = @Composable { tabPositions: List<TabRow.TabPosition> ->
                 TabRow.IndicatorContainer(tabPositions, state) {
-                    Box(Modifier
-                        .fillMaxWidth()
-                        .preferredHeight(indicatorHeight)
-                        .drawBackground(Color.Red)
+                    Box(
+                        Modifier
+                            .fillMaxWidth()
+                            .preferredHeight(indicatorHeight)
+                            .background(color = Color.Red)
                         .testTag("indicator")
                     )
                 }
@@ -275,10 +276,11 @@
 
             val indicatorContainer = @Composable { tabPositions: List<TabRow.TabPosition> ->
                 TabRow.IndicatorContainer(tabPositions, state) {
-                    Box(Modifier
-                        .fillMaxWidth()
-                        .preferredHeight(indicatorHeight)
-                        .drawBackground(Color.Red)
+                    Box(
+                        Modifier
+                            .fillMaxWidth()
+                            .preferredHeight(indicatorHeight)
+                            .background(color = Color.Red)
                         .testTag("indicator")
                     )
                 }
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
index c4f64ec..6a71f16 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
@@ -29,9 +29,9 @@
 import androidx.ui.core.testTag
 import androidx.ui.foundation.Box
 import androidx.ui.foundation.Text
+import androidx.ui.foundation.background
 import androidx.ui.foundation.contentColor
 import androidx.ui.foundation.currentTextStyle
-import androidx.ui.foundation.drawBackground
 import androidx.ui.geometry.Offset
 import androidx.ui.graphics.Color
 import androidx.ui.graphics.RectangleShape
@@ -695,7 +695,7 @@
         val latch = CountDownLatch(1)
 
         testRule.setMaterialContent {
-            Stack(Modifier.drawBackground(Color.White)) {
+            Stack(Modifier.background(color = Color.White)) {
                 FilledTextField(
                     modifier = Modifier.testTag(TextfieldTag),
                     value = "",
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
index 47c544b..3bfc7da 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
@@ -29,9 +29,9 @@
 import androidx.ui.core.testTag
 import androidx.ui.foundation.Box
 import androidx.ui.foundation.Text
+import androidx.ui.foundation.background
 import androidx.ui.foundation.contentColor
 import androidx.ui.foundation.currentTextStyle
-import androidx.ui.foundation.drawBackground
 import androidx.ui.geometry.Offset
 import androidx.ui.graphics.Color
 import androidx.ui.graphics.RectangleShape
@@ -582,7 +582,7 @@
     @SdkSuppress(minSdkVersion = Build.VERSION_CODES.O)
     fun testOutlinedTextField_visualTransformationPropagated() {
         testRule.setMaterialContent {
-            Box(Modifier.drawBackground(Color.White)) {
+            Box(Modifier.background(color = Color.White)) {
                 OutlinedTextField(
                     modifier = Modifier.testTag(TextfieldTag),
                     value = "qwerty",
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
index ed8a803..7795b03 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
@@ -23,7 +23,7 @@
 import androidx.ui.core.Modifier
 import androidx.ui.core.testTag
 import androidx.ui.foundation.TextField
-import androidx.ui.foundation.drawBackground
+import androidx.ui.foundation.background
 import androidx.ui.graphics.Color
 import androidx.ui.input.TextFieldValue
 import androidx.ui.layout.Stack
@@ -122,7 +122,7 @@
                 Stack(
                     Modifier
                         .preferredSize(parentSize.toDp())
-                        .drawBackground(Color.White)
+                        .background(color = Color.White)
                         .testTag(TextfieldTag)
                 ) {
                     TextFieldScroller(