Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -79,20 +81,27 @@ private fun LedgerAgencySelectItems(
var itemHeight by remember { mutableIntStateOf(0) }
val itemSpace = 12.dp
val maxVisibleItemCount = 3
val listState = rememberLazyListState()

Column(
LaunchedEffect(key1 = Unit) {
val currentAgencyIndex =
agencyList.indexOfFirst { it.id == currentAgencyId }.coerceAtLeast(0)
listState.animateScrollToItem(index = currentAgencyIndex)
}

LazyColumn(
modifier = Modifier
.height(
if (itemHeight > 0 && agencyList.size > maxVisibleItemCount) {
(itemHeight.pxToDp * maxVisibleItemCount) + itemSpace * (maxVisibleItemCount - 1)
} else {
Dp.Unspecified
}
)
.verticalScroll(rememberScrollState()),
),
state = listState,
verticalArrangement = Arrangement.spacedBy(space = itemSpace),
) {
agencyList.forEach { item ->
items(items = agencyList) { item ->
LedgerAgencySelectItem(
modifier = Modifier.onGloballyPositioned {
if (itemHeight == 0) {
Expand Down
Loading