mirror of
https://github.com/openflocon/Flocon.git
synced 2026-05-19 10:25:16 +00:00
Merge branch 'main' into validate-mock-response-body
This commit is contained in:
commit
cbf6fd257d
4 changed files with 26 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.height
|
|||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ArrowDownward
|
||||
|
|
@ -68,11 +69,19 @@ private fun NetworkBodyContent(
|
|||
|
||||
val scope = rememberCoroutineScope()
|
||||
val searchState = rememberSearchState()
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
LaunchedEffect(query) {
|
||||
searchState.query = query
|
||||
}
|
||||
|
||||
val resultIndex = searchState.selectedResultListIndex
|
||||
LaunchedEffect(resultIndex) {
|
||||
if(resultIndex != null && !listState.isScrollInProgress) {
|
||||
listState.animateScrollToItem(resultIndex)
|
||||
}
|
||||
}
|
||||
|
||||
FloconSurface(
|
||||
modifier = modifier,
|
||||
) {
|
||||
|
|
@ -101,6 +110,7 @@ private fun NetworkBodyContent(
|
|||
FloconJsonTree(
|
||||
json = body.text,
|
||||
searchState = searchState,
|
||||
lazyListState = listState,
|
||||
onError = { jsonError = true },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
@ -160,7 +170,7 @@ private fun SearchBar(
|
|||
imageVector = Icons.Outlined.ArrowUpward,
|
||||
onClick = previousClicked,
|
||||
contentPadding = PaddingValues(all = 4.dp),
|
||||
enabled = selectedResultIndex != null && selectedResultIndex > 0,
|
||||
enabled = selectedResultIndex != null,
|
||||
modifier = Modifier.fillMaxHeight().aspectRatio(1f),
|
||||
)
|
||||
VerticalDivider(modifier = Modifier.fillMaxHeight())
|
||||
|
|
@ -168,7 +178,7 @@ private fun SearchBar(
|
|||
imageVector = Icons.Outlined.ArrowDownward,
|
||||
onClick = nextClicked,
|
||||
contentPadding = PaddingValues(all = 4.dp),
|
||||
enabled = selectedResultIndex != null && selectedResultIndex < totalResults - 1,
|
||||
enabled = selectedResultIndex != null,
|
||||
modifier = Modifier.fillMaxHeight().aspectRatio(1f),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ aboutLibraries = "12.2.4"
|
|||
kotlinStdlib = "2.2.0"
|
||||
runner = "1.7.0"
|
||||
core = "1.7.0"
|
||||
other-jsontree = "2.5.0"
|
||||
other-jsontree = "2.6.0"
|
||||
uiToolingPreviewDesktop = "1.8.2"
|
||||
buildconfig = "5.6.8"
|
||||
paging = "3.3.2"
|
||||
|
|
|
|||
|
|
@ -1,24 +1,30 @@
|
|||
package io.github.openflocon.library.designsystem.components
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.outlined.ChevronLeft
|
||||
import androidx.compose.material.icons.outlined.ChevronRight
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import com.sebastianneubauer.jsontree.JsonTree
|
||||
import com.sebastianneubauer.jsontree.TreeState
|
||||
import com.sebastianneubauer.jsontree.defaultDarkColors
|
||||
import com.sebastianneubauer.jsontree.search.SearchState
|
||||
import com.sebastianneubauer.jsontree.search.rememberSearchState
|
||||
import io.github.openflocon.library.designsystem.FloconTheme
|
||||
|
||||
@Composable
|
||||
fun FloconJsonTree(
|
||||
json: String,
|
||||
modifier: Modifier = Modifier,
|
||||
initialState: TreeState = TreeState.FIRST_ITEM_EXPANDED,
|
||||
textStyle: TextStyle = FloconTheme.typography.bodyMedium,
|
||||
onError: (Throwable) -> Unit = {},
|
||||
searchState: SearchState = rememberSearchState()
|
||||
searchState: SearchState = rememberSearchState(),
|
||||
lazyListState: LazyListState = rememberLazyListState()
|
||||
) {
|
||||
SelectionContainer(modifier = modifier) {
|
||||
JsonTree(
|
||||
|
|
@ -27,9 +33,11 @@ fun FloconJsonTree(
|
|||
FloconCircularProgressIndicator() // TODO Better?
|
||||
},
|
||||
initialState = initialState,
|
||||
icon = Icons.Outlined.ChevronLeft,
|
||||
icon = Icons.Outlined.ChevronRight,
|
||||
searchState = searchState,
|
||||
lazyListState = lazyListState,
|
||||
colors = defaultDarkColors,
|
||||
textStyle = textStyle,
|
||||
onError = onError,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ To support Jetpack DataStore, ensure you have the `flocon-datastore` dependency:
|
|||
|
||||
```kotlin
|
||||
// build.gradle.kts
|
||||
implementation("io.github.openflocon:flocon-datastore:version")
|
||||
debugImplementation("io.github.openflocon:flocon-datastores:version")
|
||||
releaseImplementation("io.github.openflocon:flocon-datastores-no-op:version")
|
||||
```
|
||||
|
||||
Then register your DataStore:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue