mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This is just a proof of concept. If we like this direction, it will move out of the examples directory (likely re-written) and be committed in smaller pieces with unit tests and formal reviews. TBR=abarth BUG= Review URL: https://codereview.chromium.org/971183002
38 lines
695 B
Dart
38 lines
695 B
Dart
part of widgets;
|
|
|
|
const String kAssetBase = '/sky/assets/material-design-icons';
|
|
|
|
class Icon extends Component {
|
|
|
|
Style style;
|
|
int size;
|
|
String type;
|
|
sky.EventListener onClick;
|
|
|
|
Icon({
|
|
String key,
|
|
this.style,
|
|
this.size,
|
|
this.type: '',
|
|
this.onClick
|
|
}) : super(key: key);
|
|
|
|
Node render() {
|
|
String category = '';
|
|
String subtype = '';
|
|
List<String> parts = type.split('/');
|
|
if (parts.length == 2) {
|
|
category = parts[0];
|
|
subtype = parts[1];
|
|
}
|
|
|
|
return new Image(
|
|
style: style,
|
|
onClick: onClick,
|
|
width: size,
|
|
height: size,
|
|
src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png'
|
|
);
|
|
}
|
|
}
|