Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Safe

Provides spacing amounts for each side of the viewport to avoid any notches

Hierarchy

  • Safe

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Safe(__namedParameters?: object): Safe
  • Parameters

    • Default value __namedParameters: object = {}
      • instance: undefined | function

    Returns Safe

Properties

provider

provider: SafeProvider | undefined = undefined

The class instance provider override

Static provider

provider: SafeProvider = safeProvider

The global safe spacing provider. Can be overridden to provide better safe spacing detection using native libraries.

example
How to override ```ts import { Safe, Side } from '@ef-carbon/react-native-style'; Safe.provider = (side: Side) => { // Do some magic here to determine the safe spacing values }; ```

Accessors

bottom

  • get bottom(): number

left

  • get left(): number

right

  • get right(): number

top

  • get top(): number

Methods

style

  • style(type: "padding" | "margin", sides?: Iterable<Side>): ViewStyle
  • Creates a view style using the spacing constants.

    example
    import { safe, Side } from '@ef-carbon/react-native-style';
    const style = safe.style('padding', [Side.Top, Side.Bottom]);
    // {
    //   paddingTop: 0,
    //   paddingBottom: 0
    // }

    Parameters

    • type: "padding" | "margin"

      the prefix to add to the side strings

    • Optional sides: Iterable<Side>

      the side to add to the view style

    Returns ViewStyle