[go: nahoru, domu]

Actioned TODOs and updated seek bar animation demo

Test: Removed unused imports. Ran integration tests
Change-Id: Ia52257cdbfedda63227c38af0e9073e5863bca2a
diff --git a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBar.kt b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBar.kt
index 3bbc4cb..9dbb5e0 100644
--- a/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBar.kt
+++ b/ui/ui-animation/integration-tests/animation-demos/src/main/java/androidx/ui/animation/demos/AnimatableSeekBar.kt
@@ -84,9 +84,10 @@
 
     @Composable
     fun DrawSeekBar(x: Float) {
-        var paint = +memo { Paint() }
+        val paint = +memo { Paint() }
         Draw { canvas, parentSize ->
             val centerY = parentSize.height.value / 2
+            val xConstraint = x.coerceIn(0f, parentSize.width.value)
             // draw bar
             paint.color = Color.Gray
             canvas.drawRect(
@@ -95,12 +96,13 @@
             )
             paint.color = Color.Magenta
             canvas.drawRect(
-                Rect(0f, centerY - 5, x, centerY + 5),
+                Rect(0f, centerY - 5, xConstraint, centerY + 5),
                 paint
             )
+
             // draw ticker
             canvas.drawCircle(
-                Offset(x, centerY), 40f, paint
+                Offset(xConstraint, centerY), 40f, paint
             )
         }
     }
