1- import React , { useEffect , useState } from 'react' ;
2- import { View , Text , StyleSheet } from 'react-native' ;
1+ import React , { useEffect } from 'react' ;
2+ import { StyleSheet } from 'react-native' ;
33import { Navigation , NavigationFunctionComponent } from 'react-native-navigation' ;
44import { WebView } from 'react-native-webview' ;
55import testIDs from '../testIDs' ;
6+ import Screens from './Screens' ;
67
78const loadOrder : number [ ] = [ ] ;
89const listeners : Set < ( ) => void > = new Set ( ) ;
@@ -16,9 +17,7 @@ interface Props {
1617 url : string ;
1718}
1819
19- const WebViewTab : NavigationFunctionComponent < Props > = ( { componentId, tabIndex, title, url } ) => {
20- const [ isLoaded , setIsLoaded ] = useState ( false ) ;
21- const [ progress , setProgress ] = useState ( 0 ) ;
20+ const WebViewTab : NavigationFunctionComponent < Props > = ( { componentId, tabIndex, url } ) => {
2221
2322 useEffect ( ( ) => {
2423 const update = ( ) => {
@@ -50,25 +49,15 @@ const WebViewTab: NavigationFunctionComponent<Props> = ({ componentId, tabIndex,
5049 const onLoadEnd = ( ) => {
5150 loadOrder . push ( tabIndex ) ;
5251 notifyListeners ( ) ;
53- setIsLoaded ( true ) ;
5452 } ;
5553
5654 return (
57- < View style = { styles . container } >
58- < View style = { styles . header } >
59- < Text style = { styles . headerText } > Tab { tabIndex } : { title } </ Text >
60- < View style = { [ styles . status , isLoaded ? styles . loaded : styles . loading ] } >
61- < Text style = { styles . statusText } > { isLoaded ? '✓' : `${ progress } %` } </ Text >
62- </ View >
63- </ View >
64- < WebView
65- source = { { uri : url } }
66- style = { styles . webview }
67- onLoadEnd = { onLoadEnd }
68- onLoadProgress = { ( e ) => setProgress ( Math . round ( e . nativeEvent . progress * 100 ) ) }
69- startInLoadingState
70- />
71- </ View >
55+ < WebView
56+ source = { { uri : url } }
57+ style = { styles . webview }
58+ onLoadEnd = { onLoadEnd }
59+ startInLoadingState
60+ />
7261 ) ;
7362} ;
7463
@@ -94,6 +83,18 @@ const goBackToPlayground = () => {
9483 } ,
9584 } ,
9685 } ) ;
86+ // Show the BottomTabs modal after restoring root
87+ Navigation . showModal ( {
88+ bottomTabs : {
89+ children : [
90+ { stack : { children : [ { component : { name : Screens . FirstBottomTabsScreen } } ] } } ,
91+ { stack : { id : 'SecondTab' , children : [ { component : { name : Screens . SecondBottomTabsScreen } } ] } } ,
92+ ] ,
93+ options : {
94+ bottomTabs : { testID : testIDs . BOTTOM_TABS } ,
95+ } ,
96+ } ,
97+ } ) ;
9798} ;
9899
99100const TABS = [
@@ -125,13 +126,6 @@ export const launchTabsTogetherTest = () => launchTest('together');
125126export const launchTabsOnSwitchTest = ( ) => launchTest ( 'onSwitchToTab' ) ;
126127
127128const styles = StyleSheet . create ( {
128- container : { flex : 1 , backgroundColor : '#f5f6fa' } ,
129- header : { flexDirection : 'row' , justifyContent : 'space-between' , alignItems : 'center' , padding : 12 , backgroundColor : '#2c3e50' } ,
130- headerText : { color : '#fff' , fontSize : 16 , fontWeight : '700' } ,
131- status : { paddingHorizontal : 12 , paddingVertical : 6 , borderRadius : 16 , minWidth : 50 , alignItems : 'center' } ,
132- loading : { backgroundColor : '#e67e22' } ,
133- loaded : { backgroundColor : '#27ae60' } ,
134- statusText : { color : '#fff' , fontSize : 12 , fontWeight : '600' } ,
135129 webview : { flex : 1 } ,
136130} ) ;
137131
0 commit comments