fix(dark-mode): formatted string and html view text color (#8031)

This commit is contained in:
Vasil Chimev
2019-11-07 11:43:27 +00:00
committed by Manol Donev
parent eb33ede5a7
commit 0c7f8383a3
2 changed files with 16 additions and 1 deletions

View File

@ -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;
}
} }
} }

View File

@ -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;
} }
} }