chore(posts): migration to kamel

This commit is contained in:
Diego Beraldin 2023-07-31 22:58:34 +02:00
parent 561f0661b2
commit ffb88d8a5d
25 changed files with 62 additions and 62 deletions

View File

@ -31,11 +31,11 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}

View File

@ -14,7 +14,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -13,7 +13,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}
@ -40,7 +40,7 @@ kotlin {
implementation(compose.material3)
api(libs.markdown)
implementation(libs.compose.imageloader)
implementation(libs.kamel)
}
}
val commonTest by getting {

View File

@ -1,12 +1,12 @@
package com.github.diegoberaldin.raccoonforlemmy.core_md.compose.elements
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import com.github.diegoberaldin.raccoonforlemmy.core_md.utils.findChildOfTypeRecursive
import com.seiko.imageloader.rememberImagePainter
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource
import org.intellij.markdown.MarkdownElementTypes
import org.intellij.markdown.ast.ASTNode
import org.intellij.markdown.ast.getTextInNode
@ -17,10 +17,10 @@ internal fun MarkdownImage(content: String, node: ASTNode) {
node.findChildOfTypeRecursive(MarkdownElementTypes.LINK_DESTINATION)?.getTextInNode(content)
?.toString() ?: return
val painter = rememberImagePainter(link)
Image(
painter = painter,
contentDescription = "Markdown Image", // TODO
val painterResource = asyncPainterResource(data = link)
KamelImage(
resource = painterResource,
contentDescription = null,
contentScale = ContentScale.FillWidth,
modifier = Modifier.fillMaxWidth()
)

View File

@ -1,6 +1,5 @@
package com.github.diegoberaldin.raccoonforlemmy.core_md.compose.elements
import androidx.compose.foundation.Image
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.InlineTextContent
@ -22,7 +21,8 @@ import com.github.diegoberaldin.raccoonforlemmy.core_md.compose.LocalMarkdownTyp
import com.github.diegoberaldin.raccoonforlemmy.core_md.compose.LocalReferenceLinkHandler
import com.github.diegoberaldin.raccoonforlemmy.core_md.utils.TAG_IMAGE_URL
import com.github.diegoberaldin.raccoonforlemmy.core_md.utils.TAG_URL
import com.seiko.imageloader.rememberImagePainter
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource
@Composable
internal fun MarkdownText(
@ -67,10 +67,10 @@ internal fun MarkdownText(
PlaceholderVerticalAlign.Bottom
) // TODO, identify flexible scaling!
) { link ->
val painter = rememberImagePainter(link)
Image(
painter = painter,
contentDescription = "Image", // TODO
val painterResource = asyncPainterResource(data = link)
KamelImage(
resource = painterResource,
contentDescription = null,
contentScale = ContentScale.FillWidth,
modifier = Modifier.fillMaxWidth()
)

View File

@ -11,7 +11,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -11,7 +11,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -11,7 +11,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -11,7 +11,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}
@ -46,7 +46,7 @@ kotlin {
implementation(libs.voyager.navigator)
implementation(libs.voyager.tab)
implementation(libs.voyager.bottomsheet)
implementation(libs.compose.imageloader)
implementation(libs.kamel)
implementation(projects.resources)
implementation(projects.coreAppearance)

View File

@ -1,6 +1,5 @@
package com.github.diegoberaldin.raccoonforlemmy.feature_home.ui
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.runtime.Composable
@ -8,16 +7,17 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import com.github.diegoberaldin.raccoonforlemmy.data.PostModel
import com.seiko.imageloader.rememberImagePainter
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource
@Composable
internal fun PostCardImage(post: PostModel) {
val imageUrl = post.thumbnailUrl.orEmpty()
if (imageUrl.isNotEmpty()) {
val painter = rememberImagePainter(imageUrl)
Image(
val painterResource = asyncPainterResource(data = imageUrl)
KamelImage(
modifier = Modifier.fillMaxWidth().heightIn(min = 200.dp),
painter = painter,
resource = painterResource,
contentDescription = null,
contentScale = ContentScale.FillWidth,
)

View File

@ -1,6 +1,5 @@
package com.github.diegoberaldin.raccoonforlemmy.feature_home.ui
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.size
@ -15,7 +14,8 @@ import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import com.github.diegoberaldin.raccoonforlemmy.core_appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.data.PostModel
import com.seiko.imageloader.rememberImagePainter
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource
@Composable
internal fun PostCardSubtitle(post: PostModel) {
@ -33,11 +33,11 @@ internal fun PostCardSubtitle(post: PostModel) {
) {
if (communityName.isNotEmpty()) {
if (communityIcon.isNotEmpty()) {
val painter = rememberImagePainter(communityIcon)
Image(
val painterResource = asyncPainterResource(data = communityIcon)
KamelImage(
modifier = Modifier.size(iconSize)
.clip(RoundedCornerShape(iconSize / 2)),
painter = painter,
resource = painterResource,
contentDescription = null,
contentScale = ContentScale.FillBounds,
)
@ -60,11 +60,11 @@ internal fun PostCardSubtitle(post: PostModel) {
)
}
if (creatorAvatar.isNotEmpty()) {
val painter = rememberImagePainter(creatorAvatar)
Image(
val painterResource = asyncPainterResource(data = creatorAvatar)
KamelImage(
modifier = Modifier.size(iconSize)
.clip(RoundedCornerShape(iconSize / 2)),
painter = painter,
resource = painterResource,
contentDescription = null,
contentScale = ContentScale.FillBounds,
)

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}
@ -45,7 +45,9 @@ kotlin {
implementation(libs.voyager.navigator)
implementation(libs.voyager.tab)
implementation(libs.voyager.bottomsheet)
implementation(libs.compose.imageloader)
implementation(libs.kamel)
implementation(libs.ktor.cio)
implementation(libs.kamel)
implementation(projects.resources)
implementation(projects.coreArchitecture)

View File

@ -1,6 +1,5 @@
package com.github.diegoberaldin.raccoonforlemmy.feature_profile.ui
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
@ -16,15 +15,15 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import com.github.diegoberaldin.raccoonforlemmy.core_appearance.theme.CornerSize
import com.github.diegoberaldin.raccoonforlemmy.core_appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.data.UserCounterModel
import com.github.diegoberaldin.raccoonforlemmy.data.UserModel
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
import com.seiko.imageloader.rememberImagePainter
import dev.icerock.moko.resources.compose.stringResource
import io.kamel.image.KamelImage
import io.kamel.image.asyncPainterResource
@Composable
internal fun ProfileLoggedContent(
@ -34,29 +33,27 @@ internal fun ProfileLoggedContent(
) {
Column(
modifier = Modifier.fillMaxSize().padding(horizontal = Spacing.m),
verticalArrangement = Arrangement.spacedBy(Spacing.xs)
verticalArrangement = Arrangement.spacedBy(Spacing.xs),
horizontalAlignment = Alignment.CenterHorizontally,
) {
val avatar = user?.avatar.orEmpty()
if (avatar.isNotEmpty()) {
val painter = rememberImagePainter(avatar)
Image(
modifier = Modifier.size(50.dp)
val painterResource = asyncPainterResource(data = avatar)
KamelImage(
modifier = Modifier.size(100.dp)
.clip(RoundedCornerShape(CornerSize.m)),
painter = painter,
resource = painterResource,
contentDescription = null,
contentScale = ContentScale.FillBounds,
)
}
val name = user?.name.orEmpty()
Text(
modifier = Modifier.align(Alignment.CenterHorizontally),
text = name,
style = MaterialTheme.typography.titleLarge
)
Spacer(modifier = Modifier.height(Spacing.l))
Button(
modifier = Modifier.align(Alignment.CenterHorizontally),
onClick = {
onLogout()
},

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -12,7 +12,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -3,7 +3,7 @@ androidx_activity_compose = "1.7.2"
androidx_crypto = "1.0.0"
android_gradle = "7.4.2"
compose = "1.4.3"
compose_imageloader = "1.6.0"
kamel = "0.7.1"
koin = "3.2.0"
kotlin = "1.8.20"
ksp = "1.8.20-1.0.11"
@ -20,7 +20,7 @@ voyager = "1.0.0-rc05"
androidx_activity_compose = { module = "androidx.activity:activity-compose", version.ref = "androidx.activity.compose" }
androidx_security_crypto = { module = "androidx.security:security-crypto", version.ref = "androidx.crypto" }
compose_imageloader = { module = "io.github.qdsfdhvh:image-loader", version.ref = "compose.imageloader" }
kamel = { module = "media.kamel:kamel-image", version.ref = "kamel" }
markdown = { module = "org.jetbrains:markdown", version.ref = "markdown" }
multiplatform_settings = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatform.settings" }
@ -29,6 +29,7 @@ koin_test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
koin_android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
ktor_serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
ktor_cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor_contentnegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor_logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor_json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }

View File

@ -13,7 +13,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}

View File

@ -10,7 +10,7 @@ kotlin {
android {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "17"
}
}
}