Skip to content

Commit

Permalink
feat: [ANDROAPP-5683] legend description
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmateos committed Feb 5, 2024
1 parent e028271 commit ea22a60
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 273 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun FieldUiModel.supportingText() = listOfNotNull(
).ifEmpty { null }

fun FieldUiModel.legend() = legend?.let {
LegendData(Color(it.color), it.label ?: "", null)
LegendData(Color(it.color), it.label ?: "", it.legendsInfo)
}

fun FieldUiModel.orientation() = when (renderingType) {
Expand Down
8 changes: 7 additions & 1 deletion form/src/main/java/org/dhis2/form/model/LegendValue.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
package org.dhis2.form.model

data class LegendValue(val color: Int, val label: String?)
import org.hisp.dhis.mobile.ui.designsystem.component.LegendDescriptionData

data class LegendValue(
val color: Int,
val label: String?,
val legendsInfo: List<LegendDescriptionData>?,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.dhis2.form.ui.provider

import androidx.compose.ui.graphics.Color
import org.dhis2.commons.resources.ResourceManager
import org.dhis2.form.model.LegendValue
import org.hisp.dhis.android.core.D2
import org.hisp.dhis.mobile.ui.designsystem.component.LegendDescriptionData

class LegendValueProviderImpl(
val d2: D2,
Expand Down Expand Up @@ -30,10 +32,25 @@ class LegendValueProviderImpl(
.byLegendSet().eq(legendSet.uid())
.one()
.blockingGet()
val legendValues = d2.legendSetModule()
.legendSets()
.withLegends()
.uid(legendSet.uid())
.blockingGet()
if (legend != null) {
return LegendValue(
resourceManager.getColorFrom(legend.color()),
legend.displayName(),
legendValues?.legends()?.sortedBy { it.startValue() }?.map {
LegendDescriptionData(
Color(resourceManager.getColorFrom(it.color())),
it.displayName() ?: "",
IntRange(
it.startValue()?.toInt() ?: 0,
it.endValue()?.toInt() ?: 0,
),
)
},
)
}
}
Expand Down

0 comments on commit ea22a60

Please sign in to comment.