Is there a way to ensure my React navigation screen fills the entire screen?

I am currently facing an issue where my map screen is not covering the whole screen, leaving a blank space at the bottom where the custom bottom navigator should be displayed. How can I adjust my code so that the map covers this blank space at the bottom?

Here is my code:

import React from 'react';
import { StyleSheet, Text, TouchableOpacity, View, Image } from 'react-native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { NavigationContainer } from '@react-navigation/native';
import MapView from 'react-native-maps';
import { Marker } from 'react-native-maps';
import FontAwesome from "@expo/vector-icons/FontAwesome"

const Tab = createBottomTabNavigator();

function HomeScreen() {
  return (
    <View style={styles.mapContainer}>
      <MapView style={styles.map} />
    </View>
  );
}

function SettingsScreen() {
  return (
    <View style={styles.container}>
      <Text>Settings Sn</Text>
    </View>
  );
}

const CustomTabBarButton = ({ children, onPress }) => {
  return (
  <TouchableOpacity
    style={{
      top: -30,
      justifyContent: 'center',
      alignItems: 'center',
      ...styles.shadow
    }}
    onPress={onPress}
  >
    <View style={{
      width: 50,
      height: 50,
      borderRadius: 50,
      backgroundColor: "#355E3B"
    }}>
      {children}
    </View>
  </TouchableOpacity>)
};

export default function Navigation() {
  return (
    <NavigationContainer>
      <Tab.Navigator
            screenOptions={({ route }) => ({
                tabBarIcon: ({ color, focused, size }) => {
                    let icon;
                    if (route.name === "Map") {
                        icon = "map"
                        return <FontAwesome name={icon} size={28} color={color} />
                    } else if (route.name === "Settings") {
                        icon = "cog"
                        return <FontAwesome name={icon} size={28} color={color} />
                    }
                    return null
                },
                tabBarShowLabel: false,
                tabBarIconStyle: {},
                tabBarStyle: [{ 
                  display: "flex",
                  bottom: 20,
                  elevation: 5,
                  borderRadius: 10,
                  marginLeft: 10,
                  marginRight: 10,
                  height: 60
                 }, null],
                tabBarActiveTintColor: "#000000"
            })}
        >
        <Tab.Screen name="Map" component={HomeScreen}  />
        <Tab.Screen
  name="Plus"
  component={HomeScreen}
  options={{
    tabBarIcon: ({ focused }) => (
      <Image source={require('./assets/plus.png')} resizeMode='contain' style={{
        width: 30,
        height: 30
      }} />
    ),
    tabBarButton: (props) => {
      return <CustomTabBarButton {...props} />
    }
  }}
/>
        <Tab.Screen name="Settings" component={SettingsScreen} />
      </Tab.Navigator>
    </NavigationContainer>
  );
}

const styles = StyleSheet.create({
  shadow: {
    shadowColor: '#000000',
    shadowOffset: {
      width: 0,
      height: 10
    },
    shadowOpacity: 0.2,
    shadowRadius: 3.5,
    elevation: 5
  },
  container: {
    flex: 1
  },
  map: {
    width: '100%',
    height: '110%', /* Adjusted to show full screen */
  },
  mapContainer: {
    height: '100%' /* Height adjusted to cover empty space */
  }
});

Picture of problem:

https://i.sstatic.net/gz9lY.jpg

Answer №1

To achieve the desired tab bar style, utilize the absolute positioning method. By doing so, the tab bar will be placed above all other content.

