Skip to content

Instantly share code, notes, and snippets.

@LaloHao
Created August 12, 2017 23:43
Show Gist options
  • Save LaloHao/1304a8c8c23128213f199a13059182f7 to your computer and use it in GitHub Desktop.
Save LaloHao/1304a8c8c23128213f199a13059182f7 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import {
View,
Text,
TouchableOpacity
} from 'react-native';
import ModalTester from './ModalTester.js';
export default class App extends Component {
render () {
return (
<View style={{ flex: 1 }}>
<TouchableOpacity onPress={() => this.Modal.showModal()}>
<Text style={{color: 'black'}}>Mostrar</Text>
</TouchableOpacity>
<ModalTester ref={ref => this.Modal = ref}>
<TouchableOpacity onPress={() => this.Modal.hideModal()}>
<Text style={{color: 'black'}}>Esconder</Text>
</TouchableOpacity>
</ModalTester>
</View>
);
}
}
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Modal from 'react-native-modal';
export default class ModalTester extends Component {
state = {
isModalVisible: false
}
showModal = () => this.setState({ isModalVisible: true })
hideModal = () => this.setState({ isModalVisible: false })
render () {
return (
<View style={{ flex: 1 }}>
<Modal isVisible={this.state.isModalVisible}>
{this.props.children}
</Modal>
</View>
);
}
}
@dajimene
Copy link

import React, { Component } from 'react';
import { Image, StyleSheet, } from 'react-native';
import { Header, Container, Content, View, Card, CardItem, Icon, Thumbnail, Text, Button, Left, Body } from 'native-base';
import ModalTester from './../Cold/cold.js';
import Modal from 'react-native-modal';

export default class Form extends Component {

render() {
    return (


        <Container>
            <Content>
                <Header hasTabs >

                    <Button onPress={() => this.Modal.showModal()}>
                        <Text >Mostrar</Text>
                    </Button>
                </Header>


            </Content>
        </Container >
    );
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment