Skip to content

Commit

Permalink
Merge pull request #476 from qdsfdhvh/version_1.7.8
Browse files Browse the repository at this point in the history
Version 1.7.8
  • Loading branch information
qdsfdhvh authored Mar 3, 2024
2 parents 4864db2 + a4d1da1 commit 32fde02
Show file tree
Hide file tree
Showing 40 changed files with 467 additions and 218 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
+ api("io.github.qdsfdhvh:image-loader:1.7.7")
+ api("io.github.qdsfdhvh:image-loader:1.7.8")
// optional - Moko Resources Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.7.7")
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.7.8")
// optional - Blur Interceptor (only support bitmap)
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.7.7")
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.7.8")
}
}
val jvmMain by getting {
dependencies {
// optional - ImageIO Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.7.7")
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.7.8")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ kotlin {
implementation(compose.components.resources)

api(projects.imageLoaderSingleton)
implementation(projects.extension.blur)
implementation(projects.extension.composeResources)
// implementation(projects.extension.mokoResources)
implementation(projects.extension.ninePatch)
Expand Down Expand Up @@ -68,6 +67,7 @@ kotlin {
val noFilePickerMain by creating {
dependsOn(commonMain.get())
macosMain.get().dependsOn(this)
wasmJsMain.get().dependsOn(this)
}
}
targets.withType<KotlinNativeTarget>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,19 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material.FloatingActionButton
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.seiko.imageloader.demo.data.imageJsonData
import com.seiko.imageloader.demo.icon.rememberVisibility
import com.seiko.imageloader.demo.icon.rememberVisibilityOff
import com.seiko.imageloader.model.blur

@Composable
fun NetworkImagesScene(
onBack: () -> Unit,
) {
var showBlur by rememberSaveable { mutableStateOf(false) }
BackScene(
onBack = onBack,
title = { Text("Network") },
floatingActionButton = {
FloatingActionButton({ showBlur = !showBlur }) {
Icon(
if (showBlur) rememberVisibilityOff() else rememberVisibility(),
contentDescription = "show blur",
)
}
},
) { innerPadding ->
val images by rememberImageList(imageJsonData)
LazyVerticalGrid(
Expand All @@ -45,13 +27,6 @@ fun NetworkImagesScene(
items(images) { image ->
ImageItem(
data = image.imageUrl,
block = remember(showBlur) {
{
if (showBlur) {
blur(15)
}
}
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.seiko.imageloader.demo.util

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.js.Js

actual val httpEngine: HttpClientEngine
get() = Js.create()
1 change: 1 addition & 0 deletions app/intellij-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ repositories {
google()
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental")
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
Expand Down
40 changes: 40 additions & 0 deletions app/wasmJs/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
alias(libs.plugins.kotlin.multiplatform)
id("app.compose.multiplatform")
}

kotlin {
@Suppress("OPT_IN_USAGE")
wasmJs {
moduleName = "compose-imageloader-demo"
browser {
commonWebpackConfig {
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).copy(
open = mapOf(
"app" to mapOf(
"name" to "google chrome",
),
),
)
}
}
binaries.executable()
}
sourceSets {
commonMain {
dependencies {
implementation(projects.app.common)
implementation(compose.runtime)
}
}
}
}

compose.experimental {
web.application {
}
}

applyKtorWasmWorkaround(libs.versions.ktor.wasm.get())
33 changes: 33 additions & 0 deletions app/wasmJs/src/wasmJsMain/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.window.CanvasBasedWindow
import com.seiko.imageloader.ImageLoader
import com.seiko.imageloader.LocalImageLoader
import com.seiko.imageloader.component.setupDefaultComponents
import com.seiko.imageloader.demo.App
import com.seiko.imageloader.intercept.bitmapMemoryCacheConfig

@OptIn(ExperimentalComposeUiApi::class)
fun main() {
CanvasBasedWindow {
CompositionLocalProvider(
LocalImageLoader provides remember { generateImageLoader() },
) {
App()
}
}
}

private fun generateImageLoader(): ImageLoader {
return ImageLoader {
components {
setupDefaultComponents()
}
interceptor {
bitmapMemoryCacheConfig {
maxSize(32 * 1024 * 1024) // 32MB
}
}
}
}
11 changes: 11 additions & 0 deletions app/wasmJs/src/wasmJsMain/resources/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ComposeImageLoader(Wasm)</title>
</head>
<body>
<canvas id="ComposeTarget"></canvas>
<script src="wasmJs.js"></script>
</body>
</html>
13 changes: 6 additions & 7 deletions app/web/src/jsMain/resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
<head>
<meta charset="UTF-8">
<title>ComposeImageLoader</title>
<script src="skiko.js"> </script>
<link type="text/css" rel="stylesheet" href="styles.css" />
<script src="skiko.js"></script>
</head>
<body>
<div>
<canvas id="ComposeTarget" width="600" height="800"></canvas>
</div>
<script src="web.js"> </script>
<div>
<canvas id="ComposeTarget" width="800" height="600"></canvas>
</div>
<script src="web.js"></script>
</body>
</html>
</html>
8 changes: 0 additions & 8 deletions app/web/src/jsMain/resources/styles.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
macosArm64()
js(IR) {
browser()
nodejs()
}
@Suppress("OPT_IN_USAGE")
wasmJs {
browser {
// TODO: Fix wasm tests.
testTask {
enabled = false
}
}
}
@OptIn(ExperimentalKotlinGradlePluginApi::class)
applyHierarchyTemplate {
Expand All @@ -45,6 +53,7 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
}
}
withJs()
withWasm()
}
}
}
Expand All @@ -59,5 +68,6 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
}
}
configKotlin()
applyKtorWasmWorkaround(libs.findVersion("ktor-wasm").get().toString())
}
}
16 changes: 16 additions & 0 deletions build-logic/convention/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,19 @@ fun Project.configJava() {
targetCompatibility = JavaVersion.VERSION_11
}
}

