2.6.0 • Published 2 years ago

react-native-utils-scale v2.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-native-utils-scale

Getting started

$ yarn add react-native-utils-scale

IOS Setup

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

Demo

npm.io

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;
2.6.0

2 years ago

2.5.0

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.3.4

2 years ago

2.3.3

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.1.10

2 years ago

2.1.8

3 years ago

2.1.7

3 years ago

2.1.9

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.3

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago