From 02590a14af8ff3f2372a8a071c1caef7d87f0f7b Mon Sep 17 00:00:00 2001 From: DavidAparicioAlbaAsenjo <137989685+DavidAparicioAlbaAsenjo@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:55:16 +0100 Subject: [PATCH] add: [ANDROAPP-4826] Custom warning and error messages added to section (#194) * add: [ANDROAPP-4826] Custom warning and error messages added to section * update: [ANDROAPP4826] warning and error messages are optional params * update: [ANDROAPP-4826] Tests fixed --- .../mobile/ui/designsystem/component/Sections.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Sections.kt b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Sections.kt index efb8c03ea..7eb85b8b2 100644 --- a/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Sections.kt +++ b/designsystem/src/commonMain/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/Sections.kt @@ -79,7 +79,9 @@ fun Section( totalFields: Int, state: SectionState, errorCount: Int, + errorMessage: String? = null, warningCount: Int, + warningMessage: String? = null, onNextSection: () -> Unit, onSectionClick: () -> Unit, content: @Composable ColumnScope.() -> Unit, @@ -95,7 +97,9 @@ fun Section( totalFields = totalFields, state = state, errorCount = errorCount, + errorMessage = errorMessage, warningCount = warningCount, + warningMessage = warningMessage, onNextSection = onNextSection, onSectionClick = onSectionClick, ) { @@ -114,7 +118,9 @@ internal fun SectionBlock( totalFields: Int, state: SectionState, errorCount: Int, + errorMessage: String?, warningCount: Int, + warningMessage: String?, onNextSection: () -> Unit, onSectionClick: () -> Unit, content: @Composable ColumnScope.() -> Unit, @@ -147,7 +153,9 @@ internal fun SectionBlock( totalFields = totalFields, sectionState = sectionState, errorCount = errorCount, + errorMessage = errorMessage, warningCount = warningCount, + warningMessage = warningMessage, onSectionClick = { sectionState = sectionState.getNextState() onSectionClick() @@ -194,7 +202,9 @@ internal fun SectionHeader( totalFields: Int, sectionState: SectionState, errorCount: Int, + errorMessage: String? = null, warningCount: Int, + warningMessage: String? = null, showFieldsLabel: String = provideStringResource("show_fields"), hideFieldsLabel: String = provideStringResource("hide_fields"), onSectionClick: () -> Unit, @@ -295,14 +305,14 @@ internal fun SectionHeader( if (errorCount > 0) { Tag( modifier = Modifier.testTag(SectionTestTag.ERROR_LABEL), - label = provideQuantityStringResource("error", errorCount), + label = errorMessage ?: provideQuantityStringResource("error", errorCount), type = TagType.ERROR, ) } if (warningCount > 0) { Tag( modifier = Modifier.testTag(SectionTestTag.WARNING_LABEL), - label = provideQuantityStringResource("warning", warningCount), + label = warningMessage ?: provideQuantityStringResource("warning", warningCount), type = TagType.WARNING, ) }