mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 19:57:04 +05:30
common: add NetworkImage composable
This commit is contained in:
parent
450d4836c5
commit
a8016391c9
5 changed files with 77 additions and 3 deletions
|
@ -27,13 +27,21 @@ kotlin {
|
||||||
api(compose.foundation)
|
api(compose.foundation)
|
||||||
api(compose.material)
|
api(compose.material)
|
||||||
api(projects.database)
|
api(projects.database)
|
||||||
implementation("com.alialbaali.kamel:kamel-image:0.2.1")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val commonTest by getting
|
val commonTest by getting
|
||||||
val androidMain by getting { dependencies { implementation(libs.androidx.browser) } }
|
val androidMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.androidx.browser)
|
||||||
|
implementation(libs.coil.compose)
|
||||||
|
}
|
||||||
|
}
|
||||||
val androidTest by getting { dependsOn(androidAndroidTestRelease) }
|
val androidTest by getting { dependsOn(androidAndroidTestRelease) }
|
||||||
val desktopMain by getting
|
val desktopMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.kamel.image)
|
||||||
|
}
|
||||||
|
}
|
||||||
val desktopTest by getting
|
val desktopTest by getting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package dev.msfjarvis.claw.common.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import coil.annotation.ExperimentalCoilApi
|
||||||
|
import coil.compose.rememberImagePainter
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@OptIn(ExperimentalCoilApi::class)
|
||||||
|
actual fun NetworkImage(
|
||||||
|
url: String,
|
||||||
|
contentDescription: String,
|
||||||
|
modifier: Modifier,
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = rememberImagePainter(
|
||||||
|
data = url,
|
||||||
|
builder = {
|
||||||
|
transformations(CircleCropTransformation())
|
||||||
|
crossfade(true)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
modifier = Modifier.then(modifier),
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package dev.msfjarvis.claw.common.ui
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
expect fun NetworkImage(
|
||||||
|
url: String,
|
||||||
|
contentDescription: String,
|
||||||
|
modifier: Modifier,
|
||||||
|
)
|
|
@ -0,0 +1,24 @@
|
||||||
|
package dev.msfjarvis.claw.common.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.requiredSize
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import io.kamel.image.KamelImage
|
||||||
|
import io.kamel.image.lazyImageResource
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
actual fun NetworkImage(
|
||||||
|
url: String,
|
||||||
|
contentDescription: String,
|
||||||
|
modifier: Modifier,
|
||||||
|
) {
|
||||||
|
KamelImage(
|
||||||
|
resource = lazyImageResource(url),
|
||||||
|
contentDescription = contentDescription,
|
||||||
|
modifier = Modifier.then(modifier),
|
||||||
|
crossfade = true,
|
||||||
|
)
|
||||||
|
}
|
|
@ -16,6 +16,9 @@ androidx-appcompat = "androidx.appcompat:appcompat:1.4.0-alpha03"
|
||||||
androidx-browser = "androidx.browser:browser:1.3.0"
|
androidx-browser = "androidx.browser:browser:1.3.0"
|
||||||
androidx-paging-compose = "androidx.paging:paging-compose:1.0.0-alpha12"
|
androidx-paging-compose = "androidx.paging:paging-compose:1.0.0-alpha12"
|
||||||
|
|
||||||
|
coil-compose = "io.coil-kt:coil-compose:1.3.2"
|
||||||
|
kamel-image = "com.alialbaali.kamel:kamel-image:0.2.1"
|
||||||
|
|
||||||
dagger-hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
|
dagger-hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
|
||||||
dagger-hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
|
dagger-hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
|
||||||
dagger-hilt-core = { module = "com.google.dagger:hilt-core", version.ref = "hilt" }
|
dagger-hilt-core = { module = "com.google.dagger:hilt-core", version.ref = "hilt" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue