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

@freakycoder/react-native-helpers

v2.3.0

Published

All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy use

Downloads

1,973

Readme

Battle Tested ✅

All helpers in one; iPhone series support, dimensions helper, hasNotch helper, normalize text helper and text helpers for React Native with very easy use

npm version npm expo-compatible Platform - Android and iOS License: MIT

Installation

Add the dependency:

React Native

npm i @freakycoder/react-native-helpers

Peer Dependencies

Zero Dependency

DeviceInfo Usage

import {
  Screen,
  ScreenWidth,
  ScreenHeight,
  isIOS,
  isAndroid,
} from "@freakycoder/react-native-helpers";

<View>
  <Container title="Device OS" subtitle={isIOS ? "iOS" : "Android"} />
  <Container title="Screen Height" subtitle={ScreenHeight} />
  <Container title="Screen Width" subtitle={ScreenWidth} />
</View>;

Notch & DynamicIsland Usage

import {
  getStatusBarHeight,
  hasNotch,
  hasNotchOnly,
  hasDynamicIsland,
  getStatusBarHeight,
} from "@freakycoder/react-native-helpers";

<View>
  <Container
    title="hasNotch?"
    subtitle={hasNotch() ? "Has Notch" : "NOT notch"}
  />
  <Container
    title="hasDynamicIsland?"
    subtitle={
      hasDynamicIsland(Screen) ? "Has Dynamic Island" : "NOT Dynamic Island"
    }
  />
  <Container title="getStatusBarHeight?" subtitle={getStatusBarHeight()} />
</View>;

Normalize Text Usage

Method to normalize size of fonts across devices

import { normalizeText } from "@freakycoder/react-native-helpers";

fontSize: normalizeText(24),

Native Number Format Usage

Method to format the number of your texted number. You can change each options.

import { numberFormat } from "@freakycoder/react-native-helpers";

<Text>{numberFormat(50319341)</Text> // Output: 50.319.341
<Text>
  {numberFormat(1093495, "en", {
    style: "currency",
    currency: "GBP"
  })}
</Text>// Output: £ 50.319.341

Configuration - Props

DeviceInfo Props

| Property | Type | Description | |-------------------|:-------:|----------------------------------------------------------------------------------------------------------------------------| | isIOS | boolean | returns if it is an iOS device or not | | isAndroid | boolean | returns if it is an Android device or not | | ScreenWidth | number | get the device's screen width | | ScreenHeight | number | get the device's screen height | | ScreenScale | number | get the device's screen scale ratio | | ScreenFontScale | number | get the device's screen font scale ratio (depends on the user's device font scale setting) | | WindowWidth | number | get the device's window width | | WindowHeight | number | get the device's window height | | WindowScale | number | get the device's window scale ratio | | WindowFontScale | number | get the device's window font scale ratio (depends on the user's device font scale setting) | | PlatformVersion | number | returns the platform version | | ScreenMin | number | get the device's screen width/height which are minimum depend on the landscape or portrait mode | | ScreenMax | number | get the device's screen width/height which are maximum depend on the landscape or portrait mode | | vh | number | get the device's height but as a viewport unit | | vw | number | get the device's width but as a viewport unit | | vmin | number | get the device's screen width/height as a viewport unit which are minimum depend on the landscape or portrait mode | | vmax | number | get the device's screen width/height as a viewport unit which are maximum depend on the landscape or portrait mode | | getDeviceLanguage | string | get the device's language (en_US) |

DeviceInfo Props

getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland

| Property | Type | Description | |--------------------|:--------:|-------------------------------------------------------------------------------------------| | hasNotch | function | returns if the device has notch (returns true for dynamic island!) | | hasNotchOnly | function | returns if the device has notch only, it does not detect if the device has dynamic island | | hasDynamicIsland | function | returns if the device has dynamic island | | getStatusBarHeight | number | returns status bar height of the device |

Utils Props

| Property | Type | Description | |--------------------|:------------------------------------:|--------------------------------------------------------| | openAppInPlayStore | function(appPackageName) | opens the app on android or Google Play | | openAppInAppStore | function(appStoreId) | opens the app on ios or App Store | | openExternalApp | function(appPackageName, appStoreId) | opens the app on ios or android - handles the platform |

Normalize Text Props

| Property | Type | Description | |-----------|:----------------:|----------------------------------| | normalize | function(number) | returns the normalized font size |

Custom Text Props

| Property | Type | Description | |--------------|:--------------------------------:|-------------------------------------------------------------| | numberFormat | function(value, locale, options) | returns the number formatted font with its given parameters |

Roadmap

  • [x] ~~LICENSE~~
  • [x] ~~Typescript~~
  • [x] ~~iPhone Series Support~~
  • [x] ~~Dynamic Island~~
  • [ ] Separate the style helpers from device
  • [ ] More custom text helpers
  • [ ] Write an article about the lib on Medium

Author

FreakyCoder, [email protected]

License

React Native Helpers Library is available under the MIT license. See the LICENSE file for more info.