🛠️ More precise control over text entry visibility
This commit is contained in:
parent
092bbfd10b
commit
b1f7e6176f
2 changed files with 52 additions and 47 deletions
|
|
@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.displayCutout
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -150,13 +149,11 @@ fun ReaderLayout(
|
||||||
.coerceAtLeast(18.dp),
|
.coerceAtLeast(18.dp),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
itemsIndexed(
|
for (entry in text) {
|
||||||
text, key = { index, _ -> index }
|
|
||||||
) { index, textEntry ->
|
|
||||||
ReaderLayoutText(
|
ReaderLayoutText(
|
||||||
activity = activity,
|
activity = activity,
|
||||||
showMenu = showMenu,
|
showMenu = showMenu,
|
||||||
entry = textEntry,
|
entry = entry,
|
||||||
fontFamily = fontFamily,
|
fontFamily = fontFamily,
|
||||||
fontColor = fontColor,
|
fontColor = fontColor,
|
||||||
lineHeight = lineHeight,
|
lineHeight = lineHeight,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
|
@file:Suppress("FunctionName")
|
||||||
|
|
||||||
package ua.acclorite.book_story.presentation.reader
|
package ua.acclorite.book_story.presentation.reader
|
||||||
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.foundation.lazy.LazyItemScope
|
import androidx.compose.foundation.lazy.LazyListScope
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
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.domain.reader.ReaderTextAlignment
|
||||||
import ua.acclorite.book_story.ui.reader.ReaderEvent
|
import ua.acclorite.book_story.ui.reader.ReaderEvent
|
||||||
|
|
||||||
@Composable
|
fun LazyListScope.ReaderLayoutText(
|
||||||
fun LazyItemScope.ReaderLayoutText(
|
|
||||||
activity: ComponentActivity,
|
activity: ComponentActivity,
|
||||||
showMenu: Boolean,
|
showMenu: Boolean,
|
||||||
entry: ReaderText,
|
entry: ReaderText,
|
||||||
|
|
@ -40,20 +40,25 @@ fun LazyItemScope.ReaderLayoutText(
|
||||||
) {
|
) {
|
||||||
when (entry) {
|
when (entry) {
|
||||||
is ReaderText.Image -> {
|
is ReaderText.Image -> {
|
||||||
|
item {
|
||||||
ReaderLayoutTextImage(
|
ReaderLayoutTextImage(
|
||||||
entry = entry,
|
entry = entry,
|
||||||
sidePadding = sidePadding
|
sidePadding = sidePadding
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is ReaderText.Separator -> {
|
is ReaderText.Separator -> {
|
||||||
|
item {
|
||||||
ReaderLayoutTextSeparator(
|
ReaderLayoutTextSeparator(
|
||||||
sidePadding = sidePadding,
|
sidePadding = sidePadding,
|
||||||
fontColor = fontColor
|
fontColor = fontColor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is ReaderText.Chapter -> {
|
is ReaderText.Chapter -> {
|
||||||
|
item {
|
||||||
ReaderLayoutTextChapter(
|
ReaderLayoutTextChapter(
|
||||||
chapter = entry,
|
chapter = entry,
|
||||||
chapterTitleAlignment = chapterTitleAlignment,
|
chapterTitleAlignment = chapterTitleAlignment,
|
||||||
|
|
@ -63,8 +68,10 @@ fun LazyItemScope.ReaderLayoutText(
|
||||||
highlightedReadingThickness = highlightedReadingThickness
|
highlightedReadingThickness = highlightedReadingThickness
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
is ReaderText.Text -> {
|
is ReaderText.Text -> {
|
||||||
|
item {
|
||||||
ReaderLayoutTextParagraph(
|
ReaderLayoutTextParagraph(
|
||||||
paragraph = entry,
|
paragraph = entry,
|
||||||
activity = activity,
|
activity = activity,
|
||||||
|
|
@ -89,4 +96,5 @@ fun LazyItemScope.ReaderLayoutText(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue