1
- import React from 'react' ;
1
+ import React , { Component } from 'react' ;
2
2
import { NavigationProps , Options } from 'react-native-navigation' ;
3
3
import Root from '../components/Root' ;
4
4
import Button from '../components/Button' ;
5
5
import Navigation from './../services/Navigation' ;
6
6
import Screens from './Screens' ;
7
7
import { component } from '../commons/Layouts' ;
8
8
import testIDs from '../testIDs' ;
9
+ import { Text } from 'react-native' ;
10
+
11
+ export class MountedBottomTabScreensState {
12
+ static mountedBottomTabScreens : string [ ] = [ ] ;
13
+ static callback : ( mountedBottomTabScreens : string [ ] ) => void = ( ) => { } ;
14
+
15
+ static addScreen ( screen : string ) {
16
+ this . mountedBottomTabScreens . push ( screen ) ;
17
+ this . callback ( this . mountedBottomTabScreens ) ;
18
+ }
19
+ }
9
20
10
21
const {
11
22
SWITCH_TAB_BY_INDEX_BTN ,
@@ -16,9 +27,14 @@ const {
16
27
SHOW_TABS_BTN ,
17
28
HIDE_TABS_PUSH_BTN ,
18
29
FIRST_TAB_BAR_BUTTON ,
30
+ MOUNTED_SCREENS_TEXT ,
19
31
} = testIDs ;
20
32
21
- export default class FirstBottomTabScreen extends React . Component < NavigationProps > {
33
+ interface NavigationState {
34
+ mountedBottomTabScreens : string [ ] ;
35
+ }
36
+
37
+ export default class FirstBottomTabScreen extends Component < NavigationProps , NavigationState > {
22
38
static options ( ) : Options {
23
39
return {
24
40
layout : {
@@ -38,6 +54,19 @@ export default class FirstBottomTabScreen extends React.Component<NavigationProp
38
54
} ;
39
55
}
40
56
57
+ constructor ( props : NavigationProps ) {
58
+ super ( props ) ;
59
+ this . state = { mountedBottomTabScreens : [ ] } ;
60
+
61
+ MountedBottomTabScreensState . callback = ( mountedBottomTabScreens : string [ ] ) => {
62
+ this . setState ( { mountedBottomTabScreens : mountedBottomTabScreens } ) ;
63
+ } ;
64
+ }
65
+
66
+ componentDidMount ( ) {
67
+ MountedBottomTabScreensState . addScreen ( 'FirstBottomTabScreen' ) ;
68
+ }
69
+
41
70
badgeVisible = true ;
42
71
bottomTabPressedListener = Navigation . events ( ) . registerBottomTabPressedListener ( ( event ) => {
43
72
if ( event . tabIndex == 2 ) {
@@ -71,6 +100,10 @@ export default class FirstBottomTabScreen extends React.Component<NavigationProp
71
100
/>
72
101
< Button label = "Push" onPress = { this . push } />
73
102
< Button label = "Add border and shadow" onPress = { this . modifyBottomTabs } />
103
+
104
+ < Text testID = { MOUNTED_SCREENS_TEXT } >
105
+ Mounted screens: { this . state . mountedBottomTabScreens . join ( ', ' ) }
106
+ </ Text >
74
107
</ Root >
75
108
) ;
76
109
}
0 commit comments