Skip to content

Commit 9c3591e

Browse files
Better file to update...
1 parent a93eb1f commit 9c3591e

File tree

1 file changed

+53
-16
lines changed

1 file changed

+53
-16
lines changed

fab.ios.js

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,64 @@
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+
19
var common = require("./fab-common");
210
var ImageSource = require("image-source");
11+
var style = require("ui/styling");
312

413
require("utils/module-merge").merge(common, module.exports);
514

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+
}
745

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;
949

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+
}
1653

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;
2257

23-
return FloatingActionButton;
58+
return fab.backgroundColor;
59+
}
2460

25-
})(common.Fab);
61+
var changedHandler = new style.stylers.StylePropertyChangedHandler(setColor, resetColor, getNativeColorValue);
2662

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

Comments
 (0)