Skip to content

Commit dc3a030

Browse files
Property Support
1 parent 834223b commit dc3a030

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

demo/app/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ button {
2222
horizontal-align: right;
2323
vertical-align: top;
2424
color: #FFF;
25-
background-color: #ff4081;
25+
/*background-color: #ff4081;*/
2626
}

demo/app/main-page.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
row="1"
1515
icon="res://ic_add_white"
1616
tap="fabTap"
17+
backColor="#ff4081"
1718
class="fab-button" />
1819
</grid-layout>
1920
</Page>

fab-common.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
var view = require("ui/core/view");
22
var color = require("color");
3+
var dObservable = require("ui/core/dependency-observable");
4+
var proxy = require("ui/core/proxy");
35

46
var FloatingActionButton = (function (_super) {
5-
67
global.__extends(FloatingActionButton, _super);
78

89
function FloatingActionButton() {
@@ -20,22 +21,26 @@ var FloatingActionButton = (function (_super) {
2021

2122
Object.defineProperty(FloatingActionButton.prototype, "backColor", {
2223
get: function () {
23-
return this.backColorProperty;
24+
return this._getValue(FloatingActionButton.backColorProperty);
2425
},
25-
set: function(value){
26-
this.backColorProperty = new color.Color(value);
26+
set: function (value) {
27+
this._setValue(FloatingActionButton.backColorProperty, value);
2728
}
2829
});
2930

3031
Object.defineProperty(FloatingActionButton.prototype, "icon", {
3132
get: function () {
32-
return this.iconProperty;
33+
return this._getValue(FloatingActionButton.iconProperty);
3334
},
34-
set: function(value){
35-
this.iconProperty = value;
35+
set: function (value) {
36+
this._setValue(FloatingActionButton.iconProperty, value);
3637
}
3738
});
3839

40+
//Expose for iOS
41+
FloatingActionButton.backColorProperty = new dObservable.Property("backColor", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));
42+
FloatingActionButton.iconProperty = new dObservable.Property("icon", "FloatingActionButton", new proxy.PropertyMetadata(0, dObservable.PropertyMetadataSettings.AffectsLayout));
43+
3944
return FloatingActionButton;
4045
})(view.View);
4146

fab.ios.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ var ImageSource = require("image-source");
1212
var stateChanged = require("ui/core/control-state-change");
1313
var style = require("ui/styling/style");
1414
var utils = require("utils/utils");
15+
var color = require("color");
1516
var enums = require("ui/enums");
1617

17-
require("utils/module-merge").merge(common, module.exports);
18+
19+
20+
require("utils/module-merge").merge(common, module.exports);
1821

1922
var FloatingActionButton = (function (_super) {
2023
global.__extends(FloatingActionButton, _super);
@@ -25,6 +28,7 @@ var FloatingActionButton = (function (_super) {
2528

2629
var button = KCFloatingActionButton.alloc().init();
2730
this._ios = button;
31+
2832
}
2933

3034
Object.defineProperty(FloatingActionButton.prototype, "ios", {
@@ -39,6 +43,7 @@ var FloatingActionButton = (function (_super) {
3943

4044
exports.Fab = FloatingActionButton;
4145

46+
/* SETUP CSS */
4247
var FloatingActionButtonStyler = (function () {
4348
function FloatingActionButtonStyler() {
4449
}
@@ -95,3 +100,13 @@ var FloatingActionButtonStyler = (function () {
95100
})();
96101
exports.FloatingActionButtonStyler = FloatingActionButtonStyler;
97102
FloatingActionButtonStyler.registerHandlers();
103+
104+
105+
/* SETUP PROPERTIES */
106+
function onBackColorPropertyChanged(data) {
107+
if(color.Color.isValid(data.newValue)){
108+
var fab = data.object;
109+
fab.ios.buttonColor = new color.Color(data.newValue).ios;
110+
}
111+
}
112+
common.Fab.backColorProperty.metadata.onSetNativeValue = onBackColorPropertyChanged;

0 commit comments

Comments
 (0)