Skip to content

Commit

Permalink
Merge branch 'main' into coil/kmp-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves authored Jun 30, 2024
2 parents 5ceb305 + 9560670 commit 9087649
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 144 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/publish-snapshot.yml

This file was deleted.

61 changes: 19 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,6 @@ You can see the use cases of this library in the repositories below:
- [skydoves/DisneyCompose](https://github.com/skydoves/disneycompose): 🧸 A demo Disney app using Jetpack Compose and Hilt based on modern Android tech-stacks and MVVM architecture.
- [skydoves/MovieCompose](https://github.com/skydoves/MovieCompose): 🎞 A demo movie app using Jetpack Compose and Hilt based on modern Android tech stacks. <br>

## SNAPSHOT

<details>
<summary>See how to import the snapshot</summary>

### Including the SNAPSHOT
[![Landscapist](https://img.shields.io/static/v1?label=snapshot&message=landscapist&logo=apache%20maven&color=C71A36)](https://oss.sonatype.org/content/repositories/snapshots/com/github/skydoves/landscapist/) <br>
Snapshots of the current development version of Landscapist are available, which track [the latest versions](https://oss.sonatype.org/content/repositories/snapshots/com/github/skydoves/landscapist/).

To import snapshot versions on your project, add the code snippet below on your gradle file:
```Gradle
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
```

Next, add the dependency below to your **module**'s `build.gradle` file:
```gradle
dependencies {
implementation "com.github.skydoves:landscapist-glide:2.3.2-SNAPSHOT"
}
```
</details>

<div class="header">
<a href="https://github.com/bumptech/glide" target="_blank"> <img src="https://user-images.githubusercontent.com/24237865/95545537-1bc15200-0a39-11eb-883d-644f564da5d3.png" align="left" width="4%" alt="Glide" /></a>
<h1>Glide</h1>
Expand All @@ -88,9 +64,10 @@ allprojects {
```

Next, add the dependency below to your **module**'s `build.gradle` file:

```gradle
dependencies {
implementation "com.github.skydoves:landscapist-glide:2.3.4"
implementation("com.github.skydoves:landscapist-glide:2.3.5")
}
```

Expand Down Expand Up @@ -202,7 +179,7 @@ Add the dependency below to your **module**'s `build.gradle` file:

```gradle
dependencies {
implementation "com.github.skydoves:landscapist-coil:$version"
implementation("com.github.skydoves:landscapist-coil:$version")
}
```

Expand Down Expand Up @@ -317,7 +294,7 @@ CoilImage(
Add the dependency below to your **module**'s `build.gradle` file:
```gradle
dependencies {
implementation "com.github.skydoves:landscapist-fresco:$version"
implementation("com.github.skydoves:landscapist-fresco:$version")
}
```
> **Note**: `Landscapist-Fresco` includes version `3.1.0` of Fresco. So please make sure your project is using the same Fresco version or exclude the Fresco dependency to adapt yours. Also, please make sure the Jetpack Compose version on the [release page](https://github.com/skydoves/Landscapist/releases).
Expand Down Expand Up @@ -409,7 +386,7 @@ Add the below dependency to your **module**'s `build.gradle` file.

```gradle
dependencies {
implementation "com.github.skydoves:landscapist-fresco-websupport:$version"
implementation("com.github.skydoves:landscapist-fresco-websupport:$version")
}
```

Expand Down Expand Up @@ -630,9 +607,9 @@ CompositionLocalProvider(LocalImageComponent provides component) {
The `landscapist-placeholder` package provides useful image plugins, such as loading & failure placeholder supports and shimmering animation.
To use placeholder supports, add the dependency below:

```groovy
```kotlin
dependencies {
implementation "com.github.skydoves:landscapist-placeholder:$version"
implementation("com.github.skydoves:landscapist-placeholder:$version")
}
```

Expand Down Expand Up @@ -718,9 +695,9 @@ component = rememberImageComponent {
The `landscapist-animation` package provides useful image plugins related to animations, such as crossfade and circular reveal animation.
To use animation supports, add the dependency below:

```groovy
```kotlin
dependencies {
implementation "com.github.skydoves:landscapist-animation:$version"
implementation("com.github.skydoves:landscapist-animation:$version")
}
```

Expand Down Expand Up @@ -773,9 +750,9 @@ GlideImage(
The `landscapist-transformation` package provides useful image transformation plugins, such as the blur effect.
To use transformation supports, add the dependency below:

```groovy
```kotlin
dependencies {
implementation "com.github.skydoves:landscapist-transformation:$version"
implementation("com.github.skydoves:landscapist-transformation:$version")
}
```

Expand All @@ -801,9 +778,9 @@ GlideImage( // CoilImage, FrescoImage also can be used.
The `landscapist-palette` package provides useful image plugins related to palette, such as extracting primary color sets.
To use palette supports, add the dependency below:

```groovy
```kotlin
dependencies {
implementation "com.github.skydoves:landscapist-palette:$version"
implementation("com.github.skydoves:landscapist-palette:$version")
}
```

Expand Down Expand Up @@ -867,16 +844,16 @@ GlideImage( // CoilImage, FrescoImage also can be used.

The landscapist Bill of Materials (BOM) lets you manage all of your landscapist library versions by specifying only the BOM’s version.

```groovy
```kotlin
dependencies {
// Import the landscapist BOM
implementation "com.github.skydoves:landscapist-bom:$version"
implementation("com.github.skydoves:landscapist-bom:$version")

// Import landscapist libraries
implementation "com.github.skydoves:landscapist-glide" // fresco or coil
implementation "com.github.skydoves:landscapist-placeholder"
implementation "com.github.skydoves:landscapist-palette"
implementation "com.github.skydoves:landscapist-transformation"
implementation("com.github.skydoves:landscapist-glide") // fresco or coil
implementation("com.github.skydoves:landscapist-placeholder")
implementation("com.github.skydoves:landscapist-palette")
implementation("com.github.skydoves:landscapist-transformation")
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.skydoves.benchmark.landscapist.app
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.facebook.drawee.backends.pipeline.Fresco
import com.skydoves.landscapist.fresco.websupport.FrescoWebImage
Expand All @@ -33,6 +34,6 @@ fun FrescoWebSupportProfiles() {
"24237865/75087936-5c1d9f80-553e-11ea-81d3-a912634dd8f7.jpg",
)
},
previewPlaceholder = R.drawable.poster,
previewPlaceholder = painterResource(id = R.drawable.poster),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ object Configuration {
const val minSdk24 = 24
const val majorVersion = 2
const val minorVersion = 3
const val patchVersion = 4
const val patchVersion = 5
const val versionName = "$majorVersion.$minorVersion.$patchVersion"
const val versionCode = 94
const val versionCode = 95
const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT"
const val artifactGroup = "com.github.skydoves"
}
4 changes: 2 additions & 2 deletions docs/glide/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Next, add the dependency below to your **module**'s `build.gradle` file:

```Groovy
dependencies {
implementation "com.github.skydoves:landscapist-glide:2.3.4"
implementation "com.github.skydoves:landscapist-glide:2.3.5"
}
```

=== "KTS"

```kotlin
dependencies {
implementation("com.github.skydoves:landscapist-glide:2.3.4")
implementation("com.github.skydoves:landscapist-glide:2.3.5")
}
```

Expand Down
45 changes: 0 additions & 45 deletions docs/snapshot.md

This file was deleted.

2 changes: 1 addition & 1 deletion fresco-websupport/api/fresco-websupport.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public final class com/skydoves/landscapist/fresco/websupport/FrescoWebImage {
public static final fun FrescoWebImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Ljava/lang/String;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;FLandroidx/compose/ui/graphics/ColorFilter;ILandroidx/compose/runtime/Composer;II)V
public static final fun FrescoWebImage (Lkotlin/jvm/functions/Function0;Landroidx/compose/ui/Modifier;Ljava/lang/String;Landroidx/compose/ui/Alignment;Landroidx/compose/ui/layout/ContentScale;FLandroidx/compose/ui/graphics/ColorFilter;Landroidx/compose/ui/graphics/painter/Painter;Landroidx/compose/runtime/Composer;II)V
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@

package com.skydoves.landscapist.fresco.websupport

import androidx.annotation.DrawableRes
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.DefaultAlpha
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder
import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.generic.GenericDraweeHierarchyInflater
import com.facebook.drawee.view.DraweeHolder
import com.skydoves.landscapist.constraints.constraint
import com.skydoves.landscapist.rememberDrawablePainter

/**
Expand Down Expand Up @@ -87,15 +88,15 @@ public fun FrescoWebImage(
modifier: Modifier = Modifier,
contentDescription: String? = null,
alignment: Alignment = Alignment.Center,
contentScale: ContentScale = ContentScale.Fit,
contentScale: ContentScale = ContentScale.Crop,
alpha: Float = DefaultAlpha,
colorFilter: ColorFilter? = null,
@DrawableRes previewPlaceholder: Int = 0,
previewPlaceholder: Painter? = null,
) {
if (LocalInspectionMode.current && previewPlaceholder != 0) {
if (LocalInspectionMode.current && previewPlaceholder != null) {
Image(
modifier = modifier,
painter = painterResource(id = previewPlaceholder),
painter = previewPlaceholder,
alignment = alignment,
contentScale = contentScale,
alpha = alpha,
Expand All @@ -106,16 +107,18 @@ public fun FrescoWebImage(
}

val context = LocalContext.current
val builder = controllerBuilder()
val hierarchy = GenericDraweeHierarchyInflater.inflateBuilder(context, null).build()
val holder: DraweeHolder<GenericDraweeHierarchy> = DraweeHolder.create(hierarchy, context)
controllerBuilder().oldController = holder.controller
holder.controller = controllerBuilder().build()
builder.oldController = holder.controller.apply { this?.contentDescription = contentDescription }
holder.hierarchy.setActualImageScaleType(getScaleType(contentScale))
holder.controller = builder.build()

val topLevelDrawable = holder.topLevelDrawable
Box(modifier = modifier) {
BoxWithConstraints(modifier = modifier) {
if (topLevelDrawable != null) {
Image(
modifier = modifier,
modifier = Modifier.constraint(this),
painter = rememberDrawablePainter(topLevelDrawable),
contentDescription = contentDescription,
alignment = alignment,
Expand All @@ -126,3 +129,15 @@ public fun FrescoWebImage(
}
}
}

private fun getScaleType(contentScale: ContentScale): ScalingUtils.ScaleType {
return when (contentScale) {
ContentScale.Crop -> ScalingUtils.ScaleType.CENTER_CROP
ContentScale.FillWidth -> ScalingUtils.ScaleType.FIT_X
ContentScale.FillHeight -> ScalingUtils.ScaleType.FIT_Y
ContentScale.FillBounds -> ScalingUtils.ScaleType.FIT_XY
ContentScale.Fit -> ScalingUtils.ScaleType.FIT_CENTER
ContentScale.Inside -> ScalingUtils.ScaleType.CENTER_INSIDE
else -> ScalingUtils.ScaleType.CENTER_CROP
}
}
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin = "2.0.0"
dokka = "1.9.20"
jvmTarget = "11"
nexusPlugin = "0.26.0"
nexusPlugin = "0.29.0"
kotlinxCoroutines = "1.8.1"
kotlinBinaryCompatibility = "0.14.0"
androidGradlePlugin = "8.4.2"
Expand All @@ -11,17 +11,17 @@ androidxMaterial = "1.12.0"
androidxComposeBom = "2024.06.00"
androidxComposeConstraintLayout = "1.0.1"
androidxCore = "1.13.1"
androidxTestRunner = "1.5.2"
androidxTestRules = "1.5.0"
androidxJunit = "1.1.5"
androidxTestRunner = "1.6.1"
androidxTestRules = "1.6.1"
androidxJunit = "1.2.1"
androidxMacroBenchmark = "1.3.0-beta01"
androidxProfileinstaller = "1.3.1"
androidxUiAutomator = "2.3.0"
jetbrains-compose = "1.6.11"
glide = "4.16.0"
fresco = "3.2.0"
coil = "2.6.0"
coil3 = "3.0.0-alpha06"
coil3 = "3.0.0-alpha07"
ktor = "2.3.11"
palette = "3.1.0"
hilt = "2.51.1"
Expand Down
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ docs_dir: docs
# Navigation
nav:
- 'Overview': index.md
- 'Snapshot': snapshot.md
- 'Glide':
- 'Overview': glide/overview.md
- 'Custom Options': glide/options.md
Expand Down

0 comments on commit 9087649

Please sign in to comment.