2.0.0 • Published 4 years ago

react-native-beauty-webview v2.0.0

Weekly downloads
39
License
ISC
Repository
-
Last release
4 years ago

React Native Beauty Webview for easy usage

:star2: Features

  • Easy usage
  • Easy to configure
  • Beauty UI
  • Default click and copy url
  • Open on browser
  • See title of website on header
  • Navigation

:star: Screenshot

npm.io npm.io npm.io npm.io

:arrow_down: Installation

Install react-native-webview

More information about installation of react-native-webview, click here

$ yarn add react-native-webview

or

$ npm install --save react-native-webview

Install @react-native-community/clipboard

More information about installation of clipboard, click here

$ yarn add @react-native-community/clipboard

or

$ npm install --save @react-native-community/clipboard

Link native dependencies for IOS

Link native dependencies of @react-native-community/clipboard and @react-native-community/react-native-webview. If your react native verison is lower than 0.60.x, you must check the official documentation of these packages to link correctly.

$ cd ios && pod install

Install our package

$ yarn add react-native-beauty-webview

or

$ npm install --save react-native-beauty-webview

:flashlight: Example Usage

import React, {useState} from 'react';
import {
  StyleSheet,
  View,
  TouchableOpacity,
  Text,
} from 'react-native';
import BeautyWebView from 'react-native-beauty-webview';

const App = () => {
  const [visible, setVisible] = useState(false);
  const onButtonPress = () => {
    setVisible(true);
  };

  return (
      <View style={styles.container}>
        <BeautyWebView
          visible={visible} // Reguired for open and close
          onPressClose={() => setVisible(false)} // Reguired for closing the modal
          url={'https://github.com/'}
          extraMenuItems={[
            {
              title: 'Extra Item',
              onPress: () => console.log('Extra Menu Item Clicked'),
            },
          ]}
        />
        <TouchableOpacity style={styles.button} onPress={onButtonPress}>
          <Text style={styles.text}>Open</Text>
        </TouchableOpacity>
      </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
  },
  button: {
    alignSelf: 'stretch',
    justifyContent: 'center',
    alignItems: 'center',
    padding: 8,
    backgroundColor: '#2196f3',
    marginHorizontal: 20,
  },
  text: {
    color: '#fff',
    fontSize: 16,
  },
});

export default App;

:paperclip: Config

ParamsTypeDefaultRequiredDescription
visiblebooleanfalseYESVisibility of modal
onPressClosefunction-YESRun on press the close button (You must set visibilty as false)
urlstring-YESURL of the website
backgroundColorstring#fff-Background color of view
headerContent'dark' or 'light''dark'-Content type of header items like icons
headerBackgroundstring#fff-Background of header
progressColorstring#2196f3-Color of the progress bar
loadingTextstring'Loading...'-Text of the loading
copyLinkTitlestring'Copy Link'-Text of the copy menu item
openBrowserTitlestring'Open on Browser'-Text of the opening on bowser menu item
extraMenuItemsArray--Extra menu items, you can see detail on usage part on above
animationType'slide' or 'fade''slide'-Animation type of modal
progressBarType'normal' or 'background''normal'-Progress bar type
onLoadEndfunc--Run at end of the loading
onLoadStartfunc--Run before start loading
navigationVisiblebooleantrue-Show navigation buttons
closeIconComponent--Close icon of header
menuIconComponent--Menu icon of header
onGoBackfunc--Run at going back
onGoForwardfunc--Run at going forward

:warning: Dependency

@react-native-community/react-native-webview

You must install @react-native-community/react-native-webview package correctly before use this package. For more information, please click here

@react-native-community/clipboard

You must install @react-native-community/clipboard package correctly before use this package. For more information, please click here

:clipboard: References

mxck/react-native-material-menu

For menu component, I took advantages of this resource. More information about this resource, please click here