Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-utils-scale

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-utils-scale

Provide solutions to make your app flexible for different screen sizes, different devices.

  • 2.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-utils-scale

Getting started

$ yarn add react-native-utils-scale

IOS Setup

$ cd ios && pod install && cd ../

Demo

Usage


import React from 'react';
import {SafeAreaView, ScrollView, StyleSheet, Text, View} from 'react-native';
import {
  dimensionsScale,
  isAndroid,
  isIOS,
  hasNotch,
  isTablet,
  isSmallDevice,
  getDeviceInch,
} from 'react-native-utils-scale';

const {scale, fontScale, deviceWidth, deviceHeight} = dimensionsScale;

const App = () => {
  return (
    <ScrollView>
      <SafeAreaView style={styles.container}>
        <Text style={styles.fontScale}>Device width: {deviceWidth()}</Text>
        <Text style={styles.fontScale}>Device height: {deviceHeight()}</Text>
        <Text style={styles.fontScale}>Device inch: {getDeviceInch()}</Text>
        <Text style={styles.fontScale}>
          isAndroid: {isAndroid().toString()}
        </Text>
        <Text style={styles.fontScale}>isIOS: {isIOS().toString()}</Text>
        <Text style={styles.fontScale}>isTablet: {isTablet().toString()}</Text>
        <Text style={styles.fontScale}>hasNotch: {hasNotch().toString()}</Text>
        <Text style={styles.fontScale}>
          isSmallDevice: {isSmallDevice().toString()}
        </Text>

        <View style={[styles.box, styles.scale]}>
          <Text style={[styles.color, {fontSize: fontScale(14)}]}>150x150</Text>
          <Text style={[styles.color, {fontSize: fontScale(14)}]}>
            Scale: {scale(150)}x{scale(150)}
          </Text>
        </View>
      </SafeAreaView>
    </ScrollView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  fontScale: {
    fontSize: fontScale(16),
  },
  box: {
    width: 150,
    height: 150,
    backgroundColor: 'black',
    alignItems: 'center',
    justifyContent: 'center',
    margin: 16,
  },
  scale: {
    width: scale(150),
    height: scale(150),
  },
  color: {
    color: 'white',
  },
});

export default App;

Keywords

FAQs

Package last updated on 11 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc