@OptIn(ExperimentalComposeUiApi::class) @Composable fun RecentlyVisited( recentVisits: List<RecentlyVisitedItem>, menuItems: List<RecentVisitMenuItem>, backgroundColor: Color = FirefoxTheme.colors.layer2, onRecentVisitClick: (RecentlyVisitedItem, Int) -> Unit = { _, _ -> }, ) { Card( modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(8.dp), backgroundColor = backgroundColor, elevation = 6.dp, ) { val listState = rememberLazyListState() val flingBehavior = EagerFlingBehavior(lazyRowState = listState) LazyRow( modifier = Modifier.semantics { testTagsAsResourceId = true testTag = "recent.visits" }, state = listState, contentPadding = PaddingValues(16.dp), horizontalArrangement = Arrangement.spacedBy(32.dp), flingBehavior = flingBehavior, ) { val itemsList = recentVisits.chunked(VISITS_PER_COLUMN) itemsIndexed(itemsList) { pageIndex, items -> Column( modifier = Modifier.fillMaxWidth(), ) { items.forEachIndexed { index, recentVisit -> when (recentVisit) { is RecentHistoryHighlight -> RecentlyVisitedHistoryHighlight( recentVisit = recentVisit, menuItems = menuItems, clickableEnabled = listState.atLeastHalfVisibleItems.contains(pageIndex), showDividerLine = index < items.size - 1, onRecentVisitClick = { onRecentVisitClick(it, pageIndex + 1) }, ) is RecentHistoryGroup -> RecentlyVisitedHistoryGroup( recentVisit = recentVisit, menuItems = menuItems, clickableEnabled = listState.atLeastHalfVisibleItems.contains(pageIndex), showDividerLine = index < items.size - 1, onRecentVisitClick = { onRecentVisitClick(it, pageIndex + 1) }, ) } } } } } } }
A list of recently visited items.