Merge pull request #1927 from NativeScript/decoration-and-transform

TextBase and Button text-decoration and text-transform fixes
This commit is contained in:
Vladimir Enchev
2016-04-11 17:19:24 +04:00
8 changed files with 52 additions and 5 deletions

View File

@ -4,6 +4,20 @@ import button = require("ui/button");
import textField = require("ui/text-field"); import textField = require("ui/text-field");
import textView = require("ui/text-view"); import textView = require("ui/text-view");
export function changeTextButonTap(args) {
var btnChange = <button.Button>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label");
var btn = <button.Button>btnChange.parent.getViewById("Button");
var textField = <textField.TextField>btnChange.parent.getViewById("TextField");
var textView = <textView.TextView>btnChange.parent.getViewById("TextView");
if(lbl.text === "Change text") {
lbl.text = btn.text = textField.text = textView.text = "Text changed";
} else {
lbl.text = btn.text = textField.text = textView.text = "Change text";
}
}
export function butonTap(args) { export function butonTap(args) {
var btnChange = <view.View>args.object; var btnChange = <view.View>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label"); var lbl = <label.Label>btnChange.parent.getViewById("Label");

View File

@ -1,5 +1,6 @@
<Page > <Page >
<StackLayout> <StackLayout>
<Button id="ChangeText" automationText="Change text" text="Change text" tap="changeTextButonTap" />
<Button id="Change" automationText="Change" text="Change" tap="butonTap" /> <Button id="Change" automationText="Change" text="Change" tap="butonTap" />
<Label id="Label" automationText="Label" text="Label" style.textDecoration="none" /> <Label id="Label" automationText="Label" text="Label" style.textDecoration="none" />
<Button id="Button" automationText="Button" text="Button" style.textDecoration="none" /> <Button id="Button" automationText="Button" text="Button" style.textDecoration="none" />

View File

@ -4,6 +4,20 @@ import button = require("ui/button");
import textField = require("ui/text-field"); import textField = require("ui/text-field");
import textView = require("ui/text-view"); import textView = require("ui/text-view");
export function changeTextButonTap(args) {
var btnChange = <button.Button>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label");
var btn = <button.Button>btnChange.parent.getViewById("Button");
var textField = <textField.TextField>btnChange.parent.getViewById("TextField");
var textView = <textView.TextView>btnChange.parent.getViewById("TextView");
if(lbl.text === "Change text") {
lbl.text = btn.text = textField.text = textView.text = "Text changed";
} else {
lbl.text = btn.text = textField.text = textView.text = "Change text";
}
}
export function butonTap(args) { export function butonTap(args) {
var btnChange = <view.View>args.object; var btnChange = <view.View>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label"); var lbl = <label.Label>btnChange.parent.getViewById("Label");

View File

@ -1,5 +1,6 @@
<Page > <Page >
<StackLayout> <StackLayout>
<Button id="ChangeText" automationText="Change text" text="Change text" tap="changeTextButonTap" />
<Button id="Change" automationText="Change" text="Change" tap="butonTap" /> <Button id="Change" automationText="Change" text="Change" tap="butonTap" />
<Label id="Label" automationText="Label" text="label Label" style.textTransform="none" /> <Label id="Label" automationText="Label" text="label Label" style.textTransform="none" />
<Button id="Button" automationText="Button" text="button Button" style.textTransform="none" /> <Button id="Button" automationText="Button" text="button Button" style.textTransform="none" />

View File

@ -35,6 +35,10 @@ var formattedTextProperty = new dependencyObservable.Property(
function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) { function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var button = <Button>data.object; var button = <Button>data.object;
button.style._updateTextDecoration();
button.style._updateTextTransform();
button._onTextPropertyChanged(data); button._onTextPropertyChanged(data);
} }
@ -63,6 +67,9 @@ export class Button extends view.View implements definition.Button {
if (this.formattedText) { if (this.formattedText) {
this.formattedText.updateSpansBindingContext(newValue); this.formattedText.updateSpansBindingContext(newValue);
} }
this.style._updateTextDecoration();
this.style._updateTextTransform();
} }
get text(): string { get text(): string {

View File

@ -28,6 +28,10 @@ var formattedTextProperty = new dependencyObservable.Property(
function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) { function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var textBase = <TextBase>data.object; var textBase = <TextBase>data.object;
textBase.style._updateTextTransform();
textBase.style._updateTextDecoration();
textBase._onTextPropertyChanged(data); textBase._onTextPropertyChanged(data);
} }

View File

@ -142,6 +142,9 @@ export class TextField extends common.TextField {
public onLoaded() { public onLoaded() {
super.onLoaded(); super.onLoaded();
this._ios.delegate = this._delegate; this._ios.delegate = this._delegate;
this.style._updateTextDecoration();
this.style._updateTextTransform();
} }
public onUnloaded() { public onUnloaded() {

View File

@ -83,6 +83,9 @@ export class TextView extends common.TextView {
public onLoaded() { public onLoaded() {
super.onLoaded(); super.onLoaded();
this._ios.delegate = this._delegate; this._ios.delegate = this._delegate;
this.style._updateTextDecoration();
this.style._updateTextTransform();
} }
public onUnloaded() { public onUnloaded() {