/** * 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 */ 'use strict'; import type {RNTesterModuleExample} from '../../types/RNTesterTypes'; import RNTexterText from '../../components/RNTesterText'; import React from 'react'; import { Alert, Animated, Button, I18nManager, Image, PixelRatio, Platform, StyleSheet, Switch, Text, TextInput, TouchableWithoutFeedback, View, } from 'react-native'; type RTLToggleState = {isRTL: boolean, ...}; type AnimationState = { toggleStatus: any, linear: Object, windowWidth: number, ... }; const SCALE = PixelRatio.get(); const IMAGE_DIMENSION = 100 * SCALE; const IMAGE_SIZE = [IMAGE_DIMENSION, IMAGE_DIMENSION]; const IS_RTL = I18nManager.isRTL; function ListItem(props: {imageSource: number}) { return ( Text Text Text Button ); } const TextAlignmentExample = withRTLState(({isRTL, setRTL, ...props}) => { return ( {/* $FlowFixMe[incompatible-type] Natural Inference rollout. See * https://fburl.com/workplace/6291gfvu */} Left-to-Right language without text alignment. {'\u0645\u0646 \u0627\u0644\u064A\u0645\u064A\u0646 ' + '\u0625\u0644\u0649 \u0627\u0644\u064A\u0633\u0627\u0631 ' + '\u0627\u0644\u0644\u063A\u0629 \u062F\u0648\u0646 ' + '\u0645\u062D\u0627\u0630\u0627\u0629 \u0627\u0644\u0646\u0635'} {'\u05DE\u05D9\u05DE\u05D9\u05DF \u05DC\u05E9\u05DE\u05D0\u05DC ' + '\u05D4\u05E9\u05E4\u05D4 \u05D1\u05DC\u05D9 ' + '\u05D9\u05D9\u05E9\u05D5\u05E8 \u05D8\u05E7\u05E1\u05D8'} ); }); const TextInputExample = withRTLState(({isRTL, setRTL, ...props}) => { return ( {/* $FlowFixMe[incompatible-type] Natural Inference rollout. See * https://fburl.com/workplace/6291gfvu */} LRT or RTL TextInput. ); }); const IconsExample = withRTLState(({isRTL, setRTL}) => { return ( {/* $FlowFixMe[incompatible-type] Natural Inference rollout. See * https://fburl.com/workplace/6291gfvu */} Without directional meaning With directional meaning ); }); function AnimationBlock(props: { imgStyle: {transform: Array<{scaleX: number} | {translateX: any}>}, onPress: (e: any) => void, }) { return ( ); } type RTLSwitcherComponentState = { isRTL: boolean, }; function withRTLState( Component: ({ isRTL: boolean, setRTL: (isRTL: boolean) => void, style?: any, }) => React.Node, ) { return class extends React.Component< {style?: any}, RTLSwitcherComponentState, > { /* $FlowFixMe[missing-local-annot] The type annotation(s) required by * Flow's LTI update could not be added via codemod */ constructor(...args) { super(...args); this.state = { isRTL: IS_RTL, }; } // $FlowFixMe[missing-local-annot] render() { const setRTL = (isRTL: boolean) => this.setState({isRTL: isRTL}); return ( ); } }; } const RTLToggler = ({ isRTL, setRTL, }: | {isRTL: any, setRTL: any} | {isRTL: boolean, setRTL: (isRTL: boolean) => void}) => { if (Platform.OS === 'android') { return {isRTL ? 'RTL' : 'LTR'}; } const toggleRTL = () => setRTL(!isRTL); return (