Skip to content

Commit 71c3b18

Browse files
author
Tsvetan Raikov
committed
Fixed pseudoselectors to work with Angular
1 parent 62296db commit 71c3b18

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

ui/button/button.ios.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import utils = require("utils/utils");
77
import enums = require("ui/enums");
88
import dependencyObservable = require("ui/core/dependency-observable");
99
import styleScope = require("../styling/style-scope");
10+
import {Property} from "ui/core/dependency-observable";
1011

1112
class TapHandlerImpl extends NSObject {
1213
private _owner: WeakRef<Button>;
@@ -50,20 +51,21 @@ export class Button extends common.Button {
5051

5152
public onLoaded() {
5253
super.onLoaded();
53-
if (this.parent !== null && this.page !== null) {
54-
let rootPage = this.page;
55-
let scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
56-
if (scope.getVisualStates(this) !== undefined) {
57-
this._stateChangedHandler.start();
58-
}
59-
}
54+
this._updateHandler();
6055
}
6156

6257
public onUnloaded() {
6358
super.onUnloaded();
6459
this._stateChangedHandler.stop();
6560
}
6661

62+
public _onPropertyChanged(property: Property, oldValue: any, newValue: any) {
63+
super._onPropertyChanged(property, oldValue, newValue);
64+
if (property.metadata.affectsStyle) {
65+
this._updateHandler();
66+
}
67+
}
68+
6769
get ios(): UIButton {
6870
return this._ios;
6971
}
@@ -81,10 +83,23 @@ export class Button extends common.Button {
8183
// the UIControlStateNormal value. If the value for UIControlStateNormal is not set,
8284
// then the property defaults to a system value. Therefore, at a minimum, you should
8385
// set the value for the normal state.
84-
var newText = value ? value._formattedText : null;
86+
let newText = value ? value._formattedText : null;
8587
this.ios.setAttributedTitleForState(newText, UIControlState.UIControlStateNormal);
8688
this.style._updateTextDecoration();
8789
}
90+
91+
private _updateHandler() {
92+
if (this.parent !== null && this.page !== null) {
93+
let rootPage = this.page;
94+
let scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
95+
if (scope.getVisualStates(this) !== undefined) {
96+
this._stateChangedHandler.start();
97+
}
98+
else {
99+
this._stateChangedHandler.stop();
100+
}
101+
}
102+
}
88103
}
89104

90105
export class ButtonStyler implements style.Styler {

ui/core/view-common.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,7 @@ export class View extends ProxyObject implements definition.View {
894894
if (!rootPage || !rootPage.isLoaded) {
895895
return;
896896
}
897-
898-
var scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope()
897+
var scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
899898
scope.applySelectors(this);
900899
}
901900

0 commit comments

Comments
 (0)