Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ package io.github.openflocon.library.designsystem.components
import androidx.compose.foundation.layout.fillMaxSize
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()
) {
Expand All @@ -27,9 +30,10 @@ fun FloconJsonTree(
FloconCircularProgressIndicator() // TODO Better?
},
initialState = initialState,
icon = Icons.Outlined.ChevronLeft,
icon = Icons.Outlined.ChevronRight,
searchState = searchState,
colors = defaultDarkColors,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The JsonTree colors are hardcoded to defaultDarkColors. This will not look right when the application is in light theme. You should conditionally apply colors based on the current theme to ensure visual consistency.

You will also need to add the following imports:
import androidx.compose.foundation.isSystemInDarkTheme
import com.sebastianneubauer.jsontree.defaultLightColors

Suggested change
colors = defaultDarkColors,
colors = if (isSystemInDarkTheme()) defaultDarkColors else defaultLightColors,

textStyle = textStyle,
onError = onError,
modifier = Modifier.fillMaxSize()
)
Expand Down