Skip to content

Commit 404c0c0

Browse files
committed
fix(ios): fix crashes with html text in pager
1 parent 34dfd08 commit 404c0c0

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

Diff for: package.json

+20-20
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,28 @@
5353
"@angular/core": "~11.2.9",
5454
"@angular/forms": "~11.2.9",
5555
"@angular/platform-browser": "~11.2.9",
56-
"@angular/platform-browser-dynamic": "~11.2.9",
57-
"@angular/router": "~11.2.9",
58-
"@commitlint/cli": "^12.1.1",
59-
"@commitlint/config-conventional": "^12.1.1",
60-
"@nativescript-community/text": "^1.4.15",
61-
"@nativescript/angular": "11.2.0",
62-
"@nativescript/core": "8.0.1",
63-
"@nativescript/types-android": "8.0.0",
64-
"@nativescript/types-ios": "8.0.0",
65-
"@nativescript/webpack": "5.0.0-beta.6",
66-
"@types/node": "^14.14.37",
67-
"@typescript-eslint/eslint-plugin": "4.22.0",
68-
"@typescript-eslint/parser": "4.22.0",
69-
"eslint": "7.24.0",
70-
"eslint-config-prettier": "^8.2.0",
71-
"eslint-plugin-prettier": "^3.3.1",
72-
"husky": "^6.0.0",
56+
"@angular/platform-browser-dynamic": "~12.2.0",
57+
"@angular/router": "~12.2.0",
58+
"@commitlint/cli": "^13.1.0",
59+
"@commitlint/config-conventional": "^13.1.0",
60+
"@nativescript-community/text": "^1.4.19",
61+
"@nativescript/angular": "12.0.6",
62+
"@nativescript/core": "8.0.8",
63+
"@nativescript/types-android": "8.0.1",
64+
"@nativescript/types-ios": "8.0.1",
65+
"@nativescript/webpack": "beta",
66+
"@types/node": "^16.4.13",
67+
"@typescript-eslint/eslint-plugin": "4.29.0",
68+
"@typescript-eslint/parser": "4.29.0",
69+
"eslint": "7.32.0",
70+
"eslint-config-prettier": "^8.3.0",
71+
"eslint-plugin-prettier": "^3.4.0",
72+
"husky": "^7.0.1",
7373
"lerna": "^4.0.0",
74-
"prettier": "^2.2.1",
74+
"prettier": "^2.3.2",
7575
"rimraf": "^3.0.2",
76-
"ts-patch": "^1.3.2",
77-
"typescript": "~4.2.4"
76+
"ts-patch": "^1.4.2",
77+
"typescript": "~4.3.5"
7878
},
7979
"dependencies": {
8080
"ts-node": "^9.1.1"

Diff for: plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
"license": "Apache-2.0",
3333
"readmeFilename": "README.md",
3434
"dependencies": {
35-
"@nativescript-community/text": "^1.4.15"
35+
"@nativescript-community/text": "^1.4.19"
3636
}
3737
}

Diff for: src/label.ios.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
VerticalTextAlignment,
33
computeBaseLineOffset,
44
createNativeAttributedString,
5+
usingIOSDTCoreText,
56
verticalTextAlignmentProperty
67
} from '@nativescript-community/text';
78
import { Color, CoreTypes, Font, FormattedString, Span, View } from '@nativescript/core';
@@ -436,7 +437,7 @@ export class Label extends LabelBase {
436437
return false;
437438
}
438439

439-
updateHTMLString(fontSize?: number) {
440+
_updateHTMLString(fontSize?: number) {
440441
if (!this.html) {
441442
this.nativeTextViewProtected.selectable = this.selectable === true;
442443
this.attributedString = null;
@@ -483,6 +484,18 @@ export class Label extends LabelBase {
483484
}
484485
this._requestLayoutOnTextChanged();
485486
}
487+
updateHTMLString(fontSize?: number) {
488+
// when in collectionView or pager
489+
// if this is done sync (without DTCoreText) while init the cell
490+
// it breaks the UICollectionView :s
491+
if (usingIOSDTCoreText()) {
492+
this._updateHTMLString();
493+
}else {
494+
setTimeout(() => {
495+
this._updateHTMLString();
496+
}, 0);
497+
}
498+
}
486499
[colorProperty.setNative](value: Color | string) {
487500
const color = !value || value instanceof Color ? (value as Color) : new Color(value);
488501
const nativeView = this.nativeTextViewProtected;
@@ -544,10 +557,7 @@ export class Label extends LabelBase {
544557
// }
545558
_setNativeText() {
546559
if (this.html) {
547-
// when in collectionView or pager
548-
// if this is done sync while init the cell
549-
// it breaks the UICollectionView :s
550-
setTimeout(() => this.updateHTMLString(), 0);
560+
this.updateHTMLString();
551561
} else {
552562
super._setNativeText();
553563
}

0 commit comments

Comments
 (0)