linkify-text icon indicating copy to clipboard operation
linkify-text copied to clipboard

Handle normal click event

Open jamolkhon opened this issue 3 years ago • 0 comments

You can't handle non-link taps currently. This change will make this possible. Sorry, don't have time for PR.

Basically, you need to add an additional callback along with onLinkClick, and onClick block should be changed to this:

            val annotation = annotatedString.getStringAnnotations(
                start = offset,
                end = offset,
            ).firstOrNull()
            if (annotation != null) {
                if (linkEntire) {
                    onClickLink?.invoke(annotatedString.substring(annotation.start, annotation.end))
                } else {
                    uriHandler.openUri(annotation.item)
                    onClickLink?.invoke(annotatedString.substring(annotation.start, annotation.end))
                }
            } else {
                onClick?.invoke()
            }

jamolkhon avatar Aug 24 '22 09:08 jamolkhon