2.3.0 • Published 5 months ago

@freakycoder/react-native-helpers v2.3.0

Weekly downloads
484
License
MIT
Repository
github
Last release
5 months ago

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

PropertyTypeDescription
isIOSbooleanreturns if it is an iOS device or not
isAndroidbooleanreturns if it is an Android device or not
ScreenWidthnumberget the device's screen width
ScreenHeightnumberget the device's screen height
ScreenScalenumberget the device's screen scale ratio
ScreenFontScalenumberget the device's screen font scale ratio (depends on the user's device font scale setting)
WindowWidthnumberget the device's window width
WindowHeightnumberget the device's window height
WindowScalenumberget the device's window scale ratio
WindowFontScalenumberget the device's window font scale ratio (depends on the user's device font scale setting)
PlatformVersionnumberreturns the platform version
ScreenMinnumberget the device's screen width/height which are minimum depend on the landscape or portrait mode
ScreenMaxnumberget the device's screen width/height which are maximum depend on the landscape or portrait mode
vhnumberget the device's height but as a viewport unit
vwnumberget the device's width but as a viewport unit
vminnumberget the device's screen width/height as a viewport unit which are minimum depend on the landscape or portrait mode
vmaxnumberget the device's screen width/height as a viewport unit which are maximum depend on the landscape or portrait mode
getDeviceLanguagestringget the device's language (en_US)

DeviceInfo Props

getStatusBarHeight, hasNotch, hasNotchOnly, hasDynamicIsland

PropertyTypeDescription
hasNotchfunctionreturns if the device has notch (returns true for dynamic island!)
hasNotchOnlyfunctionreturns if the device has notch only, it does not detect if the device has dynamic island
hasDynamicIslandfunctionreturns if the device has dynamic island
getStatusBarHeightnumberreturns status bar height of the device

Utils Props

PropertyTypeDescription
openAppInPlayStorefunction(appPackageName)opens the app on android or Google Play
openAppInAppStorefunction(appStoreId)opens the app on ios or App Store
openExternalAppfunction(appPackageName, appStoreId)opens the app on ios or android - handles the platform

Normalize Text Props

PropertyTypeDescription
normalizefunction(number)returns the normalized font size

Custom Text Props

PropertyTypeDescription
numberFormatfunction(value, locale, options)returns the number formatted font with its given parameters

Roadmap

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

Author

FreakyCoder, kurayogun@gmail.com

License

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