Skip to content

Commit

Permalink
Merge pull request #96 from AkYML/bug/linechart_CM1448
Browse files Browse the repository at this point in the history
fix Accessibility Dialog in multiple line charts
  • Loading branch information
dkk009 authored May 17, 2023
2 parents ce606a0 + 4ef00f8 commit f5f0bdc
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions YChartsLib/src/main/java/co/yml/charts/ui/linechart/LineChart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import co.yml.charts.ui.linechart.model.SelectionHighlightPoint
import co.yml.charts.ui.linechart.model.SelectionHighlightPopUp
import co.yml.charts.common.components.ItemDivider
import co.yml.charts.common.components.accessibility.AccessibilityBottomSheetDialog
import co.yml.charts.common.components.accessibility.CombinedChartInfo
import co.yml.charts.common.components.accessibility.LinePointInfo
import co.yml.charts.common.extensions.RowClip
import co.yml.charts.common.extensions.collectIsTalkbackEnabledAsState
Expand Down Expand Up @@ -239,41 +240,42 @@ fun LineChart(modifier: Modifier, lineChartData: LineChartData) {
isTapped = false
selectionTextVisibility = false
})
if (isTalkBackEnabled) {
AccessibilityBottomSheetDialog(
modifier = Modifier.fillMaxSize(),
backgroundColor = Color.White,
content = {
LazyColumn {
items(count = linePlotData.lines.size) { lineIndex ->
linePlotData.lines[lineIndex].dataPoints.forEachIndexed { pointIndex, point ->
Column {
LinePointInfo(
xAxisData.axisLabelDescription(
xAxisData.labelData(
pointIndex
)
),
point.description,
linePlotData.lines[lineIndex].lineStyle.color
)

}
if (isTalkBackEnabled) {
with(lineChartData) {
AccessibilityBottomSheetDialog(
modifier = Modifier.fillMaxSize(),
backgroundColor = Color.White,
content = {
val linePoints = linePlotData.lines.firstOrNull()?.dataPoints
LazyColumn {
items(linePoints?.size ?: 0) { index ->
Column {
LinePointInfo(
xAxisData.axisLabelDescription(
xAxisData.labelData(
index
ItemDivider(
thickness = accessibilityConfig.dividerThickness,
dividerColor = accessibilityConfig.dividerColor
)
),
linePoints?.get(index)?.description ?: "",
linePlotData.lines.firstOrNull()?.lineStyle?.color
?: Color.Transparent
)
ItemDivider(
thickness = accessibilityConfig.dividerThickness,
dividerColor = accessibilityConfig.dividerColor
)
}

}
}
}
}
},
popUpTopRightButtonTitle = accessibilityConfig.popUpTopRightButtonTitle,
popUpTopRightButtonDescription = accessibilityConfig.popUpTopRightButtonDescription,
sheetState = accessibilitySheetState
)
},
popUpTopRightButtonTitle = accessibilityConfig.popUpTopRightButtonTitle,
popUpTopRightButtonDescription = accessibilityConfig.popUpTopRightButtonDescription,
sheetState = accessibilitySheetState
)

}

}
}
}
Expand Down

0 comments on commit f5f0bdc

Please sign in to comment.