From e0ec0fdb87edaf70df42c306d95c5df33473b54a Mon Sep 17 00:00:00 2001 From: mcarare Date: Tue, 30 Aug 2022 19:57:15 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/26444: Refactor HomeSectionHeader to have optional show all text. --- .../fenix/compose/home/HomeSectionHeader.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/compose/home/HomeSectionHeader.kt b/app/src/main/java/org/mozilla/fenix/compose/home/HomeSectionHeader.kt index ec1b34ce4c..980103b034 100644 --- a/app/src/main/java/org/mozilla/fenix/compose/home/HomeSectionHeader.kt +++ b/app/src/main/java/org/mozilla/fenix/compose/home/HomeSectionHeader.kt @@ -41,7 +41,7 @@ import org.mozilla.fenix.wallpapers.Wallpaper fun HomeSectionHeader( headerText: String, description: String, - onShowAllClick: () -> Unit + onShowAllClick: (() -> Unit)? = null ) { if (inComposePreview) { HomeSectionHeaderContent( @@ -82,7 +82,7 @@ private fun HomeSectionHeaderContent( headerText: String, description: String, showAllTextColor: Color = FirefoxTheme.colors.textAccent, - onShowAllClick: () -> Unit, + onShowAllClick: (() -> Unit)? = null, ) { Row( modifier = Modifier.fillMaxWidth(), @@ -94,18 +94,20 @@ private fun HomeSectionHeaderContent( .wrapContentHeight(align = Alignment.Top) ) - ClickableText( - text = AnnotatedString(text = stringResource(id = R.string.recent_tabs_show_all)), - modifier = Modifier.padding(start = 16.dp) - .semantics { - contentDescription = description - }, - style = TextStyle( - color = showAllTextColor, - fontSize = 14.sp - ), - onClick = { onShowAllClick() } - ) + onShowAllClick?.let { + ClickableText( + text = AnnotatedString(text = stringResource(id = R.string.recent_tabs_show_all)), + modifier = Modifier.padding(start = 16.dp) + .semantics { + contentDescription = description + }, + style = TextStyle( + color = showAllTextColor, + fontSize = 14.sp + ), + onClick = { onShowAllClick() } + ) + } } } @@ -116,7 +118,6 @@ private fun HomeSectionsHeaderPreview() { HomeSectionHeader( headerText = stringResource(R.string.recently_saved_title), description = stringResource(R.string.recently_saved_show_all_content_description_2), - onShowAllClick = {} ) } }