Update Image Loader and Implement Naive content templating #109
Update Image Loader and Implement Naive content templating #109digitalbuddha wants to merge 33 commits intomainfrom
Conversation
…twork/MastodonApiKtor.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…/repository/timeline/HomeTimelineRepository.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…n/DefaultRootComponent.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…imelineContent.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…imelineContent.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…composables/SignedInRootContent.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…imelineContent.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
…twork/MastodonApiKtor.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
|
this is stacked on my other diff |
blvckcoded
left a comment
There was a problem hiding this comment.
Just did a quick early review for it..
This looks really good! I think you should be able to remove the platform specific logic for loading urls now, I didn't see that code delete in this PR.
ui/signed-out/src/commonMain/kotlin/social/androiddev/signedout/landing/LandingContent.kt
Show resolved
Hide resolved
ui/common/src/commonMain/kotlin/social/androiddev/common/utils/HtmlParser.kt
Outdated
Show resolved
Hide resolved
ui/common/src/commonMain/kotlin/social/androiddev/common/utils/HtmlParser.kt
Outdated
Show resolved
Hide resolved
ui/common/src/commonMain/kotlin/social/androiddev/common/utils/HtmlParser.kt
Outdated
Show resolved
Hide resolved
ui/common/src/commonMain/kotlin/social/androiddev/common/utils/AsyncImage.kt
Outdated
Show resolved
Hide resolved
| modifier = modifier | ||
| ) | ||
| } | ||
| KamelImage( |
There was a problem hiding this comment.
Is this truly KMP support or just JVM?
There was a problem hiding this comment.
just jvm, but ios has native support afaik
There was a problem hiding this comment.
Cool, we should follow-up on this and change this to an expect/actual
| url = url, | ||
| contentDescription = "User avatar", | ||
| modifier = modifier.width(48.dp).clip(RoundedCornerShape(5.dp)) | ||
| modifier = modifier.width(48.dp).height(48.dp).clip(RoundedCornerShape(5.dp)) |
There was a problem hiding this comment.
modifier.size(48.dp) should already set it for both dimensions
There was a problem hiding this comment.
for some reason it was not rendering the avatars after switching to the new library. We can play with it later but yeah it never assumed a height
| api(libs.com.arkivanov.decompose) | ||
| api(libs.com.arkivanov.decompose.extensions.compose.jetbrains) | ||
| implementation("com.alialbaali.kamel:kamel-image:0.4.0") | ||
| implementation("it.skrape:skrapeit:1.2.2") |
There was a problem hiding this comment.
Is this also JVM only? Maybe we can use this as a resource and roll our own purely kotlin parser which also supports iOS
There was a problem hiding this comment.
yup yup jvm only. I think this gets us off the ground and agree we would need something more robust in future
| } | ||
|
|
||
| packagingOptions { | ||
| exclude ("META-INF/DEPENDENCIES") |
There was a problem hiding this comment.
I've always wondering what this stuff is for? Is this generated or you had to add manually to fix a build issue?
There was a problem hiding this comment.
Manually to fix a build issue. My naive understanding is that multiple libraries have the same metadata file name and clash
20026c0 to
3efb36e
Compare
# Conflicts: # app-android/build.gradle.kts # data/network/build.gradle.kts # data/network/src/commonMain/kotlin/social/androiddev/common/network/model/Status.kt # data/persistence/build.gradle.kts # data/repository/build.gradle.kts # data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/ModelMappers.kt # data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/RealHomeTimelineRepository.kt # data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/TimelineFetcher.kt # data/repository/src/commonMain/kotlin/social/androiddev/common/repository/timeline/TimelineSourceOfTruth.kt # data/repository/src/commonTest/kotlin/social/androiddev/common/repository/timeline/RealHomeTimelineRepositoryTest.kt # data/repository/src/commonTest/kotlin/social/androiddev/common/repository/timeline/fixtures/TestFixtures.kt # di/build.gradle.kts # domain/authentication/build.gradle.kts # domain/timeline/build.gradle.kts # domain/timeline/src/commonMain/kotlin/social/androiddev/domain/timeline/model/StatusLocal.kt # gradle/libs.versions.toml # ui/common/build.gradle.kts # ui/signed-in/build.gradle.kts # ui/timeline/build.gradle.kts # ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/TootContent.kt # ui/timeline/src/commonMain/kotlin/social/androiddev/timeline/navigation/TimelineViewModel.kt
|
|
||
| val content = htmlDocument(newlineReplace) | ||
|
|
||
| val body = content.body { |
There was a problem hiding this comment.
At this point, the only thing we are using skrape for is to get the paragraph body without any other tags and then for getting the list of links.
We can hand roll that logic ourselves and target ios
...onTest/kotlin/social/androiddev/common/repository/timeline/RealHomeTimelineRepositoryTest.kt
Outdated
Show resolved
Hide resolved
| dependencies { | ||
| implementation(kotlin("test")) | ||
| implementation(libs.org.jetbrains.kotlin.test.common) | ||
| implementation(libs.org.jetbrains.kotlin.test.annotations.common) |
There was a problem hiding this comment.
Formatting here looks off, but it could be because I'm on my phone
There was a problem hiding this comment.
ran spotless apply just in case
| modifier = modifier | ||
| ) | ||
| } | ||
| KamelImage( |
There was a problem hiding this comment.
Cool, we should follow-up on this and change this to an expect/actual
| * Takes a String reciever of html text | ||
| * converts it to an annotated string of text and links | ||
| */ | ||
| fun String.renderHtml(): AnnotatedString { |
There was a problem hiding this comment.
This probably should be either moved to the ViewModel itself and not a public API, or renamed to something that is more descriptive. something like
fun String.extractTootContentFromHtml()
There was a problem hiding this comment.
renamed to extractContentFromMicroFormat
When looking at Tusky, I noticed there are a few places where we get this type of text (profile and server about is another)
Going to leave as a utility for now
ui/signed-in/build.gradle.kts
Outdated
| implementation(projects.data.persistence) | ||
| implementation(projects.data.repository) | ||
| implementation(projects.domain.timeline) | ||
| implementation(libs.io.insert.koin.core) |
There was a problem hiding this comment.
The koin dependency is already added at line 19.
…/repository/timeline/RealHomeTimelineRepositoryTest.kt Co-authored-by: Omid Ghenatnevi <O.Ghenatnevi@gmail.com>
📑 What does this PR do?
Adds an image loading library
Adds a html parsing library
displays the avatar
parses content html and displays as annotated string with links in blue
✅ Checklist
🧪 How can this PR been tested?
🧾 Tasks Remaining: (List of tasks remaining to be implemented)
🖼️ Screenshots (if applicable):