Merge pull request #2030 from NativeScript/raikov/pseudoselectors-angular

Fixed pseudoselectors to work with Angular
This commit is contained in:
tzraikov
2016-04-26 15:06:38 +03:00
2 changed files with 24 additions and 10 deletions

View File

@ -7,6 +7,7 @@ import utils = require("utils/utils");
import enums = require("ui/enums");
import dependencyObservable = require("ui/core/dependency-observable");
import styleScope = require("../styling/style-scope");
import {Property} from "ui/core/dependency-observable";
class TapHandlerImpl extends NSObject {
private _owner: WeakRef<Button>;
@ -50,13 +51,7 @@ export class Button extends common.Button {
public onLoaded() {
super.onLoaded();
if (this.parent !== null && this.page !== null) {
let rootPage = this.page;
let scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
if (scope.getVisualStates(this) !== undefined) {
this._stateChangedHandler.start();
}
}
this._updateHandler();
}
public onUnloaded() {
@ -64,6 +59,13 @@ export class Button extends common.Button {
this._stateChangedHandler.stop();
}
public _onPropertyChanged(property: Property, oldValue: any, newValue: any) {
super._onPropertyChanged(property, oldValue, newValue);
if (property.metadata.affectsStyle) {
this._updateHandler();
}
}
get ios(): UIButton {
return this._ios;
}
@ -81,10 +83,23 @@ export class Button extends common.Button {
// the UIControlStateNormal value. If the value for UIControlStateNormal is not set,
// then the property defaults to a system value. Therefore, at a minimum, you should
// set the value for the normal state.
var newText = value ? value._formattedText : null;
let newText = value ? value._formattedText : null;
this.ios.setAttributedTitleForState(newText, UIControlState.UIControlStateNormal);
this.style._updateTextDecoration();
}
private _updateHandler() {
if (this.parent !== null && this.page !== null) {
let rootPage = this.page;
let scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
if (scope.getVisualStates(this) !== undefined) {
this._stateChangedHandler.start();
}
else {
this._stateChangedHandler.stop();
}
}
}
}
export class ButtonStyler implements style.Styler {

View File

@ -894,8 +894,7 @@ export class View extends ProxyObject implements definition.View {
if (!rootPage || !rootPage.isLoaded) {
return;
}
var scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope()
var scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
scope.applySelectors(this);
}