modal

 app.js

import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import Index from './Components/Practice'
const App = () => {
  return (
<Index/>
  )
}

export default App

*****************************************************************
practice
index.js
import React, {useState} from 'react';
import {
  View,
  Text,
  TextInput,
  Button,
  TouchableOpacity,
  TouchableHighlight,
  TouchableWithoutFeedback,
  Pressable,
  Alert,
  ToastAndroid,
  Modal,
} from 'react-native';
import Styles from './styles';
const Index = () => {
  const [Data, setData] = useState('');
  const [submiting, setsubmiting] = useState(false);
  const [Modalb, setModalb] = useState(false);

  const onPressHandler = () => {
    if (Data.length > 3) {
      setsubmiting(!submiting);
    } else {
      setModalb(true);
    }
  };
  return (
    <View style={Styles.container}>
      <Modal
        visible={Modalb}
        transparent
        onRequestClose={() => setModalb(false)}
        animationType="slide"
        hardwareAccelerated>
        <View style={Styles.modal_center_view}>
          <View style={Styles.modalview}>
            <View style={Styles.warningview}>
              <Text style={Styles.warningtxt}>WARNING!</Text>
            </View>
            <View style={Styles.warning_view_text}>
              <Text style={Styles.wartxt}>hellos her it is modal</Text>
            </View>
            <Pressable
              style={Styles.modal_btn}
              onPress={() => setModalb(false)}>
              <Text style={Styles.ok_txt}> OK</Text>
            </Pressable>
          </View>
        </View>
      </Modal>
      <Text style={Styles.txt}>Please enter your Name</Text>
      <TextInput
        style={Styles.input}
        placeholder="enter text here"
        onChangeText={value => setData(value)}
      />
      <Pressable
        style={({pressed}) => [
          {backgroundColor: pressed ? 'yellow' : 'green'},
          Styles.btn,
        ]}
        onPress={onPressHandler}>
        <Text style={Styles.btntxt}>{submiting ? 'Click' : 'Clear'}</Text>
      </Pressable>

      {submiting ? (
        <Text style={Styles.txt2}>your Registered As {Data}</Text>
      ) : null}
    </View>
  );
};

export default Index;
practice
styles.js
import {StyleSheet} from 'react-native';
import {
  widthPercentageToDP as wp,
  heightPercentageToDP as hp,
} from 'react-native-responsive-screen';
const Styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'skyblue',
    alignItems: 'center',
  },
  txt: {
    fontSize: hp(5),
  },
  input: {
    borderWidth: hp(0.5),
    width: wp(60),
    height: hp(10),
    borderRadius: wp(5),
    textAlign: 'left',
    fontSize: hp(4),
  },
  txt2: {
    fontSize: hp(5),
    textAlign: 'center',
  },
  btn: {
    height: hp(8),
    width: wp(40),
    borderWidth: hp(0.5),
    borderRadius: hp(2),
    alignItems: 'center',
    justifyContent: 'center',
  },
  btntxt: {
    fontSize: hp(5),
  },
  modalview: {
    height: hp(50),
    width: wp(70),
    backgroundColor: 'deepskyblue',
    borderWidth: wp(0.3),
    borderRadius: hp(2),
   
  },
  modal_center_view: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  warningview:{
      height:hp(7),
      backgroundColor:'yellow',
borderRadius:hp(2),
      alignItems:'center',
      justifyContent:'center',
     
  },
  warningtxt:{
      fontSize:hp(4)
  },
  warning_view_text:{
      alignItems:'center',
      justifyContent:'center'
  },
  wartxt:{
      fontSize:hp(5),
      textAlign:'center',
      justifyContent:'center'
  },
  modal_btn:{
      backgroundColor:'yellow',
      marginTop:hp(25),
      alignItems:'center',
      justifyContent:'center',
      height:hp(5.2),
      borderBottomLeftRadius:hp(2),
      borderBottomRightRadius:hp(2)
  },
  ok_txt:{
   fontSize:hp(3.5)  
  }

});

export default Styles;
***************************************************************
pkg.json
  "dependencies": {
    "react": "17.0.2",
    "react-native": "0.65.1",
    "react-native-responsive-screen": "^1.4.2"
  },

Comments

Popular posts from this blog

Privacy Policy for Live Weather Forecast - Realtime app

NFC Checker App Privacy Policy

FlatList