Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified packages/core/platforms/android/widgets-release.aar
Binary file not shown.
14 changes: 5 additions & 9 deletions packages/core/ui/text-base/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,24 +572,20 @@ export class TextBase extends TextBaseCommon {
}
}

function getCapitalizedString(str: string): string {
let newString = str.toLowerCase();
newString = newString.replace(/(?:^|\s'*|[-"([{])+\S/g, (c) => c.toUpperCase());
return newString;
}

export function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string {
if (!text || !isString(text)) {
return '';
}

// Use the java string methods to get localized transformations.
// This will respect the locale set by native apis or the localize plugins.
switch (textTransform) {
case 'uppercase':
return text.toUpperCase();
return org.nativescript.widgets.Utils.stringToUpperCase(text);
case 'lowercase':
return text.toLowerCase();
return org.nativescript.widgets.Utils.stringToLowerCase(text);
case 'capitalize':
return getCapitalizedString(text);
return org.nativescript.widgets.Utils.capitalizeString(text);
case 'none':
default:
return text;
Expand Down
8 changes: 5 additions & 3 deletions packages/core/ui/text-base/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,15 @@ export function getTransformedText(text: string, textTransform: CoreTypes.TextTr
return '';
}

// Use the NSString localized properties to get localized transformations.
// This will respect the locale set by native apis or the localize plugins.
switch (textTransform) {
case 'uppercase':
return NSStringFromNSAttributedString(text).uppercaseString;
return NSStringFromNSAttributedString(text).localizedUppercaseString;
case 'lowercase':
return NSStringFromNSAttributedString(text).lowercaseString;
return NSStringFromNSAttributedString(text).localizedLowercaseString;
case 'capitalize':
return NSStringFromNSAttributedString(text).capitalizedString;
return NSStringFromNSAttributedString(text).localizedCapitalizedString;
default:
return text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ declare module org {
public static enableEdgeToEdge(activity: androidx.activity.ComponentActivity, statusBarLight: java.lang.Integer, statusBarDark: java.lang.Integer, navigationBarLight: java.lang.Integer, navigationBarDark: java.lang.Integer, handleDarkMode: org.nativescript.widgets.Utils.HandleDarkMode): void;
public static enableEdgeToEdge(activity: androidx.activity.ComponentActivity, window: android.view.Window, handleDarkMode: org.nativescript.widgets.Utils.HandleDarkMode): void;
public static enableEdgeToEdge(activity: androidx.activity.ComponentActivity, window: android.view.Window): void;
public static stringToUpperCase(value: string): string;
public static stringToLowerCase(value: string): string;
public static capitalizeString(value: string): string;
public static ignoreEdgeToEdgeOnOlderDevices: boolean;
public constructor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,36 @@ public void run() {
});
}

public static String stringToUpperCase(final String value) {
return value.toUpperCase();
}

public static String stringToLowerCase(final String value) {
return value.toLowerCase();
}

public static String capitalizeString(final String value) {
if (value == null || value.isEmpty()) {
return value;
}

final char[] buffer = value.toLowerCase().toCharArray();
boolean capitalizeNext = true;

for (int i = 0; i < buffer.length; i++) {
final char ch = buffer[i];

// Capitalize characters when located after numbers, whitespace, and punctuation marks but not apostrophe
if (!Character.isLetter(ch) && ch != '\'') {
capitalizeNext = true;
} else if (capitalizeNext) {
buffer[i] = Character.toTitleCase(ch);
capitalizeNext = false;
}
}
return new String(buffer);
}

/**
* Return true if child is a descendant of parent, (or equal to the parent).
*/
Expand Down
Loading