File tree Expand file tree Collapse file tree
android_app/app/src/main/java/com/health/openscale/ui/screen/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import android.R.attr.textSize
2121import android.text.Layout
2222import android.text.TextUtils
2323import android.util.Log
24+ import androidx.compose.foundation.gestures.detectTapGestures
2425import androidx.compose.foundation.layout.padding
2526import androidx.compose.material3.MaterialTheme
2627import androidx.compose.runtime.Composable
@@ -169,24 +170,22 @@ fun PeriodChart(
169170 chart = chart,
170171 modelProducer = modelProducer,
171172 modifier = modifier.pointerInput(data) {
172- while (true ) {
173- awaitPointerEventScope {
174- val event = awaitPointerEvent()
175- if (event.changes.all { it.changedToUp() }) {
176- hoveredIndex?.let { index ->
177- if (index in data.indices) {
178- val clickedData = data[index]
179- // Toggle selection
180- if (clickedData == selectedPeriod) {
181- onPeriodClick(null )
182- } else {
183- onPeriodClick(clickedData)
184- }
173+ detectTapGestures(
174+ onPress = {
175+ awaitRelease()
176+ hoveredIndex?.let { index ->
177+ if (index in data.indices) {
178+ val clickedData = data[index]
179+ // Toggle selection
180+ if (clickedData == selectedPeriod) {
181+ onPeriodClick(null )
182+ } else {
183+ onPeriodClick(clickedData)
185184 }
186185 }
187186 }
188187 }
189- }
188+ )
190189 }
191190 )
192191}
You can’t perform that action at this time.
0 commit comments