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 { compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_17
} }
kotlinOptions { kotlinOptions {
jvmTarget = "1.8" jvmTarget = "17"
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ androidx_activity_compose = "1.7.2"
androidx_crypto = "1.0.0" androidx_crypto = "1.0.0"
android_gradle = "7.4.2" android_gradle = "7.4.2"
compose = "1.4.3" compose = "1.4.3"
compose_imageloader = "1.6.0" kamel = "0.7.1"
koin = "3.2.0" koin = "3.2.0"
kotlin = "1.8.20" kotlin = "1.8.20"
ksp = "1.8.20-1.0.11" 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_activity_compose = { module = "androidx.activity:activity-compose", version.ref = "androidx.activity.compose" }
androidx_security_crypto = { module = "androidx.security:security-crypto", version.ref = "androidx.crypto" } 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" } markdown = { module = "org.jetbrains:markdown", version.ref = "markdown" }
multiplatform_settings = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatform.settings" } 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" } koin_android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
ktor_serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" } 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_contentnegotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
ktor_logging = { module = "io.ktor:ktor-client-logging", 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" } ktor_json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }

View File

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

View File

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