1
+ /**************************************************************************************
2
+ * Made for the {N} community by Brad Martin @BradWayneMartin
3
+ * Thanks to Lazaro Danillo for his contributions - https://github.com/lazaromenezes
4
+ * https://twitter.com/BradWayneMartin
5
+ * https://github.com/bradmartin
6
+ * Pull requests are welcome. Enjoy!
7
+ *************************************************************************************/
8
+
1
9
var common = require ( "./fab-common" ) ;
2
10
var ImageSource = require ( "image-source" ) ;
11
+ var style = require ( "ui/styling" ) ;
3
12
4
13
require ( "utils/module-merge" ) . merge ( common , module . exports ) ;
5
14
6
- var FloatingActionButton = ( function ( _super ) {
15
+ var FloatingActionButton = ( function ( _super ) {
16
+ global . __extends ( FloatingActionButton , _super ) ;
17
+
18
+ function FloatingActionButton ( ) {
19
+ var _this = this ;
20
+ _super . call ( this ) ;
21
+ var size = CGRectMake ( 0 , 0 , 50 , 50 ) ;
22
+ this . _ios = MNFloatingActionButton . alloc ( ) . initWithFrame ( size ) ;
23
+
24
+ }
25
+
26
+ Object . defineProperty ( FloatingActionButton . prototype , "ios" , {
27
+ get : function ( ) {
28
+ return this . _ios ;
29
+ }
30
+ } ) ;
31
+
32
+ return FloatingActionButton ;
33
+
34
+ } ) ( common . Fab ) ;
35
+
36
+ exports . Fab = FloatingActionButton ;
37
+
38
+ // this function is called when the `color` Style property changes on a `NumberPicker` instance
39
+ function setColor ( view , value ) {
40
+ var fab = view . ios ;
41
+
42
+ // value is UIColor, so we may apply it directly
43
+ fab . backgroundColor = value ;
44
+ }
7
45
8
- global . __extends ( FloatingActionButton , _super ) ;
46
+ // this function is called when the `color` Style property changes and the new value is `undefined`
47
+ function resetColor ( view , value ) {
48
+ var fab = view . ios ;
9
49
10
- function FloatingActionButton ( ) {
11
- _super . apply ( this , arguments ) ;
12
- debugger ;
13
- var button = MNFloatingActionButton . alloc ( ) . init ( ) ;
14
-
15
- }
50
+ // value is native UIColor, so apply it directly
51
+ fab . backgroundColor = value ;
52
+ }
16
53
17
- Object . defineProperty ( FloatingActionButton . prototype , "ios" , {
18
- get : function ( ) {
19
- return this . _ios ;
20
- }
21
- } ) ;
54
+ // this function is called when the `Styler` is about to reset the `color` property to its default (original) value.
55
+ function getNativeColorValue ( view ) {
56
+ var fab = view . ios ;
22
57
23
- return FloatingActionButton ;
58
+ return fab . backgroundColor ;
59
+ }
24
60
25
- } ) ( common . Fab ) ;
61
+ var changedHandler = new style . stylers . StylePropertyChangedHandler ( setColor , resetColor , getNativeColorValue ) ;
26
62
27
- exports . Fab = FloatingActionButton ;
63
+ // register the handler for the color property on the NumberPicker type
64
+ style . stylers . registerHandler ( style . properties . colorProperty , changedHandler , "FloatingActionButton" ) ;
0 commit comments