Skip to content

Commit

Permalink
Add Picasso to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes committed Sep 25, 2020
1 parent 5ba8890 commit c60950c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -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
13 changes: 1 addition & 12 deletions README.md
Expand Up @@ -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:<version>"
}
```

### 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.
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Expand Up @@ -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"))
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion generate_docs.sh
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion mkdocs.yml
Expand Up @@ -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:
Expand Down
59 changes: 25 additions & 34 deletions 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()) {
Expand All @@ -56,34 +55,34 @@ 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
)
```

### 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 */
}
}
```
Expand All @@ -96,20 +95,12 @@ repositories {
}
dependencies {
implementation "dev.chrisbanes.accompanist:accompanist-coil:<version>"
implementation "dev.chrisbanes.accompanist:accompanist-picasso:<version>"
}
```

## 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/
4 changes: 2 additions & 2 deletions 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

0 comments on commit c60950c

Please sign in to comment.