@@ -72,12 +72,19 @@ class UITabBarControllerImpl extends UITabBarController {
72
72
public viewWillTransitionToSizeWithTransitionCoordinator ( size : CGSize , coordinator : UIViewControllerTransitionCoordinator ) : void {
73
73
super . viewWillTransitionToSizeWithTransitionCoordinator ( size , coordinator ) ;
74
74
UIViewControllerTransitionCoordinator . prototype . animateAlongsideTransitionCompletion
75
- . call ( coordinator , null , ( ) => {
75
+ . call ( coordinator , ( ) => {
76
76
const owner = this . _owner . get ( ) ;
77
- if ( owner && owner . items ) {
78
- // owner.items.forEach(tabItem => tabItem._updateTitleAndIconPositions()); TODO:
77
+ if ( owner && owner . tabStrip && owner . tabStrip . items ) {
78
+ const tabStrip = owner . tabStrip ;
79
+ tabStrip . items . forEach ( tabStripItem => {
80
+ updateBackgroundPositions ( tabStrip , tabStripItem ) ;
81
+
82
+ const index = tabStripItem . _index ;
83
+ const tabBarItemController = this . viewControllers [ index ] ;
84
+ updateTitleAndIconPositions ( tabStripItem , tabBarItemController . tabBarItem , tabBarItemController ) ;
85
+ } ) ;
79
86
}
80
- } ) ;
87
+ } , null ) ;
81
88
}
82
89
83
90
// Mind implementation for other controllers
@@ -213,6 +220,26 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
213
220
}
214
221
}
215
222
223
+ function updateBackgroundPositions ( tabStrip : TabStrip , tabStripItem : TabStripItem ) {
224
+ let bgView = ( < any > tabStripItem ) . bgView ;
225
+ if ( ! bgView ) {
226
+ const index = tabStripItem . _index ;
227
+ const width = tabStrip . nativeView . frame . size . width / tabStrip . items . length ;
228
+ const frame = CGRectMake ( width * index , 0 , width , tabStrip . nativeView . frame . size . width ) ;
229
+ bgView = UIView . alloc ( ) . initWithFrame ( frame ) ;
230
+ tabStrip . nativeView . insertSubviewAtIndex ( bgView , 0 ) ;
231
+ ( < any > tabStripItem ) . bgView = bgView ;
232
+ } else {
233
+ const index = tabStripItem . _index ;
234
+ const width = tabStrip . nativeView . frame . size . width / tabStrip . items . length ;
235
+ const frame = CGRectMake ( width * index , 0 , width , tabStrip . nativeView . frame . size . width ) ;
236
+ bgView . frame = frame ;
237
+ }
238
+
239
+ const backgroundColor = tabStripItem . style . backgroundColor ;
240
+ bgView . backgroundColor = backgroundColor instanceof Color ? backgroundColor . ios : backgroundColor ;
241
+ }
242
+
216
243
function updateTitleAndIconPositions ( tabStripItem : TabStripItem , tabBarItem : UITabBarItem , controller : UIViewController ) {
217
244
if ( ! tabStripItem || ! tabBarItem ) {
218
245
return ;
@@ -345,21 +372,11 @@ export class BottomNavigation extends TabNavigationBase {
345
372
}
346
373
347
374
public setTabBarItemBackgroundColor ( tabStripItem : TabStripItem , value : UIColor | Color ) : void {
348
- if ( ! this . tabStrip ) {
375
+ if ( ! this . tabStrip || ! tabStripItem ) {
349
376
return ;
350
377
}
351
378
352
- let bgView = ( < any > tabStripItem ) . bgView ;
353
- if ( ! bgView ) {
354
- const index = ( < any > tabStripItem ) . index ;
355
- const width = this . tabStrip . nativeView . frame . size . width / this . tabStrip . items . length ;
356
- const frame = CGRectMake ( width * index , 0 , width , this . tabStrip . nativeView . frame . size . width ) ;
357
- bgView = UIView . alloc ( ) . initWithFrame ( frame ) ;
358
- this . tabStrip . nativeView . insertSubviewAtIndex ( bgView , 0 ) ;
359
- ( < any > tabStripItem ) . bgView = bgView ;
360
- }
361
-
362
- bgView . backgroundColor = value instanceof Color ? value . ios : value ;
379
+ updateBackgroundPositions ( this . tabStrip , tabStripItem ) ;
363
380
}
364
381
365
382
public setTabBarItemColor ( tabStripItem : TabStripItem , value : UIColor | Color ) : void {
@@ -509,7 +526,7 @@ export class BottomNavigation extends TabNavigationBase {
509
526
applyStatesToItem ( tabBarItem , states ) ;
510
527
511
528
controller . tabBarItem = tabBarItem ;
512
- ( < any > tabStripItem ) . index = i ;
529
+ tabStripItem . _index = i ;
513
530
tabStripItem . setNativeView ( tabBarItem ) ;
514
531
}
515
532
0 commit comments