Skip to content

Commit

Permalink
Make initial node expand strategy configurable from client
Browse files Browse the repository at this point in the history
  • Loading branch information
varkrishna committed May 11, 2024
1 parent d44478f commit 9e3b928
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Sources/JSONViewer/JSONNodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public struct JSONNodeView: View {
public var body: some View {
VStack {
if node.isExpandable {
ExpandableJSONNodeView(fontConfiguration: $fontConfiguration, node: node, level: level, isExpanded: isExpandedNode()) { event in
ExpandableJSONNodeView(fontConfiguration: $fontConfiguration, node: node, level: level, isExpanded: isExpandedNode(), initialNodeExpandStategy: initialNodeExpandStategy) { event in
switch event {
case .onToggle(let _):
case .onToggle( _):
toggleNodeState()
case .onDoubleTap(let node):
actionHandler?(.onDoubleTap(node: node))
Expand Down Expand Up @@ -94,6 +94,7 @@ private struct ExpandableJSONNodeView: View {
let node: JSONNode
let level: Int
let isExpanded: Bool
var initialNodeExpandStategy: InitialNodeExpandStrategy
let actionHandler: (JSONNodeActionInternalEvents) -> Void

var body: some View {
Expand All @@ -119,7 +120,7 @@ private struct ExpandableJSONNodeView: View {
.buttonStyle(PlainButtonStyle())

if isExpanded {
JSONNodeSuccessorView(fontConfiguration: $fontConfiguration, node: node, level: level) { event in
JSONNodeSuccessorView(fontConfiguration: $fontConfiguration, node: node, level: level, initialNodeExpandStategy: self.initialNodeExpandStategy) { event in
switch event {
case .onDoubleTap(let node):
actionHandler(.onDoubleTap(node: node))
Expand Down Expand Up @@ -167,7 +168,7 @@ private struct JSONNodeSuccessorView: View {

let node: JSONNode
let level: Int
let initialNodeExpandStategy: InitialNodeExpandStrategy = .root
let initialNodeExpandStategy: InitialNodeExpandStrategy
let actionHandler: (JSONNodeActionEvents) -> Void

var body: some View {
Expand Down

0 comments on commit 9e3b928

Please sign in to comment.