mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
chore: cleanup
This commit is contained in:
@ -23,7 +23,7 @@ export class TestPageMainViewModel extends Observable {
|
|||||||
console.log(" EXAMPLE: " + selectedExample);
|
console.log(" EXAMPLE: " + selectedExample);
|
||||||
if (this._examples.has(selectedExample)) {
|
if (this._examples.has(selectedExample)) {
|
||||||
this.navigateToExample(this._examples.get(selectedExample));
|
this.navigateToExample(this._examples.get(selectedExample));
|
||||||
} else if (selectedExample.indexOf("/") > 0) {
|
} else if (selectedExample && selectedExample.indexOf("/") > 0) {
|
||||||
this.navigateToExample(selectedExample);
|
this.navigateToExample(selectedExample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { TextTransformation, TextDecoration, TextAlignment, TextTransform, White
|
|||||||
|
|
||||||
// Requires
|
// Requires
|
||||||
import { Font } from "../styling/font";
|
import { Font } from "../styling/font";
|
||||||
import { backgroundColorProperty } from "../styling/style-properties";
|
import { backgroundColorProperty, VerticalAlignment } from "../styling/style-properties";
|
||||||
import {
|
import {
|
||||||
TextBaseCommon, formattedTextProperty, textAlignmentProperty, textDecorationProperty, fontSizeProperty,
|
TextBaseCommon, formattedTextProperty, textAlignmentProperty, textDecorationProperty, fontSizeProperty,
|
||||||
textProperty, textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty,
|
textProperty, textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty,
|
||||||
@ -444,9 +444,9 @@ function createSpannableStringBuilder(formattedString: FormattedString, defaultF
|
|||||||
|
|
||||||
class BaselineAdjustedSpan extends android.text.style.MetricAffectingSpan {
|
class BaselineAdjustedSpan extends android.text.style.MetricAffectingSpan {
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
align: string | number = "baseline";
|
align: VerticalAlignment = "baseline";
|
||||||
|
|
||||||
constructor(fontSize: number, align?: string | number) {
|
constructor(fontSize: number, align?: VerticalAlignment) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.align = align;
|
this.align = align;
|
||||||
@ -464,7 +464,7 @@ class BaselineAdjustedSpan extends android.text.style.MetricAffectingSpan {
|
|||||||
updateState(paint: android.text.TextPaint) {
|
updateState(paint: android.text.TextPaint) {
|
||||||
const metrics = paint.getFontMetrics();
|
const metrics = paint.getFontMetrics();
|
||||||
|
|
||||||
if (!this.align || this.align === "baseline") {
|
if (!this.align || ["baseline", "stretch"].includes(this.align)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import { TextDecoration, TextAlignment, TextTransform, layout, getClosestPropert
|
|||||||
|
|
||||||
// Requires
|
// Requires
|
||||||
import { Font } from "../styling/font";
|
import { Font } from "../styling/font";
|
||||||
|
import { VerticalAlignment } from "../styling/style-properties";
|
||||||
import {
|
import {
|
||||||
TextBaseCommon, textProperty, formattedTextProperty, textAlignmentProperty, textDecorationProperty,
|
TextBaseCommon, textProperty, formattedTextProperty, textAlignmentProperty, textDecorationProperty,
|
||||||
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty,
|
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty,
|
||||||
@ -216,12 +217,11 @@ export class TextBase extends TextBaseCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setColor(color: UIColor): void {
|
_setColor(color: UIColor): void {
|
||||||
const nativeView = this.nativeTextViewProtected;
|
if (this.nativeTextViewProtected instanceof UIButton) {
|
||||||
if (nativeView instanceof UIButton) {
|
this.nativeTextViewProtected.setTitleColorForState(color, UIControlState.Normal);
|
||||||
nativeView.setTitleColorForState(color, UIControlState.Normal);
|
this.nativeTextViewProtected.titleLabel.textColor = color;
|
||||||
nativeView.titleLabel.textColor = color;
|
|
||||||
} else {
|
} else {
|
||||||
nativeView.textColor = color;
|
this.nativeTextViewProtected.textColor = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ export class TextBase extends TextBaseCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (style.letterSpacing !== 0 && this.nativeTextViewProtected.font) {
|
if (style.letterSpacing !== 0 && this.nativeTextViewProtected.font) {
|
||||||
const kern = style.letterSpacing * this.nativeTextViewProtected.font.pointSize
|
const kern = style.letterSpacing * this.nativeTextViewProtected.font.pointSize;
|
||||||
dict.set(NSKernAttributeName, kern);
|
dict.set(NSKernAttributeName, kern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,8 +372,8 @@ export class TextBase extends TextBaseCommon {
|
|||||||
return mas;
|
return mas;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBaselineOffset(font: UIFont, align?: string | number): number {
|
getBaselineOffset(font: UIFont, align?: VerticalAlignment): number {
|
||||||
if (!align || align === "baseline") {
|
if (!align || ["stretch", "baseline"].includes(align)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user