From c16982a94e9e5ff0c59114ecfbf7b32dbcf8ce82 Mon Sep 17 00:00:00 2001 From: David Carr Date: Mon, 9 Dec 2024 11:13:05 +0000 Subject: [PATCH 1/2] Update child page header to make title optional, add label to topic lazy column --- .../govuk/app/design/ui/component/Header.kt | 32 +++++++++++++------ .../uk/govuk/app/topics/ui/TopicScreen.kt | 3 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt b/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt index 4725f7eb..43502582 100644 --- a/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt +++ b/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt @@ -42,11 +42,11 @@ fun TabHeader( @Composable fun ChildPageHeader( - text: String, onBack: () -> Unit, modifier: Modifier = Modifier, + text: String? = null ) { - Column(modifier) { + Column(modifier.fillMaxWidth()) { Box( modifier = Modifier.height(64.dp), contentAlignment = Alignment.CenterStart @@ -61,12 +61,14 @@ fun ChildPageHeader( ) } } - LargeTitleBoldLabel( - text = text, - modifier = modifier - .fillMaxWidth() - .padding(horizontal = GovUkTheme.spacing.medium) - ) + text?.let { + LargeTitleBoldLabel( + text = it, + modifier = modifier + .fillMaxWidth() + .padding(horizontal = GovUkTheme.spacing.medium) + ) + } } } @@ -80,10 +82,20 @@ private fun TabHeaderPreview() { @Preview(showBackground = true) @Composable -private fun ChildPageHeaderPreview() { +private fun ChildPageHeaderWithTitlePreview() { + GovUkTheme { + ChildPageHeader( + onBack = { }, + text = "Child page title" + ) + } +} + +@Preview(showBackground = true) +@Composable +private fun ChildPageHeaderNoTitlePreview() { GovUkTheme { ChildPageHeader( - text = "Child page title", onBack = { } ) } diff --git a/feature/topics/src/main/kotlin/uk/govuk/app/topics/ui/TopicScreen.kt b/feature/topics/src/main/kotlin/uk/govuk/app/topics/ui/TopicScreen.kt index 7074aa0d..7afa6874 100644 --- a/feature/topics/src/main/kotlin/uk/govuk/app/topics/ui/TopicScreen.kt +++ b/feature/topics/src/main/kotlin/uk/govuk/app/topics/ui/TopicScreen.kt @@ -21,6 +21,7 @@ import uk.govuk.app.design.ui.component.BodyRegularLabel import uk.govuk.app.design.ui.component.ChildPageHeader import uk.govuk.app.design.ui.component.ExternalLinkListItem import uk.govuk.app.design.ui.component.InternalLinkListItem +import uk.govuk.app.design.ui.component.LargeTitleBoldLabel import uk.govuk.app.design.ui.component.LargeVerticalSpacer import uk.govuk.app.design.ui.component.ListHeader import uk.govuk.app.design.ui.component.MediumVerticalSpacer @@ -110,7 +111,6 @@ private fun TopicScreen( } ChildPageHeader( - text = topic.title, onBack = onBack ) @@ -130,6 +130,7 @@ private fun TopicScreen( LazyColumn(Modifier.padding(horizontal = GovUkTheme.spacing.medium)) { item { Column { + LargeTitleBoldLabel(topic.title) MediumVerticalSpacer() topic.description?.let { description -> BodyRegularLabel(description) From 73af4716f2f798b43acaf161941082c6f7f81cd0 Mon Sep 17 00:00:00 2001 From: David Carr Date: Wed, 11 Dec 2024 10:36:36 +0000 Subject: [PATCH 2/2] Fix spacing --- .../govuk/app/design/ui/component/Header.kt | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt b/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt index 8c9aeefa..cca64f97 100644 --- a/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt +++ b/design/src/main/kotlin/uk/govuk/app/design/ui/component/Header.kt @@ -1,10 +1,8 @@ package uk.govuk.app.design.ui.component -import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding @@ -37,7 +35,7 @@ fun TabHeader( Title2BoldLabel( text = text, textAlign = TextAlign.Center, - modifier = modifier.weight(1f) + modifier = Modifier.weight(1f) ) } } @@ -55,9 +53,7 @@ fun ChildPageHeader( Row( modifier = Modifier .height(64.dp) - .fillMaxWidth() - .padding(GovUkTheme.spacing.small), - horizontalArrangement = Arrangement.SpaceBetween, + .fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, ) { if (onBack != null) { @@ -69,12 +65,11 @@ fun ChildPageHeader( contentDescription = stringResource(R.string.content_desc_back), tint = GovUkTheme.colourScheme.textAndIcons.link ) - Spacer(Modifier) } } if (onAction != null && actionText != null) { - Spacer(Modifier) + Spacer(Modifier.weight(1f)) TextButton( onClick = onAction @@ -90,20 +85,12 @@ fun ChildPageHeader( } if (text != null) { - Row( - modifier = modifier - .defaultMinSize(64.dp) + LargeTitleBoldLabel( + text = text, + modifier = Modifier .fillMaxWidth() - .padding(GovUkTheme.spacing.small), - verticalAlignment = Alignment.CenterVertically, - ) { - LargeTitleBoldLabel( - text = text, - modifier = modifier - .fillMaxWidth() - .padding(horizontal = GovUkTheme.spacing.medium) - ) - } + .padding(horizontal = GovUkTheme.spacing.medium) + ) } } }