fixed wrong left padding in the books with different and sometimes wrong inner structure
This commit is contained in:
1 parent
65925f2a07
commit
3e83185e4f
6 files changed
+204
-10
No files matched your search
@@ -118,7 +118,7 @@ internal fun ContinuousBookReader(
|
||||
val hyphenation = remember { HyphenationRegistry() }
|
||||
val scope = rememberCoroutineScope()
|
||||
val textLineMetricsByItem = remember(contentPlan) { mutableStateMapOf<Int, TextLineMetrics>() }
|
||||
val contentPadding = PaddingValues(top=6.dp, bottom = 6.dp, start = 0.dp, end = 6.dp)
|
||||
val contentPadding = PaddingValues(top=6.dp, bottom = 6.dp, start = 4.dp, end = 6.dp)
|
||||
val userScrollConnection = remember(onUserScroll) {
|
||||
object : NestedScrollConnection {
|
||||
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
|
||||
@@ -1346,12 +1346,12 @@ internal fun buildReaderContentPlan(book: Fb2Book): ReaderContentPlan {
|
||||
epigraph.textAuthors.forEach { addTextSentences(itemIndex, it) }
|
||||
}
|
||||
|
||||
fun addSection(section: Fb2Section, depth: Int) {
|
||||
fun addSection(section: Fb2Section, readerDepth: Int) {
|
||||
if (section.title.isNullOrBlank()) {
|
||||
elements += ReaderElement.SectionSeparator
|
||||
} else {
|
||||
val itemIndex = elements.size
|
||||
elements += ReaderElement.SectionTitle(section.title!!, depth)
|
||||
elements += ReaderElement.SectionTitle(section.title!!, readerDepth)
|
||||
sentences += ReadAloudSentence(
|
||||
index = sentences.size,
|
||||
itemIndex = itemIndex,
|
||||
@@ -1363,18 +1363,19 @@ internal fun buildReaderContentPlan(book: Fb2Book): ReaderContentPlan {
|
||||
)
|
||||
pendingPauseBeforeMillis = 0L
|
||||
}
|
||||
section.readableBlocks().forEach { block ->
|
||||
val blocks = section.readableBlocks()
|
||||
blocks.forEach { block ->
|
||||
val itemIndex = elements.size
|
||||
when (block) {
|
||||
Fb2Block.EmptyLine -> elements += ReaderElement.FixedSpacer(16)
|
||||
is Fb2Block.Image -> elements += ReaderElement.BookImage(block.image)
|
||||
is Fb2Block.Paragraph -> {
|
||||
addTextSentences(itemIndex, block.content)
|
||||
elements += ReaderElement.Paragraph(block.content, depth)
|
||||
elements += ReaderElement.Paragraph(block.content, readerDepth)
|
||||
}
|
||||
is Fb2Block.Poem -> {
|
||||
addPoemSentences(itemIndex, block.poem)
|
||||
elements += ReaderElement.Poem(block.poem, depth)
|
||||
elements += ReaderElement.Poem(block.poem, readerDepth)
|
||||
}
|
||||
is Fb2Block.Subtitle -> {
|
||||
addTextSentences(
|
||||
@@ -1387,15 +1388,16 @@ internal fun buildReaderContentPlan(book: Fb2Book): ReaderContentPlan {
|
||||
}
|
||||
is Fb2Block.Epigraph -> {
|
||||
addEpigraphSentences(itemIndex, block.epigraph)
|
||||
elements += ReaderElement.Epigraph(block.epigraph, depth)
|
||||
elements += ReaderElement.Epigraph(block.epigraph, readerDepth)
|
||||
}
|
||||
is Fb2Block.Cite -> {
|
||||
addCiteSentences(itemIndex, block.cite)
|
||||
elements += ReaderElement.Cite(block.cite, depth)
|
||||
elements += ReaderElement.Cite(block.cite, readerDepth)
|
||||
}
|
||||
}
|
||||
}
|
||||
section.sections.forEach { addSection(it, depth + 1) }
|
||||
val childDepth = if (blocks.isEmpty()) readerDepth else readerDepth + 1
|
||||
section.sections.forEach { addSection(it, childDepth) }
|
||||
}
|
||||
|
||||
elements += ReaderElement.Cover
|
||||
|
||||
Reference in new issue
Block a user