Squashed commit of the following: commit 9d9c46ced116079add8ae1beaed854b38962d608 Author: Paul Frazee <pfrazee@gmail.com> Date: Tue Jan 23 14:12:32 2024 -0800 Fix reference error on the web build commit 1981621c5b6f2b63b3e3875b68721161487d7df0 Merge:cda4fe4a0d9b6954Author: Paul Frazee <pfrazee@gmail.com> Date: Tue Jan 23 12:43:51 2024 -0800 Merge branch 'feat/selectable-text' of https://github.com/haileyok/social-app into haileyok-feat/selectable-text commit0d9b695447Merge:3c381f94f1a7a571Author: Hailey <153161762+haileyok@users.noreply.github.com> Date: Fri Jan 19 16:42:13 2024 -0800 Merge branch 'main' into feat/selectable-text commit3c381f9470Merge:f9510156fb596e7fAuthor: Hailey <153161762+haileyok@users.noreply.github.com> Date: Thu Jan 18 23:48:10 2024 -0800 Merge branch 'main' into feat/selectable-text commitf951015637Author: Hailey <me@haileyok.com> Date: Thu Jan 18 23:46:25 2024 -0800 update readme commitaa9b8b06edAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 23:37:49 2024 -0800 calculate line height commit9fe479630cAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 23:19:31 2024 -0800 improve height calculation, render on prop changes commit209caffa7dAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 22:53:08 2024 -0800 presses commit384c8ec3a8Author: Hailey <me@haileyok.com> Date: Thu Jan 18 21:57:56 2024 -0800 line break mode commitadfcf05fe4Author: Hailey <me@haileyok.com> Date: Thu Jan 18 21:50:21 2024 -0800 onTextLayout event commite9ba104e6fAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 21:34:35 2024 -0800 better naming commite335f5ab7fAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 21:31:38 2024 -0800 remove android commit9e197934baAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 21:28:28 2024 -0800 remove expo module commit99882c7e39Author: Hailey <me@haileyok.com> Date: Thu Jan 18 21:27:43 2024 -0800 handle presses commit18f818649eAuthor: Hailey <me@haileyok.com> Date: Thu Jan 18 21:14:38 2024 -0800 make use of rctshadowview commit7134e1106eAuthor: Hailey <me@haileyok.com> Date: Wed Jan 17 20:38:39 2024 -0800 stop unnecessary layouts, resize container before setting text commit340b84f053Author: Hailey <me@haileyok.com> Date: Wed Jan 17 11:17:36 2024 -0800 handle prop changes for both children and root views commitd906fe4fcfAuthor: Hailey <me@haileyok.com> Date: Tue Jan 16 18:42:22 2024 -0800 handle onpress better commitb6b0964168Author: Hailey <me@haileyok.com> Date: Tue Jan 16 16:57:31 2024 -0800 resolve animation issue, animate alt text expansion commitdaedd1f671Author: Hailey <me@haileyok.com> Date: Tue Jan 16 15:47:24 2024 -0800 move getChildren to didMoveToWindow commit87d44e4b57Author: Hailey <me@haileyok.com> Date: Mon Jan 15 18:48:36 2024 -0800 simplify getPressed commitd92584bad7Author: Hailey <me@haileyok.com> Date: Mon Jan 15 17:56:43 2024 -0800 just more cleanup commitd39f7a937dAuthor: Hailey <me@haileyok.com> Date: Mon Jan 15 17:03:19 2024 -0800 remove unnecessary property for gesture recognizer commita35513a1d2Author: Hailey <me@haileyok.com> Date: Mon Jan 15 16:55:36 2024 -0800 remove debug line commit788956aa01Author: Hailey <me@haileyok.com> Date: Mon Jan 15 16:33:44 2024 -0800 typo commita3ba6e7825Author: Hailey <me@haileyok.com> Date: Mon Jan 15 13:42:25 2024 -0800 make alt text selectable commite5472a13daAuthor: Hailey <me@haileyok.com> Date: Mon Jan 15 05:27:15 2024 -0800 re-render on numberOfLines change commit9f5b7602c1Author: Hailey <me@haileyok.com> Date: Mon Jan 15 04:57:35 2024 -0800 more implementations commitaa96bba066Author: Hailey <me@haileyok.com> Date: Mon Jan 15 03:12:43 2024 -0800 merge main in what are you doing there? go away fix recognizer to clear selected text on tap remove jank/hacks update readme remove android stuff (?) don't remove clipped subview on android for selection enable selection of alt text add numberOfLines properly apply container styles handle both selection and expand press events in alt text far better implementation revert link changes revert lightbox changes for now fix file name commitec8c05f3f0Merge:2435a25212a0ceeeAuthor: Hailey <me@haileyok.com> Date: Fri Jan 12 23:41:10 2024 -0800 Merge branch 'main' into feat/selectable-text # Conflicts: # src/view/com/util/Link.tsx commit2435a25257Author: Hailey <me@haileyok.com> Date: Fri Jan 12 23:30:13 2024 -0800 cleanup commitfdf75927f6Author: Hailey <me@haileyok.com> Date: Fri Jan 12 23:25:23 2024 -0800 remove debug commit36d8cd82efAuthor: Hailey <me@haileyok.com> Date: Fri Jan 12 23:25:17 2024 -0800 reset text selection on text update commitb8f7bc23c2Author: Hailey <me@haileyok.com> Date: Fri Jan 12 23:24:43 2024 -0800 use textkit 1 commit5216464458Author: Hailey <me@haileyok.com> Date: Fri Jan 12 22:50:15 2024 -0800 properly handle link press events commit2802902c69Author: Hailey <me@haileyok.com> Date: Fri Jan 12 22:49:47 2024 -0800 modify Link so that we can create the TextLink press handler outside commit860610e63aAuthor: Hailey <me@haileyok.com> Date: Fri Jan 12 19:17:51 2024 -0800 always make sure we use the latest styles commit7f05d0141bAuthor: Hailey <me@haileyok.com> Date: Fri Jan 12 16:57:08 2024 -0800 update readme with tech info commitb8318446a3Author: Hailey <me@haileyok.com> Date: Fri Jan 12 16:34:35 2024 -0800 remove all uitextview padding commit0f0b6aa131Author: Hailey <me@haileyok.com> Date: Fri Jan 12 16:34:28 2024 -0800 cleanup imports commitc9f0064836Author: Hailey <me@haileyok.com> Date: Fri Jan 12 16:18:08 2024 -0800 update interface commit7dcac644baAuthor: Hailey <me@haileyok.com> Date: Fri Jan 12 16:13:49 2024 -0800 remove useless struct commit5174744213Author: Hailey <me@haileyok.com> Date: Fri Jan 12 16:13:34 2024 -0800 adjust deps commitce8b9ed62bAuthor: Hailey <me@haileyok.com> Date: Thu Jan 11 22:15:50 2024 -0800 add readme, update info commit33c6e3b15cAuthor: Hailey <me@haileyok.com> Date: Thu Jan 11 22:04:53 2024 -0800 remove unnecessary android/web stuff commitfbca531bdfAuthor: Hailey <me@haileyok.com> Date: Thu Jan 11 22:02:30 2024 -0800 simplify cast of string.index to int before i forget commit648552eafbAuthor: Hailey <me@haileyok.com> Date: Thu Jan 11 02:01:20 2024 -0800 wip commitc6d2e54923Author: Hailey <me@haileyok.com> Date: Thu Jan 11 00:38:47 2024 -0800 selectable text experiment
React Native UITextView
Drop in replacement for <Text> that renders a UITextView, support selection and native translation features on iOS.
Installation
In this project, no installation is required. The pod will be installed automatically during a pod install.
In another project, clone the repo and copy the modules/react-native-ui-text-view directory to your own project
directory. Afterward, run pod install.
Usage
Replace the outermost <Text> with <UITextView>. Styles and press events should be handled the same way they would
with <Text>. Both <UITextView> and <Text> are supported as children of the root <UITextView>.
Technical
React Native's Text component allows for "infinite" nesting of further Text components. To make a true "drop-in",
we want to do the same thing.
To achieve this, we first need to handle determining if we are dealing with an ancestor or root UITextView component.
We can implement similar logic to the Text component see Text.js.
We create a context that contains a boolean to tell us if we have already rendered the root UITextView. We also store
the root styles so that we can apply those styles if the ancestor UITextViews have not overwritten those styles.
All of our children are placed into RNUITextView, which is the main native view that will display the iOS UITextView.
We next map each child into the view. We have to be careful here to check if the child's children prop is a string. If
it is, that means we have encountered what was once an RN Text component. RN doesn't let us pass plain text as
children outside of Text, so we instead just pass the text into the text prop on RNUITextViewChild. We continue
down the tree, until we run out of children.
On the native side, we make use of the shadow view to calculate text container dimensions before the views are mounted.
We cannot simply set the UITextView text first, since React will not have properly measured the layout before this
occurs.
As for Text props, the following props are implemented:
- All accessibility props
allowFontScalingadjustsFontSizeToFitellipsizeModenumberOfLinesonLayoutonPressonTextLayoutselectable
All ViewStyle props will apply to the root UITextView. Individual children will respect these TextStyle styles:
colorfontSizefontStylefontWeightfontVariantletterSpacinglineHeighttextDecorationLine