tabBarStyle: {
  position: 'absolute',
  display: 'flex',
  bottom: 20,
  elevation: 5,
  borderRadius: 10,
  marginLeft: 10,
  marginRight: 10,
  height: 60,
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Refusing to include two values due to the presence of a comma in JavaScript

I'm trying to add two values with commas and .00 (Example: 1,200.23 + 2,500.44) but it's not working because the textbox includes commas as required by my system. The result shows NaN because the comma is considered a special character. It was w ...

Every time I try to launch NPM start, an error pops up on my screen

Whenever I try to execute the command: npm start An error message pops up saying: npm ERR! missing script: start This is what my package.json file looks like: { "name": "react-app", "version": "0.1.0", "private": true, "dependencies": { " ...

Steer clear of using multiple returns in a loop in JavaScript by utilizing async/await to eliminate the callback pyramid or callback hell

My code consists of multiple return blocks, such as the SignUp() function. connectors.js const connectors = { Auth: { signUp(args) { return new Promise((resolve, reject) => { // Validate the data if (! ...

What is the process for developing an interface adapter using TypeScript?

I need to update the client JSON with my own JSON data Client JSON: interface Cols { displayName: string; } { cols:[ { displayName: 'abc'; } ] } My JSON: interface Cols { label: string; } { cols:[ { label:&a ...

I'm having trouble with installing nx as it keeps showing the error message 'Platform Dependency for NX is Missing.'

I encountered an issue when running npm install: $ npm i npm WARN deprecated @babel/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b5b475e4c4245065b59445b44584a470648474a5858065b59445b4e595f424e586b1c051a13051d">[email  ...

AADSTS9002326: Token redemption across different origins is only allowed for the 'Single Page Application (SPA)'

I've encountered an issue while making a token request to an API service hosted on the Azure platform. Despite solving the cross-origin problem with proxy pass settings via Plesk, I'm still facing an error that seems unsolvable. {"error&qu ...

Customizing CSS to override Semantic React UI styles

Is there a way to customize the default Header provided by react semantic UI? Currently, I have placed my Header within a div so that I can apply custom styles. <div className="portfolioTitle"> <Header as="h1">Check out this amazing ...

Material-UI's style is taking precedence over other styles that have been defined

Introduction Last week, I posted a similar query which touched on the same issue. However, as the solution seems to be different this time around, I am revisiting it in a new thread. Check out the updated version of the CodeSanbox Example that reflects t ...

Adjusting a NodeJS module for easier integration into codebases

I have organized some functions in a file within a node module structure... Here are the files and folder structure I created: - package.json - README.md - LICENSE.md - code |_______ code.js Currently, to use these functions, I include them like th ...

React Native backhandler malfunctioning - seeking solution

Version react-native-router-flux v4.0.0-beta.31, react-native v0.55.2 Expected outcome The backhandler should respond according to the conditions specified in the backhandler function provided to the Router props. Current behavior Every time the har ...

Align Text with Icon Using FontAwesome

Hey, I'm having a bit of trouble with something simple and it's driving me crazy. All I want to do is center the text vertically next to a FontAwesome icon. However, no matter what I try, I just can't seem to get it to work. I've looke ...

Encountering a FeathersJS Twitch OAuth 401 Unauthorized error

I'm a newcomer to FeathersJS and I've been trying to set up OAuth login with Twitch. Following the steps outlined in the Feathers documentation for setting up GitHub login OAuth, I created a Twitch OAuth application. However, when attempting to s ...

Access scope information when clicking with ng-click

I am currently using a php api to update my database, but I want the ability to choose which item gets updated with ng-click. app.controller('ReviewProductsController', function ($scope, $http) { $scope.hide_product = function () { ...

Is there a way to enforce mandatory fields on material-table?

During my current project, I am utilizing a material-table interface to perform CRUD operations. I am interested in finding out if there is a way to make certain fields required when necessary. Despite my research efforts yielding minimal results, I have ...

Executing numerous Ajax requests within a single Rails view

Two ajax requests are being used on a single page, one showcasing a date and the other displaying a calendar. The first request updates the date upon clicking a date on the calendar. The second request allows for switching between months on the calendar. ...

Automatically convert user input to MM/DD/YYYY format in typescript as they type the date

Hello, I am currently working on a React Native app where users input their date using TextInput. As the user types, I would like to automatically format the date as MM/DD/YYYY. Here is the function I have created so far: const formatDate(value: string ...

During the process of adding a new template to my Angular project, I came across an issue within the core.min.js and script.js files

index.html <html class="wide wow-animation" lang="en"> <body> <app-root></app-root> <!-- Javascript--> <script src="assets/js/core.min.js"></script> <script src="assets/js/script.js"></script& ...

Working with Vue.js: Binding to dynamically generated form elements

I am facing an issue where form elements are not available in the html document until an inline script runs on page load. In Vue.js, how can I bind to these form elements after the page loads? While with jQuery I could use a $('.element').each(), ...

Trouble with React Material-UI Select component onChange event

I encountered an issue while using Material-UI select where I am unable to access the selected value due to a warning message: index.js:1 Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside S ...

The error message received is: "mongoose TypeError: Schema is not defined as

Encountering a curious issue here. I have multiple mongoose models, and oddly enough, only one of them is throwing this error: TypeError: Schema is not a constructor This situation strikes me as quite odd because all my other schemas are functioning prop ...