From bca127132955bcf965412546c31eb1ba840dfd5b Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Thu, 14 Nov 2019 14:22:20 +0200 Subject: [PATCH 1/9] fix(android): Fatal Exception: java.lang.OutOfMemoryError (#8061) (#8098) Crashlytics: **Async.java line 181** **org.nativescript.widgets.Async$Image$DownloadImageTask.doInBackground** ``` Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 3601932 byte allocation with 970044 free bytes and 947KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java) at android.graphics.BitmapFactory.nativeDecodeStream(BitmapFactory.java) at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:863) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:839) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:877) at org.nativescript.widgets.Async$Image$DownloadImageTask.doInBackground(Async.java:181) at org.nativescript.widgets.Async$Image$4.run(Async.java:157) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at org.nativescript.widgets.Async$PriorityThreadFactory$1.run(Async.java:86) at java.lang.Thread.run(Thread.java:818) ``` Crashlytics **Async.java line 473** **org.nativescript.widgets.Async$Http$RequestResult.readResponseStream** ``` Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 3000012 byte allocation with 2043950 free bytes and 1996KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java) at android.graphics.BitmapFactory.nativeDecodeByteArray(BitmapFactory.java) at android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:744) at org.nativescript.widgets.Async$Http$RequestResult.readResponseStream(Async.java:473) at org.nativescript.widgets.Async$Http$HttpRequestTask.doInBackground(Async.java:555) at org.nativescript.widgets.Async$Http$1.run(Async.java:307) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at org.nativescript.widgets.Async$PriorityThreadFactory$1.run(Async.java:86) at java.lang.Thread.run(Thread.java:818) ``` ## PR Checklist - [x] The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/CONTRIBUTING.md#commit-messages. - [x] There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. - [x] You have signed the [CLA](http://www.nativescript.org/cla). - [x] All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/DevelopmentWorkflow.md#running-unit-tests. - [ ] Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/WritingUnitTests.md. ## What is the current behavior? Uncaught exception resulting in crash. This was introduced in v6.2.0. ## What is the new behavior? Additional `catch` block for uncaught exception type `OutOfMemoryError` Fixes: https://www.telerik.com/account/support-tickets/view-ticket/1436458 --- .../src/main/java/org/nativescript/widgets/Async.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java index 265a905ce..9aa553f00 100644 --- a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java +++ b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/Async.java @@ -180,11 +180,8 @@ public class Async { stream = new java.net.URL(params[0]).openStream(); Bitmap bmp = BitmapFactory.decodeStream(stream); return bmp; - } catch (MalformedURLException e) { - Log.e(TAG, "Failed to decode stream, MalformedURLException: " + e.getMessage()); - return null; - } catch (IOException e) { - Log.e(TAG, "Failed to decode stream, IOException: " + e.getMessage()); + } catch (Throwable t) { + Log.e(TAG, "Failed to decode stream, Throwable: " + t.getMessage()); return null; } finally { if (stream != null) { @@ -472,8 +469,8 @@ public class Async { bitmapOptions.inSampleSize = scale; this.responseAsImage = BitmapFactory.decodeByteArray(responseStream.buf(), 0, responseStream.size(), bitmapOptions); } - } catch (Exception e) { - Log.e(TAG, "Failed to decode byte array, Exception: " + e.getMessage()); + } catch (Throwable t) { + Log.e(TAG, "Failed to decode byte array, Throwable: " + t.getMessage()); } if (this.responseAsImage == null) { From d983f799234db8588a18e001d25f044d0deb56eb Mon Sep 17 00:00:00 2001 From: Alexander Djenkov Date: Thu, 14 Nov 2019 16:43:19 +0200 Subject: [PATCH 2/9] fix(frame): nested frame wrong background after parent navigation (#8095) --- nativescript-core/ui/frame/frame.android.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/nativescript-core/ui/frame/frame.android.ts b/nativescript-core/ui/frame/frame.android.ts index 8468ccf55..778c40597 100644 --- a/nativescript-core/ui/frame/frame.android.ts +++ b/nativescript-core/ui/frame/frame.android.ts @@ -10,7 +10,7 @@ import * as application from "../../application"; import { _stack, FrameBase, NavigationType, Observable, - traceCategories, traceEnabled, traceError, traceWrite, View + traceCategories, traceEnabled, traceError, traceWrite, View, Color } from "./frame-common"; import { @@ -91,6 +91,7 @@ function getAttachListener(): android.view.View.OnAttachStateChangeListener { } export class Frame extends FrameBase { + public _originalBackground: any; private _android: AndroidFrame; private _containerViewId: number = -1; private _tearDownPending = false; @@ -241,6 +242,16 @@ export class Frame extends FrameBase { this.disposeCurrentFragment(); } + onLoaded(): void { + if (this._originalBackground) { + this.backgroundColor = null; + this.backgroundColor = this._originalBackground; + this._originalBackground = null; + } + + super.onLoaded(); + } + onUnloaded() { super.onUnloaded(); @@ -946,6 +957,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { if (hasRemovingParent) { const bitmapDrawable = new android.graphics.drawable.BitmapDrawable(application.android.context.getResources(), this.backgroundBitmap); + this.frame._originalBackground = this.frame.backgroundColor || new Color("White"); this.frame.nativeViewProtected.setBackgroundDrawable(bitmapDrawable); this.backgroundBitmap = null; } From b069ff38f3f9e32507089f8599da78546da78dbd Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Mon, 18 Nov 2019 13:39:00 +0200 Subject: [PATCH 3/9] fix(iOS): check for iOS 13 APIs (#8093) --- nativescript-core/application/application.ios.ts | 3 +-- .../ui/activity-indicator/activity-indicator.ios.ts | 2 +- .../ui/bottom-navigation/bottom-navigation.ios.ts | 4 +++- nativescript-core/ui/core/view/view.ios.ts | 4 +++- nativescript-core/ui/frame/frame.ios.ts | 4 +++- nativescript-core/ui/html-view/html-view.ios.ts | 2 +- nativescript-core/ui/page/page.ios.ts | 6 ++++-- nativescript-core/ui/tab-view/tab-view.ios.ts | 4 +++- nativescript-core/ui/tabs/tabs.ios.ts | 10 ++++++---- nativescript-core/ui/text-base/text-base.ios.ts | 4 ++-- nativescript-core/ui/text-view/text-view.ios.ts | 4 ++-- tests/app/ui/page/page-tests-common.ts | 2 +- 12 files changed, 30 insertions(+), 19 deletions(-) diff --git a/nativescript-core/application/application.ios.ts b/nativescript-core/application/application.ios.ts index 13efff29b..5a4191d56 100644 --- a/nativescript-core/application/application.ios.ts +++ b/nativescript-core/application/application.ios.ts @@ -89,7 +89,7 @@ class CADisplayLinkTarget extends NSObject { } class IOSApplication implements IOSApplicationDefinition { - private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor; + private _backgroundColor = (majorVersion <= 12 || !UIColor.systemBackgroundColor) ? UIColor.whiteColor : UIColor.systemBackgroundColor; private _delegate: typeof UIApplicationDelegate; private _window: UIWindow; private _observers: Array; @@ -121,7 +121,6 @@ class IOSApplication implements IOSApplicationDefinition { } get systemAppearance(): "light" | "dark" | null { - // userInterfaceStyle is available on UITraitCollection since iOS 12. if (majorVersion <= 11) { return null; diff --git a/nativescript-core/ui/activity-indicator/activity-indicator.ios.ts b/nativescript-core/ui/activity-indicator/activity-indicator.ios.ts index 9ce1dfb51..153e45673 100644 --- a/nativescript-core/ui/activity-indicator/activity-indicator.ios.ts +++ b/nativescript-core/ui/activity-indicator/activity-indicator.ios.ts @@ -9,7 +9,7 @@ const majorVersion = ios.MajorVersion; export class ActivityIndicator extends ActivityIndicatorBase { nativeViewProtected: UIActivityIndicatorView; - private _activityIndicatorViewStyle = majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium; + private _activityIndicatorViewStyle = (majorVersion <= 12 || !UIActivityIndicatorViewStyle.Medium) ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium; createNativeView() { const viewStyle = this._activityIndicatorViewStyle; diff --git a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts b/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts index b5e06d67a..f94154dfc 100644 --- a/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts +++ b/nativescript-core/ui/bottom-navigation/bottom-navigation.ios.ts @@ -93,7 +93,9 @@ class UITabBarControllerImpl extends UITabBarController { if (majorVersion >= 13) { const owner = this._owner.get(); - if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + if (owner && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } diff --git a/nativescript-core/ui/core/view/view.ios.ts b/nativescript-core/ui/core/view/view.ios.ts index 83c5e4ce2..30c58eb69 100644 --- a/nativescript-core/ui/core/view/view.ios.ts +++ b/nativescript-core/ui/core/view/view.ios.ts @@ -1012,7 +1012,9 @@ export namespace ios { if (majorVersion >= 13) { const owner = this.owner.get(); - if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + if (owner && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ eventName: traitCollectionColorAppearanceChangedEvent, object: owner }); } } diff --git a/nativescript-core/ui/frame/frame.ios.ts b/nativescript-core/ui/frame/frame.ios.ts index 145754bfb..bd3b1e1e1 100644 --- a/nativescript-core/ui/frame/frame.ios.ts +++ b/nativescript-core/ui/frame/frame.ios.ts @@ -540,7 +540,9 @@ class UINavigationControllerImpl extends UINavigationController { if (majorVersion >= 13) { const owner = this._owner.get(); - if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + if (owner && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } diff --git a/nativescript-core/ui/html-view/html-view.ios.ts b/nativescript-core/ui/html-view/html-view.ios.ts index 3252c3626..d5c1d5b6e 100644 --- a/nativescript-core/ui/html-view/html-view.ios.ts +++ b/nativescript-core/ui/html-view/html-view.ios.ts @@ -59,7 +59,7 @@ export class HtmlView extends HtmlViewBase { null ); - if (majorVersion >= 13) { + if (majorVersion >= 13 && UIColor.labelColor) { this.nativeViewProtected.textColor = UIColor.labelColor; } } diff --git a/nativescript-core/ui/page/page.ios.ts b/nativescript-core/ui/page/page.ios.ts index 4fd9a4fc3..d54cdf649 100644 --- a/nativescript-core/ui/page/page.ios.ts +++ b/nativescript-core/ui/page/page.ios.ts @@ -287,7 +287,9 @@ class UIViewControllerImpl extends UIViewController { if (majorVersion >= 13) { const owner = this._owner.get(); - if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + if (owner && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } @@ -298,7 +300,7 @@ export class Page extends PageBase { nativeViewProtected: UIView; viewController: UIViewControllerImpl; - private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor; + private _backgroundColor = (majorVersion <= 12 && !UIColor.systemBackgroundColor) ? UIColor.whiteColor : UIColor.systemBackgroundColor; private _ios: UIViewControllerImpl; public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction. diff --git a/nativescript-core/ui/tab-view/tab-view.ios.ts b/nativescript-core/ui/tab-view/tab-view.ios.ts index 02e00b24f..7d0cef33c 100644 --- a/nativescript-core/ui/tab-view/tab-view.ios.ts +++ b/nativescript-core/ui/tab-view/tab-view.ios.ts @@ -78,7 +78,9 @@ class UITabBarControllerImpl extends UITabBarController { if (majorVersion >= 13) { const owner = this._owner.get(); - if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + if (owner && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } diff --git a/nativescript-core/ui/tabs/tabs.ios.ts b/nativescript-core/ui/tabs/tabs.ios.ts index d7d622371..3358e7d16 100644 --- a/nativescript-core/ui/tabs/tabs.ios.ts +++ b/nativescript-core/ui/tabs/tabs.ios.ts @@ -24,7 +24,7 @@ export * from "./tabs-common"; const majorVersion = iosUtils.MajorVersion; // Equivalent to dispatch_async(dispatch_get_main_queue(...)) call -const invokeOnRunLoop = (function() { +const invokeOnRunLoop = (function () { const runloop = CFRunLoopGetMain(); return (action: () => any) => { @@ -100,7 +100,7 @@ class UIPageViewControllerImpl extends UIPageViewController { tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner)); - if (majorVersion <= 12) { + if (majorVersion <= 12 || !UIColor.labelColor) { tabBar.tintColor = UIColor.blueColor; tabBar.barTintColor = UIColor.whiteColor; tabBar.setTitleColorForState(UIColor.blackColor, MDCTabBarItemState.Normal); @@ -216,7 +216,9 @@ class UIPageViewControllerImpl extends UIPageViewController { if (majorVersion >= 13) { const owner = this._owner.get(); - if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { + if (owner && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && + this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner }); } } @@ -1087,7 +1089,7 @@ export class Tabs extends TabsBase { // HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606 invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null)); } - + this._canSelectItem = true; this._setCanBeLoaded(value); this._loadUnloadTabItems(value); diff --git a/nativescript-core/ui/text-base/text-base.ios.ts b/nativescript-core/ui/text-base/text-base.ios.ts index 4665757c0..12cb12e30 100644 --- a/nativescript-core/ui/text-base/text-base.ios.ts +++ b/nativescript-core/ui/text-base/text-base.ios.ts @@ -153,7 +153,7 @@ export class TextBase extends TextBaseCommon { this.nativeTextViewProtected.setAttributedTitleForState(attrText, UIControlState.Normal); } else { - if (majorVersion >= 13) { + if (majorVersion >= 13 && UIColor.labelColor) { this.nativeTextViewProtected.textColor = UIColor.labelColor; } @@ -205,7 +205,7 @@ export class TextBase extends TextBaseCommon { if (dict.size > 0 || isTextView) { if (style.color) { dict.set(NSForegroundColorAttributeName, style.color.ios); - } else if (majorVersion >= 13) { + } else if (majorVersion >= 13 && UIColor.labelColor) { dict.set(NSForegroundColorAttributeName, UIColor.labelColor); } } diff --git a/nativescript-core/ui/text-view/text-view.ios.ts b/nativescript-core/ui/text-view/text-view.ios.ts index a1411cffd..a45d643d9 100644 --- a/nativescript-core/ui/text-view/text-view.ios.ts +++ b/nativescript-core/ui/text-view/text-view.ios.ts @@ -116,8 +116,8 @@ export class TextView extends EditableTextBase implements TextViewDefinition { private _isShowingHint: boolean; public _isEditing: boolean; - private _hintColor = majorVersion <= 12 ? UIColor.blackColor.colorWithAlphaComponent(0.22) : UIColor.placeholderTextColor; - private _textColor = majorVersion <= 12 ? null : UIColor.labelColor; + private _hintColor = (majorVersion <= 12 || !UIColor.placeholderTextColor) ? UIColor.blackColor.colorWithAlphaComponent(0.22) : UIColor.placeholderTextColor; + private _textColor = (majorVersion <= 12 || !UIColor.labelColor) ? null : UIColor.labelColor; createNativeView() { const textView = NoScrollAnimationUITextView.new(); diff --git a/tests/app/ui/page/page-tests-common.ts b/tests/app/ui/page/page-tests-common.ts index 2a71baeed..c488ddb9d 100644 --- a/tests/app/ui/page/page-tests-common.ts +++ b/tests/app/ui/page/page-tests-common.ts @@ -385,7 +385,7 @@ export function test_page_backgroundColor() { helper.navigate(factory); if (isIOS) { - const backgroundColor = ios.MajorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor; + const backgroundColor = (ios.MajorVersion <= 12 || !UIColor.systemBackgroundColor) ? UIColor.whiteColor : UIColor.systemBackgroundColor; TKUnit.assertEqual(page.nativeView.backgroundColor, backgroundColor, "page backgroundColor is wrong"); } else { const whiteColor = new Color("white"); From 800f5bcfe4520cd1aeebf7bc84070299d3520f89 Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Thu, 21 Nov 2019 14:48:33 +0200 Subject: [PATCH 4/9] fix: tab navigations don't work with lowercase xml (#8016) --- api-reports/NativeScript.api.md | 3 ++ .../tab-navigation-base.ts | 10 +++--- .../tab-strip-item/tab-strip-item.ts | 13 ++++---- .../tab-strip/tab-strip.ts | 4 +-- .../ui/tab-view/tab-view-common.ts | 2 +- tests/app/package.json | 3 +- tests/app/test-runner.ts | 9 +++++ .../bottom-navigation-tests-new.ts | 33 +++++++++++++++++++ tests/app/ui/tab-view/tab-view-tests-new.ts | 19 +++++++++++ tests/app/ui/tabs/tabs-tests-new.ts | 33 +++++++++++++++++++ tests/webpack.config.js | 4 +-- 11 files changed, 116 insertions(+), 17 deletions(-) create mode 100644 tests/app/ui/bottom-navigation/bottom-navigation-tests-new.ts create mode 100644 tests/app/ui/tab-view/tab-view-tests-new.ts create mode 100644 tests/app/ui/tabs/tabs-tests-new.ts diff --git a/api-reports/NativeScript.api.md b/api-reports/NativeScript.api.md index c585fb21b..ecb5ddee9 100644 --- a/api-reports/NativeScript.api.md +++ b/api-reports/NativeScript.api.md @@ -2304,6 +2304,9 @@ export class TabStripItem extends View { image: Image; + // (undocumented) + _index: number; + label: Label; on(eventNames: string, callback: (data: EventData) => void); diff --git a/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.ts b/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.ts index ddd1429de..eb8d96ed0 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-navigation-base/tab-navigation-base.ts @@ -1,12 +1,12 @@ // Types import { TabNavigationBase as TabNavigationBaseDefinition, SelectedIndexChangedEventData } from "."; -import { TabContentItem } from "../tab-content-item"; -import { TabStrip } from "../tab-strip"; import { TabStripItem } from "../tab-strip-item"; import { ViewBase, AddArrayFromBuilder, AddChildFromBuilder, EventData } from "../../core/view"; // Requires -import { View, Property, CoercibleProperty, isIOS, Color } from "../../core/view"; +import { View, Property, CoercibleProperty, isIOS } from "../../core/view"; +import { TabContentItem } from "../tab-content-item"; +import { TabStrip } from "../tab-strip"; // TODO: Impl trace // export const traceCategory = "TabView"; @@ -29,14 +29,14 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti } public _addChildFromBuilder(name: string, value: any): void { - if (name === "TabContentItem") { + if (value instanceof TabContentItem) { if (!this.items) { this.items = new Array(); } this.items.push(value); this._addView(value); // selectedIndexProperty.coerce(this); - } else if (name === "TabStrip") { + } else if (value instanceof TabStrip) { // Setting tabStrip will trigger onTabStripChanged this.tabStrip = value; } diff --git a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts index 09ea676e7..bab24db82 100644 --- a/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts +++ b/nativescript-core/ui/tab-navigation-base/tab-strip-item/tab-strip-item.ts @@ -3,8 +3,6 @@ import { TabStripItem as TabStripItemDefinition } from "."; import { PropertyChangeData } from "../../../data/observable"; import { TabNavigationBase } from "../tab-navigation-base"; import { TabStrip } from "../tab-strip"; -import { Image } from "../../image/image"; -import { Label } from "../../label/label"; import { Color } from "../../../color"; import { AddChildFromBuilder } from "../../core/view"; @@ -12,8 +10,9 @@ import { AddChildFromBuilder } from "../../core/view"; import { View, ViewBase, CSSType, backgroundColorProperty, backgroundInternalProperty, PseudoClassHandler } from "../../core/view"; -import { Tabs } from "../../tabs"; import { isIOS } from "../../../platform"; +import { Image } from "../../image/image"; +import { Label } from "../../label/label"; export * from "../../core/view"; export const traceCategory = "TabView"; @@ -173,14 +172,14 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi } public _addChildFromBuilder(name: string, value: any): void { - if (name === "Image") { + if (value instanceof Image) { this.image = value; this.iconSource = (value).src; this._addView(value); // selectedIndexProperty.coerce(this); } - if (name === "Label") { + if (value instanceof Label) { this.label =