| 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 '../theme/colors.dart'; | 6 import '../theme/colors.dart'; |
| 7 import 'ink_well.dart'; | 7 import 'ink_well.dart'; |
| 8 import 'material.dart'; | 8 import 'material.dart'; |
| 9 | 9 |
| 10 class FloatingActionButton extends Component { | 10 class FloatingActionButton extends Component { |
| 11 // TODO(abarth): We need a better way to become a container for absolutely | 11 // TODO(abarth): We need a better way to become a container for absolutely |
| 12 // positioned elements. | 12 // positioned elements. |
| 13 static final Style _style = new Style(''' | 13 static final Style _style = new Style(''' |
| 14 transform: translateX(0); | |
| 15 width: 56px; | 14 width: 56px; |
| 16 height: 56px; | 15 height: 56px; |
| 17 background-color: ${Red[500]}; | 16 background-color: ${Red[500]}; |
| 18 border-radius: 28px;''' | 17 border-radius: 28px;''' |
| 19 ); | 18 ); |
| 20 static final Style _clipStyle = new Style(''' | 19 static final Style _clipStyle = new Style(''' |
| 21 transform: translateX(0); | |
| 22 position: absolute; | 20 position: absolute; |
| 23 display: flex; | |
| 24 flex-direction: row; | |
| 25 justify-content: center; | 21 justify-content: center; |
| 26 align-items: center; | 22 align-items: center; |
| 27 top: 0; | 23 top: 0; |
| 28 left: 0; | 24 left: 0; |
| 29 right: 0; | 25 right: 0; |
| 30 bottom: 0; | 26 bottom: 0; |
| 31 -webkit-clip-path: circle(28px at center);'''); | 27 -webkit-clip-path: circle(28px at center);'''); |
| 32 | 28 |
| 33 UINode content; | 29 UINode content; |
| 34 int level; | 30 int level; |
| 35 | 31 |
| 36 FloatingActionButton({ Object key, this.content, this.level: 0 }) | 32 FloatingActionButton({ Object key, this.content, this.level: 0 }) |
| 37 : super(key: key); | 33 : super(key: key); |
| 38 | 34 |
| 39 UINode build() { | 35 UINode build() { |
| 40 List<UINode> children = []; | 36 List<UINode> children = []; |
| 41 | 37 |
| 42 if (content != null) | 38 if (content != null) |
| 43 children.add(content); | 39 children.add(content); |
| 44 | 40 |
| 45 return new Material( | 41 return new Material( |
| 46 content: new Container( | 42 content: new Container( |
| 47 style: _style, | 43 style: _style, |
| 48 children: [new StyleNode(new InkWell(children: children), _clipStyle)]), | 44 children: [new StyleNode(new InkWell(children: children), _clipStyle)]), |
| 49 level: level); | 45 level: level); |
| 50 } | 46 } |
| 51 } | 47 } |
| OLD | NEW |