Skip to content

Commit

Permalink
add: [ANDROAPP-4826] Custom warning and error messages added to secti…
Browse files Browse the repository at this point in the history
…on (#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
  • Loading branch information
DavidAparicioAlbaAsenjo authored Feb 12, 2024
1 parent 057a018 commit 02590a1
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -95,7 +97,9 @@ fun Section(
totalFields = totalFields,
state = state,
errorCount = errorCount,
errorMessage = errorMessage,
warningCount = warningCount,
warningMessage = warningMessage,
onNextSection = onNextSection,
onSectionClick = onSectionClick,
) {
Expand All @@ -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,
Expand Down Expand Up @@ -147,7 +153,9 @@ internal fun SectionBlock(
totalFields = totalFields,
sectionState = sectionState,
errorCount = errorCount,
errorMessage = errorMessage,
warningCount = warningCount,
warningMessage = warningMessage,
onSectionClick = {
sectionState = sectionState.getNextState()
onSectionClick()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
}
Expand Down

0 comments on commit 02590a1

Please sign in to comment.