Designing a unique modal, unexpectedly encountering a white border surrounding the custom modal


I am trying to create a welcome modal that I can import into my MainScreen.js file and integrate it there. However, no matter how I style the modal, a white surface always appears around it despite my attempts to make it look like a "popup window". Below is the relevant code snippet where I am facing this issue.

MainScreen.js

//Code for setting up the MainScreen

return(
    <View style={styles.screen}>
        <View style={styles.tophalf}>
            <CustomItemPicker/>
        </View>
        <View style={styles.bottomhalf}>
            <View style={styles.topbuttons}>
                <CustomButton 
                    style={styles.button} 
                    onPress={addTheItem}
                    children="Add a Item"
                />
                <CustomButton
                    style={styles.button}
                    onPress={() => props.navigation.push('Profile')}
                    children = "My Profile"
                />
            </View>
            <View style={styles.bottombuttons}>
                <CustomButton
                    style={styles.button}
                    children = "My Messages"
                />
                <CustomButton
                    style={styles.button}
                    children = "options"
                />
            </View>
        </View>
        <WelcomeModal
        modalVisible={modalVisible}
        />
    </View>
)
};

//Visual Definition of all components

const styles = StyleSheet.create({
screen:{
    flexDirection: "column",
    flex: 1
},
button:{
    fontFamily: "AmaticBold",
    //Shadow Properties
    shadowColor: "#000",
    shadowOffset: {
        width: 0,
        height: 5,
    },
    shadowOpacity: 0.34,
    shadowRadius: 6,
    elevation: 3.5,
    width: 125,
    textAlign: 'center'
},
tophalf:{
    flex: 1,
    alignItems: "center",
    justifyContent:"center"
},
bottomhalf:{
    flex:1,
    alignItems: "center",
    flexDirection: 'column',
    justifyContent: 'space-between'
},
topbuttons:{
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'space-around'
},
bottombuttons:{
    flex: 1,
    flexDirection: 'row',
    justifyContent: 'space-around'
}

});

export default MainScreen;

WelcomeModal:

const WelcomeModal = props =>{
return(
    <Modal
    animationType="slide"
    transparent={false}
    visible={props.modalVisible}
    >
        <View style={styles.ModalWindow}>
            <View style={styles.modalItemsWrapper}>
                <Text style={{fontFamily:"AmaticBold", fontSize: 10}}>
                bla bla bla bla bla 
                </Text>
            </View>
            <View style={styles.modalItemsWrapper2}>
                <Text>Pick a Nickname: </Text>
                <TextInput/>
            </View>
            <View>
                <Text></Text>
                <Checkbox/>
                <Checkbox/>
                <Checkbox/>
            </View>
        </View>
    </Modal>
)
};

const styles = StyleSheet.create({
ModalWindow:{
    backgroundColor: "red"
    margin: 50,
    flexDirection: 'column',
    alignItems: 'center',
    borderColor: "black",
    borderRadius: 10,
    borderWidth: 2
    //justifyContent: "center",
},
modalItemsWrapper:{
    //Empty for now
}
});

export default WelcomeModal;

Here is an image showing the result (MainScreen with implemented WelcomeModal) https://i.sstatic.net/Yggda.jpg

Although the WelcomeModal looks visually appealing and has a proper border, the issue arises when the modal appears as full screen and the MainScreen is hidden behind the white surface surrounding the red custom Modal. I am seeking help to resolve this problem. Any assistance would be greatly appreciated.

Answer №1

After seeking assistance from a react-native discord community, I was able to find a solution that resolved my issue:

const WelcomeModal = props =>{
    return(
        <Modal
        animationType="slide"
        transparent={true}
        visible={props.modalVisible}
        >
            <View style={{flex:1, backgroundColor: "transparent"}}>
                <View style={styles.ModalWrapper}>
                    <View style={styles.modalItemsWrapper}>
                        <Text style={{fontFamily:"AmaticBold", fontSize: 10}}>
                        bla bla bla bla bla 
                        </Text>
                    </View>
                    <View style={styles.modalItemsWrapper2}>
                        <Text>Pick a Nickname: </Text>
                        <TextInput/>
                    </View>
                    <View>
                        <Text></Text>
                        <Checkbox/>
                        <Checkbox/>
                        <Checkbox/>
                    </View> 
                </View>
            </View>
        </Modal>
    )
};

const styles = StyleSheet.create({
    ModalWrapper:{
        margin: 50,
        flexDirection: 'column',
        alignItems: 'center',
        borderColor: "black",
        borderRadius: 10,
        borderWidth: 2,
        backgroundColor: "red"
    },
    modalItemsWrapper:{

    }
});

export default WelcomeModal;

The key to solving my problem was utilizing transparent={true} in the modal properties and adjusting the backgroundColor of the enclosing view within the modal to "transparent", resulting in only the desired red modal being displayed.

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

Obtaining data with jQuery.Ajax technology

I am attempting to retrieve real-time data from a different URL and display it in a text field every second without refreshing the entire page. The content of the URL is constantly changing, so I want the field to update accordingly. However, despite my ef ...

Having trouble with the dropdown menu in Bootstrap?

I'm having trouble creating a responsive dropdown menu. When I click on the dropdown items, nothing happens. Here's the code: <div class="navbar-header"> <button type="button" class="navbar-toggel" data-toggel="collapse" data-target="#m ...

Trigger an AJAX request to execute a PHP script when a button is clicked

When I click a button, I want to run an ajax function that calls a PHP script and displays the resulting data under a specific div. However, it is not currently working as expected. Upon checking the console, I noticed that no value is being passed to the ...

What is preventing my video from filling the entire screen?

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=d ...

Risks associated with working with position:relative and left/top in web development

When using position: relative; with multiple elements, are there any potential issues to be aware of? Unlike position: absolute;, which may not display correctly on different monitors. For example: <img src="blah.png"/ class="someClass"> <im ...

Tips for effectively handling unique properties of a React component (such as Redux integration and custom CSS) when sharing through NPM distribution

Question: How can custom Redux containers and CSS be effectively managed with NPM? It can be challenging to handle these custom files through traditional package distribution platforms like NPM, especially when they need to be edited in various projects. ...

The element is implicitly assigned an 'any' type due to the fact that an expression of type 'any' cannot be used to index types in nodejs and solidity

I am in need of setting networks in my contract using NodeJS and TypeScript. Below is the code I have written: let networkId: any = await global.web3.eth.net.getId(); let tetherData = await Tether.networks[networkId]; Unfortunately, I encountered ...

I'm seeking assistance in troubleshooting the issue I'm encountering with the npm installation of Tachyons. Can anyone provide their expertise

Every time I attempt to install npm tachyons, I encounter this error. Can someone offer assistance with resolving it? When trying to install npm tachyons, I consistently run into this error. Any guidance on how to fix it would be greatly appreciated. ...

Add a prefix to a value entered by the user

I need help with adding a prefix to an input field value using Jquery. I want the input field value to be submitted as "Referrer Email: {email address}" where the {email address} part will be dynamic. The snippet below is what I found, but I'm having ...

disable scripting on small screens

In my wordpress header, I have a script that animates the #s-nav when the user scrolls up and not down (excluding the first time). However, I want to prevent this animation from happening on mobile devices (I need to adjust the css for screens < 768px) ...

Toggling display of divs with jQuery using plus and minus icons

Is it possible to use two different icons as a sprite image for when the show and hide functions are active on a div element? For instance, having a + icon displayed when showing the div, and then switching to a - icon when hiding it. The current code I ...

When using React and React Router v6, make sure to implement a 404 status code response for unmatched routes

When it comes to managing unmatched routes with React Router, I have a solid understanding: <Routes> {/* Public routes */} <Route exact path="/" element={<Home />} /> // Other routes... {/* Error routes */} ...

The Reactjs dependency tree could not be resolved

In my current project, I've been attempting to integrate react-tinder-card. After running the command: npm install --save react-tinder-card I encountered this error in my console: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency ...

Transform Promise-based code to use async/await

I'm attempting to rephrase this code using the async \ await syntax: public loadData(id: string): void { this.loadDataAsync() .then((data: any): void => { // Perform actions with data }) .catch((ex): v ...

The chosen value remains constant even after altering the selected option

I am trying to create a scroll-down bar that allows users to select different options, and once an option is selected, its value should appear in the bar. However, I'm facing an issue where the value does not change according to the selection: const [ ...

Effortlessly sending information to the Material UI 'Table' element within a ReactJS application

I have integrated a materialUI built-in component to display data on my website. While the code closely resembles examples from the MaterialUI API site, I have customized it for my specific use case with five labeled columns. You can view my code below: h ...

Retrieving the output of a method from an object in JavaScript

I need help with a JavaScript issue. I have an object that I want to iterate through in order to display all the values of its properties. However, when I try to print out the value returned by one of its methods, I am only getting the code of the method i ...

Swap out AJAX following a successful retrieval and when managing errors

I currently have a basic AJAX load function set up to load a specific URL: <div id="load"> <h1 id="status">Loading...</h1> </div> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup({cache: false}); var ...

jQuery sends ajax success to input type number

I am encountering an issue with the ajax success loading function when using input type number. Interestingly, when I switch the input type to text, it works perfectly fine. However, once I change the input type back to number, the loading ceases. <s ...

The text within a textarea that is set to 100% width extends outside of its

I'm encountering an issue with a textarea (and potentially any input element) appearing too wide when the width is set to 100%. Below is my CSS code. Firstly, I am resetting all styles. html, body, div, span, applet, object, iframe, h1, h2, h3, h4, ...