diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 14c774cb..4aa436ba 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1237,6 +1237,72 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga + - react-native-safe-area-context (4.11.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - react-native-safe-area-context/common (= 4.11.0) + - react-native-safe-area-context/fabric (= 4.11.0) + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga + - react-native-safe-area-context/common (4.11.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga + - react-native-safe-area-context/fabric (4.11.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - react-native-safe-area-context/common + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga - React-nativeconfig (0.75.2) - React-NativeModulesApple (0.75.2): - glog @@ -1497,7 +1563,49 @@ PODS: - React-logger (= 0.75.2) - React-perflogger (= 0.75.2) - React-utils (= 0.75.2) - - RNLiveMarkdown (0.1.169): + - RNCAsyncStorage (2.0.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga + - RNGestureHandler (2.20.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga + - RNLiveMarkdown (0.1.170): - DoubleConversion - glog - hermes-engine @@ -1517,9 +1625,9 @@ PODS: - ReactCodegen - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - - RNLiveMarkdown/newarch (= 0.1.169) + - RNLiveMarkdown/newarch (= 0.1.170) - Yoga - - RNLiveMarkdown/newarch (0.1.169): + - RNLiveMarkdown/newarch (0.1.170): - DoubleConversion - glog - hermes-engine @@ -1540,6 +1648,51 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga + - RNScreens (3.34.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-RCTImage + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - RNScreens/common (= 3.34.0) + - Yoga + - RNScreens/common (3.34.0): + - DoubleConversion + - glog + - hermes-engine + - RCT-Folly (= 2024.01.01.00) + - RCTRequired + - RCTTypeSafety + - React-Core + - React-debug + - React-Fabric + - React-featureflags + - React-graphics + - React-ImageManager + - React-NativeModulesApple + - React-RCTFabric + - React-RCTImage + - React-rendererdebug + - React-utils + - ReactCodegen + - ReactCommon/turbomodule/bridging + - ReactCommon/turbomodule/core + - Yoga - SocketRocket (0.7.0) - Yoga (0.0.0) @@ -1581,6 +1734,7 @@ DEPENDENCIES: - React-logger (from `../node_modules/react-native/ReactCommon/logger`) - React-Mapbuffer (from `../node_modules/react-native/ReactCommon`) - React-microtasksnativemodule (from `../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`) + - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) - React-nativeconfig (from `../node_modules/react-native/ReactCommon`) - React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`) - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) @@ -1607,7 +1761,10 @@ DEPENDENCIES: - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) - ReactCodegen (from `build/generated/ios`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)" + - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNLiveMarkdown (from `../..`) + - RNScreens (from `../node_modules/react-native-screens`) - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: @@ -1686,6 +1843,8 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon" React-microtasksnativemodule: :path: "../node_modules/react-native/ReactCommon/react/nativemodule/microtasks" + react-native-safe-area-context: + :path: "../node_modules/react-native-safe-area-context" React-nativeconfig: :path: "../node_modules/react-native/ReactCommon" React-NativeModulesApple: @@ -1738,8 +1897,14 @@ EXTERNAL SOURCES: :path: build/generated/ios ReactCommon: :path: "../node_modules/react-native/ReactCommon" + RNCAsyncStorage: + :path: "../node_modules/@react-native-async-storage/async-storage" + RNGestureHandler: + :path: "../node_modules/react-native-gesture-handler" RNLiveMarkdown: :path: "../.." + RNScreens: + :path: "../node_modules/react-native-screens" Yoga: :path: "../node_modules/react-native/ReactCommon/yoga" @@ -1779,6 +1944,7 @@ SPEC CHECKSUMS: React-logger: 8db32983d75dc2ad54f278f344ccb9b256e694fc React-Mapbuffer: 1c08607305558666fd16678b85ef135e455d5c96 React-microtasksnativemodule: f13f03163b6a5ec66665dfe80a0df4468bb766a6 + react-native-safe-area-context: f1fda705dfe14355f41933debb5932887e234cc5 React-nativeconfig: 57781b79e11d5af7573e6f77cbf1143b71802a6d React-NativeModulesApple: 7ff2e2cfb2e5fa5bdedcecf28ce37e696c6ef1e1 React-perflogger: 8a360ccf603de6ddbe9ff8f54383146d26e6c936 @@ -1805,7 +1971,10 @@ SPEC CHECKSUMS: React-utils: 81a715d9c0a2a49047e77a86f3a2247408540deb ReactCodegen: 60973d382704c793c605b9be0fc7f31cb279442f ReactCommon: 6ef348087d250257c44c0204461c03f036650e9b - RNLiveMarkdown: 00ab78496be2ae15a15a83f14ba732c01624f02c + RNCAsyncStorage: 597673c6086d359029afefef8fd5859f1f35ab87 + RNGestureHandler: c374c750a0a9bacd95f5c740d146ab9428549d6b + RNLiveMarkdown: d747d551a329f6ce0c066eeb1ef08480ce05d61b + RNScreens: de6e57426ba0e6cbc3fb5b4f496e7f08cb2773c2 SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 2a45d7e59592db061217551fd3bbe2dd993817ae diff --git a/example/package.json b/example/package.json index 6dd71838..91e7c9fb 100644 --- a/example/package.json +++ b/example/package.json @@ -9,8 +9,15 @@ "start": "react-native start" }, "dependencies": { + "@react-native-async-storage/async-storage": "^2.0.0", + "@react-navigation/native": "^6.1.18", + "@react-navigation/native-stack": "^6.11.0", + "@react-navigation/stack": "^6.4.1", "react": "18.3.1", - "react-native": "0.75.2" + "react-native": "0.75.2", + "react-native-gesture-handler": "^2.20.0", + "react-native-safe-area-context": "^4.11.0", + "react-native-screens": "^3.34.0" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/example/src/App.tsx b/example/src/App.tsx index d3d63426..9640bcc8 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,152 +1,247 @@ +import { + HeaderBackButton, + type HeaderBackButtonProps, +} from '@react-navigation/elements'; +import type { + NavigationProp, + NavigationState, + PathConfigMap, +} from '@react-navigation/native'; import * as React from 'react'; -import {Button, StyleSheet, Text, View} from 'react-native'; -import {MarkdownTextInput} from '@expensify/react-native-live-markdown'; -import type {TextInput} from 'react-native'; -import * as TEST_CONST from './testConstants'; -import {PlatformInfo} from './PlatformInfo'; +import { + ActivityIndicator, + FlatList, + Linking, + Platform, + Pressable, + ScrollView, + StyleSheet, + Text, + View, +} from 'react-native'; -export default function App() { - const [value, setValue] = React.useState(TEST_CONST.EXAMPLE_CONTENT); - const [textColorState, setTextColorState] = React.useState(false); - const [linkColorState, setLinkColorState] = React.useState(false); - const [textFontSizeState, setTextFontSizeState] = React.useState(false); - const [emojiFontSizeState, setEmojiFontSizeState] = React.useState(false); - const [selection, setSelection] = React.useState({start: 0, end: 0}); - - const style = React.useMemo(() => { - return { - color: textColorState ? 'gray' : 'black', - fontSize: textFontSizeState ? 15 : 20, - }; - }, [textColorState, textFontSizeState]); +import {NavigationContainer, useNavigation} from '@react-navigation/native'; - const markdownStyle = React.useMemo(() => { - return { - emoji: { - fontSize: emojiFontSizeState ? 15 : 20, - }, - link: { - color: linkColorState ? 'red' : 'blue', +import AsyncStorage from '@react-native-async-storage/async-storage'; +import { + createNativeStackNavigator, + type NativeStackNavigationProp, +} from '@react-navigation/native-stack'; +import { + createStackNavigator, + type StackNavigationProp, +} from '@react-navigation/stack'; +import {EXAMPLES} from './examples'; + +function noop() { + // do nothing +} + +type RootStackParamList = {[P in keyof typeof EXAMPLES]: undefined} & { + Home: undefined; +}; + +interface HomeScreenProps { + navigation: + | StackNavigationProp + | NativeStackNavigationProp; +} + +const EXAMPLES_NAMES = Object.keys(EXAMPLES); + +function HomeScreen({navigation}: HomeScreenProps) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [wasClicked, setWasClicked] = React.useState([]); + + return ( + ( + { + navigation.navigate(name); + if (!wasClicked.includes(name)) { + setTimeout(() => setWasClicked([...wasClicked, name]), 500); + } + }} + wasClicked={wasClicked.includes(name)} + /> + )} + renderScrollComponent={props => } + ItemSeparatorComponent={ItemSeparator} + style={styles.list} + /> + ); +} + +interface ItemProps { + icon?: string; + title: string; + onPress: () => void; + missingOnFabric?: boolean; + wasClicked?: boolean; +} + +function Item({icon, title, onPress, wasClicked}: ItemProps) { + return ( + + {icon && {icon + ' '}} + {title} + + ); +} + +function ItemSeparator() { + return ; +} + +const Stack = + Platform.OS === 'macos' + ? createStackNavigator() + : createNativeStackNavigator(); + +const linking = { + prefixes: [], + config: { + screens: EXAMPLES_NAMES.reduce>( + (acc, name) => { + acc[name] = name; + return acc; }, - }; - }, [emojiFontSizeState, linkColorState]); + {Home: ''}, + ), + }, +}; - // TODO: use MarkdownTextInput ref instead of TextInput ref - const ref = React.useRef(null); +function BackButton(props: HeaderBackButtonProps) { + const navigation = useNavigation>(); return ( - - - setSelection(e.nativeEvent.selection)} - selection={selection} - id={TEST_CONST.INPUT_ID} - maxLength={30000} - /> - {JSON.stringify(value)} -