Skip to content

Commit 612ad3f

Browse files
Working Delegate events
1 parent 7279d9f commit 612ad3f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

checkbox.ios.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {Style, properties as styleProps} from 'ui/styling';
1111
declare var CGRectMake: any;
1212

1313
export class CheckBox extends ContentView{
14+
private _initalizing: boolean = true;
1415
private _iosCheckbox: BEMCheckBox;
1516
private _iosLabel: UILabel;
1617
private _delegate: BEMCheckBoxDelegateImpl;
@@ -149,6 +150,7 @@ export class CheckBox extends ContentView{
149150
}
150151

151152
public onLoaded() {
153+
this._iosCheckbox.delegate = this._delegate;
152154
// Only here is where the view xml width/height is defined
153155
this._iosCheckbox.frame.size.width = this.width;
154156
this._iosCheckbox.frame.size.height = this.height;
@@ -188,6 +190,8 @@ export class CheckBox extends ContentView{
188190
if (typeof this._offAnimationType !== 'undefined') {
189191
this.offAnimationType = this._offAnimationType;
190192
}
193+
194+
this._initalizing = false;
191195
}
192196

193197
public toggle(){
@@ -213,10 +217,10 @@ export class CheckBox extends ContentView{
213217
}
214218

215219
function onCheckedPropertyChanged(data: PropertyChangeData) {
216-
console.log("Check Changed");
217-
218-
if(this._ios){
219-
this._ios.on = data.newValue;
220+
if(!this._initalizing){
221+
if(this._ios){
222+
this._ios.on = data.newValue;
223+
}
220224
}
221225
}
222226

@@ -225,8 +229,10 @@ function onCheckedPropertyChanged(data: PropertyChangeData) {
225229

226230

227231
function onTextPropertyChanged(data: PropertyChangeData) {
228-
if(this._iosLabel)
229-
this._iosLabel.text = this.text;
232+
if(!this._initalizing){
233+
if(this._iosLabel)
234+
this._iosLabel.text = this.text;
235+
}
230236
}
231237

232238
// register the setNativeValue callbacks
@@ -246,12 +252,10 @@ class BEMCheckBoxDelegateImpl extends NSObject implements BEMCheckBoxDelegate {
246252
}
247253

248254
public animationDidStopForCheckBox(checkBox: BEMCheckBox): void {
249-
debugger;
250-
console.log("animationDidStopForCheckBox");
255+
//TODO: Maybe trigger event
251256
}
252257

253258
public didTapCheckBox(checkBox: BEMCheckBox): void {
254-
debugger;
255-
console.log("didTapCheckBox");
259+
this._owner.get().checked = checkBox.on;
256260
}
257261
}

0 commit comments

Comments
 (0)