From 0c7f8383a38cd5b1ae295403e90e351c99d0fa5f Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Thu, 7 Nov 2019 11:43:27 +0000 Subject: [PATCH 1/4] 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; } } From 7fa997865b5ad9fd3144f6a0c5845ad1847b8315 Mon Sep 17 00:00:00 2001 From: Vasil Trifonov Date: Thu, 7 Nov 2019 15:14:37 +0200 Subject: [PATCH 2/4] fix: ensure @CallSuper native methods call superFunc (#8025) --- nativescript-core/ui/frame/frame.android.ts | 62 ++++++++++++--------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/nativescript-core/ui/frame/frame.android.ts b/nativescript-core/ui/frame/frame.android.ts index 096adb628..8468ccf55 100644 --- a/nativescript-core/ui/frame/frame.android.ts +++ b/nativescript-core/ui/frame/frame.android.ts @@ -937,18 +937,21 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onDestroyView(fragment: org.nativescript.widgets.FragmentBase, superFunc: Function): void { - if (traceEnabled()) { - traceWrite(`${fragment}.onDestroyView()`, traceCategories.NativeLifecycle); - } + try { + if (traceEnabled()) { + traceWrite(`${fragment}.onDestroyView()`, traceCategories.NativeLifecycle); + } - const hasRemovingParent = fragment.getRemovingParentFragment(); + const hasRemovingParent = fragment.getRemovingParentFragment(); - if (hasRemovingParent) { - const bitmapDrawable = new android.graphics.drawable.BitmapDrawable(application.android.context.getResources(), this.backgroundBitmap); - this.frame.nativeViewProtected.setBackgroundDrawable(bitmapDrawable); - this.backgroundBitmap = null; + if (hasRemovingParent) { + const bitmapDrawable = new android.graphics.drawable.BitmapDrawable(application.android.context.getResources(), this.backgroundBitmap); + this.frame.nativeViewProtected.setBackgroundDrawable(bitmapDrawable); + this.backgroundBitmap = null; + } + } finally { + superFunc.call(fragment); } - superFunc.call(fragment); } @profile @@ -982,14 +985,17 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { @profile public onPause(fragment: org.nativescript.widgets.FragmentBase, superFunc: Function): void { - // Get view as bitmap and set it as background. This is workaround for the disapearing nested fragments. - // TODO: Consider removing it when update to androidx.fragment:1.2.0 - const hasRemovingParent = fragment.getRemovingParentFragment(); + try { + // Get view as bitmap and set it as background. This is workaround for the disapearing nested fragments. + // TODO: Consider removing it when update to androidx.fragment:1.2.0 + const hasRemovingParent = fragment.getRemovingParentFragment(); - if (hasRemovingParent) { - this.backgroundBitmap = this.loadBitmapFromView(this.frame.nativeViewProtected); + if (hasRemovingParent) { + this.backgroundBitmap = this.loadBitmapFromView(this.frame.nativeViewProtected); + } + } finally { + superFunc.call(fragment); } - superFunc.call(fragment); } @profile @@ -1154,19 +1160,21 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { @profile public onDestroy(activity: any, superFunc: Function): void { - if (traceEnabled()) { - traceWrite("NativeScriptActivity.onDestroy();", traceCategories.NativeLifecycle); + try { + if (traceEnabled()) { + traceWrite("NativeScriptActivity.onDestroy();", traceCategories.NativeLifecycle); + } + + const rootView = this._rootView; + if (rootView) { + rootView._tearDownUI(true); + } + + const exitArgs = { eventName: application.exitEvent, object: application.android, android: activity }; + application.notify(exitArgs); + } finally { + superFunc.call(activity); } - - const rootView = this._rootView; - if (rootView) { - rootView._tearDownUI(true); - } - - const exitArgs = { eventName: application.exitEvent, object: application.android, android: activity }; - application.notify(exitArgs); - - superFunc.call(activity); } @profile From f68647233f5d05d0774c513539c16f42ec12ef21 Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Fri, 8 Nov 2019 11:14:29 +0200 Subject: [PATCH 3/4] fix(dev-tools): use app root in getDocument() (#8071) --- .../debugger/devtools-elements.common.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/nativescript-core/debugger/devtools-elements.common.ts b/nativescript-core/debugger/devtools-elements.common.ts index 5abfb667d..71473ef5a 100644 --- a/nativescript-core/debugger/devtools-elements.common.ts +++ b/nativescript-core/debugger/devtools-elements.common.ts @@ -4,6 +4,9 @@ import { getNodeById } from "./dom-node"; import { ViewBase } from "../ui/core/view-base"; import { mainThreadify } from "../utils/utils"; +// Use lazy requires for core modules +const getAppRootView = () => require("../application").getRootView(); + let unsetValue; function unsetViewValue(view, name) { if (!unsetValue) { @@ -24,19 +27,19 @@ function getViewById(nodeId: number): ViewBase { } export function getDocument() { - const topMostFrame = require("../ui/frame").Frame.topmost(); - if (!topMostFrame) { + const appRoot = getAppRootView(); + if (!appRoot) { return undefined; } try { - topMostFrame.ensureDomNode(); + appRoot.ensureDomNode(); } catch (e) { console.log("ERROR in getDocument(): " + e); } - return topMostFrame.domNode.toObject(); + return appRoot.domNode.toObject(); } export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> { From 1528498a31883a446e8d95340ffcc198dbd36a8b Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Tue, 12 Nov 2019 16:53:50 +0200 Subject: [PATCH 4/4] docs: cut the 6.2.1 release (#8087) --- CHANGELOG.md | 18 ++++++++++++++++++ nativescript-core/package.json | 2 +- tns-core-modules-package/package.json | 2 +- tns-core-modules-widgets/package.json | 2 +- tns-platform-declarations/package.json | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 788d329cf..071bbef9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ + +## [6.2.1](https://github.com/NativeScript/NativeScript/compare/6.2.0...6.2.1) (2019-11-12) + + +### Bug Fixes + +* **dark-mode:** formatted string and html view text color ([#8031](https://github.com/NativeScript/NativeScript/issues/8031)) ([0c7f838](https://github.com/NativeScript/NativeScript/commit/0c7f838)) +* ensure @CallSuper native methods call superFunc ([#8025](https://github.com/NativeScript/NativeScript/issues/8025)) ([7fa9978](https://github.com/NativeScript/NativeScript/commit/7fa9978)) +* **dev-tools:** use app root in getDocument() ([#8071](https://github.com/NativeScript/NativeScript/issues/8071)) ([f686472](https://github.com/NativeScript/NativeScript/commit/f686472)) +* **gradient:** import LinearGradient with alias ([#8063](https://github.com/NativeScript/NativeScript/issues/8063)) ([eb33ede](https://github.com/NativeScript/NativeScript/commit/eb33ede)) + + +### Features + +* **application:** add system appearance changed event to typings ([#8034](https://github.com/NativeScript/NativeScript/issues/8034)) ([2a34368](https://github.com/NativeScript/NativeScript/commit/2a34368)) + + + # [6.2.0](https://github.com/NativeScript/NativeScript/compare/6.1.2...6.2.0) (2019-10-24) diff --git a/nativescript-core/package.json b/nativescript-core/package.json index a6bc4365a..2f1e6d8cb 100644 --- a/nativescript-core/package.json +++ b/nativescript-core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "Telerik NativeScript Core Modules", - "version": "6.2.0", + "version": "6.2.1", "homepage": "https://www.nativescript.org", "repository": { "type": "git", diff --git a/tns-core-modules-package/package.json b/tns-core-modules-package/package.json index 71981a748..d25278a09 100644 --- a/tns-core-modules-package/package.json +++ b/tns-core-modules-package/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "Telerik NativeScript Core Modules", - "version": "6.2.0", + "version": "6.2.1", "homepage": "https://www.nativescript.org", "repository": { "type": "git", diff --git a/tns-core-modules-widgets/package.json b/tns-core-modules-widgets/package.json index 7a5a212c4..ad730cc55 100644 --- a/tns-core-modules-widgets/package.json +++ b/tns-core-modules-widgets/package.json @@ -1,6 +1,6 @@ { "name": "tns-core-modules-widgets", - "version": "6.2.0", + "version": "6.2.1", "description": "Native widgets used in the NativeScript framework.", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" diff --git a/tns-platform-declarations/package.json b/tns-platform-declarations/package.json index 83b9b9f7e..081435039 100644 --- a/tns-platform-declarations/package.json +++ b/tns-platform-declarations/package.json @@ -1,6 +1,6 @@ { "name": "tns-platform-declarations", - "version": "6.2.0", + "version": "6.2.1", "description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects", "main": "", "scripts": {