Posts

Showing posts from December, 2020

React Native Download Pdf

 Run the following command with your project directory     npm i  rn-fetch-blob    AndroidManifest.xml Add below permissions in AndroidManifest.xml <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" /> Code for download pdf     open index.js   and replace the code with the following code Index.js       import React,{Component} from 'react';                       import { View, Button, Alert,  PermissionsAndroid} from "react-native";     import styles from './styles';                                           import RNFetchBlob from 'rn-fetch-blob';                    class PdfDownload extends Component {                        actualDownload = (pdf_url,ID) => {             const { config, fs } = RNFetchBlob;             c

React Native Modal box

Run the following command with your project directory     npm i react-native-modalbox Code for modal box      Open index.js and replace the code with the following code index.js  import React,{Component} from 'react'; import { View, Button } from "react-native"; import styles from './styles'; import ModalBox from "./ModalBox"; class Account extends Component {     closePhoto = () => {         this._modalPhoto.close();     };     openPhoto = () => {         this._modalPhoto.open();     };     render() {         return (             <View style={styles.container}>                 <Button title="open" onPress={this.openPhoto}></Button>                 <Login ref={(com) => (this._modalPhoto = com)} />             </View>         );     } } export default Account; ModalBox.js import React, { Component, useState } from "react"; import { Text, TouchableOpacity } from "react-native"; import

Custom drawer in react native(drawer navigator)

Run the following command with your project directory      npm i react-navigation-drawer         npm i react-navigation        npm i react-navigation-tab    project structure      src          ->actions          ->common          ->components          ->containers          ->navigation              -index.js               -customDrawer.js          ->reducers          ->services          ->store Code for custom drawer in react native     Open index.js in navigation folder and replace the code with the following code index.js import React from 'react'; import { createAppContainer, createSwitchNavigator } from "react-navigation"; import { createDrawerNavigator } from 'react-navigation-drawer'; import { createStackNavigator } from 'react-navigation-stack'; import CustomDrawer from "./CustomDrawer"; import Example from './containers/Example'; const SettingsStack = createStackNavigator({     SettingsList: {         s