@@ -15,6 +15,11 @@ const TABID = '_tabId';
15
15
const INDEX = '_index' ;
16
16
const ownerSymbol = Symbol ( '_owner' ) ;
17
17
18
+ class IconInfo {
19
+ drawable : android . graphics . drawable . BitmapDrawable ;
20
+ height : number ;
21
+ }
22
+
18
23
type PagerAdapter = new ( owner : WeakRef < TabNavigation > ) => androidx . viewpager . widget . PagerAdapter ;
19
24
20
25
// eslint-disable-next-line no-redeclare
@@ -813,12 +818,13 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
813
818
// ICON
814
819
const iconSource = tabStripItem . image && tabStripItem . image . src ;
815
820
if ( iconSource ) {
816
- const icon = this . getIcon ( tabStripItem , itemColor ) ;
821
+ const iconInfo = this . getIconInfo ( tabStripItem , itemColor ) ;
817
822
818
- if ( icon ) {
823
+ if ( iconInfo ) {
819
824
// TODO: Make this native call that accepts string so that we don't load Bitmap in JS.
820
825
// tslint:disable-next-line:deprecation
821
- tabItemSpec . iconDrawable = icon ;
826
+ tabItemSpec . iconDrawable = iconInfo . drawable ;
827
+ tabItemSpec . imageHeight = iconInfo . height ;
822
828
} else {
823
829
// TODO:
824
830
// traceMissingIcon(iconSource);
@@ -829,7 +835,7 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
829
835
return tabItemSpec ;
830
836
}
831
837
832
- private getIcon ( tabStripItem : TabStripItem , color ?: Color ) : android . graphics . drawable . BitmapDrawable {
838
+ private getOriginalIcon ( tabStripItem : TabStripItem , color ?: Color ) : android . graphics . Bitmap {
833
839
const iconSource = tabStripItem . image && tabStripItem . image . src ;
834
840
if ( ! iconSource ) {
835
841
return null ;
@@ -848,28 +854,40 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
848
854
is = ImageSource . fromFileOrResourceSync ( iconSource ) ;
849
855
}
850
856
851
- let imageDrawable : android . graphics . drawable . BitmapDrawable ;
852
- if ( is && is . android ) {
853
- let image = is . android ;
857
+ return is && is . android ;
858
+ }
854
859
860
+ private getDrawableInfo ( image : android . graphics . Bitmap ) : IconInfo {
861
+ if ( image ) {
855
862
if ( this . tabStrip && this . tabStrip . isIconSizeFixed ) {
856
863
image = this . getFixedSizeIcon ( image ) ;
857
864
}
858
865
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
+ } ;
863
872
}
864
873
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 ) ;
866
881
}
867
882
868
883
private getFixedSizeIcon ( image : android . graphics . Bitmap ) : android . graphics . Bitmap {
869
884
const inWidth = image . getWidth ( ) ;
870
885
const inHeight = image . getHeight ( ) ;
871
886
872
- const iconSpecSize = getIconSpecSize ( { width : inWidth , height : inHeight } ) ;
887
+ const iconSpecSize = getIconSpecSize ( {
888
+ width : inWidth ,
889
+ height : inHeight
890
+ } ) ;
873
891
874
892
const widthPixels = iconSpecSize . width * Utils . layout . getDisplayDensity ( ) ;
875
893
const heightPixels = iconSpecSize . height * Utils . layout . getDisplayDensity ( ) ;
@@ -993,9 +1011,9 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
993
1011
}
994
1012
const tabBarItem = this . getTabBarItemView ( tabStripItem . _index ) ;
995
1013
996
- const drawable = this . getIcon ( tabStripItem , color ) ;
1014
+ const drawableInfo = this . getIconInfo ( tabStripItem , color ) ;
997
1015
const imgView = tabBarItem . getChildAt ( 0 ) as android . widget . ImageView ;
998
- imgView . setImageDrawable ( drawable ) ;
1016
+ imgView . setImageDrawable ( drawableInfo . drawable ) ;
999
1017
if ( color ) {
1000
1018
imgView . setColorFilter ( color . android ) ;
1001
1019
}
0 commit comments