jonataslaw / readmore

A Flutter plugin than allow expand and collapse text dynamically
MIT License
257 stars 79 forks source link

Enhanced styling and interaction support for mentions, hashtags, and URLs #53

Closed maRci002 closed 6 months ago

maRci002 commented 6 months ago

Issue Description

Summary

I propose adding enhanced styling and interaction capabilities for specific text patterns within ReadMoreText, such as mentions, hashtags, and URLs. This feature would allow developers to customize the appearance of these elements and define custom actions when they are tapped, such as navigating to a user's profile when a mention is clicked.

Use Case

In many applications, text content includes special elements like mentions (<@userId>), hashtags (#topic), and URLs that users expect to interact with. For example, tapping on a mention might navigate to that user's profile page, and clicking a hashtag could show related content. Additionally, these elements often require distinct styling to stand out from the surrounding text, signaling to users that they are interactive.

Proposed Solution

Introduce a mechanism to define custom styles and tap actions for mentions, hashtags, and URLs within the ReadMoreText widget. This could be achieved through a list of Annotation objects (or a similar construct) where each annotation includes:

This approach would not only enhance the visual differentiation of these special text elements but also enable developers to implement interactive behaviors, enhancing user engagement with the content.

Handling Modified Data

An important aspect of this feature is handling cases where the displayed text is modified, such as converting a mention from <@userId> to a readable username (e.g., UserA). The solution should gracefully support such transformations, ensuring that the custom styles and interactions are preserved.

Impact

Implementing this feature would significantly increase the utility and flexibility of the ReadMoreText widget, making it a more powerful tool for developers creating content-rich applications.

maRci002 commented 6 months ago

FYI, this is available in PR #54

https://github.com/jonataslaw/readmore/assets/8436039/3c7fc530-e550-4636-8de7-367cfe6ba9bd