diff options
author | Hailey <me@haileyok.com> | 2024-04-03 18:05:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 18:05:03 -0700 |
commit | 7fb117d213149dfee9d0e79292b267b3cd5bde0e (patch) | |
tree | 74910683224f4d7fd7d660888ef36c13c3fca993 /modules/react-native-ui-text-view/src/UITextView.tsx | |
parent | a356b1be1a08814766ae9deadd7b8467a35feb0e (diff) | |
download | voidsky-7fb117d213149dfee9d0e79292b267b3cd5bde0e.tar.zst |
Upgrade `UITextView` to latest (#3090)
* uitextview use library w/ fixes bump bump multiple uitextview fixes * bump * update to latest * cleanup
Diffstat (limited to 'modules/react-native-ui-text-view/src/UITextView.tsx')
-rw-r--r-- | modules/react-native-ui-text-view/src/UITextView.tsx | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/modules/react-native-ui-text-view/src/UITextView.tsx b/modules/react-native-ui-text-view/src/UITextView.tsx deleted file mode 100644 index bbb45dccc..000000000 --- a/modules/react-native-ui-text-view/src/UITextView.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import React from 'react' -import {Platform, StyleSheet, TextProps, ViewStyle} from 'react-native' -import {RNUITextView, RNUITextViewChild} from './index' - -const TextAncestorContext = React.createContext<[boolean, ViewStyle]>([ - false, - StyleSheet.create({}), -]) -const useTextAncestorContext = () => React.useContext(TextAncestorContext) - -const textDefaults: TextProps = { - allowFontScaling: true, - selectable: true, -} - -export function UITextView({style, children, ...rest}: TextProps) { - const [isAncestor, rootStyle] = useTextAncestorContext() - - // Flatten the styles, and apply the root styles when needed - const flattenedStyle = React.useMemo( - () => StyleSheet.flatten([rootStyle, style]), - [rootStyle, style], - ) - - if (Platform.OS !== 'ios') { - throw new Error('UITextView is only available on iOS') - } - - if (!isAncestor) { - return ( - <TextAncestorContext.Provider value={[true, flattenedStyle]}> - <RNUITextView - {...textDefaults} - {...rest} - ellipsizeMode={rest.ellipsizeMode ?? rest.lineBreakMode ?? 'tail'} - style={[{flex: 1}, flattenedStyle]} - onPress={undefined} // We want these to go to the children only - onLongPress={undefined}> - {React.Children.toArray(children).map((c, index) => { - if (React.isValidElement(c)) { - return c - } else if (typeof c === 'string') { - return ( - <RNUITextViewChild - key={index} - style={flattenedStyle} - text={c} - {...rest} - /> - ) - } - })} - </RNUITextView> - </TextAncestorContext.Provider> - ) - } else { - return ( - <> - {React.Children.toArray(children).map((c, index) => { - if (React.isValidElement(c)) { - return c - } else if (typeof c === 'string') { - return ( - <RNUITextViewChild - key={index} - style={flattenedStyle} - text={c} - {...rest} - /> - ) - } - })} - </> - ) - } -} |