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