@@ -15,6 +15,11 @@ const TABID = '_tabId';
1515const INDEX = '_index' ;
1616const ownerSymbol = Symbol ( '_owner' ) ;
1717
18+ class IconInfo {
19+ drawable : android . graphics . drawable . BitmapDrawable ;
20+ height : number ;
21+ }
22+
1823type PagerAdapter = new ( owner : WeakRef < TabNavigation > ) => androidx . viewpager . widget . PagerAdapter ;
1924
2025// eslint-disable-next-line no-redeclare
@@ -813,12 +818,13 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
813818 // ICON
814819 const iconSource = tabStripItem . image && tabStripItem . image . src ;
815820 if ( iconSource ) {
816- const icon = this . getIcon ( tabStripItem , itemColor ) ;
821+ const iconInfo = this . getIconInfo ( tabStripItem , itemColor ) ;
817822
818- if ( icon ) {
823+ if ( iconInfo ) {
819824 // TODO: Make this native call that accepts string so that we don't load Bitmap in JS.
820825 // tslint:disable-next-line:deprecation
821- tabItemSpec . iconDrawable = icon ;
826+ tabItemSpec . iconDrawable = iconInfo . drawable ;
827+ tabItemSpec . imageHeight = iconInfo . height ;
822828 } else {
823829 // TODO:
824830 // traceMissingIcon(iconSource);
@@ -829,7 +835,7 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
829835 return tabItemSpec ;
830836 }
831837
832- private getIcon ( tabStripItem : TabStripItem , color ?: Color ) : android . graphics . drawable . BitmapDrawable {
838+ private getOriginalIcon ( tabStripItem : TabStripItem , color ?: Color ) : android . graphics . Bitmap {
833839 const iconSource = tabStripItem . image && tabStripItem . image . src ;
834840 if ( ! iconSource ) {
835841 return null ;
@@ -848,28 +854,40 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
848854 is = ImageSource . fromFileOrResourceSync ( iconSource ) ;
849855 }
850856
851- let imageDrawable : android . graphics . drawable . BitmapDrawable ;
852- if ( is && is . android ) {
853- let image = is . android ;
857+ return is && is . android ;
858+ }
854859
860+ private getDrawableInfo ( image : android . graphics . Bitmap ) : IconInfo {
861+ if ( image ) {
855862 if ( this . tabStrip && this . tabStrip . isIconSizeFixed ) {
856863 image = this . getFixedSizeIcon ( image ) ;
857864 }
858865
859- imageDrawable = new android . graphics . drawable . BitmapDrawable ( appResources , image ) ;
860- } else {
861- // TODO
862- // traceMissingIcon(iconSource);
866+ const imageDrawable = new android . graphics . drawable . BitmapDrawable ( appResources , image ) ;
867+
868+ return {
869+ drawable : imageDrawable ,
870+ height : image . getHeight ( )
871+ } ;
863872 }
864873
865- return imageDrawable ;
874+ return new IconInfo ( ) ;
875+ }
876+
877+ private getIconInfo ( tabStripItem : TabStripItem , color ?: Color ) : IconInfo {
878+ const originalIcon = this . getOriginalIcon ( tabStripItem , color ) ;
879+
880+ return this . getDrawableInfo ( originalIcon ) ;
866881 }
867882
868883 private getFixedSizeIcon ( image : android . graphics . Bitmap ) : android . graphics . Bitmap {
869884 const inWidth = image . getWidth ( ) ;
870885 const inHeight = image . getHeight ( ) ;
871886
872- const iconSpecSize = getIconSpecSize ( { width : inWidth , height : inHeight } ) ;
887+ const iconSpecSize = getIconSpecSize ( {
888+ width : inWidth ,
889+ height : inHeight
890+ } ) ;
873891
874892 const widthPixels = iconSpecSize . width * Utils . layout . getDisplayDensity ( ) ;
875893 const heightPixels = iconSpecSize . height * Utils . layout . getDisplayDensity ( ) ;
@@ -993,9 +1011,9 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
9931011 }
9941012 const tabBarItem = this . getTabBarItemView ( tabStripItem . _index ) ;
9951013
996- const drawable = this . getIcon ( tabStripItem , color ) ;
1014+ const drawableInfo = this . getIconInfo ( tabStripItem , color ) ;
9971015 const imgView = tabBarItem . getChildAt ( 0 ) as android . widget . ImageView ;
998- imgView . setImageDrawable ( drawable ) ;
1016+ imgView . setImageDrawable ( drawableInfo . drawable ) ;
9991017 if ( color ) {
10001018 imgView . setColorFilter ( color . android ) ;
10011019 }
0 commit comments