npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-responsive-view-port

v1.0.7

Published

TODO

Downloads

13

Readme

React Native Responsive View Port

react-native-view-port is a light weight library that provides a functionality to make your React Native UI responsive. This is an independent package dosn't use any additional packages or libraries.

It provides a solution to convert your existing React-native project to make it responsive. It supports apps that are built only for single orientation.

To save time in making or converting react-native project responsive try this.

| 7-Inch Screen | 9-Inch Screen | | --- | --- | | | |

| 10-Inch Screen | 12-Inch Screen | | --- | --- | | | |

Setup

Installation

$ npm install react-native-responsive-view-port --save

or

$ yarn add react-native-responsive-view-port

Usage

  • When importing this package to the component, package gets the device's width and height. If we have a base device in mind that we build the app for, We can pass their width and height for the future screens references. If we don't pass these values by default, Base device config will be 1280X800. Based on these it calculates the device's view-ports to scale the UI for different devices.

  • The package provides a function createViewPortConfig which takes width and height of the base device as a number value I.e. createViewPortConfig(1920, 1080) . It returns an object with view-port height vh and view-port width vw for corresponding base device size. Below given example demonstrates how to use the function and the returned view-port values.

  • Main objectives of these package is to make the product responsive and to do it in a easy and effortless way. So the function returns an object with vh and vw which can be used similar to the view-ports that are used in web development.

  • To make your code responsive multiply the vw and vh values with the style elements. i.e. width: 200 * vw; height: 150 * vh; fontSize: 25 * vh.

  • The suggested approach is to import the package to a common exported component and pass the base device width and height and export the vh and vw values for global use in your project. Try the given example for better understanding.

Props

import {createViewPortConfig} from 'react-native-responsive-view-port';
// If you don't pass base device width and height it calculates view-port for the following
// default values default baseDevice width=1280 and height=800
const { vw, vh } = createViewPortConfig();
Function you need to call. This function by default returns the viewport values for screen size 1280 X 800.

| Prop | Default | Type | Description | | :------------- | :-------------: | :------: | :---------------------------------------------------------------------------------------------------------- | | createViewPortConfig | () => {} | function | Call to get viewport values.|

Basic


import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  TextInput,
  Button,
  TouchableHighlight,
  Image,
  Alert
} from 'react-native';
import {createViewPortConfig} from 'react-native-responsive-view-port';

const { vw, vh } = createViewPortConfig();

const imageUrl = 'https://media.glassdoor.com/sql/958743/mroads-squarelogo-1458830826065.png';
const userImage = 'https://img.icons8.com/pastel-glyph/2x/user-male.png';
const emailImage = 'https://image.flaticon.com/icons/png/512/9/9923.png';
const passwordImage = 'http://icons.iconarchive.com/icons/iconsmind/outline/512/Key-icon.png';

export default class Register extends Component {

  constructor(props) {
    super(props);
    state = {
      fullName: '',
      email   : '',
      password: '',
    }
  }

  render() {
    return (
      <View style={styles.container}>
        <View style={styles.viewCard}>
	<View style={styles.imageContainer} ><Image style={styles.imageStyle} source={{uri: imageUrl }}/></View>
	<View style={styles.inputContainer}>
	  <Image style={styles.inputIcon} source={{uri: userImage }}/>
	  <TextInput style={styles.inputs}
	    placeholder="Full name"
	    keyboardType="email-address"
            underlineColorAndroid='transparent'
	    onChangeText={(fullName) => this.setState({fullName})}
	   />
	</View>
	<View style={styles.inputContainer}>
	  <Image style={styles.inputIcon} source={{uri: emailImage }}/>
	  <TextInput style={styles.inputs}
	    placeholder="Email"
	    keyboardType="email-address"
	    underlineColorAndroid='transparent'
	    onChangeText={(email) => this.setState({email})}
	   />
	</View>
	<View style={styles.inputContainer}>
	  <Image style={styles.inputIcon} source={{uri: passwordImage }}/>
	  <TextInput style={styles.inputs}
	    placeholder="Password"
	    secureTextEntry={true}
	    underlineColorAndroid='transparent'
	    onChangeText={(password) => this.setState({password})}
	  />
	</View>
	<TouchableHighlight style={[styles.buttonContainer, styles.signupButton]}>
	  <Text style={styles.signUpText}>Sign up</Text>
	</TouchableHighlight>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#545454',
  },
	viewCard: {
		backgroundColor: '#d3d3d3',
		justifyContent: 'center',
		alignItems: 'center',
		paddingVertical: 10 * vh,
		paddingHorizontal: 15 * vw,
		borderRadius: 8,
		shadowOffset:{  width: 10 * vw,  height: 10 * vw },
		shadowColor: 'black',
		shadowOpacity: 1.0,
		elevation: 10,
		width: 500 * vw,
	},
  inputContainer: {
      borderBottomColor: '#F5FCFF',
      backgroundColor: '#FFFFFF',
      borderBottomWidth: 1,
      width: 450 * vw,
      height: 60 * vh,
      marginBottom: 20 * vh,
      flexDirection: 'row',
      alignItems:'center',
      borderRadius: 8,
  },
  inputs:{
      height: 60 * vh,
      marginLeft: 16 * vw,
      borderBottomColor: '#FFFFFF',
      flex:1,
      justifyContent: 'center',
      fontSize: 25 * vh,
  },
  inputIcon:{
    width: 45 * vw,
    height: 45 * vw,
    marginLeft: 10 * vw,
    justifyContent: 'center',
  },
  imageContainer: {
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#d3d3d3',
    marginVertical: 10 * vh,
  },
  imageStyle: {
    width: 130 * vw,
    height: 130 * vw,
    justifyContent: 'center',
    borderRadius: 8,
  },
  buttonContainer: {
    height: 60 * vh,
    flexDirection: 'row',
    justifyContent: 'center',
    alignItems: 'center',
    marginBottom: 20 * vh,
    width: 125 * vw,
    borderRadius: 8,
  },
  signupButton: {
    backgroundColor: 'green',
  },
  signUpText: {
    color: 'white',
    fontSize: 25 * vh,
  }
});