jonataslaw / readmore

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

Add custom styling and interactions for mentions, hashtags, and URLs #54

Closed maRci002 closed 6 months ago

maRci002 commented 6 months ago

closes #53

closes #42

https://github.com/jonataslaw/readmore/assets/8436039/f821568d-69ee-4ad3-a074-b5607b4ca463

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

Summary

This pull request introduces the ability to apply custom styling and define tap actions for special text elements such as mentions, hashtags, and URLs within the ReadMoreText widget. By leveraging a flexible annotation system, developers can now enhance the interactivity and visual appeal of text content, providing a richer user experience.

Features

Implementation Details

Example Usage

ReadMoreText(
  'This is a sample text with a #hashtag, a mention <@123>, and a URL: https://example.com.',
  annotations: [
    Annotation(
      regExp: RegExp(r'<@(\d+)>'),
      spanBuilder: ({required String text, TextStyle? textStyle}) => TextSpan(
        text: 'User123',
        style: textStyle?.copyWith(color: Colors.blue),
        recognizer: TapGestureRecognizer()..onTap = () { /* Navigate to user profile */ },
      ),
    ),
    // Additional annotations for hashtags and URLs...
  ],
)
jonataslaw commented 6 months ago

It is awesome!!! Thank you for your contribution!

maRci002 commented 6 months ago

Should I update the changelog?

There are some breaking changes:

jonataslaw commented 6 months ago

That would be amazing! I will upload the new version to pub.dev today Thanks for your effort

maRci002 commented 6 months ago

I think there aren't any breaking changes:

Soon I will update PR

jonataslaw commented 6 months ago

LGTM

maRci002 commented 6 months ago

I am going to push one more commit to update the README, Changelog, and the flagship video. The code is ok which was merged.