OLD | NEW |
1 part of widgets; | 1 part of widgets; |
2 | 2 |
3 const String kAssetBase = '/sky/assets/material-design-icons'; | 3 const String kAssetBase = '/sky/assets/material-design-icons'; |
4 | 4 |
5 class Icon extends Component { | 5 class Icon extends Component { |
6 | 6 |
7 Style style; | 7 Style style; |
8 int size; | 8 int size; |
9 String type; | 9 String type; |
10 sky.EventListener onClick; | |
11 | 10 |
12 Icon({ | 11 Icon({ |
13 String key, | 12 String key, |
14 this.style, | 13 this.style, |
15 this.size, | 14 this.size, |
16 this.type: '', | 15 this.type: '' |
17 this.onClick | |
18 }) : super(key: key); | 16 }) : super(key: key); |
19 | 17 |
20 Node render() { | 18 Node render() { |
21 String category = ''; | 19 String category = ''; |
22 String subtype = ''; | 20 String subtype = ''; |
23 List<String> parts = type.split('/'); | 21 List<String> parts = type.split('/'); |
24 if (parts.length == 2) { | 22 if (parts.length == 2) { |
25 category = parts[0]; | 23 category = parts[0]; |
26 subtype = parts[1]; | 24 subtype = parts[1]; |
27 } | 25 } |
28 | 26 |
29 return new Image( | 27 return new Image( |
30 style: style, | 28 style: style, |
31 onClick: onClick, | |
32 width: size, | 29 width: size, |
33 height: size, | 30 height: size, |
34 src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png' | 31 src: '${kAssetBase}/${category}/2x_web/ic_${subtype}_${size}dp.png' |
35 ); | 32 ); |
36 } | 33 } |
37 } | 34 } |
OLD | NEW |