Skip to content

Commit fd5796d

Browse files
committed
chore(core-tabs): fix icons generation on iOS
1 parent a96531d commit fd5796d

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/core-tabs/tab-navigation/index.ios.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @module @nativescript-community/ui-material-core-tabs/tab-navigation
33
*/
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';
55
import { TabContentItem } from '../tab-content-item';
66
import { getIconSpecSize, itemsProperty, selectedIndexProperty, tabStripProperty } from '../tab-navigation-base';
77
import { TabStrip } from '../tab-strip';
@@ -253,6 +253,7 @@ export abstract class TabNavigation<
253253
public nativeViewProtected: UIView;
254254
public selectedIndex: number;
255255
public mCanSelectItem: boolean;
256+
//@ts-ignore
256257
public isLoaded: boolean;
257258
public viewController: T;
258259
public items: TabContentItem[];
@@ -630,21 +631,28 @@ export abstract class TabNavigation<
630631
}
631632
const iconTag = [iconSource, font.fontStyle, font.fontWeight, font.fontSize, font.fontFamily, color].join(';');
632633

633-
let isFontIcon = false;
634+
const isFontIcon = false;
634635
let image: UIImage = this.mIconsCache[iconTag];
635636
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+
}
641650
} else {
642-
is = ImageSource.fromFileOrResourceSync(iconSource);
651+
is = iconSource;
643652
}
644653

645-
if (is && is.ios) {
646-
image = is.ios;
647-
654+
image = is?.ios;
655+
if (image) {
648656
if (this.tabStrip && this.tabStrip.isIconSizeFixed) {
649657
image = this.getFixedSizeIcon(image);
650658
}

0 commit comments

Comments
 (0)