From f43af80f7c0bd49cf560224ff26d50be5d2150e4 Mon Sep 17 00:00:00 2001 From: "Andres Gomez, Thomas (ITDV RL)" Date: Fri, 5 Jul 2024 11:38:29 +0200 Subject: [PATCH] Add selectable text to the adventure detail. --- .../adventure/detail/AdventureDetailScreen.kt | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/pixelized/rplexicon/ui/screens/adventure/detail/AdventureDetailScreen.kt b/app/src/main/java/com/pixelized/rplexicon/ui/screens/adventure/detail/AdventureDetailScreen.kt index 51d5e55..72263fc 100644 --- a/app/src/main/java/com/pixelized/rplexicon/ui/screens/adventure/detail/AdventureDetailScreen.kt +++ b/app/src/main/java/com/pixelized/rplexicon/ui/screens/adventure/detail/AdventureDetailScreen.kt @@ -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, + ) + } } } }