Commit Graph

3 Commits

Author SHA1 Message Date
Joshua Gross 0556e86d09 TextInput: support modifying TextInputs with multiple Fragments (Cxx side)
Summary:
Support for modifying AndroidTextInputs with multiple Fragments was added on the Java side in a previous diff.

This diff adds support on the C++ side for the following scenario:

A <TextInput> is initially given contents via children <Text> notes, which represents multiple Fragments (that could have different TextAttributes like color, font size, backgroundcolor, etc). The Android EditText view must get this initial data, and then all updates after that on the Android side must flow to C++ so that the C++ ShadowNode can perform layout and measurement with up-to-date data.

At the same time, the <TextInput> node could be updated from the JS side. All else equal, this would cause the native Android EditText to be replaced with the old, original contents of the <TextInput> that may not have been updated at all from the JS side.

To mitigate this, we keep track of two AttributedStrings with Fragments on the C++ side: the AttributedString representing the values coming from <TextInput> children, from JS (`treeAttributedString`); and the AttributedString representing the current value the user is interacting with (`attributedString`). If the children from JS don't change, we don't update Android/Java with that AttributedString. If the children from JS do change, we overwrite any user input with the tree from JS.

Changelog: [Internal]

Reviewed By: shergin, mdvacca

Differential Revision: D18785976

fbshipit-source-id: a1f3a935e02379cabca8ab62a39cb3c0cf3fbca5
2019-12-05 13:20:30 -08:00
Joshua Gross da5ea0215a AndroidTextInput: keep track of mostRecentEventCount in C++ State
Summary:
Keep track of AndroidTextInput's mostRecentEventCount in C++ State.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18672368

fbshipit-source-id: ea7a635629050a6d4957cbcef6ec0bda5faaad9a
2019-11-27 12:55:47 -08:00
Joshua Gross 07580f0f7e AndroidTextInput: support proper measuring of AndroidTextInput text, and displaying attributed strings
Summary:
Use a similar setup as Paragraph, and support in Fabric:

- Correct measuring of AndroidTextInput
- Correct display of AndroidTextInput attributed strings

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D18669957

fbshipit-source-id: 84e0ad8021c9edf8219e0c673c781276ca29787d
2019-11-27 12:55:46 -08:00