sergeymild / react-native-jsi-view-helpers

React Native Jsi view helpers for measure text and view.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-native-jsi-view-helpers

React Native Jsi view helpers

Installation

package.json
"react-native-jsi-view-helpers": "sergeymild/react-native-jsi-view-helpers#1.0.0"
yarn
npx pod-install

Usage

import { viewHelpers } from "react-native-jsi-view-helpers";

export interface MeasureParams {
  text: string;
  fontSize: number;
  maxWidth: number;
  allowFontScaling?: boolean;
  usePreciseWidth?: boolean;
  fontFamily?: string;
  weight?: TextProps['fontWeight']
}

export interface MeasureTextResult {
  height: number;
  width: number;
  lineCount: number;
  lastLineWidth: number;
}

export interface MeasureViewResult {
  height: number;
  width: number;
  x: number;
  y: number;
}

export class viewHelpers {
  static measureText(params: MeasureParams): MeasureTextResult;
  static measureView(ref: React.RefObject<any>): MeasureViewResult;
  
  // scroll to any child in ScrollView
  static scrollToChild(
    params:
      | {
          // nativeID of scroll view
          scrollNativeID: string;
          // nativeID of child in scroll view (can be nested in another views)
          childNativeID: string;
          // offset
          offset?: number;
          // scroll to child end view (by default scroll to top)
          scrollToEnd?: boolean;
        }
      | {
          // ref of scroll view
          scrollViewRef: React.RefObject<ScrollView>;
          childNativeID: string;
          offset?: number;
          scrollToEnd?: boolean;
        }
  )
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

React Native Jsi view helpers for measure text and view.

License:MIT License


Languages

Language:TypeScript 36.1%Language:Java 27.1%Language:Objective-C 9.8%Language:Objective-C++ 8.8%Language:C++ 7.8%Language:Kotlin 3.2%Language:Ruby 2.7%Language:Swift 1.8%Language:JavaScript 1.7%Language:CMake 0.9%Language:C 0.2%