about summary refs log tree commit diff
path: root/modules/react-native-ui-text-view/src/index.tsx
blob: d5bde136f71cdec8a52c4e67608a6e1c2adb0a26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
  requireNativeComponent,
  UIManager,
  Platform,
  type ViewStyle,
  TextProps,
} from 'react-native'

const LINKING_ERROR =
  `The package 'react-native-ui-text-view' doesn't seem to be linked. Make sure: \n\n` +
  Platform.select({ios: "- You have run 'pod install'\n", default: ''}) +
  '- You rebuilt the app after installing the package\n' +
  '- You are not using Expo Go\n'

export interface RNUITextViewProps extends TextProps {
  children: React.ReactNode
  style: ViewStyle[]
}

export interface RNUITextViewChildProps extends TextProps {
  text: string
  onTextPress?: (...args: any[]) => void
  onTextLongPress?: (...args: any[]) => void
}

export const RNUITextView =
  UIManager.getViewManagerConfig &&
  UIManager.getViewManagerConfig('RNUITextView') != null
    ? requireNativeComponent<RNUITextViewProps>('RNUITextView')
    : () => {
        throw new Error(LINKING_ERROR)
      }

export const RNUITextViewChild =
  UIManager.getViewManagerConfig &&
  UIManager.getViewManagerConfig('RNUITextViewChild') != null
    ? requireNativeComponent<RNUITextViewChildProps>('RNUITextViewChild')
    : () => {
        throw new Error(LINKING_ERROR)
      }

export * from './UITextView'