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

fix(label-android): numeric text ignores text-transform by manoldonev · Pull Request #7123 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (3) .xml  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
18 changes: 18 additions & 0 deletions apps/app/ui-tests-app/issues/issue-5125.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NavigatedData } from "tns-core-modules/ui/page";
import { Page } from "tns-core-modules/ui/page";
import { Observable } from "tns-core-modules/data/observable";

export class HomeViewModel extends Observable {
public stringValue = "test";
public stringNumericValue = "12345";
public numericValue = 12345;

constructor() {
super();
}
}

export function onNavigatingTo(args: NavigatedData) {
const page = <Page>args.object;
page.bindingContext = new HomeViewModel();
}
16 changes: 16 additions & 0 deletions apps/app/ui-tests-app/issues/issue-5125.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Page xmlns="http://schemas.nativescript.org/tns.xsd" id="main-page" navigatingTo="onNavigatingTo">
<StackLayout>
<Label text="string value:" />
<Label text="{{ stringValue }}" />
<Label text="string value with uppercase:" />
<Label textTransform="uppercase" text="{{ stringValue }}" />
<Label text="string numeric value:" />
<Label text="{{ stringNumericValue }}" />
<Label text="string numeric value with uppercase:" />
<Label textTransform="uppercase" text="{{ stringNumericValue }}" />
<Label text="numeric value:" />
<Label text="{{ numericValue }}" />
<Label text="numeric value with uppercase:" />
<Label textTransform="uppercase" text="{{ numericValue }}" />
</StackLayout>
</Page>
1 change: 1 addition & 0 deletions apps/app/ui-tests-app/issues/main-page.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function loadExamples() {
examples.set("tabview-with-scrollview_4022", "issues/tabview-with-scrollview_4022");
examples.set("3354-ios", "issues/issue-3354");
examples.set("4450", "issues/issue-4450");
examples.set("5125", "issues/issue-5125");
examples.set("5274", "issues/issue-5274");
examples.set("ng-repo-1599", "issues/issue-ng-repo-1599");
examples.set("ng-repo-1626", "issues/issue-ng-repo-1626");
Expand Down
6 changes: 4 additions & 2 deletions tns-core-modules/ui/text-base/text-base.android.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function initializeTextTransformation(): void {
return createSpannableStringBuilder(formattedText);
}
else {
return getTransformedText(this.textBase.text, this.textBase.textTransform);
const text = this.textBase.text;
const stringValue = (text === null || text === undefined) ? "" : text.toString();
return getTransformedText(stringValue, this.textBase.textTransform);
}
}

Expand Down Expand Up @@ -133,7 +135,7 @@ export class TextBase extends TextBaseCommon {

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

Back | FazBrowse Home | New Git URL