@@ -12,30 +12,33 @@ class FormCtrl {
12
12
static const String COLOR_RGB = "rgb" ;
13
13
static const String COLOR_NAME = "name" ;
14
14
15
+ static const _COLOR_TYPES = const [COLOR_RGB , COLOR_HSL , COLOR_HEX , COLOR_NAME ];
16
+
17
+ static const _RESOLUTIONS = const ['1024x600' ,
18
+ '1280x800' ,
19
+ '1366x768' ,
20
+ '1440x900' ,
21
+ '1600x900' ,
22
+ '1680x1050' ,
23
+ '1920x1080' ,
24
+ '1920x1200' ,
25
+ '2560x1440' ,
26
+ '2560x1600' ];
27
+
15
28
Scope scope;
16
29
NgForm form;
17
- List colors = [];
18
- List lastFormattedColors = [];
30
+ final List colors = [];
31
+ final List formattedColors = [];
19
32
20
33
FormCtrl (Scope this .scope, NgForm this .form) {
21
34
newColor (COLOR_HEX , '#222' );
22
35
newColor (COLOR_HEX , '#444' );
23
36
newColor (COLOR_HEX , '#000' );
24
37
}
25
38
26
- get color_types => [COLOR_RGB , COLOR_HSL , COLOR_HEX , COLOR_NAME ];
27
- get resolutions => [
28
- '1024x600' ,
29
- '1280x800' ,
30
- '1366x768' ,
31
- '1440x900' ,
32
- '1600x900' ,
33
- '1680x1050' ,
34
- '1920x1080' ,
35
- '1920x1200' ,
36
- '2560x1440' ,
37
- '2560x1600'
38
- ];
39
+ List <String > get color_types => _COLOR_TYPES ;
40
+
41
+ List <String > get resolutions => _RESOLUTIONS ;
39
42
40
43
submit () {
41
44
this .form.reset ();
@@ -56,7 +59,7 @@ class FormCtrl {
56
59
}
57
60
58
61
formatColors () {
59
- var formatted = [] ;
62
+ formattedColors. clear () ;
60
63
colors.forEach ((color) {
61
64
var value = null ;
62
65
switch (color['type' ]) {
@@ -84,11 +87,10 @@ class FormCtrl {
84
87
break ;
85
88
}
86
89
if (value != null ) {
87
- formatted .add (value);
90
+ formattedColors .add (value);
88
91
}
89
92
});
90
- lastFormattedColors = formatted;
91
- return formatted;
93
+ return formattedColors;
92
94
}
93
95
94
96
newColor ([String type = COLOR_HEX , String color]) {
0 commit comments