From a0e4828fbc4aab0d2576ef42255bc7c3b1da2b4e Mon Sep 17 00:00:00 2001 From: = Date: Thu, 15 Feb 2024 10:45:15 +0100 Subject: [PATCH] update: [ANDROAPP-4826] visual changes when there is no fields in the section --- form/src/main/java/org/dhis2/form/ui/Form.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/form/src/main/java/org/dhis2/form/ui/Form.kt b/form/src/main/java/org/dhis2/form/ui/Form.kt index c4b7584871f..b330ea52cbc 100644 --- a/form/src/main/java/org/dhis2/form/ui/Form.kt +++ b/form/src/main/java/org/dhis2/form/ui/Form.kt @@ -109,6 +109,10 @@ fun Form( focusManager.clearFocus() } } + + val sectionMessage = if (section.fields.isEmpty()) resources.getString(R.string.form_without_fields) else null + + val sectionState = if (section.fields.isEmpty()) SectionState.FIXED else section.state Section( title = section.title, @@ -116,16 +120,16 @@ fun Form( description = if (sections.size >= 2 && section.fields.isNotEmpty()) section.description else null, completedFields = section.completedFields(), totalFields = section.fields.size, - state = section.state, + state = sectionState, errorCount = section.errorCount(), warningCount = section.warningCount(), - warningMessage = resources.getString(R.string.form_without_fields), + warningMessage = sectionMessage, onNextSection = onNextSection, onSectionClick = { intentHandler.invoke(FormIntent.OnSection(section.uid)) }, content = { - if (sections.size >= 2 && section.fields.isNotEmpty()) { + if (section.fields.isNotEmpty()) { section.fields.forEachIndexed { index, fieldUiModel -> fieldUiModel.setCallback(callback) FieldProvider(