From 0c7f8383a38cd5b1ae295403e90e351c99d0fa5f Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Thu, 7 Nov 2019 11:43:27 +0000 Subject: [PATCH] fix(dark-mode): formatted string and html view text color (#8031) --- nativescript-core/ui/html-view/html-view.ios.ts | 13 ++++++++++++- nativescript-core/ui/text-base/text-base.ios.ts | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/nativescript-core/ui/html-view/html-view.ios.ts b/nativescript-core/ui/html-view/html-view.ios.ts index f0cb9dcb4..3252c3626 100644 --- a/nativescript-core/ui/html-view/html-view.ios.ts +++ b/nativescript-core/ui/html-view/html-view.ios.ts @@ -1,9 +1,12 @@ import { HtmlViewBase, View, layout, htmlProperty } from "./html-view-common"; +import { ios } from "../../utils/utils"; export * from "./html-view-common"; +const majorVersion = ios.MajorVersion; + export class HtmlView extends HtmlViewBase { nativeViewProtected: UITextView; @@ -50,6 +53,14 @@ export class HtmlView extends HtmlViewBase { [htmlProperty.setNative](value: string) { const htmlString = NSString.stringWithString(value + ""); const nsData = htmlString.dataUsingEncoding(NSUnicodeStringEncoding); - this.nativeViewProtected.attributedText = NSAttributedString.alloc().initWithDataOptionsDocumentAttributesError(nsData, { [NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType }, null); + this.nativeViewProtected.attributedText = NSAttributedString.alloc().initWithDataOptionsDocumentAttributesError( + nsData, + { [NSDocumentTypeDocumentAttribute]: NSHTMLTextDocumentType }, + null + ); + + if (majorVersion >= 13) { + this.nativeViewProtected.textColor = UIColor.labelColor; + } } } diff --git a/nativescript-core/ui/text-base/text-base.ios.ts b/nativescript-core/ui/text-base/text-base.ios.ts index c7c07218b..4665757c0 100644 --- a/nativescript-core/ui/text-base/text-base.ios.ts +++ b/nativescript-core/ui/text-base/text-base.ios.ts @@ -153,6 +153,10 @@ export class TextBase extends TextBaseCommon { this.nativeTextViewProtected.setAttributedTitleForState(attrText, UIControlState.Normal); } else { + if (majorVersion >= 13) { + this.nativeTextViewProtected.textColor = UIColor.labelColor; + } + this.nativeTextViewProtected.attributedText = attrText; } }