| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import '../fn.dart'; | 5 import '../fn.dart'; |
| 6 import 'material.dart'; | 6 import 'material.dart'; |
| 7 import '../theme/colors.dart'; | 7 import '../theme/colors.dart'; |
| 8 import '../theme/shadows.dart'; | 8 import '../theme/shadows.dart'; |
| 9 | 9 |
| 10 class FloatingActionButton extends Component { | 10 class FloatingActionButton extends Component { |
| 11 static final Style _style = new Style(''' | 11 static final Style _style = new Style(''' |
| 12 position: absolute; | 12 position: absolute; |
| 13 bottom: 16px; | 13 bottom: 16px; |
| 14 right: 16px; | 14 right: 16px; |
| 15 z-index: 5; | 15 z-index: 5; |
| 16 transform: translateX(0); | 16 transform: translateX(0); |
| 17 width: 56px; | 17 width: 56px; |
| 18 height: 56px; | 18 height: 56px; |
| 19 background-color: ${Red[500]}; | 19 background-color: ${Red[500]}; |
| 20 color: white; | 20 color: white; |
| 21 box-shadow: ${Shadow[3]}; | |
| 22 border-radius: 28px;''' | 21 border-radius: 28px;''' |
| 23 ); | 22 ); |
| 24 static final Style _clipStyle = new Style(''' | 23 static final Style _clipStyle = new Style(''' |
| 25 transform: translateX(0); | 24 transform: translateX(0); |
| 26 position: absolute; | 25 position: absolute; |
| 27 display: flex; | 26 display: flex; |
| 28 justify-content: center; | 27 justify-content: center; |
| 29 align-items: center; | 28 align-items: center; |
| 30 top: 0; | 29 top: 0; |
| 31 left: 0; | 30 left: 0; |
| 32 right: 0; | 31 right: 0; |
| 33 bottom: 0; | 32 bottom: 0; |
| 34 -webkit-clip-path: circle(28px at center);'''); | 33 -webkit-clip-path: circle(28px at center);'''); |
| 35 | 34 |
| 36 Node content; | 35 Node content; |
| 36 int level; |
| 37 | 37 |
| 38 FloatingActionButton({ Object key, this.content }) : super(key: key); | 38 FloatingActionButton({ Object key, this.content, this.level: 0 }) |
| 39 : super(key: key); |
| 39 | 40 |
| 40 Node build() { | 41 Node build() { |
| 41 List<Node> children = []; | 42 List<Node> children = []; |
| 42 | 43 |
| 43 if (content != null) | 44 if (content != null) |
| 44 children.add(content); | 45 children.add(content); |
| 45 | 46 |
| 47 List<Style> containerStyle = [_style]; |
| 48 if (level > 0) |
| 49 containerStyle.add(Material.shadowStyle[level]); |
| 50 |
| 46 return new Container( | 51 return new Container( |
| 47 key: "Container", | 52 key: "Container", |
| 48 style: _style, | 53 styles: containerStyle, |
| 49 children: [ | 54 children: [ |
| 50 new Material( | 55 new Material( |
| 51 key: "Clip", | 56 key: "Clip", |
| 52 style: _clipStyle, | 57 styles: [_clipStyle], |
| 53 children: children | 58 children: children |
| 54 ) | 59 ) |
| 55 ] | 60 ] |
| 56 ); | 61 ); |
| 57 } | 62 } |
| 58 } | 63 } |
| OLD | NEW |