icon_button.dart 958 Bytes
Newer Older
1 2 3 4 5 6 7 8
// 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 'dart:sky' as sky;

import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/icon.dart';
9
import 'package:sky/widgets/framework.dart';
10
import 'package:sky/widgets/gesture_detector.dart';
11 12 13

class IconButton extends Component {

14
  IconButton({ Key key, this.icon, this.onPressed, this.color }) : super(key: key);
15 16 17 18 19 20 21 22 23 24 25 26 27 28

  final String icon;
  final Function onPressed;
  final Color color;

  Widget build() {
    Widget child = new Icon(type: icon, size: 24);
    if (color != null) {
      child = new ColorFilter(
        color: color,
        transferMode: sky.TransferMode.srcATop,
        child: child
      );
    }
29
    return new GestureDetector(
30
      onTap: onPressed,
31 32 33
      child: new Padding(
        child: child,
        padding: const EdgeDims.all(8.0))
34 35 36 37
    );
  }

}