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);
|
||||
if (this._examples.has(selectedExample)) {
|
||||
this.navigateToExample(this._examples.get(selectedExample));
|
||||
} else if (selectedExample.indexOf("/") > 0) {
|
||||
} else if (selectedExample && selectedExample.indexOf("/") > 0) {
|
||||
this.navigateToExample(selectedExample);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import { TextTransformation, TextDecoration, TextAlignment, TextTransform, White
|
||||
|
||||
// Requires
|
||||
import { Font } from "../styling/font";
|
||||
import { backgroundColorProperty } from "../styling/style-properties";
|
||||
import { backgroundColorProperty, VerticalAlignment } from "../styling/style-properties";
|
||||
import {
|
||||
TextBaseCommon, formattedTextProperty, textAlignmentProperty, textDecorationProperty, fontSizeProperty,
|
||||
textProperty, textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty,
|
||||
@ -444,9 +444,9 @@ function createSpannableStringBuilder(formattedString: FormattedString, defaultF
|
||||
|
||||
class BaselineAdjustedSpan extends android.text.style.MetricAffectingSpan {
|
||||
fontSize: number;
|
||||
align: string | number = "baseline";
|
||||
align: VerticalAlignment = "baseline";
|
||||
|
||||
constructor(fontSize: number, align?: string | number) {
|
||||
constructor(fontSize: number, align?: VerticalAlignment) {
|
||||
super();
|
||||
|
||||
this.align = align;
|
||||
@ -464,7 +464,7 @@ class BaselineAdjustedSpan extends android.text.style.MetricAffectingSpan {
|
||||
updateState(paint: android.text.TextPaint) {
|
||||
const metrics = paint.getFontMetrics();
|
||||
|
||||
if (!this.align || this.align === "baseline") {
|
||||
if (!this.align || ["baseline", "stretch"].includes(this.align)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { TextDecoration, TextAlignment, TextTransform, layout, getClosestPropert
|
||||
|
||||
// Requires
|
||||
import { Font } from "../styling/font";
|
||||
import { VerticalAlignment } from "../styling/style-properties";
|
||||
import {
|
||||
TextBaseCommon, textProperty, formattedTextProperty, textAlignmentProperty, textDecorationProperty,
|
||||
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty,
|
||||
@ -216,12 +217,11 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
_setColor(color: UIColor): void {
|
||||
const nativeView = this.nativeTextViewProtected;
|
||||
if (nativeView instanceof UIButton) {
|
||||
nativeView.setTitleColorForState(color, UIControlState.Normal);
|
||||
nativeView.titleLabel.textColor = color;
|
||||
if (this.nativeTextViewProtected instanceof UIButton) {
|
||||
this.nativeTextViewProtected.setTitleColorForState(color, UIControlState.Normal);
|
||||
this.nativeTextViewProtected.titleLabel.textColor = color;
|
||||
} else {
|
||||
nativeView.textColor = color;
|
||||
this.nativeTextViewProtected.textColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +286,7 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -372,8 +372,8 @@ export class TextBase extends TextBaseCommon {
|
||||
return mas;
|
||||
}
|
||||
|
||||
getBaselineOffset(font: UIFont, align?: string | number): number {
|
||||
if (!align || align === "baseline") {
|
||||
getBaselineOffset(font: UIFont, align?: VerticalAlignment): number {
|
||||
if (!align || ["stretch", "baseline"].includes(align)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user