Optimize the content styles of articles
This commit is contained in:
parent
66094f8075
commit
5867186751
|
@ -238,7 +238,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
withComposableStyle(
|
withComposableStyle(
|
||||||
style = { h5Style().toSpanStyle() }
|
style = { h5Style().toSpanStyle() }
|
||||||
) {
|
) {
|
||||||
append(element.text())
|
append("\n${element.text()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
withComposableStyle(
|
withComposableStyle(
|
||||||
style = { h5Style().toSpanStyle() }
|
style = { h5Style().toSpanStyle() }
|
||||||
) {
|
) {
|
||||||
append(element.text())
|
append("\n${element.text()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
withComposableStyle(
|
withComposableStyle(
|
||||||
style = { h5Style().toSpanStyle() }
|
style = { h5Style().toSpanStyle() }
|
||||||
) {
|
) {
|
||||||
append(element.text())
|
append("\n${element.text()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
withComposableStyle(
|
withComposableStyle(
|
||||||
style = { h5Style().toSpanStyle() }
|
style = { h5Style().toSpanStyle() }
|
||||||
) {
|
) {
|
||||||
append(element.text())
|
append("\n${element.text()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
withComposableStyle(
|
withComposableStyle(
|
||||||
style = { h5Style().toSpanStyle() }
|
style = { h5Style().toSpanStyle() }
|
||||||
) {
|
) {
|
||||||
append(element.text())
|
append("\n${element.text()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
withComposableStyle(
|
withComposableStyle(
|
||||||
style = { h5Style().toSpanStyle() }
|
style = { h5Style().toSpanStyle() }
|
||||||
) {
|
) {
|
||||||
append(element.text())
|
append("\n${element.text()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,6 +442,7 @@ private fun TextComposer.appendTextChildren(
|
||||||
// .padding(horizontal = PADDING_HORIZONTAL.dp)
|
// .padding(horizontal = PADDING_HORIZONTAL.dp)
|
||||||
.width(MAX_CONTENT_WIDTH.dp)
|
.width(MAX_CONTENT_WIDTH.dp)
|
||||||
) {
|
) {
|
||||||
|
Spacer(modifier = Modifier.height(PADDING_HORIZONTAL.dp))
|
||||||
DisableSelection {
|
DisableSelection {
|
||||||
BoxWithConstraints(
|
BoxWithConstraints(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
@ -466,7 +467,11 @@ private fun TextComposer.appendTextChildren(
|
||||||
) {
|
) {
|
||||||
val imageSize = maxImageSize()
|
val imageSize = maxImageSize()
|
||||||
RYAsyncImage(
|
RYAsyncImage(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = PADDING_HORIZONTAL.dp)
|
||||||
|
.clip(IMAGE_SHAPE)
|
||||||
|
.clickable { },
|
||||||
data = imageCandidates.getBestImageForMaxSize(
|
data = imageCandidates.getBestImageForMaxSize(
|
||||||
pixelDensity = pixelDensity(),
|
pixelDensity = pixelDensity(),
|
||||||
maxSize = imageSize,
|
maxSize = imageSize,
|
||||||
|
@ -593,10 +598,12 @@ private fun TextComposer.appendTextChildren(
|
||||||
) {
|
) {
|
||||||
RYAsyncImage(
|
RYAsyncImage(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = PADDING_HORIZONTAL.dp)
|
||||||
|
.clip(IMAGE_SHAPE)
|
||||||
.clickable {
|
.clickable {
|
||||||
onLinkClick(video.link)
|
onLinkClick(video.link)
|
||||||
}
|
},
|
||||||
.fillMaxWidth(),
|
|
||||||
data = video.imageUrl,
|
data = video.imageUrl,
|
||||||
size = maxImageSize(),
|
size = maxImageSize(),
|
||||||
contentDescription = stringResource(R.string.touch_to_play_video),
|
contentDescription = stringResource(R.string.touch_to_play_video),
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package me.ash.reader.ui.component.reader
|
package me.ash.reader.ui.component.reader
|
||||||
|
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
@ -27,12 +28,14 @@ import androidx.compose.ui.text.SpanStyle
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
import androidx.compose.ui.text.font.FontFamily
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
import androidx.compose.ui.text.style.TextDecoration
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import me.ash.reader.ui.ext.alphaLN
|
import me.ash.reader.ui.ext.alphaLN
|
||||||
|
|
||||||
const val PADDING_HORIZONTAL = 24.0
|
const val PADDING_HORIZONTAL = 24.0
|
||||||
const val MAX_CONTENT_WIDTH = 840.0
|
const val MAX_CONTENT_WIDTH = 840.0
|
||||||
|
val IMAGE_SHAPE = RoundedCornerShape(32.dp)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun bodyForeground(): Color =
|
fun bodyForeground(): Color =
|
||||||
|
@ -71,7 +74,7 @@ fun h4Style(): TextStyle =
|
||||||
@Composable
|
@Composable
|
||||||
fun h5Style(): TextStyle =
|
fun h5Style(): TextStyle =
|
||||||
MaterialTheme.typography.headlineSmall.copy(
|
MaterialTheme.typography.headlineSmall.copy(
|
||||||
color = bodyForeground()
|
color = bodyForeground(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -83,7 +86,8 @@ fun h6Style(): TextStyle =
|
||||||
@Composable
|
@Composable
|
||||||
fun captionStyle(): TextStyle =
|
fun captionStyle(): TextStyle =
|
||||||
MaterialTheme.typography.bodySmall.copy(
|
MaterialTheme.typography.bodySmall.copy(
|
||||||
color = bodyForeground().copy(alpha = 0.6f)
|
color = bodyForeground().copy(alpha = 0.6f),
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -79,7 +79,7 @@ class TextComposer(
|
||||||
) -> R
|
) -> R
|
||||||
): R {
|
): R {
|
||||||
val url = link ?: findClosestLink()
|
val url = link ?: findClosestLink()
|
||||||
builder.ensureDoubleNewline()
|
//builder.ensureDoubleNewline()
|
||||||
terminateCurrentText()
|
terminateCurrentText()
|
||||||
val onClick: (() -> Unit)? = if (url?.isNotBlank() == true) {
|
val onClick: (() -> Unit)? = if (url?.isNotBlank() == true) {
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user