Comments (11)
I managed to prototype this feature on both iOS and Android. It's a proof-of-concept of respective platforms' possibilities, in tiny Swift/Kotlin native apps.
Both platforms resisted, but it was possible to achieve the desired effect on both of them in a surprisingly analogous manner.
To support left/right padding, it was necessary to inject artificial characters into the NSAttributedString
/ Spannable
and later style at appropriate places to actually give them the desired bounding box (width). It's nearly for sure necessary on iOS and might be necessary on Android.
To support spanning across multiple lines, on both platforms, it was necessary to override some new (from React Native's perspective) APIs. On iOS it was necessary to subclass NSLayoutManager
and NSLayoutManagerDelegate
, on Android it was necessary to subclass TextView.onDraw
.
@NickGerleman What's the next step here? Should I file a PR with a formal API proposal? Should I file a separate one for each new feature, or one joint one, or maybe only fillLineGap
requires a proposal PR and the others can be considered "adding missing functionality"?
from discussions-and-proposals.
The first PR is slowly getting closer to being merged (🎉), but it's not the end of our quest. It's just the beginning.
I want to start organizing the next steps.
First topic I would like to raise is modelling the new styles on the "core" (ReactCommon
) level.
Currently, we have AttributedString
, modeling a list of text fragments with denormalized style:
As I see it, what's necessary is to adjust it to a list of spans, which would hold styles like background color, border and padding. The rest of text styles could be kept in fragments. A span would contain a list of fragments.
This assumes we don't want to support span nesting, at least initially.
What do you think about this? Is it a reasonable model?
from discussions-and-proposals.
@NickGerleman What do you think about this? I took much effort to sketch this idea in a clear way, also ensuring it fits well into the existing React Native ecosystem. I hope this proposal can be considered serious and achievable.
I'm tagging you because we already had an opportunity to work on the React Native Text
subsystem and I really appreciate all the feedback you gave me then. If you don't have time right now to look at this, it would be awesome if you gave some hints on how can I get some eyes on this proposal.
from discussions-and-proposals.
I think a prop like fillLineGap
is reasonable, and extra CSS properties on nested text make sense. The most significant challenge may be that we are constrained by what is allowed by the platforms text drawing system.
Right now, these are flattened into a single stream of rich text characters drawn by the platform's underlying text system. On Android, you do get a Paint
instance for text spans, where you can do some pretty custom things.
RN does allow views inline in text as well. This is akin to an element formatted with inline-flex
, and any view styling can be added to it. But this will not line-break, and acts differently from the goal here.
from discussions-and-proposals.
Please feel free to make PRs for these, preferably as granular as possible. I have context to review the Android implementation, and can try to flag someone to look at the iOS one.
from discussions-and-proposals.
@NickGerleman I was asking about feature proposal PRs in this repo (React Native: Discussions and Proposals), did you also mean that? So far this is an issue.
from discussions-and-proposals.
@NickGerleman @cortinico I opened a few small PRs, trying (maybe naively) to ask Meta engineers who (somewhat) recently worked on the surrounding code. I hoped it could somehow parallelize the process.
This is mostly minor refactoring which makes the diff of the later changes more reviewer-friendly. I would hope to merge this in less than a month.
from discussions-and-proposals.
Also, could I get my own issue in the React Native repo for tracking this project?
from discussions-and-proposals.
could I get my own issue in the React Native repo for tracking this project
Sure feel free to open an issue an I can assign it to you
from discussions-and-proposals.
I have only access to the templates. Should I abuse one of them?
from discussions-and-proposals.
from discussions-and-proposals.
Related Issues (20)
- [Web] Avoid react updates on each animation frame HOT 1
- Android - Disable context menu for TextInput component HOT 1
- Merge dynamic link library HOT 6
- Import image like React js HOT 2
- how can i use `threadsafe.h` from JSI?
- Improve error messages
- WebTransport support in RN
- is there a way to specify "Debug server host & port for device" in the command line at startup. HOT 2
- [iOS][Information] App store submissions will require a privacy manifest and signature for hermes HOT 1
- Meta Quest 2D app support
- Navigation between native to react-native Android HOT 1
- Custom Background Colour for Modal Display
- Add support for Custom Rotors in React Native
- Add support of hyphenationFactor and languageIdentifier properties for <Text> in iOs 15+ HOT 1
- react-navigation@4 support in [email protected] HOT 1
- Improved error messages and also a question/comment about fetch
- ScrollViewStickyHeader should be exported from react-native
- [Question] Why ReactInstanceManager needs to be initialized on main thread? HOT 2
- [Proposal] Enhance Linking API for File-Based App Launches on iOS
- ScrollView Indicator style prop missing for Android
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discussions-and-proposals.