[fenix] For https://github.com/mozilla-mobile/fenix/issues/26444: Refactor HomeSectionHeader to have optional show all text.

pull/600/head
mcarare 2 years ago committed by mergify[bot]
parent 3b67e25c8b
commit e0ec0fdb87

@ -41,7 +41,7 @@ import org.mozilla.fenix.wallpapers.Wallpaper
fun HomeSectionHeader( fun HomeSectionHeader(
headerText: String, headerText: String,
description: String, description: String,
onShowAllClick: () -> Unit onShowAllClick: (() -> Unit)? = null
) { ) {
if (inComposePreview) { if (inComposePreview) {
HomeSectionHeaderContent( HomeSectionHeaderContent(
@ -82,7 +82,7 @@ private fun HomeSectionHeaderContent(
headerText: String, headerText: String,
description: String, description: String,
showAllTextColor: Color = FirefoxTheme.colors.textAccent, showAllTextColor: Color = FirefoxTheme.colors.textAccent,
onShowAllClick: () -> Unit, onShowAllClick: (() -> Unit)? = null,
) { ) {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
@ -94,18 +94,20 @@ private fun HomeSectionHeaderContent(
.wrapContentHeight(align = Alignment.Top) .wrapContentHeight(align = Alignment.Top)
) )
ClickableText( onShowAllClick?.let {
text = AnnotatedString(text = stringResource(id = R.string.recent_tabs_show_all)), ClickableText(
modifier = Modifier.padding(start = 16.dp) text = AnnotatedString(text = stringResource(id = R.string.recent_tabs_show_all)),
.semantics { modifier = Modifier.padding(start = 16.dp)
contentDescription = description .semantics {
}, contentDescription = description
style = TextStyle( },
color = showAllTextColor, style = TextStyle(
fontSize = 14.sp color = showAllTextColor,
), fontSize = 14.sp
onClick = { onShowAllClick() } ),
) onClick = { onShowAllClick() }
)
}
} }
} }
@ -116,7 +118,6 @@ private fun HomeSectionsHeaderPreview() {
HomeSectionHeader( HomeSectionHeader(
headerText = stringResource(R.string.recently_saved_title), headerText = stringResource(R.string.recently_saved_title),
description = stringResource(R.string.recently_saved_show_all_content_description_2), description = stringResource(R.string.recently_saved_show_all_content_description_2),
onShowAllClick = {}
) )
} }
} }

Loading…
Cancel
Save