/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow * @format */ import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import type {TextLayoutLine} from 'react-native/Libraries/Types/CoreEventTypes'; import RNTesterText from '../../components/RNTesterText'; import {useTheme} from '../../components/RNTesterTheme'; import {useState} from 'react'; import {View} from 'react-native'; function InlineView(props: { textAlign: 'auto' | 'left' | 'right' | 'center' | 'justify', long?: boolean, }): React.Node { return ( Parent Child Child { /* $FlowFixMe[invalid-compare] Error discovered during Constant * Condition roll out. See https://fburl.com/workplace/5whu3i34. */ props !== null && props.long === true && ( aaaa a aaaa aaaaaa aaa a a a aaaaa sdsds dsdSAD asd ASDasd ASDas ) } ); } function TextInlineViewsExample(props: {}): React.Node { return ( BoringLayout StaticLayout ); } function EmptyTextExample(): React.Node { const {BorderColor} = useTheme(); return ( ); } function TextAndLayoutLinesJSON({ testID, ellipsizeMode, }: $ReadOnly<{ testID: string, ellipsizeMode: 'head' | 'tail' | 'middle' | 'clip', }>): React.Node { const [lines, setLines] = useState(); return ( {ellipsizeMode} setLines(ev.nativeEvent.lines)}> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin volutpat molestie nunc non tristique. {JSON.stringify(lines, null, 2)} ); } function NumberOfLinesTextLayoutExample(): React.Node { return ( ); } component RtlInlineViewExample( label: string, testID: string, children: React.Node, ) { return ( {label} {children} ); } component RtlAndInlineViewsExample() { return ( مَٰنِ ٱلرَّحِيمِ Hello {' '} World! مَٰنِ ٱلرَّحِيمِ مَٰنِ ٱلرَّحِيمِ مَٰنِ ٱلرَّحِيمِ Hello Hello مَٰنِ ٱلرَّحِيمِ ); } export default [ { title: 'Empty Text', name: 'emptyText', render: EmptyTextExample, }, { title: 'TextInlineViewsExample', name: 'inlineViews', description: 'Shows how inline views are rendered when text is subject to alignment.', expect: 'The red box should align correctly with the rest of the text.', render: TextInlineViewsExample, }, { title: 'RTL and Inline Views', name: 'rtlInlineViews', description: 'RTL Script and Layout Direction, Combined with Inline Views', scrollable: true, render: RtlAndInlineViewsExample, }, { title: 'numberOfLines with onTextLayout', name: 'numberOfLinesLayout', description: 'Shows the behavior of numberOfLines and ellipsizeMode in conjunction with the onTextLayout event', scrollable: true, render: NumberOfLinesTextLayoutExample, }, ] as $ReadOnlyArray;