blob: 1752710cdc3f4c2375119ee0aaeb648b9db2f455 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import '../fn.dart';
import 'material.dart';
import '../theme/colors.dart';
class FloatingActionButton extends Component {
static final Style _style = new Style('''
position: absolute;
bottom: 16px;
right: 16px;
z-index: 5;
transform: translateX(0);
width: 56px;
height: 56px;
background-color: ${Red[500]};
color: white;
border-radius: 28px;'''
);
static final Style _clipStyle = new Style('''
transform: translateX(0);
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
left: 0;
right: 0;
bottom: 0;
-webkit-clip-path: circle(28px at center);''');
Node content;
int level;
FloatingActionButton({ Object key, this.content, this.level: 0 })
: super(key: key);
Node build() {
List<Node> children = [];
if (content != null)
children.add(content);
List<Style> containerStyle = [_style];
if (level > 0)
containerStyle.add(Material.shadowStyle[level]);
return new Container(
key: "Container",
styles: containerStyle,
children: [
new Material(
key: "Clip",
styles: [_clipStyle],
children: children
)
]
);
}
}