1
1
/**************************************************************************************
2
- * Made for the {N} community by Brad Martin @BradWayneMartin
2
+ * Made for the {N} community by Brad Martin @BradWayneMartin
3
3
* Thanks to Lazaro Danillo for his contributions - https://github.com/lazaromenezes
4
4
* https://twitter.com/BradWayneMartin
5
5
* https://github.com/bradmartin
6
6
* Pull requests are welcome. Enjoy!
7
7
*************************************************************************************/
8
8
9
9
var common = require ( "./fab-common" ) ;
10
+ var color = require ( "color" ) ;
10
11
var ImageSource = require ( "image-source" ) ;
11
12
12
13
require ( "utils/module-merge" ) . merge ( common , module . exports ) ;
23
24
24
25
this . _android = new android . support . design . widget . FloatingActionButton ( this . _context ) ;
25
26
26
- if ( this . rippleColor )
27
- this . _android . setRippleColor ( this . rippleColor . android ) ;
28
-
29
- if ( this . backColor )
30
- this . _android . setBackgroundTintList ( android . content . res . ColorStateList . valueOf ( this . backColor . android ) ) ;
31
-
32
- if ( this . icon ) {
33
- var iconDrawable = null ;
34
-
35
- if ( ImageSource . isFileOrResourcePath ( this . icon ) ) {
36
- iconDrawable = ImageSource . fromFileOrResource ( this . icon ) ;
37
- this . _android . setImageBitmap ( iconDrawable . android ) ;
38
- }
39
- else {
40
- var drawableId = android . content . res . Resources . getSystem ( ) . getIdentifier ( this . icon , "drawable" , "android" ) ;
41
- iconDrawable = android . content . res . Resources . getSystem ( ) . getDrawable ( drawableId ) ;
42
- this . _android . setImageDrawable ( iconDrawable ) ;
43
- }
44
- }
45
-
46
27
var that = new WeakRef ( this ) ;
47
28
48
29
this . _android . setOnClickListener ( new android . view . View . OnClickListener ( {
69
50
} ) ( common . Fab ) ;
70
51
71
52
exports . Fab = FloatingActionButton ;
53
+
54
+ /* SETUP PROPERTIES */
55
+ //Background Color
56
+ function onBackColorPropertyChanged ( data ) {
57
+ if ( color . Color . isValid ( data . newValue ) ) {
58
+ var fab = data . object ;
59
+ var droidColor = new color . Color ( data . newValue ) . android ;
60
+ fab . android . setBackgroundTintList ( android . content . res . ColorStateList . valueOf ( droidColor ) ) ;
61
+ }
62
+ }
63
+ common . Fab . backColorProperty . metadata . onSetNativeValue = onBackColorPropertyChanged ;
64
+
65
+ //Icon
66
+ function onIconPropertyChanged ( data ) {
67
+ var fab = data . object ;
68
+ var icon = data . newValue ;
69
+ var iconDrawable = null ;
70
+
71
+ if ( ImageSource . isFileOrResourcePath ( icon ) ) {
72
+ iconDrawable = ImageSource . fromFileOrResource ( icon ) ;
73
+ fab . android . setImageBitmap ( iconDrawable . android ) ;
74
+ }
75
+ else {
76
+ var drawableId = android . content . res . Resources . getSystem ( ) . getIdentifier ( icon , "drawable" , "android" ) ;
77
+ iconDrawable = android . content . res . Resources . getSystem ( ) . getDrawable ( drawableId ) ;
78
+ fab . android . setImageDrawable ( iconDrawable ) ;
79
+ }
80
+ }
81
+ common . Fab . iconProperty . metadata . onSetNativeValue = onIconPropertyChanged ;
82
+
83
+ //Ripple Color
84
+ function onRippleColorPropertyChanged ( data ) {
85
+ if ( color . Color . isValid ( data . newValue ) ) {
86
+ var fab = data . object ;
87
+ var droidColor = new color . Color ( data . newValue ) . android ;
88
+ fab . android . setRippleColor ( droidColor ) ;
89
+ }
90
+ }
91
+ common . Fab . rippleColorProperty . metadata . onSetNativeValue = onRippleColorPropertyChanged ;
0 commit comments