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

About support .svg or other format picture (like .gif) #121

Open equationl opened 1 year ago

equationl commented 1 year ago

In my project, I need to show .svg picture.

I can easy to edit like this to support:

Edit .\richtext-commonmark\src\androidMain\kotlin\com\halilibo\richtext\markdown\RemoteImage.kt :

val painter = rememberAsyncImagePainter(
  model = ImageRequest.Builder(LocalContext.current)
    .data(data = url)
    .size(Size.ORIGINAL)
    .crossfade(true)
    .build(),
  imageLoader = ImageLoader.Builder(LocalContext.current)
    .components {
      add(SvgDecoder.Factory())
    }
    .build()
)

I can using same way to show .gif, But it just for me.

Is there a way to make this library support optional? Cause not everyone need this.

alexispurslane commented 1 year ago

I really, really need SVG support for a project I'm working on, so I'd like this to be an option in the library as well. Especially since I can't figure out how to get gradle to build richtext as a subproject of my app

zayass commented 3 months ago

You can customize ImageLoader through internal coil mechanism without any changes in library

The singleton ImageLoader can be configured by implementing ImageLoaderFactory on your Application class.