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 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) {
var btnChange = <view.View>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label");

View File

@ -1,5 +1,6 @@
<Page >
<StackLayout>
<Button id="ChangeText" automationText="Change text" text="Change text" tap="changeTextButonTap" />
<Button id="Change" automationText="Change" text="Change" tap="butonTap" />
<Label id="Label" automationText="Label" text="Label" 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 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) {
var btnChange = <view.View>args.object;
var lbl = <label.Label>btnChange.parent.getViewById("Label");

View File

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

View File

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

View File

@ -18,16 +18,20 @@ var textProperty = new dependencyObservable.Property(
"text",
"TextBase",
new proxy.PropertyMetadata("", dependencyObservable.PropertyMetadataSettings.AffectsLayout)
);
);
var formattedTextProperty = new dependencyObservable.Property(
"formattedText",
"TextBase",
new proxy.PropertyMetadata("", dependencyObservable.PropertyMetadataSettings.AffectsLayout)
);
);
function onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
var textBase = <TextBase>data.object;
textBase.style._updateTextTransform();
textBase.style._updateTextDecoration();
textBase._onTextPropertyChanged(data);
}
@ -53,7 +57,7 @@ export class TextBase extends view.View implements definition.TextBase, formatte
if (this.formattedText) {
this.formattedText.updateSpansBindingContext(newValue);
}
this.style._updateTextTransform();
this.style._updateTextDecoration();
}

View File

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

View File

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