OLD | NEW |
1 part of widgets; | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 import '../fn.dart'; |
2 | 6 |
3 const String kAssetBase = '/sky/assets/material-design-icons'; | 7 const String kAssetBase = '/sky/assets/material-design-icons'; |
4 | 8 |
5 class Icon extends Component { | 9 class Icon extends Component { |
6 | |
7 Style style; | 10 Style style; |
8 int size; | 11 int size; |
9 String type; | 12 String type; |
10 | 13 |
11 Icon({ | 14 Icon({ |
12 String key, | 15 String key, |
13 this.style, | 16 this.style, |
14 this.size, | 17 this.size, |
15 this.type: '' | 18 this.type: '' |
16 }) : super(key: key); | 19 }) : super(key: key); |
17 | 20 |
18 Node build() { | 21 Node build() { |
19 String category = ''; | 22 String category = ''; |
20 String subtype = ''; | 23 String subtype = ''; |
21 List<String> parts = type.split('/'); | 24 List<String> parts = type.split('/'); |
22 if (parts.length == 2) { | 25 if (parts.length == 2) { |
23 category = parts[0]; | 26 category = parts[0]; |
24 subtype = parts[1]; | 27 subtype = parts[1]; |
25 } | 28 } |
26 | 29 |
27 return new Image( | 30 return new Image( |
28 style: style, | 31 style: style, |
29 width: size, | 32 width: size, |
30 height: size, | 33 height: size, |
31 src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png' | 34 src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png' |
32 ); | 35 ); |
33 } | 36 } |
34 } | 37 } |
OLD | NEW |