@OptIn( ExperimentalFoundationApi::class, ExperimentalComposeUiApi::class, ) @Composable @Suppress("LongMethod") private fun RecentTabItem( tab: RecentTab.Tab, menuItems: List<RecentTabMenuItem>, backgroundColor: Color, onRecentTabClick: (String) -> Unit = {}, ) { var isMenuExpanded by remember { mutableStateOf(false) } Card( modifier = Modifier .fillMaxWidth() .height(112.dp) .combinedClickable( enabled = true, onClick = { onRecentTabClick(tab.state.id) }, onLongClick = { isMenuExpanded = true }, ), shape = RoundedCornerShape(8.dp), backgroundColor = backgroundColor, elevation = 6.dp, ) { Row( modifier = Modifier.padding(16.dp), ) { RecentTabImage( tab = tab, modifier = Modifier .size(108.dp, 80.dp) .clip(RoundedCornerShape(8.dp)), contentScale = ContentScale.Crop, ) Spacer(modifier = Modifier.width(16.dp)) Column( modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.SpaceBetween, ) { Text( text = tab.state.content.title.ifEmpty { tab.state.content.url.trimmed() }, modifier = Modifier.semantics { testTagsAsResourceId = true testTag = "recent.tab.title" }, color = FirefoxTheme.colors.textPrimary, fontSize = 14.sp, maxLines = 2, overflow = TextOverflow.Ellipsis, ) Row { RecentTabIcon( url = tab.state.content.url, modifier = Modifier .size(18.dp) .clip(RoundedCornerShape(2.dp)), contentScale = ContentScale.Crop, icon = tab.state.content.icon, ) Spacer(modifier = Modifier.width(8.dp)) Text( text = tab.state.content.url.trimmed(), modifier = Modifier.semantics { testTagsAsResourceId = true testTag = "recent.tab.url" }, color = FirefoxTheme.colors.textSecondary, fontSize = 12.sp, overflow = TextOverflow.Ellipsis, maxLines = 1, ) } } RecentTabMenu( showMenu = isMenuExpanded, menuItems = menuItems, tab = tab, onDismissRequest = { isMenuExpanded = false }, ) } } }
A recent tab item.