halilozercan / compose-richtext

A collection of Compose libraries for advanced text formatting and alternative display types.
https://halilibo.com/compose-richtext
Apache License 2.0
787 stars 65 forks source link

Support set picture fill max screen width, and support set call back when click picture #113

Closed equationl closed 1 year ago

equationl commented 1 year ago

From #108 #73 .

Add imgFillMaxWidth: Boolean to MarkdownParseOptions, which can make img fill parent's layout max width.

And add onImgClicked: ((String) -> Unit)? = null to RichTextScope.Markdown, which support call onImgClicked(url) when picture in MarkDown be clicked.

equationl commented 1 year ago

This is set imgFillMaxWidth = true:

s1

And this is false: s2

About click img:

              Markdown(
                content = sampleMarkdown,
                markdownParseOptions = markdownParseOptions,
                onLinkClicked = {
                  Toast.makeText(context, it, Toast.LENGTH_SHORT).show()
                },
                onImgClicked = {
                  Toast.makeText(context, it, Toast.LENGTH_SHORT).show()
                }
              )

s3

equationl commented 1 year ago

@halilozercan Hello, please check this PR, thanks

equationl commented 1 year ago

114 better than this