Add selectable text to the adventure detail.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-07-05 11:38:29 +02:00
parent 4ccf578f45
commit f43af80f7c

View file

@ -14,6 +14,7 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material3.ExperimentalMaterial3Api
@ -206,33 +207,35 @@ private fun AdventureDetailContent(
}
}
)
LazyColumn(
state = lazyListState,
contentPadding = paddingValues,
) {
itemsIndexed(
items = adventures.value,
) { index, adventure ->
val previous = adventures.value.getOrNull(index - 1)
AdventureLine(
modifier = when {
titleLayoutInfo.value == null && titleIndex.value == index -> {
Modifier.onGloballyPositioned { coordinate ->
titleLayoutInfo.value = TitleLayoutInfo(
position = coordinate.positionInParent().y,
height = coordinate.size.height.toFloat(),
)
SelectionContainer {
LazyColumn(
state = lazyListState,
contentPadding = paddingValues,
) {
itemsIndexed(
items = adventures.value,
) { index, adventure ->
val previous = adventures.value.getOrNull(index - 1)
AdventureLine(
modifier = when {
titleLayoutInfo.value == null && titleIndex.value == index -> {
Modifier.onGloballyPositioned { coordinate ->
titleLayoutInfo.value = TitleLayoutInfo(
position = coordinate.positionInParent().y,
height = coordinate.size.height.toFloat(),
)
}
}
}
else -> Modifier
},
paddingValues = rememberPaddingValues(
current = adventure,
previous = previous,
),
item = adventure,
)
else -> Modifier
},
paddingValues = rememberPaddingValues(
current = adventure,
previous = previous,
),
item = adventure,
)
}
}
}
}