|
1 | 1 | /** |
2 | 2 | * @module @nativescript-community/ui-material-core-tabs/tab-navigation |
3 | 3 | */ |
4 | | -import { Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageSource, Property, Utils, View, ViewBase, booleanConverter, getTransformedText } from '@nativescript/core'; |
| 4 | +import { Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageAsset, ImageSource, Property, Utils, View, ViewBase, booleanConverter, getTransformedText } from '@nativescript/core'; |
5 | 5 | import { TabContentItem } from '../tab-content-item'; |
6 | 6 | import { getIconSpecSize, itemsProperty, selectedIndexProperty, tabStripProperty } from '../tab-navigation-base'; |
7 | 7 | import { TabStrip } from '../tab-strip'; |
@@ -253,6 +253,7 @@ export abstract class TabNavigation< |
253 | 253 | public nativeViewProtected: UIView; |
254 | 254 | public selectedIndex: number; |
255 | 255 | public mCanSelectItem: boolean; |
| 256 | + //@ts-ignore |
256 | 257 | public isLoaded: boolean; |
257 | 258 | public viewController: T; |
258 | 259 | public items: TabContentItem[]; |
@@ -630,21 +631,28 @@ export abstract class TabNavigation< |
630 | 631 | } |
631 | 632 | const iconTag = [iconSource, font.fontStyle, font.fontWeight, font.fontSize, font.fontFamily, color].join(';'); |
632 | 633 |
|
633 | | - let isFontIcon = false; |
| 634 | + const isFontIcon = false; |
634 | 635 | let image: UIImage = this.mIconsCache[iconTag]; |
635 | 636 | if (!image) { |
636 | | - let is: ImageSource; |
637 | | - if (Utils.isFontIconURI(iconSource)) { |
638 | | - isFontIcon = true; |
639 | | - const fontIconCode = iconSource.split('//')[1]; |
640 | | - is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color); |
| 637 | + let is: ImageSource | ImageAsset; |
| 638 | + if (typeof iconSource === 'string') { |
| 639 | + if (Utils.isFontIconURI(iconSource)) { |
| 640 | + const fontIconCode = iconSource.split('//')[1]; |
| 641 | + const target = tabStripItem.image ? tabStripItem.image : tabStripItem; |
| 642 | + const font = target.style.fontInternal; |
| 643 | + if (!color) { |
| 644 | + color = target.style.color; |
| 645 | + } |
| 646 | + is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color); |
| 647 | + } else { |
| 648 | + is = ImageSource.fromFileOrResourceSync(iconSource); |
| 649 | + } |
641 | 650 | } else { |
642 | | - is = ImageSource.fromFileOrResourceSync(iconSource); |
| 651 | + is = iconSource; |
643 | 652 | } |
644 | 653 |
|
645 | | - if (is && is.ios) { |
646 | | - image = is.ios; |
647 | | - |
| 654 | + image = is?.ios; |
| 655 | + if (image) { |
648 | 656 | if (this.tabStrip && this.tabStrip.isIconSizeFixed) { |
649 | 657 | image = this.getFixedSizeIcon(image); |
650 | 658 | } |
|
0 commit comments