HomeOur TeamContact

Full Screen Modal

By Utkarsh Lubal
Published in Modal
June 13, 2022
1 min read
Full Screen Modal

Table Of Contents

01
Introduction
02
Installation
03
Example
04
Tutorial

Introduction

The goal of react-native-modal is expanding the original React Native <Modal> component by adding animations, style customization options, and new features, while still providing a simple API.

Installation

npm i react-native-modal

Example


import React, { Component } from 'react';
import { Text, TouchableOpacity, StyleSheet, View } from 'react-native';
import Modal from 'react-native-modal';

export default class Example extends Component {
  state = {
    visibleModal: null,
  };

  _renderButton = (text, onPress) => (
    <TouchableOpacity onPress={onPress}>
      <View style={styles.button}>
        <Text>{text}</Text>
      </View>
    </TouchableOpacity>
  );

  _renderModalContent = () => (
    <View style={styles.modalContent}>
      <Text>You Clicked On Modal !</Text>
      {this._renderButton('Close', () => this.setState({ visibleModal: null }))}
    </View>
  );

  render() {
    return (
      <View style={styles.container}>
        {this._renderButton('Full Screen modal', () => this.setState({ visibleModal: 1 }))}

         <Modal
          isVisible={this.state.visibleModal === 1}
          backdropColor={'lightgreen'}
          animationIn={'zoomInDown'}
          animationOut={'zoomOutUp'}
          animationInTiming={1000}
          animationOutTiming={1000}
        >
          {this._renderModalContent()}
        </Modal>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  button: {
    backgroundColor: 'lightblue',
    padding: 12,
    margin: 16,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 4,
  },
  modalContent: {
    backgroundColor: 'white',
    padding: 22,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 4,
  },
  bottomModal: {
    justifyContent: 'flex-end',
    margin: 0,
  },
});

Tutorial


Tags

full screen
Previous Article
Line Chart
Next Article
Bottom half modal
Utkarsh Lubal

Utkarsh Lubal

Full Stack Developer

Related Posts

Confirm Simple Dialog
Confirm Simple Dialog
May 06, 2023
1 min

Quick Links

Advertise with usAbout UsContact Us

Social Media