// 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 'package:sky/src/widgets/basic.dart'; import 'package:sky/src/widgets/button_base.dart'; import 'package:sky/src/widgets/framework.dart'; import 'package:sky/src/widgets/gesture_detector.dart'; import 'package:sky/src/widgets/icon.dart'; import 'package:sky/src/widgets/ink_well.dart'; import 'package:sky/src/widgets/material.dart'; import 'package:sky/src/widgets/theme.dart'; // TODO(eseidel): This needs to change based on device size? // http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-keylines-spacing const double _kSize = 56.0; class FloatingActionButton extends ButtonBase { FloatingActionButton({ Key key, this.child, this.backgroundColor, this.onPressed }) : super(key: key); Widget child; Color backgroundColor; Function onPressed; void syncConstructorArguments(FloatingActionButton source) { super.syncConstructorArguments(source); child = source.child; backgroundColor = source.backgroundColor; onPressed = source.onPressed; } Widget buildContent() { IconThemeColor iconThemeColor = IconThemeColor.white; Color materialColor = backgroundColor; if (materialColor == null) { ThemeData themeData = Theme.of(this); materialColor = themeData.accentColor; iconThemeColor = themeData.accentColorBrightness == ThemeBrightness.dark ? IconThemeColor.white : IconThemeColor.black; } return new Material( color: materialColor, type: MaterialType.circle, level: highlight ? 3 : 2, child: new ClipOval( child: new GestureDetector( onTap: onPressed, child: new Container( width: _kSize, height: _kSize, child: new InkWell( child: new Center( child: new IconTheme( data: new IconThemeData(color: iconThemeColor), child: child ) ) ) ) ) ) ); } }