diff --git a/ui/ui-material/api/0.1.0-dev01.txt b/ui/ui-material/api/0.1.0-dev01.txt
index ff52462..cd753df 100644
--- a/ui/ui-material/api/0.1.0-dev01.txt
+++ b/ui/ui-material/api/0.1.0-dev01.txt
@@ -178,7 +178,7 @@
 
   public final class MaterialThemeKt {
     ctor public MaterialThemeKt();
-    method public static void MaterialButtonShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+    method public static void MaterialShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static void MaterialTheme(androidx.ui.material.MaterialColors colors = androidx.ui.material.MaterialColors(), androidx.ui.material.MaterialTypography typography = androidx.ui.material.MaterialTypography(), kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static androidx.compose.Ambient<androidx.ui.material.MaterialColors> getColors();
     method public static androidx.compose.Ambient<androidx.ui.material.Shapes> getCurrentShapeAmbient();
@@ -255,10 +255,12 @@
   }
 
   public final class Shapes {
-    ctor public Shapes(androidx.ui.engine.geometry.Shape button);
+    ctor public Shapes(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape component1();
-    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button);
+    method public androidx.ui.engine.geometry.Shape component2();
+    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape getButton();
+    method public androidx.ui.engine.geometry.Shape getCard();
   }
 
   public final class SwitchKt {
@@ -374,7 +376,9 @@
 
   public final class CardKt {
     ctor public CardKt();
-    method public static void Card(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({ 
+    method public static void Card(androidx.ui.engine.geometry.Shape shape = +themeShape({ 
+    card
+}), androidx.ui.graphics.Color color = +themeColor({ 
     surface
 }), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 1.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
   }
diff --git a/ui/ui-material/api/current.txt b/ui/ui-material/api/current.txt
index ff52462..cd753df 100644
--- a/ui/ui-material/api/current.txt
+++ b/ui/ui-material/api/current.txt
@@ -178,7 +178,7 @@
 
   public final class MaterialThemeKt {
     ctor public MaterialThemeKt();
-    method public static void MaterialButtonShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+    method public static void MaterialShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static void MaterialTheme(androidx.ui.material.MaterialColors colors = androidx.ui.material.MaterialColors(), androidx.ui.material.MaterialTypography typography = androidx.ui.material.MaterialTypography(), kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static androidx.compose.Ambient<androidx.ui.material.MaterialColors> getColors();
     method public static androidx.compose.Ambient<androidx.ui.material.Shapes> getCurrentShapeAmbient();
@@ -255,10 +255,12 @@
   }
 
   public final class Shapes {
-    ctor public Shapes(androidx.ui.engine.geometry.Shape button);
+    ctor public Shapes(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape component1();
-    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button);
+    method public androidx.ui.engine.geometry.Shape component2();
+    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape getButton();
+    method public androidx.ui.engine.geometry.Shape getCard();
   }
 
   public final class SwitchKt {
@@ -374,7 +376,9 @@
 
   public final class CardKt {
     ctor public CardKt();
-    method public static void Card(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({ 
+    method public static void Card(androidx.ui.engine.geometry.Shape shape = +themeShape({ 
+    card
+}), androidx.ui.graphics.Color color = +themeColor({ 
     surface
 }), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 1.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
   }
diff --git a/ui/ui-material/api/public_plus_experimental_0.1.0-dev01.txt b/ui/ui-material/api/public_plus_experimental_0.1.0-dev01.txt
index ff52462..cd753df 100644
--- a/ui/ui-material/api/public_plus_experimental_0.1.0-dev01.txt
+++ b/ui/ui-material/api/public_plus_experimental_0.1.0-dev01.txt
@@ -178,7 +178,7 @@
 
   public final class MaterialThemeKt {
     ctor public MaterialThemeKt();
-    method public static void MaterialButtonShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+    method public static void MaterialShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static void MaterialTheme(androidx.ui.material.MaterialColors colors = androidx.ui.material.MaterialColors(), androidx.ui.material.MaterialTypography typography = androidx.ui.material.MaterialTypography(), kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static androidx.compose.Ambient<androidx.ui.material.MaterialColors> getColors();
     method public static androidx.compose.Ambient<androidx.ui.material.Shapes> getCurrentShapeAmbient();
@@ -255,10 +255,12 @@
   }
 
   public final class Shapes {
-    ctor public Shapes(androidx.ui.engine.geometry.Shape button);
+    ctor public Shapes(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape component1();
-    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button);
+    method public androidx.ui.engine.geometry.Shape component2();
+    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape getButton();
+    method public androidx.ui.engine.geometry.Shape getCard();
   }
 
   public final class SwitchKt {
@@ -374,7 +376,9 @@
 
   public final class CardKt {
     ctor public CardKt();
-    method public static void Card(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({ 
+    method public static void Card(androidx.ui.engine.geometry.Shape shape = +themeShape({ 
+    card
+}), androidx.ui.graphics.Color color = +themeColor({ 
     surface
 }), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 1.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
   }
diff --git a/ui/ui-material/api/public_plus_experimental_current.txt b/ui/ui-material/api/public_plus_experimental_current.txt
index ff52462..cd753df 100644
--- a/ui/ui-material/api/public_plus_experimental_current.txt
+++ b/ui/ui-material/api/public_plus_experimental_current.txt
@@ -178,7 +178,7 @@
 
   public final class MaterialThemeKt {
     ctor public MaterialThemeKt();
-    method public static void MaterialButtonShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+    method public static void MaterialShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static void MaterialTheme(androidx.ui.material.MaterialColors colors = androidx.ui.material.MaterialColors(), androidx.ui.material.MaterialTypography typography = androidx.ui.material.MaterialTypography(), kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static androidx.compose.Ambient<androidx.ui.material.MaterialColors> getColors();
     method public static androidx.compose.Ambient<androidx.ui.material.Shapes> getCurrentShapeAmbient();
@@ -255,10 +255,12 @@
   }
 
   public final class Shapes {
-    ctor public Shapes(androidx.ui.engine.geometry.Shape button);
+    ctor public Shapes(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape component1();
-    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button);
+    method public androidx.ui.engine.geometry.Shape component2();
+    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape getButton();
+    method public androidx.ui.engine.geometry.Shape getCard();
   }
 
   public final class SwitchKt {
@@ -374,7 +376,9 @@
 
   public final class CardKt {
     ctor public CardKt();
-    method public static void Card(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({ 
+    method public static void Card(androidx.ui.engine.geometry.Shape shape = +themeShape({ 
+    card
+}), androidx.ui.graphics.Color color = +themeColor({ 
     surface
 }), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 1.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
   }
diff --git a/ui/ui-material/api/restricted_0.1.0-dev01.txt b/ui/ui-material/api/restricted_0.1.0-dev01.txt
index ff52462..cd753df 100644
--- a/ui/ui-material/api/restricted_0.1.0-dev01.txt
+++ b/ui/ui-material/api/restricted_0.1.0-dev01.txt
@@ -178,7 +178,7 @@
 
   public final class MaterialThemeKt {
     ctor public MaterialThemeKt();
-    method public static void MaterialButtonShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+    method public static void MaterialShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static void MaterialTheme(androidx.ui.material.MaterialColors colors = androidx.ui.material.MaterialColors(), androidx.ui.material.MaterialTypography typography = androidx.ui.material.MaterialTypography(), kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static androidx.compose.Ambient<androidx.ui.material.MaterialColors> getColors();
     method public static androidx.compose.Ambient<androidx.ui.material.Shapes> getCurrentShapeAmbient();
@@ -255,10 +255,12 @@
   }
 
   public final class Shapes {
-    ctor public Shapes(androidx.ui.engine.geometry.Shape button);
+    ctor public Shapes(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape component1();
-    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button);
+    method public androidx.ui.engine.geometry.Shape component2();
+    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape getButton();
+    method public androidx.ui.engine.geometry.Shape getCard();
   }
 
   public final class SwitchKt {
@@ -374,7 +376,9 @@
 
   public final class CardKt {
     ctor public CardKt();
-    method public static void Card(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({ 
+    method public static void Card(androidx.ui.engine.geometry.Shape shape = +themeShape({ 
+    card
+}), androidx.ui.graphics.Color color = +themeColor({ 
     surface
 }), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 1.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
   }
diff --git a/ui/ui-material/api/restricted_current.txt b/ui/ui-material/api/restricted_current.txt
index ff52462..cd753df 100644
--- a/ui/ui-material/api/restricted_current.txt
+++ b/ui/ui-material/api/restricted_current.txt
@@ -178,7 +178,7 @@
 
   public final class MaterialThemeKt {
     ctor public MaterialThemeKt();
-    method public static void MaterialButtonShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
+    method public static void MaterialShapeTheme(kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static void MaterialTheme(androidx.ui.material.MaterialColors colors = androidx.ui.material.MaterialColors(), androidx.ui.material.MaterialTypography typography = androidx.ui.material.MaterialTypography(), kotlin.jvm.functions.Function0<kotlin.Unit> children);
     method public static androidx.compose.Ambient<androidx.ui.material.MaterialColors> getColors();
     method public static androidx.compose.Ambient<androidx.ui.material.Shapes> getCurrentShapeAmbient();
@@ -255,10 +255,12 @@
   }
 
   public final class Shapes {
-    ctor public Shapes(androidx.ui.engine.geometry.Shape button);
+    ctor public Shapes(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape component1();
-    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button);
+    method public androidx.ui.engine.geometry.Shape component2();
+    method public androidx.ui.material.Shapes copy(androidx.ui.engine.geometry.Shape button, androidx.ui.engine.geometry.Shape card);
     method public androidx.ui.engine.geometry.Shape getButton();
+    method public androidx.ui.engine.geometry.Shape getCard();
   }
 
   public final class SwitchKt {
@@ -374,7 +376,9 @@
 
   public final class CardKt {
     ctor public CardKt();
-    method public static void Card(androidx.ui.engine.geometry.Shape shape = RectangleShape, androidx.ui.graphics.Color color = +themeColor({ 
+    method public static void Card(androidx.ui.engine.geometry.Shape shape = +themeShape({ 
+    card
+}), androidx.ui.graphics.Color color = +themeColor({ 
     surface
 }), androidx.ui.foundation.shape.border.Border? border = null, androidx.ui.core.Dp elevation = 1.dp, kotlin.jvm.functions.Function0<kotlin.Unit> children);
   }
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/MaterialTheme.kt b/ui/ui-material/src/main/java/androidx/ui/material/MaterialTheme.kt
index 87ddd92..6e6457a 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/MaterialTheme.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/MaterialTheme.kt
@@ -29,6 +29,7 @@
 import androidx.ui.core.sp
 import androidx.ui.core.withDensity
 import androidx.ui.engine.geometry.Shape
+import androidx.ui.foundation.shape.RectangleShape
 import androidx.ui.foundation.shape.corner.RoundedCornerShape
 import androidx.ui.graphics.Color
 import androidx.ui.graphics.luminance
@@ -67,7 +68,7 @@
         Typography.Provider(value = typography) {
             CurrentTextStyleProvider(value = typography.body1) {
                 MaterialRippleTheme {
-                    MaterialButtonShapeTheme(children = children)
+                    MaterialShapeTheme(children = children)
                 }
             }
         }
@@ -280,14 +281,18 @@
     /**
      * Shape used for [Button]
      */
-    val button: Shape
-    // TODO(Andrey): Add shapes for Card, other surfaces? will see what we need.
+    val button: Shape,
+    /**
+     * Shape used for [Card]
+     */
+    val card: Shape
+    // TODO(Andrey): Add shapes for other surfaces? will see what we need.
 )
 
 /**
  * Ambient used to specify the default shapes for the surfaces.
  *
- * @see [MaterialButtonShapeTheme] for the default Material Design value
+ * @see [MaterialShapeTheme] for the default Material Design value
  */
 val CurrentShapeAmbient = Ambient.of<Shapes> {
     throw IllegalStateException("No default shapes provided.")
@@ -297,10 +302,11 @@
  * Applies the default [Shape]s for all the surfaces.
  */
 @Composable
-fun MaterialButtonShapeTheme(children: @Composable() () -> Unit) {
+fun MaterialShapeTheme(children: @Composable() () -> Unit) {
     val value = +withDensity {
         Shapes(
-            button = RoundedCornerShape(4.dp)
+            button = RoundedCornerShape(4.dp),
+            card = RectangleShape
         )
     }
     CurrentShapeAmbient.Provider(value = value, children = children)
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/surface/Card.kt b/ui/ui-material/src/main/java/androidx/ui/material/surface/Card.kt
index 8ec7d6a..65aaf11 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/surface/Card.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/surface/Card.kt
@@ -22,11 +22,11 @@
 import androidx.ui.core.Dp
 import androidx.ui.core.dp
 import androidx.ui.engine.geometry.Shape
-import androidx.ui.foundation.shape.RectangleShape
 import androidx.ui.foundation.shape.border.Border
 import androidx.ui.graphics.Color
 import androidx.ui.material.MaterialColors
 import androidx.ui.material.themeColor
+import androidx.ui.material.themeShape
 
 /**
  * Cards are [Surface]s that display content and actions on a single topic.
@@ -44,7 +44,7 @@
  */
 @Composable
 fun Card(
-    shape: Shape = RectangleShape, // TODO (Andrey: Take the default shape from the theme)
+    shape: Shape = +themeShape { card },
     color: Color = +themeColor { surface },
     border: Border? = null,
     elevation: Dp = 1.dp,