Add support for HTML in the detail page.
This commit is contained in:
parent
a559a24fa4
commit
4c6edb8a70
2 changed files with 22 additions and 3 deletions
|
|
@ -0,0 +1,19 @@
|
|||
package com.pixelized.biblib.ui.composable.common
|
||||
|
||||
import android.widget.TextView
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import androidx.core.text.HtmlCompat
|
||||
|
||||
@Composable
|
||||
fun HtmlText(
|
||||
html: String,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
AndroidView(
|
||||
modifier = modifier,
|
||||
factory = { context -> TextView(context) },
|
||||
update = { it.text = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_COMPACT) }
|
||||
)
|
||||
}
|
||||
|
|
@ -27,6 +27,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.pixelized.biblib.R
|
||||
import com.pixelized.biblib.ui.composable.common.HtmlText
|
||||
import com.pixelized.biblib.ui.composable.items.Image
|
||||
import com.pixelized.biblib.ui.data.BookUio
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
|
|
@ -135,9 +136,8 @@ fun DetailPage(book: BookUio) {
|
|||
label = book.series ?: "-",
|
||||
)
|
||||
}
|
||||
Text(
|
||||
style = typography.body1,
|
||||
text = book.description,
|
||||
HtmlText(
|
||||
html = book.description,
|
||||
modifier = Modifier.padding(bottom = 16.dp)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue