Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

expo modal

import React, { useState } from 'react';
import { Alert, Modal, StyleSheet, Text, Pressable, View } from 'react-native';

const App = () => {
  const [modalVisible, setModalVisible] = useState(false);
  return (
    <View style={styles.centeredView}>
      <Modal
        animationType="slide"
        transparent={true}
        visible={modalVisible}
        onRequestClose={() => {
          Alert.alert('Modal has been closed.');
          setModalVisible(!modalVisible);
        }}>
        <View style={styles.centeredView}>
          <View style={styles.modalView}>
            <Text style={styles.modalText}>Hello World!</Text>
            <Pressable
              style={[styles.button, styles.buttonClose]}
              onPress={() => setModalVisible(!modalVisible)}>
              <Text style={styles.textStyle}>Hide Modal</Text>
            </Pressable>
          </View>
        </View>
      </Modal>
      <Pressable style={[styles.button, styles.buttonOpen]} onPress={() => setModalVisible(true)}>
        <Text style={styles.textStyle}>Show Modal</Text>
      </Pressable>
    </View>
  );
};

const styles = StyleSheet.create({
  centeredView: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    marginTop: 22,
  },
  modalView: {
    margin: 20,
    backgroundColor: 'white',
    borderRadius: 20,
    padding: 35,
    alignItems: 'center',
    shadowColor: '#000',
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 4,
    elevation: 5,
  },
  button: {
    borderRadius: 20,
    padding: 10,
    elevation: 2,
  },
  buttonOpen: {
    backgroundColor: '#F194FF',
  },
  buttonClose: {
    backgroundColor: '#2196F3',
  },
  textStyle: {
    color: 'white',
    fontWeight: 'bold',
    textAlign: 'center',
  },
  modalText: {
    marginBottom: 15,
    textAlign: 'center',
  },
});

export default App;
Comment

PREVIOUS NEXT
Code Example
Javascript :: word randomizer 
Javascript :: pop array 
Javascript :: Prevent safari loading from cache when back button is clicked 
Javascript :: text background fabricjs 
Javascript :: javascript html video seek to time 
Javascript :: google geocode nodejs 
Javascript :: javascript remove from array 
Javascript :: get role id from role position 
Javascript :: javascript screenshot 
Javascript :: gatsby tailwind 
Javascript :: catch errors async await javascript 
Javascript :: how to insert div around element in javascript 
Javascript :: how to create date object with specific time in moment js 
Javascript :: upgrade or update nodejs 
Javascript :: validation in react native 
Javascript :: moment.set 
Javascript :: map keys to list node js 
Javascript :: javascript pure ajax 
Javascript :: different uniqid usage 
Javascript :: define value in js 
Javascript :: react native docs 
Javascript :: --resolveJsonModule 
Javascript :: module pattern function syntax 
Javascript :: vs code shortcut for switching to terminal to editor 
Javascript :: cypress run specific test 
Javascript :: toggle password hide show 
Javascript :: how to display date in javascript 
Javascript :: javascript call php function with parameters 
Javascript :: sort by attribute in reactjs 
Javascript :: full month name using moment 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =