chore: remove unused Markdown dependencies

This commit is contained in:
Harsh Shandilya 2023-06-09 20:00:44 +05:30
parent 2dc8eae861
commit 40cd7758dc
No known key found for this signature in database
8 changed files with 2 additions and 142 deletions

View file

@ -70,7 +70,6 @@ dependencies {
implementation(libs.androidx.profileinstaller)
implementation(libs.androidx.work.runtime.ktx)
implementation(libs.coil)
implementation(libs.copydown)
implementation(libs.crux)
implementation(libs.dagger)
implementation(libs.jsoup)

View file

@ -1,20 +0,0 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.injection
import com.deliveryhero.whetstone.app.ApplicationScope
import com.squareup.anvil.annotations.ContributesTo
import dagger.Binds
import dagger.Module
import dev.msfjarvis.claw.android.ui.util.HTMLConverterImpl
import dev.msfjarvis.claw.common.comments.HTMLConverter
@Module
@ContributesTo(ApplicationScope::class)
interface HTMLConverterModule {
@Binds fun HTMLConverterImpl.bind(): HTMLConverter
}

View file

@ -1,21 +0,0 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android.ui.util
import androidx.compose.runtime.Stable
import dev.msfjarvis.claw.common.comments.HTMLConverter
import io.github.furstenheim.CopyDown
import javax.inject.Inject
@Stable
class HTMLConverterImpl @Inject constructor() : HTMLConverter {
private val copydown = CopyDown()
override fun convertHTMLToMarkdown(html: String): String {
return copydown.convert(html)
}
}

View file

@ -43,9 +43,6 @@ dependencies {
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.ui.text)
implementation(libs.coil.compose)
implementation(libs.compose.richtext.markdown)
implementation(libs.compose.richtext.material3)
implementation(libs.compose.richtext.ui)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.napier)

View file

@ -1,15 +0,0 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.comments
import androidx.compose.runtime.Stable
/** Defines a contract to convert strings of HTML to Markdown. */
@Stable
fun interface HTMLConverter {
fun convertHTMLToMarkdown(html: String): String
}

View file

@ -1,5 +1,5 @@
/*
* Copyright © 2021-2022 Harsh Shandilya.
* Copyright © 2021-2023 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
@ -17,7 +17,6 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.ProvidedValue
import androidx.compose.ui.platform.LocalContext
import com.halilibo.richtext.ui.material3.SetupMaterial3RichText
private val LightThemeColors =
lightColorScheme(
@ -98,8 +97,6 @@ fun LobstersTheme(
else -> if (darkTheme) DarkThemeColors else LightThemeColors
}
CompositionLocalProvider(*providedValues) {
MaterialTheme(colorScheme = colorScheme, typography = AppTypography) {
SetupMaterial3RichText { content() }
}
MaterialTheme(colorScheme = colorScheme, typography = AppTypography, content = content)
}
}

View file

@ -1,72 +0,0 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.common.ui
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextDecoration
import com.halilibo.richtext.markdown.Markdown
import com.halilibo.richtext.ui.RichText
import com.halilibo.richtext.ui.RichTextStyle
import com.halilibo.richtext.ui.string.RichTextStringStyle
import dev.msfjarvis.claw.common.theme.LobstersTheme
import dev.msfjarvis.claw.common.ui.preview.ThemePreviews
@Composable
internal fun ThemedRichText(
text: String,
modifier: Modifier = Modifier,
) {
val linkStyle =
SpanStyle(
background = MaterialTheme.colorScheme.surfaceVariant,
color = MaterialTheme.colorScheme.onSurface,
fontWeight = FontWeight.Bold,
textDecoration = TextDecoration.Underline,
)
val stringStyle = RichTextStringStyle.Default.copy(linkStyle = linkStyle)
CompositionLocalProvider(
LocalTextStyle provides MaterialTheme.typography.bodyLarge,
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
) {
RichText(
modifier = modifier,
style = RichTextStyle.Default.copy(stringStyle = stringStyle),
) {
Markdown(text)
}
}
}
@ThemePreviews
@Composable
internal fun ThemedRichTextPreview() {
val text =
"""
### Heading
This is a paragraph body
```
This is a code block
```
This is an `inline code block`
[This is a link](https://github.com/msfjarvis/compose-lobsters)
![Image](https://avatars.githubusercontent.com/u/13348378?v=4)
"""
.trimIndent()
LobstersTheme { ThemedRichText(text = text) }
}

View file

@ -9,7 +9,6 @@ dagger = "2.46.1"
junit = "5.9.3"
kotlin = "1.8.10"
retrofit = "2.9.0"
richtext = "0.16.0"
sentry-sdk = "6.22.0"
serialization = "1.5.1"
sqldelight = "2.0.0-rc01"
@ -57,10 +56,6 @@ build-vcu = "nl.littlerobots.version-catalog-update:nl.littlerobots.version-cata
build-versions = "com.github.ben-manes:gradle-versions-plugin:0.47.0"
coil = { module = "io.coil-kt:coil", version.ref = "coil" }
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
compose-richtext-markdown = { module = "com.halilibo.compose-richtext:richtext-commonmark", version.ref = "richtext" }
compose-richtext-material3 = { module = "com.halilibo.compose-richtext:richtext-ui-material3", version.ref = "richtext" }
compose-richtext-ui = { module = "com.halilibo.compose-richtext:richtext-ui", version.ref = "richtext" }
copydown = "io.github.furstenheim:copy_down:1.1"
crux = "com.chimbori.crux:crux:3.12.0"
dagger = { module = "com.google.dagger:dagger", version.ref = "dagger" }
dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }