Commit 0d7b61f5 authored by Adam Barth's avatar Adam Barth

Improve elevation docs (#3502)

Fixes #3501
parent d74025f4
...@@ -96,6 +96,8 @@ class AppBar extends StatelessWidget { ...@@ -96,6 +96,8 @@ class AppBar extends StatelessWidget {
final TabBar<dynamic> tabBar; final TabBar<dynamic> tabBar;
/// The z-coordinate at which to place this app bar. /// The z-coordinate at which to place this app bar.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
/// The color to use for the the app bar's material. /// The color to use for the the app bar's material.
......
...@@ -51,6 +51,8 @@ class Drawer extends StatelessWidget { ...@@ -51,6 +51,8 @@ class Drawer extends StatelessWidget {
}) : super(key: key); }) : super(key: key);
/// The z-coordinate at which to place this drawer. /// The z-coordinate at which to place this drawer.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
......
...@@ -43,7 +43,7 @@ class _DropDownMenuPainter extends CustomPainter { ...@@ -43,7 +43,7 @@ class _DropDownMenuPainter extends CustomPainter {
final BoxPainter painter = new BoxDecoration( final BoxPainter painter = new BoxDecoration(
backgroundColor: color, backgroundColor: color,
borderRadius: 2.0, borderRadius: 2.0,
boxShadow: elevationToShadow[elevation] boxShadow: kElevationToShadow[elevation]
).createBoxPainter(); ).createBoxPainter();
double top = renderBox.globalToLocal(new Point(0.0, menuTop)).y; double top = renderBox.globalToLocal(new Point(0.0, menuTop)).y;
...@@ -310,6 +310,8 @@ class DropDownButton<T> extends StatefulWidget { ...@@ -310,6 +310,8 @@ class DropDownButton<T> extends StatefulWidget {
final ValueChanged<T> onChanged; final ValueChanged<T> onChanged;
/// The z-coordinate at which to place the menu when open. /// The z-coordinate at which to place the menu when open.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
@override @override
......
...@@ -73,6 +73,8 @@ class FloatingActionButton extends StatefulWidget { ...@@ -73,6 +73,8 @@ class FloatingActionButton extends StatefulWidget {
final VoidCallback onPressed; final VoidCallback onPressed;
/// The z-coordinate at which to place this button. /// The z-coordinate at which to place this button.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
/// The z-coordinate at which to place this button when the user is touching the button. /// The z-coordinate at which to place this button when the user is touching the button.
......
...@@ -181,6 +181,8 @@ class Material extends StatefulWidget { ...@@ -181,6 +181,8 @@ class Material extends StatefulWidget {
final MaterialType type; final MaterialType type;
/// The z-coordinate at which to place this material. /// The z-coordinate at which to place this material.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
/// The color to paint the material. /// The color to paint the material.
...@@ -266,7 +268,7 @@ class _MaterialState extends State<Material> { ...@@ -266,7 +268,7 @@ class _MaterialState extends State<Material> {
duration: kThemeChangeDuration, duration: kThemeChangeDuration,
decoration: new BoxDecoration( decoration: new BoxDecoration(
borderRadius: kMaterialEdges[config.type], borderRadius: kMaterialEdges[config.type],
boxShadow: config.elevation == 0 ? null : elevationToShadow[config.elevation], boxShadow: config.elevation == 0 ? null : kElevationToShadow[config.elevation],
shape: config.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle shape: config.type == MaterialType.circle ? BoxShape.circle : BoxShape.rectangle
), ),
child: new Container( child: new Container(
......
...@@ -417,6 +417,8 @@ class PopupMenuButton<T> extends StatefulWidget { ...@@ -417,6 +417,8 @@ class PopupMenuButton<T> extends StatefulWidget {
final String tooltip; final String tooltip;
/// The z-coordinate at which to place the menu when open. /// The z-coordinate at which to place the menu when open.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
......
...@@ -57,6 +57,8 @@ class RaisedButton extends MaterialButton { ...@@ -57,6 +57,8 @@ class RaisedButton extends MaterialButton {
final Color disabledColor; final Color disabledColor;
/// The z-coordinate at which to place this button. /// The z-coordinate at which to place this button.
///
/// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
final int elevation; final int elevation;
/// The z-coordinate at which to place this button when highlighted. /// The z-coordinate at which to place this button when highlighted.
......
...@@ -18,9 +18,10 @@ import 'package:flutter/painting.dart'; ...@@ -18,9 +18,10 @@ import 'package:flutter/painting.dart';
/// effect for that elevation. /// effect for that elevation.
/// ///
/// See also: /// See also:
///
/// * [Material] /// * [Material]
/// * <https://www.google.com/design/spec/what-is-material/elevation-shadows.html> /// * <https://www.google.com/design/spec/what-is-material/elevation-shadows.html>
const Map<int, List<BoxShadow>> elevationToShadow = _elevationToShadow; // to hide the literal from the docs const Map<int, List<BoxShadow>> kElevationToShadow = _elevationToShadow; // to hide the literal from the docs
const Color _kKeyUmbraOpacity = const Color(0x33000000); // alpha = 0.2 const Color _kKeyUmbraOpacity = const Color(0x33000000); // alpha = 0.2
const Color _kKeyPenumbraOpacity = const Color(0x24000000); // alpha = 0.14 const Color _kKeyPenumbraOpacity = const Color(0x24000000); // alpha = 0.14
......
...@@ -268,7 +268,7 @@ class _RenderSwitch extends RenderToggleable { ...@@ -268,7 +268,7 @@ class _RenderSwitch extends RenderToggleable {
return new BoxDecoration( return new BoxDecoration(
backgroundColor: color, backgroundColor: color,
shape: BoxShape.circle, shape: BoxShape.circle,
boxShadow: elevationToShadow[1] boxShadow: kElevationToShadow[1]
); );
} }
......
...@@ -16,7 +16,7 @@ void main() { ...@@ -16,7 +16,7 @@ void main() {
gradient: new RadialGradient( gradient: new RadialGradient(
center: FractionalOffset.topLeft, radius: 1.8, center: FractionalOffset.topLeft, radius: 1.8,
colors: <Color>[Colors.yellow[500], Colors.blue[500]]), colors: <Color>[Colors.yellow[500], Colors.blue[500]]),
boxShadow: elevationToShadow[3]) boxShadow: kElevationToShadow[3])
); );
layout(root); layout(root);
expect(root.size.width, equals(800.0)); expect(root.size.width, equals(800.0));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment