🛠️ More precise control over text entry visibility

This commit is contained in:
Acclorite 2025-01-08 13:20:52 +02:00
parent 092bbfd10b
commit b1f7e6176f
2 changed files with 52 additions and 47 deletions

View file

@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.displayCutout
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -150,13 +149,11 @@ fun ReaderLayout(
.coerceAtLeast(18.dp),
)
) {
itemsIndexed(
text, key = { index, _ -> index }
) { index, textEntry ->
for (entry in text) {
ReaderLayoutText(
activity = activity,
showMenu = showMenu,
entry = textEntry,
entry = entry,
fontFamily = fontFamily,
fontColor = fontColor,
lineHeight = lineHeight,

View file

@ -1,8 +1,9 @@
@file:Suppress("FunctionName")
package ua.acclorite.book_story.presentation.reader
import androidx.activity.ComponentActivity
import androidx.compose.foundation.lazy.LazyItemScope
import androidx.compose.runtime.Composable
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontStyle
@ -14,8 +15,7 @@ import ua.acclorite.book_story.domain.reader.ReaderText
import ua.acclorite.book_story.domain.reader.ReaderTextAlignment
import ua.acclorite.book_story.ui.reader.ReaderEvent
@Composable
fun LazyItemScope.ReaderLayoutText(
fun LazyListScope.ReaderLayoutText(
activity: ComponentActivity,
showMenu: Boolean,
entry: ReaderText,
@ -40,53 +40,61 @@ fun LazyItemScope.ReaderLayoutText(
) {
when (entry) {
is ReaderText.Image -> {
ReaderLayoutTextImage(
entry = entry,
sidePadding = sidePadding
)
item {
ReaderLayoutTextImage(
entry = entry,
sidePadding = sidePadding
)
}
}
is ReaderText.Separator -> {
ReaderLayoutTextSeparator(
sidePadding = sidePadding,
fontColor = fontColor
)
item {
ReaderLayoutTextSeparator(
sidePadding = sidePadding,
fontColor = fontColor
)
}
}
is ReaderText.Chapter -> {
ReaderLayoutTextChapter(
chapter = entry,
chapterTitleAlignment = chapterTitleAlignment,
fontColor = fontColor,
sidePadding = sidePadding,
highlightedReading = highlightedReading,
highlightedReadingThickness = highlightedReadingThickness
)
item {
ReaderLayoutTextChapter(
chapter = entry,
chapterTitleAlignment = chapterTitleAlignment,
fontColor = fontColor,
sidePadding = sidePadding,
highlightedReading = highlightedReading,
highlightedReadingThickness = highlightedReadingThickness
)
}
}
is ReaderText.Text -> {
ReaderLayoutTextParagraph(
paragraph = entry,
activity = activity,
showMenu = showMenu,
fontFamily = fontFamily,
fontColor = fontColor,
lineHeight = lineHeight,
fontStyle = fontStyle,
textAlignment = textAlignment,
horizontalAlignment = horizontalAlignment,
fontSize = fontSize,
letterSpacing = letterSpacing,
sidePadding = sidePadding,
paragraphIndentation = paragraphIndentation,
fullscreenMode = fullscreenMode,
doubleClickTranslation = doubleClickTranslation,
highlightedReading = highlightedReading,
highlightedReadingThickness = highlightedReadingThickness,
toolbarHidden = toolbarHidden,
openTranslator = openTranslator,
menuVisibility = menuVisibility
)
item {
ReaderLayoutTextParagraph(
paragraph = entry,
activity = activity,
showMenu = showMenu,
fontFamily = fontFamily,
fontColor = fontColor,
lineHeight = lineHeight,
fontStyle = fontStyle,
textAlignment = textAlignment,
horizontalAlignment = horizontalAlignment,
fontSize = fontSize,
letterSpacing = letterSpacing,
sidePadding = sidePadding,
paragraphIndentation = paragraphIndentation,
fullscreenMode = fullscreenMode,
doubleClickTranslation = doubleClickTranslation,
highlightedReading = highlightedReading,
highlightedReadingThickness = highlightedReadingThickness,
toolbarHidden = toolbarHidden,
openTranslator = openTranslator,
menuVisibility = menuVisibility
)
}
}
}
}