From c60950c0fde6db5a3f068d8897a23e483f1a211d Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 25 Sep 2020 12:44:46 +0100 Subject: [PATCH] Add Picasso to docs --- .gitignore | 2 ++ README.md | 13 +-------- build.gradle | 4 +++ generate_docs.sh | 6 +++- mkdocs.yml | 5 +++- picasso/README.md | 59 +++++++++++++++++---------------------- picasso/gradle.properties | 4 +-- 7 files changed, 43 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index bbedd8eeb..4d12cf501 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,8 @@ docs/index.md docs/contributing.md docs/coil.md docs/coil/ +docs/picasso.md +docs/picasso/ # Mkdocs temporary serving folder site *.bak \ No newline at end of file diff --git a/README.md b/README.md index 98893ac2e..96af2984e 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,11 @@ Accompanist is a group of libraries that contains some utilities which I've found myself copying around projects which use [Jetpack Compose][compose]. Currently, it contains: 🖼️ [Coil image loading composables](./coil/README.md) +🖼️ [Picasso image loading composables](./picasso/README.md) [Jetpack Compose][compose] is a fast-moving project and I'll be updating these libraries to match the latest tagged release as quickly as possible. Each [release listing](https://github.com/chrisbanes/accompanist/releases) will outline what version of Compose libraries it depends on. -## Download - -```groovy -repositories { - mavenCentral() -} - -dependencies { - implementation "dev.chrisbanes.accompanist:accompanist-coil:" -} -``` - ### Accompanist Snapshots Snapshots of the current development version of Accompanist are available, which track the latest commit. See [here](docs/using-snapshot-version.md) for more information. diff --git a/build.gradle b/build.gradle index 0c83abbf2..c61827327 100644 --- a/build.gradle +++ b/build.gradle @@ -141,6 +141,10 @@ subprojects { packageListUrl.set(new URL("file://$rootDir/package-list-coil-base")) } } + externalDocumentationLink { + url.set(new URL("https://square.github.io/picasso/2.x/picasso/")) + packageListUrl.set(new URL("https://square.github.io/picasso/2.x/picasso/package-list")) + } } } } diff --git a/generate_docs.sh b/generate_docs.sh index 1e30dc081..33664424f 100755 --- a/generate_docs.sh +++ b/generate_docs.sh @@ -22,9 +22,13 @@ sed -i.bak 's/images\/social.png/header.png/' docs/index.md cp coil/README.md docs/coil.md mkdir -p docs/coil cp coil/images/crossfade.gif docs/coil/crossfade.gif - sed -i.bak 's/images\/crossfade.gif/crossfade.gif/' docs/coil.md +cp picasso/README.md docs/picasso.md +mkdir -p docs/picasso +cp picasso/images/crossfade.gif docs/picasso/crossfade.gif +sed -i.bak 's/images\/crossfade.gif/crossfade.gif/' docs/picasso.md + # Convert docs/xxx.md links to just xxx/ sed -i.bak 's/docs\/\([a-zA-Z-]*\).md/\1/' docs/index.md diff --git a/mkdocs.yml b/mkdocs.yml index 8f41ec38a..5ca293c7e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,12 +13,15 @@ repo_url: 'https://github.com/chrisbanes/accompanist' nav: - 'Overview': index.md - 'Coil': coil.md + - 'Picasso': picasso.md - 'API': - 'Coil': api/coil/index.md + - 'Picasso': api/picasso/index.md + - 'Image Loading Core': api/imageloading-core/index.md - 'Snapshots': using-snapshot-version.md - 'Contributing': contributing.md - 'Maintainers': - - 'Update guide': updating.md + - 'Update guide': updating.md # Configuration theme: diff --git a/picasso/README.md b/picasso/README.md index 764b92bf4..38f19cc67 100644 --- a/picasso/README.md +++ b/picasso/README.md @@ -1,39 +1,38 @@ -# Jetpack Compose + Coil +# Jetpack Compose + Picasso -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.chrisbanes.accompanist/accompanist-coil/badge.svg)](https://search.maven.org/search?q=g:dev.chrisbanes.accompanist) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.chrisbanes.accompanist/accompanist-picasso/badge.svg)](https://search.maven.org/search?q=g:dev.chrisbanes.accompanist) -This library brings easy-to-use composable which can fetch and display images from external sources, such as network, using the [Coil][coil] image loading library. +This library brings easy-to-use composable which can fetch and display images from external sources, such as network, using the [Picasso][picasso] image loading library. +## `PicassoImage()` -## `CoilImage()` - -The primary API is via the `CoilImage()` functions. There are a number of function versions available. +The primary API is via the `PicassoImage()` functions. There are a 2 function versions available. The simplest usage is like so: ```kotlin -CoilImage( +PicassoImage( data = "https://loremflickr.com/300/300" ) ``` -This loads the `data` passed in with [Coil][coil], and then displays the resulting image using the standard `Image` composable. +This loads the `data` passed in with [Picasso][Picasso], and then displays the resulting image using the standard `Image` composable. -There is also a version of this function which accepts a Coil [`ImageRequest`](https://coil-kt.github.io/coil/image_requests/), allowing full customization of the request. This allows usage of things like (but not limited to) transformations: +There is also a version of this function which accepts a Picasso [`ImageRequest`](https://Picasso-kt.github.io/Picasso/image_requests/), allowing full customization of the request. This allows usage of things like (but not limited to) transformations: ```kotlin -CoilImage( - request = GetRequest.Builder(ContextAmbient.current) - .data("https://loremflickr.com/300/300") - .transformations(CircleCropTransformation()) - .build() +PicassoImage( + data = "https://loremflickr.com/300/300", + requestBuilder = { + rotate(90f) + } ) ``` It also provides optional content 'slots', allowing you to provide custom content to be displayed when the request is loading, and/or if the image request failed: ``` kotlin -CoilImage( +PicassoImage( data = "https://loremflickr.com/300/300", loading = { Box(Modifier.matchParentSize()) { @@ -56,10 +55,10 @@ There are two ways to enable the animation: ### `fadeIn` parameter -A `fadeIn: Boolean` parameter has been added to `CoilImage` (default: `false`). When enabled, a default fade-in animation will be used when the image is successfully loaded: +A `fadeIn: Boolean` parameter is available on `PicassoImage` (default: `false`). When enabled, a default fade-in animation will be used when the image is successfully loaded: ``` kotlin -CoilImage( +PicassoImage( data = "https://picsum.photos/300/300", fadeIn = true ) @@ -67,23 +66,23 @@ CoilImage( ### Custom layout -If you need more control over the animation, you can use the `content` composable version of `CoilImage`, to display the result in a `MaterialLoadingImage`: +If you need more control over the animation, you can use the `content` composable version of `PicassoImage`, to display the result in a `MaterialLoadingImage`: ``` kotlin -CoilImage( +PicassoImage( data = "https://random.image", ) { imageState -> when (imageState) { - is CoilImageState.Success -> { + is ImageLoadState.Success -> { MaterialLoadingImage( result = imageState, fadeInEnabled = true, fadeInDurationMs = 600, ) } - is CoilImageState.Error -> /* TODO */ - CoilImageState.Loading -> /* TODO */ - CoilImageState.Empty -> /* TODO */ + is ImageLoadState.Error -> /* TODO */ + ImageLoadState.Loading -> /* TODO */ + ImageLoadState.Empty -> /* TODO */ } } ``` @@ -96,20 +95,12 @@ repositories { } dependencies { - implementation "dev.chrisbanes.accompanist:accompanist-coil:" + implementation "dev.chrisbanes.accompanist:accompanist-picasso:" } ``` -## Limitations - -* Compose currently only supports static bitmap images, which means that we need to convert the resulting images to a `Bitmap`. This means that using things like Coil's [GIF support](https://coil-kt.github.io/coil/gifs/) will result in only the first frame being rendered, instead of animating. - Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap]. These are updated on every commit. -### What's the goal of the library? - -Eventually the goal is to upstream all of this functionality back to [Coil][coil]. [Jetpack Compose][compose]'s development is currently moving very fast, which means that there are frequent API changes between releases. For now, it makes sense to keep this as a seperately released library to track the latest Compose release. - [compose]: https://developer.android.com/jetpack/compose -[snap]: https://oss.sonatype.org/content/repositories/snapshots/dev/chrisbanes/accompanist/accompanist-coil/ -[coil]: https://github.com/coil-kt/coil +[snap]: https://oss.sonatype.org/content/repositories/snapshots/dev/chrisbanes/accompanist/accompanist-picasso/ +[picasso]: https://square.github.io/picasso/ diff --git a/picasso/gradle.properties b/picasso/gradle.properties index 9d7327d15..f307457c9 100644 --- a/picasso/gradle.properties +++ b/picasso/gradle.properties @@ -1,3 +1,3 @@ -POM_ARTIFACT_ID=accompanist-coil -POM_NAME=Accompanist Coil integration +POM_ARTIFACT_ID=accompanist-picasso +POM_NAME=Accompanist Picasso integration POM_PACKAGING=aar \ No newline at end of file