FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(label-android): numeric text ignores text-transform (#7123) · NativeScript/NativeScript@82f7e24 · GitHub

Commit 82f7e24

Browse files
authored
fix(label-android): numeric text ignores text-transform (#7123)
1 parent 5c165f5 commit 82f7e24

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NavigatedData } from "tns-core-modules/ui/page";
2+
import { Page } from "tns-core-modules/ui/page";
3+
import { Observable } from "tns-core-modules/data/observable";
4+
5+
export class HomeViewModel extends Observable {
6+
public stringValue = "test";
7+
public stringNumericValue = "12345";
8+
public numericValue = 12345;
9+
10+
constructor() {
11+
super();
12+
}
13+
}
14+
15+
export function onNavigatingTo(args: NavigatedData) {
16+
const page = <Page>args.object;
17+
page.bindingContext = new HomeViewModel();
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" id="main-page" navigatingTo="onNavigatingTo">
2+
<StackLayout>
3+
<Label text="string value:" />
4+
<Label text="{{ stringValue }}" />
5+
<Label text="string value with uppercase:" />
6+
<Label textTransform="uppercase" text="{{ stringValue }}" />
7+
<Label text="string numeric value:" />
8+
<Label text="{{ stringNumericValue }}" />
9+
<Label text="string numeric value with uppercase:" />
10+
<Label textTransform="uppercase" text="{{ stringNumericValue }}" />
11+
<Label text="numeric value:" />
12+
<Label text="{{ numericValue }}" />
13+
<Label text="numeric value with uppercase:" />
14+
<Label textTransform="uppercase" text="{{ numericValue }}" />
15+
</StackLayout>
16+
</Page>

‎apps/app/ui-tests-app/issues/main-page.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export function loadExamples() {
2626
examples.set("tabview-with-scrollview_4022", "issues/tabview-with-scrollview_4022");
2727
examples.set("3354-ios", "issues/issue-3354");
2828
examples.set("4450", "issues/issue-4450");
29+
examples.set("5125", "issues/issue-5125");
2930
examples.set("5274", "issues/issue-5274");
3031
examples.set("ng-repo-1599", "issues/issue-ng-repo-1599");
3132
examples.set("ng-repo-1626", "issues/issue-ng-repo-1626");

‎tns-core-modules/ui/text-base/text-base.android.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ function initializeTextTransformation(): void {
3636
return createSpannableStringBuilder(formattedText);
3737
}
3838
else {
39-
return getTransformedText(this.textBase.text, this.textBase.textTransform);
39+
const text = this.textBase.text;
40+
const stringValue = (text === null || text === undefined) ? "" : text.toString();
41+
return getTransformedText(stringValue, this.textBase.textTransform);
4042
}
4143
}
4244

@@ -133,7 +135,7 @@ export class TextBase extends TextBaseCommon {
133135

134136
if (spannableStringBuilder && nativeView instanceof android.widget.Button &&
135137
!(nativeView.getTransformationMethod() instanceof TextTransformation)) {
136-
// Replace Android Button's default transformation (in case the developer has not already specified a text-transform) method
138+
// Replace Android Button's default transformation (in case the developer has not already specified a text-transform) method
137139
// with our transformation method which can handle formatted text.
138140
// Otherwise, the default tranformation method of the Android Button will overwrite and ignore our spannableStringBuilder.
139141
nativeView.setTransformationMethod(new TextTransformation(this));

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL