Skip to content

Commit dbf3782

Browse files
committed
Fix event firing multiple times
1 parent 61da746 commit dbf3782

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

checkbox.ios.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Color } from "color";
99
import { Label } from "ui/label";
1010
import { Button } from "ui/button";
1111
import { StackLayout } from "ui/layouts/stack-layout";
12+
import { Observable } from "data/observable";
1213

1314

1415
declare var CGRectMake: any, CGPointMake: any;
@@ -23,7 +24,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
2324
private _hideBox: boolean;
2425
private _boxType: number;
2526
private _tint: string;
26-
private _checkBoxBackgroundColor:string;
27+
private _checkBoxBackgroundColor: string;
2728
private _onCheckColor: string;
2829
private _animationDuration: number;
2930
private _onAnimationType: number;
@@ -51,7 +52,7 @@ export class CheckBox extends Button implements CheckBoxInterface {
5152
this._setValue(CheckBox.checkedProperty, value);
5253
}
5354

54-
set checkBoxBackgroundColor(color:string){
55+
set checkBoxBackgroundColor(color: string) {
5556
(<any>this._iosCheckbox).backgroundColor = new Color(color).ios;
5657
this._checkBoxBackgroundColor = color;
5758
}
@@ -223,6 +224,14 @@ export class CheckBox extends Button implements CheckBoxInterface {
223224
public _onCheckedPropertyChanged(data: PropertyChangeData) {
224225
if (this._iosCheckbox) {
225226
this._iosCheckbox.setOnAnimated(data.newValue, true);
227+
let _old = data.oldValue;
228+
let _new = data.newValue;
229+
let obj = new Observable({
230+
view: this,
231+
oldValue: _old,
232+
newValue: _new
233+
});
234+
this.notify({ eventName: "checkedChanged", object: obj });
226235
}
227236
}
228237
}
@@ -258,12 +267,6 @@ class BEMCheckBoxDelegateImpl extends NSObject implements BEMCheckBoxDelegate {
258267
public didTapCheckBox(checkBox: BEMCheckBox): void {
259268
let owner = this._owner.get();
260269
if (owner) {
261-
var eventData = {
262-
eventName: "tap",
263-
object: owner
264-
};
265-
266-
owner.notify(eventData);
267270
owner._onPropertyChangedFromNative(CheckBox.checkedProperty, checkBox.on);
268271
}
269272
}

0 commit comments

Comments
 (0)