mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
got to layouts
This commit is contained in:
@@ -17,8 +17,8 @@ function getCapitalizedString(str: string): string {
|
||||
return newWords.join(" ");
|
||||
}
|
||||
|
||||
function formatString(text: string, textTransform: "none" | "capitalize" | "uppercase" | "lowercase"): string {
|
||||
switch (textTransform) {
|
||||
export function getTransformedText(text: string, transform: "none" | "capitalize" | "uppercase" | "lowercase"): string {
|
||||
switch (transform) {
|
||||
case "uppercase":
|
||||
return text.toUpperCase();
|
||||
|
||||
@@ -46,14 +46,15 @@ class TextTransformation extends android.text.method.ReplacementTransformationMe
|
||||
|
||||
protected getReplacement(): native.Array<string> {
|
||||
let result: string = "";
|
||||
let textTransform = this.textTransform
|
||||
if (this.formattedText) {
|
||||
for (let i = 0, length = this.formattedText.spans.length; i < length; i++) {
|
||||
let span = this.formattedText.spans.getItem(i);
|
||||
result += formatString(span.text, this.textTransform);
|
||||
result += getTransformedText(span.text, textTransform);
|
||||
// span.text = formatString(span.text, this.textTransform);
|
||||
}
|
||||
} else {
|
||||
result = formatString(this.originalText, this.textTransform);
|
||||
result = getTransformedText(this.originalText, textTransform);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
6
tns-core-modules/ui/text-base/text-base.d.ts
vendored
6
tns-core-modules/ui/text-base/text-base.d.ts
vendored
@@ -68,12 +68,16 @@
|
||||
//@endprivate
|
||||
}
|
||||
|
||||
export type TextTransform = "none" | "capitalize" | "uppercase" | "lowercase";
|
||||
|
||||
export function getTransformedText(text: string, transform: TextTransform): string;
|
||||
|
||||
export const textProperty: Property<TextBase, string>;
|
||||
export const formattedTextProperty: Property<TextBase, FormattedString>;
|
||||
|
||||
export const textAlignmentProperty: InheritedCssProperty<Style, "left" | "center" | "right">;
|
||||
export const textDecorationProperty: CssProperty<Style, "none" | "underline" | "line-through">;
|
||||
export const textTransformProperty: CssProperty<Style, "none" | "capitalize" | "uppercase" | "lowercase">;
|
||||
export const textTransformProperty: CssProperty<Style, TextTransform>;
|
||||
export const whiteSpaceProperty: CssProperty<Style, "normal" | "nowrap">;
|
||||
export const letterSpacingProperty: CssProperty<Style, number>;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ function NSStringFromNSAttributedString(source: NSAttributedString | string): NS
|
||||
return NSString.stringWithString(source instanceof NSAttributedString && source.string || <string>source);
|
||||
}
|
||||
|
||||
function getTransformedText(text: string, transform: "none" | "capitalize" | "uppercase" | "lowercase"): string {
|
||||
export function getTransformedText(text: string, transform: "none" | "capitalize" | "uppercase" | "lowercase"): string {
|
||||
switch (transform) {
|
||||
case "uppercase":
|
||||
return NSStringFromNSAttributedString(text).uppercaseString;
|
||||
|
||||
Reference in New Issue
Block a user