2000calories / flutter_easy_rich_text

The EasyRichText widget provides an easy way to use RichText.
https://pub.dev/packages/easy_rich_text
MIT License
79 stars 34 forks source link

iOS issues when tapping on tel and when telephone is at the end of the line #26

Closed manuel-escola closed 2 years ago

manuel-escola commented 2 years ago

I am facing the following issue:

I want to tap on a telephone URL. It works on Android but not on iPhone. I thought the issue was initially related to the empty spaces between digits, so I tried to change a part of your code to:

case 'tel':
        tapGestureRecognizer = TapGestureRecognizer()
          ..onTap = () {
            _launchURL("tel:${str.replaceAll(' ', '')}"); // replaceAll was added
          };
        break;

This fixes almost all the issues on iPhone. Something similar could also be done for web and email, if necessary.

However, there still is one issues that needs to be addressed.

When a new line is started, the end of the previous line should mark the end of a telephone number (if there is one at the end of the line and there is no punctuation.

The following examples work fine: "My phone 078 123 45 67. \n\n 434 434 44" "My phone 078 123 45 67. 434 434 44" "My phone 078 123 45 67 434 434 44"

However, the following one doesn't work correctly (the second phone number can be correctly tapped, but not the first one): "My phone 078 123 45 67 \n\n 434 434 44"

2000calories commented 2 years ago

I do not have a iphone to test the issue. I hope the following information can help you.

Here is the regular expression pattern used for tel. static String telPattern = "[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s/0-9]{5,11}";

You can use a custom pattern that fit your need.

    EasyRichTextPattern(
      //targetString: EasyRegexPattern.telPattern,
      targetString: customPattern
      urlType: 'tel',
      style: TextStyle(
        decoration: TextDecoration.underline,
      ),
    ),
2000calories commented 2 years ago

Request pulled and published v1.0.2