11import React , { Component } from 'react' ;
2- import { View , Text , TouchableOpacity , Image , ImageURISource } from 'react-native' ;
3- import { Navigation , ImageResource } from 'react-native-navigation' ;
2+ import { View , Text , TouchableOpacity , Image , ImageURISource } from 'react-native' ;
3+ import { Navigation , ImageResource } from 'react-native-navigation' ;
44import { ComponentProps } from '../ComponentProps' ;
55import { VISIBLE_SCREEN_TEST_ID } from '../constants' ;
66import { LayoutStore } from '../Stores/LayoutStore' ;
@@ -10,8 +10,7 @@ import { events } from '../Stores/EventsStore';
1010import _ from 'lodash' ;
1111import { switchTabByIndex } from '../actions/layoutActions' ;
1212
13-
14- function isURISource ( src : ImageResource | undefined ) : src is ImageURISource {
13+ function isURISource ( src : ImageResource | undefined ) : src is ImageURISource {
1514 return ! ! src && typeof src === 'object' && 'uri' in src ;
1615}
1716
@@ -36,12 +35,15 @@ export const ComponentScreen = connect(
3635 if ( bottomTabsOptions ?. visible === false ) return null ;
3736 const buttons = bottomTabs ! . children ! . map ( ( child , i ) => {
3837 const bottomTabOptions = child . resolveOptions ( ) . bottomTab ;
39- const icon = ( bottomTabs as any ) . selectedIndex === i ? bottomTabOptions ?. selectedIcon : bottomTabOptions ?. icon ;
38+ const icon =
39+ ( bottomTabs as any ) . selectedIndex === i
40+ ? bottomTabOptions ?. selectedIcon
41+ : bottomTabOptions ?. icon ;
4042 const iconURI = isURISource ( icon ) ? icon . uri : undefined ;
4143 return (
4244 < View key = { `tab-${ i } ` } >
4345 < TouchableOpacity
44- style = { { padding :10 } }
46+ style = { { padding : 10 } }
4547 testID = { bottomTabOptions ?. testID }
4648 onPress = { ( ) => {
4749 events . invokeBottomTabPressed ( {
@@ -51,22 +53,34 @@ export const ComponentScreen = connect(
5153 switchTabByIndex ( this . props . layoutNode . getBottomTabs ( ) , i ) ;
5254 } }
5355 >
54- < View style = { { justifyContent : 'center' , alignItems : 'center' } } >
55- < Text > { bottomTabOptions ?. badge } </ Text >
56- { iconURI && < Image style = { { width : 18 , height : 18 , marginBottom : 5 } } source = { { uri : iconURI } } /> }
57- < Text style = { { fontSize : 12 } } > { bottomTabOptions ?. text || '' } </ Text >
58- </ View >
56+ < View style = { { justifyContent : 'center' , alignItems : 'center' } } >
57+ < Text > { bottomTabOptions ?. badge } </ Text >
58+ { iconURI && (
59+ < Image
60+ style = { { width : 18 , height : 18 , marginBottom : 5 } }
61+ source = { { uri : iconURI } }
62+ />
63+ ) }
64+ < Text style = { { fontSize : 12 } } > { bottomTabOptions ?. text || '' } </ Text >
65+ </ View >
5966 </ TouchableOpacity >
6067 </ View >
6168 ) ;
6269 } ) ;
6370
6471 return (
65- < View
66- testID = { bottomTabsOptions ?. testID }
67- style = { { flexDirection : 'row' , justifyContent : 'center' , width : '100%' , backgroundColor : '#F0F2F5' } } >
72+ < View
73+ testID = { bottomTabsOptions ?. testID }
74+ style = { {
75+ flexDirection : 'row' ,
76+ justifyContent : 'center' ,
77+ width : '100%' ,
78+ backgroundColor : '#F0F2F5' ,
79+ } }
80+ >
6881 { buttons }
69- </ View > ) ;
82+ </ View >
83+ ) ;
7084 }
7185
7286 render ( ) {
0 commit comments