// TODO: Remove when ktor 3.0.0 rc
// https://youtrack.jetbrains.com/issue/KTOR-5587
fun Project.applyKtorWasmWorkaround(version: String) {
configurations.all {
if (name.startsWith("wasmJs")) {
resolutionStrategy.eachDependency {
if (requested.group.startsWith("io.ktor") &&
requested.name.startsWith("ktor-")
) {
useVersion(version)
}
}
}
}
}
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ object ProjectVersion {
private const val monir = "7"

// backwards compatible bug fixes
private const val path = "7"
private const val path = "8"
const val version = "$major.$monir.$path"
}

Expand Down
10 changes: 5 additions & 5 deletions docs/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
+ api("io.github.qdsfdhvh:image-loader:1.7.7")
+ api("io.github.qdsfdhvh:image-loader:1.7.8")
// optional - Moko Resources Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.7.7")
+ api("io.github.qdsfdhvh:image-loader-extension-moko-resources:1.7.8")
// optional - Blur Interceptor (only support bitmap)
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.7.7")
+ api("io.github.qdsfdhvh:image-loader-extension-blur:1.7.8")
}
}
val jvmMain by getting {
dependencies {
// optional - ImageIO Decoder
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.7.7")
+ api("io.github.qdsfdhvh:image-loader-extension-imageio:1.7.8")
}
}
}
Expand All @@ -38,7 +38,7 @@ Copy the following snippets if you are using [gradle version catalog](https://do

```xml title="libs.versions.toml"
[versions]
image-loader = "1.7.7"
image-loader = "1.7.8"

[libraries]
image-loader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "image-loader" }
Expand Down
25 changes: 0 additions & 25 deletions extension/blur/build.gradle.kts

This file was deleted.

1 change: 0 additions & 1 deletion extension/blur/gradle.properties

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 32fde02

Please sign in to comment.