mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
fix(dark-mode): formatted string and html view text color (#8031)
This commit is contained in:

committed by
Manol Donev

parent
eb33ede5a7
commit
0c7f8383a3
@ -1,9 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
HtmlViewBase, View, layout, htmlProperty
|
HtmlViewBase, View, layout, htmlProperty
|
||||||
} from "./html-view-common";
|
} from "./html-view-common";
|
||||||
|
import { ios } from "../../utils/utils";
|
||||||
|
|
||||||
export * from "./html-view-common";
|
export * from "./html-view-common";
|
||||||
|
|
||||||
|
const majorVersion = ios.MajorVersion;
|
||||||
|
|
||||||
export class HtmlView extends HtmlViewBase {
|
export class HtmlView extends HtmlViewBase {
|
||||||
nativeViewProtected: UITextView;
|
nativeViewProtected: UITextView;
|
||||||
|
|
||||||
@ -50,6 +53,14 @@ export class HtmlView extends HtmlViewBase {
|
|||||||
[htmlProperty.setNative](value: string) {
|
[htmlProperty.setNative](value: string) {
|
||||||
const htmlString = NSString.stringWithString(value + "");
|
const htmlString = NSString.stringWithString(value + "");
|
||||||
const nsData = htmlString.dataUsingEncoding(NSUnicodeStringEncoding);
|
const nsData = htmlString.dataUsingEncoding(NSUnicodeStringEncoding);
|
||||||
this.nativeViewProtected.attributedText = NSAttributedString.alloc().initWithDataOptionsDocumentAttributesError(nsData, <any>{ [NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType }, null);
|
this.nativeViewProtected.attributedText = NSAttributedString.alloc().initWithDataOptionsDocumentAttributesError(
|
||||||
|
nsData,
|
||||||
|
<any>{ [NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType },
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
|
if (majorVersion >= 13) {
|
||||||
|
this.nativeViewProtected.textColor = UIColor.labelColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,10 @@ export class TextBase extends TextBaseCommon {
|
|||||||
this.nativeTextViewProtected.setAttributedTitleForState(attrText, UIControlState.Normal);
|
this.nativeTextViewProtected.setAttributedTitleForState(attrText, UIControlState.Normal);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (majorVersion >= 13) {
|
||||||
|
this.nativeTextViewProtected.textColor = UIColor.labelColor;
|
||||||
|
}
|
||||||
|
|
||||||
this.nativeTextViewProtected.attributedText = attrText;
|
this.nativeTextViewProtected.attributedText = attrText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user