From a682e6dc25b30ecd47efc5451ceb0b1dbab49e96 Mon Sep 17 00:00:00 2001 From: Nebojsa Vuksic Date: Fri, 8 Aug 2025 00:33:05 +0200 Subject: [PATCH] Refactor: Replace `ContentItemRow` with simplified `SimpleListItem` in locations list rendering --- .../weatherApp/ui/WeatherAppSample.kt | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt b/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt index d7f05bb..43b6a6d 100644 --- a/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt +++ b/src/main/kotlin/org/jetbrains/plugins/template/weatherApp/ui/WeatherAppSample.kt @@ -1,6 +1,5 @@ package org.jetbrains.plugins.template.weatherApp.ui -import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -8,11 +7,8 @@ import androidx.compose.runtime.collectAsState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Color.Companion.Transparent import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified import org.jetbrains.jewel.foundation.lazy.SelectableLazyColumn import org.jetbrains.jewel.foundation.lazy.SelectionMode import org.jetbrains.jewel.foundation.lazy.itemsIndexed @@ -164,33 +160,11 @@ private fun MyLocationList( key = { _, item -> item.label }, ) { index, item -> - ContentItemRow( - item = item, isSelected = myLocationsUIState.selectedIndex == index, isActive = isActive - ) + SimpleListItem(text = item.label, isSelected = myLocationsUIState.selectedIndex == index, isActive = isActive) } } } -@Composable -private fun ContentItemRow(item: Location, isSelected: Boolean, isActive: Boolean) { - val color = when { - isSelected && isActive -> retrieveColorOrUnspecified("List.selectionBackground") - isSelected && !isActive -> retrieveColorOrUnspecified("List.selectionInactiveBackground") - else -> Transparent - } - Row( - modifier = Modifier - .height(JewelTheme.globalMetrics.rowHeight) - .background(color) - .padding(horizontal = 4.dp) - .padding(end = scrollbarContentSafePadding()), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(4.dp), - ) { - Text(text = item.label, modifier = Modifier.weight(1f), overflow = TextOverflow.Ellipsis, maxLines = 1) - } -} - @Composable private fun RightColumn( myLocationViewModel: MyLocationsViewModelApi,