Search code examples
cssreact-nativeoverlaynative-basereact-native-elements

Text visible but not 2 buttons in same Overlay bloc


I am adding an overlay (react-native-element 3.2) to React Native 0.62.3 app. The page is arrange with Native Base 2.13.14. I notice before that Native Base page does not get along with react-native-elements or native elements. Here is the code:

import { Container,  Left, Right, Body, Icon, Header,Text, Button, Content,  Form, Textarea, Card, CardItem } from 'native-base';
import { Col, Row, Grid } from 'react-native-easy-grid';
import {Overlay} from 'react-native-elements';

return (
               
        <Container style={styles.container}>
            
                <Header>
                    <Left>
                        <Button onPress={showOverlay} transparent>
                        <Icon name="arrow-back-sharp" />
                        </Button>
                    </Left>
                    
                    <Right>
                        <ReturnButton type={"fortrade"} />
                        <ReturnButton type={"forsale"} />
                        <Button onPress={clickSave} disabled={!post} transparent>
                            <Icon name='checkmark-outline' />
                        </Button>  
                    </Right>
                </Header>
                
                <Content style={styles.contentContainer}
                    showsHorizontalScrollIndicator={false}
                    showsVerticalScrollIndicator={false}
                    >
                        <Form>
                            <TextInput onChangeText={nameChange} placeholder={'作品名称'} value={name} />
                            <TextInput onChangeText={authorChange} placeholder={'作者'} value={author} />
                            
                            <TextInput keyboardType={'number-pad'} autoFocus={true} value={price.toString()} onChangeText={priceChange} placeholder={'卖价'} />
                            <TextInput keyboardType={'number-pad'} value={shippingCost.toString()} onChangeText={shChange} placeholder={'运费'} />
                            
                            <Textarea padder rowSpan={2} bordered placeholder={'介绍'} onChangeText={despChange} value={description} />
                        </Form>
                        
                        <DisplayImages pics={imgs} deleteImage={()=>{}} noDelete={true} updateImage={() => {}} swipeImage={swipeImage}/> 
                        
                </Content>
                
                    //<<==below is the overlay
                    <Overlay isVisible={isOverlayVisible} onBackdropPress={toggleOverlay}>
                            <View style={{position:"relative", width:200, paddingTop:10, alignContents:"top", alignItems:"center"}}>
                                <Text>I am here</Text>
                                <Button onPress={sellerMakeDeposit} title="存保证金" />
                                <Button onPress={sellerCancel} title="下市" />
                            </View>
                    </Overlay>  
                
                
                <Footerbar />              
                
        </Container>
    );
};

const styles = StyleSheet.create({
    modalContainer: {  
        flex: 1,  
        alignItems: 'center',  
        justifyContent: 'center',  
        backgroundColor: '#ecf0f1',  
      }, 
    modal: {  
        justifyContent: 'center',  
        alignItems: 'center',   
        //backgroundColor : "#00BCD4",   
        height: 200 ,  
        width: '67%',  
        borderRadius:10, 
        borderWidth: 1,  
        borderColor: 'black',    
        marginTop: 80,  
        marginLeft: 50,  
    },  
    modealOpacity: {
        flex:1,
    },
    tags:{

    },
    row:{
        paddingTop:0,
    },
    content:{

    //alignContent:"center",
    },

    container: {
        paddingTop:0,
    //justifyContent: 'center',     
    },
    contentContainer: {
        paddingTop:2,
        paddingLeft: 10,
        paddingRight:10,
        backgroundColor: '#F5FCFF',
    },
});

Here is the page displayed:

enter image description here

The is visible. However 2 buttons are nowhere to see. Tried to set height:400 and the button was still not visible. How to make button fit into the overlay screen?


Solution

  • Try modifying your Overlay block like shown below:

    enter image description here

    <Overlay isVisible={isOverlayVisible} onBackdropPress={toggleOverlay}>
            <View
              style={{
                position: 'relative',
                width: 200,
                paddingTop: 10,
                alignContents: 'top',
                alignItems: 'center',
              }}>
              <Text>I am here</Text>
              <View
                style={{
                  flexDirection: 'row',
                }}>
                <Button style={{ margin: 5 }} onPress={sellerMakeDeposit}>
                  <Text>存保证金</Text>
                </Button>
                <Button style={{ margin: 5 }} onPress={sellerCancel}>
                  <Text>下市</Text>
                </Button>
              </View>
            </View>
          </Overlay>