Skip to content

Commit

Permalink
Add workaround for incorrect height on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekzaw committed Sep 19, 2024
1 parent 41af79a commit 99d9418
Show file tree
Hide file tree
Showing 5 changed files with 366 additions and 70 deletions.
28 changes: 0 additions & 28 deletions .yarn/patches/react-native-npm-0.75.2-bbf00acd5a.patch

This file was deleted.

16 changes: 8 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autoli
rootProject.name = 'LiveMarkdownExample'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
includeBuild('../node_modules/react-native') {
dependencySubstitution {
substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
}
}
// includeBuild('../node_modules/react-native') {
// dependencySubstitution {
// substitute(module("com.facebook.react:react-android")).using(project(":packages:react-native:ReactAndroid"))
// substitute(module("com.facebook.react:react-native")).using(project(":packages:react-native:ReactAndroid"))
// substitute(module("com.facebook.react:hermes-android")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
// substitute(module("com.facebook.react:hermes-engine")).using(project(":packages:react-native:ReactAndroid:hermes-engine"))
// }
// }
12 changes: 11 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import {Button, StyleSheet, Text, View} from 'react-native';
import Animated from 'react-native-reanimated';
import {
MarkdownTextInput,
parseExpensiMark,
Expand All @@ -8,8 +9,17 @@ import type {TextInput} from 'react-native';
import * as TEST_CONST from './testConstants';
import {PlatformInfo} from './PlatformInfo';

// This is a workaround that ensures that `ReanimatedCommitHook` is registered before `MarkdownCommitHook`.
// Otherwise, `ReanimatedCommitHook` will cause `AndroidTextInputShadowNode` to be cloned
// and `AndroidTextInputComponentDescriptor` will overwrite a custom `TextLayoutManager` with the default one,
// leading to incorrect height of `MarkdownTextInput` component.
// We don't need this workaround in New Expensify App since Reanimated is imported before Live Markdown.
console.log(Animated);

export default function App() {
const [value, setValue] = React.useState(TEST_CONST.EXAMPLE_CONTENT);
const [value, setValue] = React.useState(
['# Hello world', '# Hello world', '# Hello world'].join('\n'),
);
const [textColorState, setTextColorState] = React.useState(false);
const [linkColorState, setLinkColorState] = React.useState(false);
const [textFontSizeState, setTextFontSizeState] = React.useState(false);
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@
"@types/react": "17.0.21",
"link@^2.1.1": "patch:link@npm%3A2.1.1#./.yarn/patches/link-npm-2.1.1-1c9fea076e.patch",
"html-entities@^2.5.2": "patch:html-entities@npm%3A2.5.2#./.yarn/patches/html-entities-npm-2.5.2-0b6113e376.patch",
"html-entities@^2.3.2": "patch:html-entities@npm%3A2.5.2#./.yarn/patches/html-entities-npm-2.5.2-0b6113e376.patch",
"[email protected]": "patch:react-native@npm%3A0.75.2#./.yarn/patches/react-native-npm-0.75.2-bbf00acd5a.patch",
"[email protected]": "patch:react-native@npm%3A0.75.2#./.yarn/patches/react-native-npm-0.75.2-bbf00acd5a.patch"
"html-entities@^2.3.2": "patch:html-entities@npm%3A2.5.2#./.yarn/patches/html-entities-npm-2.5.2-0b6113e376.patch"
},
"peerDependencies": {
"expensify-common": ">=2.0.85",
Expand Down
Loading

0 comments on commit 99d9418

Please sign in to comment.