Skip to content

Commit 3d7ac2e

Browse files
committed
fix(ios): more N 8.4 fixes
1 parent e952796 commit 3d7ac2e

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/label.android.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import {
1515
Property,
1616
PropertyChangeData,
1717
Span,
18+
Utils,
1819
View,
1920
booleanConverter,
2021
profile
2122
} from '@nativescript/core';
2223
import { Color } from '@nativescript/core/color';
2324
import { CSSShadow } from '@nativescript/core/ui/styling/css-shadow';
24-
import { Font, FontStyle, FontStyleType, FontWeight, FontWeightType } from '@nativescript/core/ui/styling/font';
25+
import { Font, FontStyleType, FontWeightType } from '@nativescript/core/ui/styling/font';
2526
import {
2627
Length,
2728
colorProperty,
@@ -42,7 +43,6 @@ import {
4243
} from '@nativescript/core/ui/text-base';
4344
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
4445
import lazy from '@nativescript/core/utils/lazy';
45-
import { Utils } from '@nativescript/core';
4646
import { Label as LabelViewDefinition, LineBreak } from './label';
4747
import { autoFontSizeProperty, lineBreakProperty, selectableProperty, textShadowProperty } from './label-common';
4848

@@ -446,10 +446,10 @@ export class Label extends LabelBase {
446446

447447
[lineHeightProperty.setNative](value: number) {
448448
if (sdkVersion() >= 28) {
449-
this.nativeTextViewProtected.setLineHeight(value * layout.getDisplayDensity());
449+
this.nativeTextViewProtected.setLineHeight(value * Utils.layout.getDisplayDensity());
450450
} else {
451451
const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
452-
this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity() - fontHeight, 1);
452+
this.nativeTextViewProtected.setLineSpacing(value * Utils.layout.getDisplayDensity() - fontHeight, 1);
453453
}
454454
}
455455

@@ -458,7 +458,7 @@ export class Label extends LabelBase {
458458
this.nativeTextViewProtected.setTypeface(androidFont);
459459
if (this.lineHeight && sdkVersion() < 28) {
460460
const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
461-
this.nativeTextViewProtected.setLineSpacing(this.lineHeight * layout.getDisplayDensity() - fontHeight, 1);
461+
this.nativeTextViewProtected.setLineSpacing(this.lineHeight * Utils.layout.getDisplayDensity() - fontHeight, 1);
462462
}
463463
}
464464

src/label.ios.ts

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { VerticalTextAlignment, createNativeAttributedString, verticalTextAlignmentProperty } from '@nativescript-community/text';
2-
import { Color, CoreTypes, Font, FormattedString, Span, View } from '@nativescript/core';
2+
import { Color, CoreTypes, Font, FormattedString, Span, Utils, View } from '@nativescript/core';
33
import {
44
borderBottomWidthProperty,
55
borderLeftWidthProperty,
@@ -18,8 +18,8 @@ import {
1818
whiteSpaceProperty
1919
} from '@nativescript/core/ui/text-base';
2020
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
21+
import { iOSNativeHelper } from '@nativescript/core/utils';
2122
import { isNullOrUndefined, isString } from '@nativescript/core/utils/types';
22-
import { Utils } from '@nativescript/core';
2323
import { TextShadow } from './label';
2424
import {
2525
LabelBase,
@@ -32,7 +32,6 @@ import {
3232
selectableProperty,
3333
textShadowProperty
3434
} from './label-common';
35-
import { iOSNativeHelper } from '@nativescript/core/utils';
3635

3736
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
3837
export * from './label-common';
@@ -311,15 +310,15 @@ export class Label extends LabelBase {
311310
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
312311
const nativeView = this.nativeTextViewProtected;
313312
if (nativeView) {
314-
const width = layout.getMeasureSpecSize(widthMeasureSpec);
315-
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
313+
const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
314+
const widthMode = Utils.layout.getMeasureSpecMode(widthMeasureSpec);
316315

317-
const height = layout.getMeasureSpecSize(heightMeasureSpec);
318-
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
316+
const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
317+
const heightMode = Utils.layout.getMeasureSpecMode(heightMeasureSpec);
319318
let resetFont;
320319
if (this.autoFontSize) {
321-
const finiteWidth = widthMode === layout.EXACTLY;
322-
const finiteHeight = heightMode === layout.EXACTLY;
320+
const finiteWidth = widthMode === Utils.layout.EXACTLY;
321+
const finiteHeight = heightMode === Utils.layout.EXACTLY;
323322
if (!finiteWidth || !finiteHeight) {
324323
resetFont = this.updateAutoFontSize({
325324
textView: nativeView,
@@ -330,12 +329,12 @@ export class Label extends LabelBase {
330329
}
331330
}
332331

333-
const desiredSize = layout.measureNativeView(nativeView, width, widthMode, height, heightMode);
332+
const desiredSize = Utils.layout.measureNativeView(nativeView, width, widthMode, height, heightMode);
334333
if (!this.formattedText && !this.html && resetFont) {
335334
nativeView.font = resetFont;
336335
}
337336

338-
const labelWidth = widthMode === layout.AT_MOST ? Math.min(desiredSize.width, width) : desiredSize.width;
337+
const labelWidth = widthMode === Utils.layout.AT_MOST ? Math.min(desiredSize.width, width) : desiredSize.width;
339338
// const labelHeight = heightMode === layout.AT_MOST ? Math.min(desiredSize.height, height) : desiredSize.height;
340339
const measureWidth = Math.max(labelWidth, this.effectiveMinWidth);
341340
const measureHeight = Math.max(desiredSize.height, this.effectiveMinHeight);

0 commit comments

Comments
 (0)