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

@ -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) }
}