Repository navigation
Expand file tree
/
Copy pathNodeInspectorView.swift
More file actions
84 lines (75 loc) · 2.46 KB
/
Copy pathNodeInspectorView.swift
File metadata and controls
84 lines (75 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// NodeInspectorView.swift
// ROOtPaint_Engine
//
// Created by M1N0-H1DDEN on 12.12.2025.
//
import SwiftUI
struct NodeInspectorView: View {
@ObservedObject var vm: GraphViewModel
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationStack {
if let id = vm.selectedNodeID, let node = vm.node(id) {
InspectorForm(node: node) { updated in
vm.updateNode(updated)
}
.navigationTitle("Inspector")
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button("Zavřít") { dismiss() }
}
}
} else {
ContentUnavailableView("Vyber bublinu", systemImage: "cursorarrow.rays")
.navigationTitle("Inspector")
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button("Zavřít") { dismiss() }
}
}
}
}
.presentationDetents([.medium, .large])
}
}
private struct InspectorForm: View {
@State var node: RootNode3D
let onCommit: (RootNode3D) -> Void
var body: some View {
Form {
Section("Bublina") {
TextField("Název", text: $node.title)
TextEditor(text: $node.note)
.frame(minHeight: 120)
HStack {
Text("Radius")
Slider(value: Binding(
get: { Double(node.radius) },
set: { node.radius = Float($0) }
), in: 0.18...0.55)
}
}
Section("Targety") {
ForEach($node.targets) { $t in
HStack {
Toggle(isOn: $t.isDone) { }
.labelsHidden()
TextField("Text targetu", text: $t.text)
}
}
.onDelete { idx in
node.targets.remove(atOffsets: idx)
}
Button {
node.targets.append(RootTarget3D(text: "Nový target", isDone: false))
} label: {
Label("Přidat target", systemImage: "plus")
}
}
}
.onChange(of: node) { _, nv in
onCommit(nv)
}
}
}