icon.dart 829 字节
Newer Older
1 2 3 4
// 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.

5
import 'wrappers.dart';
6 7 8 9 10 11 12 13 14 15 16 17

// TODO(eseidel): This should use package:.
const String kAssetBase = '/packages/sky/assets/material-design-icons';

class Icon extends Component {

  Icon({
    String key,
    this.size,
    this.type: ''
  }) : super(key: key);

18 19
  final int size;
  final String type;
H
Hixie 已提交
20

21 22 23 24 25 26 27 28
  UINode build() {
    String category = '';
    String subtype = '';
    List<String> parts = type.split('/');
    if (parts.length == 2) {
      category = parts[0];
      subtype = parts[1];
    }
E
Eric Seidel 已提交
29
    return new Image(
30
      size: new Size(size.toDouble(), size.toDouble()),
E
Eric Seidel 已提交
31
      src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png'
32
    );
33
  }
H
Hixie 已提交
34

35
}