@@ -3,7 +3,7 @@ import { TabContentItem } from '../tab-content-item';
3
3
import { getIconSpecSize , itemsProperty , selectedIndexProperty , tabStripProperty } from '../tab-navigation-base' ;
4
4
import { TabStrip } from '../tab-strip' ;
5
5
import { TabStripItem } from '../tab-strip-item' ;
6
- import { TabNavigationBase , animationEnabledProperty , offscreenTabLimitProperty , swipeEnabledProperty } from './index-common' ;
6
+ import { TabNavigationBase , TabsPosition , animationEnabledProperty , offscreenTabLimitProperty , swipeEnabledProperty } from './index-common' ;
7
7
export * from './index-common' ;
8
8
export { TabContentItem , TabStrip , TabStripItem } ;
9
9
@@ -27,6 +27,22 @@ function makeFragmentName(viewId: number, id: number): string {
27
27
return 'android:viewpager:' + viewId + ':' + id ;
28
28
}
29
29
30
+ /**
31
+ * Gets the parent fragment manager from a fragment to be used in destroying or hiding it.
32
+ * @param fragment target fragment
33
+ * @returns the parent fragment manager or null if none exists.
34
+ */
35
+ function _getParentFragmentManagerFromFragment ( fragment : androidx . fragment . app . Fragment ) {
36
+ if ( ! fragment ) {
37
+ return null ;
38
+ }
39
+ try {
40
+ return fragment . getParentFragmentManager ( ) ;
41
+ } catch ( e ) {
42
+ return null ;
43
+ }
44
+ }
45
+
30
46
function getTabById ( id : number ) : TabNavigation {
31
47
const ref = tabs . find ( ( ref ) => {
32
48
const tab = ref . get ( ) ;
@@ -89,8 +105,8 @@ function initializeNativeClasses() {
89
105
// TODO: Consider removing it when update to androidx.fragment:1.2.0
90
106
if ( hasRemovingParent && this . owner . selectedIndex === this . index && this . owner . nativeViewProtected ) {
91
107
const bitmapDrawable = new android . graphics . drawable . BitmapDrawable ( appResources , this . backgroundBitmap ) ;
92
- this . owner . mOriginalBackground = this . owner . backgroundColor || new Color ( 'White' ) ;
93
- this . owner . nativeViewProtected . setBackgroundDrawable ( bitmapDrawable ) ;
108
+ this . owner . _originalBackground = this . owner . backgroundColor || new Color ( 'White' ) ;
109
+ this . owner . nativeViewProtected . setBackground ( bitmapDrawable ) ;
94
110
this . backgroundBitmap = null ;
95
111
}
96
112
@@ -209,7 +225,7 @@ function initializeNativeClasses() {
209
225
}
210
226
const fragment : androidx . fragment . app . Fragment = object as androidx . fragment . app . Fragment ;
211
227
if ( ! this . mCurTransaction ) {
212
- const fragmentManager = fragment . getParentFragmentManager ( ) ;
228
+ const fragmentManager = _getParentFragmentManagerFromFragment ( fragment ) ;
213
229
this . mCurTransaction = fragmentManager ?. beginTransaction ( ) ;
214
230
}
215
231
@@ -389,7 +405,8 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
389
405
protected mViewPager : com . nativescript . material . core . TabViewPager ;
390
406
protected mPagerAdapter : androidx . viewpager . widget . PagerAdapter ;
391
407
protected mAndroidViewId = - 1 ;
392
- public mOriginalBackground : any ;
408
+ // value from N core!!!
409
+ public _originalBackground : any ;
393
410
protected mTextTransform : CoreTypes . TextTransformType = 'uppercase' ;
394
411
protected mSelectedItemColor : Color ;
395
412
protected mUnSelectedItemColor : Color ;
@@ -483,7 +500,8 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
483
500
const context = this . _context ;
484
501
const tabsBar = ( this . mTabsBar = this . createNativeTabBar ( context ) ) ;
485
502
setElevation ( null , tabsBar , this . tabsPosition ) ;
486
- if ( this . tabsPosition !== 'top' ) {
503
+ console . log ( 'handleTabStripChanged' , this . tabsPosition ) ;
504
+ if ( this . tabsPosition !== TabsPosition . Top ) {
487
505
tabsBar . setLayoutParams ( this . tabBarLayoutParams ) ;
488
506
}
489
507
nativeView . addView ( tabsBar ) ;
@@ -587,10 +605,10 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
587
605
public onLoaded ( ) : void {
588
606
super . onLoaded ( ) ;
589
607
590
- if ( this . mOriginalBackground ) {
608
+ if ( this . _originalBackground ) {
591
609
this . backgroundColor = null ;
592
- this . backgroundColor = this . mOriginalBackground ;
593
- this . mOriginalBackground = null ;
610
+ this . backgroundColor = this . _originalBackground ;
611
+ this . _originalBackground = null ;
594
612
}
595
613
596
614
this . setItems ( this . items as any ) ;
@@ -660,7 +678,7 @@ export abstract class TabNavigation<T extends android.view.ViewGroup = any> exte
660
678
fragmentExitTransition . setResetOnTransitionEnd ( true ) ;
661
679
}
662
680
if ( fragment && fragment . isAdded ( ) && ! fragment . isRemoving ( ) ) {
663
- const pfm = fragment . getParentFragmentManager ( ) ;
681
+ const pfm = _getParentFragmentManagerFromFragment ( fragment ) ;
664
682
if ( pfm && ! pfm . isDestroyed ( ) ) {
665
683
try {
666
684
if ( pfm . isStateSaved ( ) ) {
0 commit comments