mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge pull request #2030 from NativeScript/raikov/pseudoselectors-angular
Fixed pseudoselectors to work with Angular
This commit is contained in:
@ -7,6 +7,7 @@ import utils = require("utils/utils");
|
|||||||
import enums = require("ui/enums");
|
import enums = require("ui/enums");
|
||||||
import dependencyObservable = require("ui/core/dependency-observable");
|
import dependencyObservable = require("ui/core/dependency-observable");
|
||||||
import styleScope = require("../styling/style-scope");
|
import styleScope = require("../styling/style-scope");
|
||||||
|
import {Property} from "ui/core/dependency-observable";
|
||||||
|
|
||||||
class TapHandlerImpl extends NSObject {
|
class TapHandlerImpl extends NSObject {
|
||||||
private _owner: WeakRef<Button>;
|
private _owner: WeakRef<Button>;
|
||||||
@ -50,13 +51,7 @@ export class Button extends common.Button {
|
|||||||
|
|
||||||
public onLoaded() {
|
public onLoaded() {
|
||||||
super.onLoaded();
|
super.onLoaded();
|
||||||
if (this.parent !== null && this.page !== null) {
|
this._updateHandler();
|
||||||
let rootPage = this.page;
|
|
||||||
let scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
|
|
||||||
if (scope.getVisualStates(this) !== undefined) {
|
|
||||||
this._stateChangedHandler.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onUnloaded() {
|
public onUnloaded() {
|
||||||
@ -64,6 +59,13 @@ export class Button extends common.Button {
|
|||||||
this._stateChangedHandler.stop();
|
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 {
|
get ios(): UIButton {
|
||||||
return this._ios;
|
return this._ios;
|
||||||
}
|
}
|
||||||
@ -81,10 +83,23 @@ export class Button extends common.Button {
|
|||||||
// the UIControlStateNormal value. If the value for UIControlStateNormal is not set,
|
// 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
|
// then the property defaults to a system value. Therefore, at a minimum, you should
|
||||||
// set the value for the normal state.
|
// 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.ios.setAttributedTitleForState(newText, UIControlState.UIControlStateNormal);
|
||||||
this.style._updateTextDecoration();
|
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 {
|
export class ButtonStyler implements style.Styler {
|
||||||
|
@ -894,8 +894,7 @@ export class View extends ProxyObject implements definition.View {
|
|||||||
if (!rootPage || !rootPage.isLoaded) {
|
if (!rootPage || !rootPage.isLoaded) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope();
|
||||||
var scope: styleScope.StyleScope = (<any>rootPage)._getStyleScope()
|
|
||||||
scope.applySelectors(this);
|
scope.applySelectors(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user