Skip to content

Commit a92d05f

Browse files
Migrate to JsonTree 2.5.0
1 parent d882e8d commit a92d05f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

composeApp/src/desktopMain/kotlin/com/sebastianneubauer/jsontreeviewer/App.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.height
1919
import androidx.compose.foundation.layout.padding
2020
import androidx.compose.foundation.layout.size
2121
import androidx.compose.foundation.layout.width
22+
import androidx.compose.foundation.lazy.rememberLazyListState
2223
import androidx.compose.foundation.shape.CircleShape
2324
import androidx.compose.foundation.shape.RoundedCornerShape
2425
import androidx.compose.material.CircularProgressIndicator
@@ -122,6 +123,7 @@ private fun Content(
122123
) {
123124
val coroutineScope = rememberCoroutineScope()
124125
val searchState = rememberSearchState()
126+
val listState = rememberLazyListState()
125127
val searchQuery by remember(searchState.query) { mutableStateOf(searchState.query.orEmpty()) }
126128
var showSidebar by remember { mutableStateOf(false) }
127129

@@ -133,6 +135,13 @@ private fun Content(
133135
}
134136
}
135137

138+
val resultIndex = searchState.selectedResultListIndex
139+
LaunchedEffect(resultIndex) {
140+
if(resultIndex != null && !listState.isScrollInProgress) {
141+
listState.animateScrollToItem(resultIndex)
142+
}
143+
}
144+
136145
Column(
137146
modifier = Modifier
138147
.fillMaxSize()
@@ -174,7 +183,7 @@ private fun Content(
174183
Spacer(modifier = Modifier.width(8.dp))
175184

176185
Text(
177-
text = "${searchState.selectedResult}/${searchState.totalResults}",
186+
text = "${searchState.selectedResultListIndex?.let { it + 1 } ?: 0}/${searchState.totalResults}",
178187
color = Color.Gray
179188
)
180189

@@ -194,6 +203,7 @@ private fun Content(
194203
modifier = Modifier.weight(1F),
195204
json = json,
196205
searchState = searchState,
206+
lazyListState = listState,
197207
showIndices = true,
198208
showItemCount = true,
199209
expandSingleChildren = true,

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ compose-plugin = "1.7.3"
44
junit = "4.13.2"
55
kotlin = "2.1.0"
66
kotlinx-coroutines = "1.10.1"
7-
jsontree = "2.5.0-SNAPSHOT"
7+
jsontree = "2.5.0"
88

99
[libraries]
1010
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencyResolutionManagement {
2626
}
2727
mavenCentral()
2828
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") }
29+
mavenLocal()
2930
}
3031
}
3132

0 commit comments

Comments
 (0)