From dab2ee3f0dc18e101a90babecab4ed53b7ac317f Mon Sep 17 00:00:00 2001 From: Nir Yosef Date: Wed, 20 Sep 2023 10:05:11 +0300 Subject: [PATCH 1/6] Make bottom tabs more visually correct (#7788) I have made some changes it order to make the bottom tabs more correct when rendering visually (by using react-native-web). before: ![image](https://github.com/wix/react-native-navigation/assets/8758348/6d8c9717-e8bc-4ddd-b711-c1d5bb704559) after: ![image](https://github.com/wix/react-native-navigation/assets/8758348/8a75748b-437d-42e1-ac3f-987a66b45ed1) --- lib/Mock/Components/ComponentScreen.tsx | 34 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/Mock/Components/ComponentScreen.tsx b/lib/Mock/Components/ComponentScreen.tsx index 21b0a80168d..40ba36a74cb 100644 --- a/lib/Mock/Components/ComponentScreen.tsx +++ b/lib/Mock/Components/ComponentScreen.tsx @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import { Button, View, Text } from 'react-native'; -import { Navigation } from 'react-native-navigation'; +import { View, Text, TouchableOpacity, Image, ImageURISource} from 'react-native'; +import { Navigation, ImageResource} from 'react-native-navigation'; import { ComponentProps } from '../ComponentProps'; import { VISIBLE_SCREEN_TEST_ID } from '../constants'; import { LayoutStore } from '../Stores/LayoutStore'; @@ -10,6 +10,11 @@ import { events } from '../Stores/EventsStore'; import _ from 'lodash'; import { switchTabByIndex } from '../actions/layoutActions'; + +function isURISource(src: ImageResource| undefined): src is ImageURISource { + return !!src && typeof src === 'object' && 'uri' in src; +} + export const ComponentScreen = connect( class extends Component { constructor(props: ComponentProps) { @@ -27,16 +32,17 @@ export const ComponentScreen = connect( renderTabBar() { const bottomTabs = this.props.layoutNode.getBottomTabs(); if (!bottomTabs) return null; - const bottomTabsOptions = bottomTabs.resolveOptions().bottomTabs; if (bottomTabsOptions?.visible === false) return null; const buttons = bottomTabs!.children!.map((child, i) => { const bottomTabOptions = child.resolveOptions().bottomTab; + const icon = (bottomTabs as any).selectedIndex === i ? bottomTabOptions?.selectedIcon : bottomTabOptions?.icon; + const iconURI = isURISource(icon) ? icon.uri : undefined; return ( -