Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Image Loader and Implement Naive content templating #109

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

digitalbuddha
Copy link
Contributor

@digitalbuddha digitalbuddha commented Dec 21, 2022

📑 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

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

🧪 How can this PR been tested?

🧾 Tasks Remaining: (List of tasks remaining to be implemented)

  • What is remaining to be implemented in this PR? Mention a list of them

🖼️ Screenshots (if applicable):

Screen Shot 2022-12-21 at 9 53 25 AM

digitalbuddha and others added 20 commits December 20, 2022 10:31
…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>
@digitalbuddha digitalbuddha marked this pull request as draft December 21, 2022 14:53
@digitalbuddha
Copy link
Contributor Author

this is stacked on my other diff

Copy link
Member

@crocsandcoffee crocsandcoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

modifier = modifier
)
}
KamelImage(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this truly KMP support or just JVM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just jvm, but ios has native support afaik

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, we should follow-up on this and change this to an expect/actual

contentDescription = "User avatar",
modifier = modifier.width(48.dp).clip(RoundedCornerShape(5.dp))
modifier = modifier.width(48.dp).height(48.dp).clip(RoundedCornerShape(5.dp))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifier.size(48.dp) should already set it for both dimensions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@@ -45,6 +48,9 @@ kotlin {
implementation(compose.material)
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this also JVM only? Maybe we can use this as a resource and roll our own purely kotlin parser which also supports iOS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup yup jvm only. I think this gets us off the ground and agree we would need something more robust in future

@@ -26,6 +26,13 @@ android {
targetCompatibility = JavaVersion.VERSION_11
}

packagingOptions {
exclude ("META-INF/DEPENDENCIES")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always wondering what this stuff is for? Is this generated or you had to add manually to fix a build issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually to fix a build issue. My naive understanding is that multiple libraries have the same metadata file name and clash

Base automatically changed from miken/feedData to main December 21, 2022 17:11
# 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
@digitalbuddha digitalbuddha changed the title Miken/feed UI Update Image Loader and Implement Naive content templating Dec 21, 2022
@digitalbuddha digitalbuddha marked this pull request as ready for review December 21, 2022 17:57

val content = htmlDocument(newlineReplace)

val body = content.body {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@crocsandcoffee crocsandcoffee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

dependencies {
implementation(kotlin("test"))
implementation(libs.org.jetbrains.kotlin.test.common)
implementation(libs.org.jetbrains.kotlin.test.annotations.common)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting here looks off, but it could be because I'm on my phone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ran spotless apply just in case

modifier = modifier
)
}
KamelImage(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

implementation(projects.data.persistence)
implementation(projects.data.repository)
implementation(projects.domain.timeline)
implementation(libs.io.insert.koin.core)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The koin dependency is already added at line 19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants