Skip to content

Commit 9f716c9

Browse files
committed
chore(bottom-navigation): fix icons generation on iOS
1 parent 0df1691 commit 9f716c9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

Diff for: src/bottom-navigation/index.ios.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TabStrip } from '@nativescript-community/ui-material-core-tabs/tab-stri
66
import { TabStripItem } from '@nativescript-community/ui-material-core-tabs/tab-strip-item';
77
// Types
88
// Requires
9-
import { CSSType, Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageSource, Property, Utils, View, booleanConverter } from '@nativescript/core';
9+
import { CSSType, Color, CoreTypes, Device, Font, Frame, IOSHelper, ImageSource, ImageAsset, Property, Utils, View, booleanConverter } from '@nativescript/core';
1010
import { getTransformedText } from '@nativescript/core/ui/text-base';
1111
import { iOSNativeHelper } from '@nativescript/core/utils';
1212
export { TabContentItem, TabStrip, TabStripItem };
@@ -690,19 +690,28 @@ export class BottomNavigation extends TabNavigationBase {
690690
}
691691
const iconTag = [iconSource, font.fontStyle, font.fontWeight, font.fontSize, font.fontFamily, color].join(';');
692692

693-
let isFontIcon = false;
693+
const isFontIcon = false;
694694
let image: UIImage = this.mIconsCache[iconTag];
695695
if (!image) {
696-
let is;
697-
if (Utils.isFontIconURI(iconSource)) {
698-
isFontIcon = true;
699-
const fontIconCode = iconSource.split('//')[1];
700-
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
696+
let is: ImageSource | ImageAsset;
697+
if (typeof iconSource === 'string') {
698+
if (Utils.isFontIconURI(iconSource)) {
699+
const fontIconCode = iconSource.split('//')[1];
700+
const target = tabStripItem.image ? tabStripItem.image : tabStripItem;
701+
const font = target.style.fontInternal;
702+
if (!color) {
703+
color = target.style.color;
704+
}
705+
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
706+
} else {
707+
is = ImageSource.fromFileOrResourceSync(iconSource);
708+
}
701709
} else {
702-
is = ImageSource.fromFileOrResourceSync(iconSource);
710+
is = iconSource;
703711
}
704712

705-
if (is && is.ios) {
713+
image = is?.ios;
714+
if (image) {
706715
image = is.ios;
707716

708717
if (this.tabStrip && this.tabStrip.isIconSizeFixed) {

0 commit comments

Comments
 (0)