1
1
package com.squareup.workflow1.traceviewer
2
2
3
+ import androidx.compose.foundation.background
3
4
import androidx.compose.foundation.border
4
5
import androidx.compose.foundation.clickable
5
6
import androidx.compose.foundation.layout.Arrangement
@@ -47,13 +48,11 @@ public fun DrawWorkflowTree(root: WorkflowNode) {
47
48
val nodeCount = remember { mutableStateOf(0 ) }
48
49
val nodeMapSize = remember { mutableStateOf(0 )}
49
50
val readyToDraw = remember { mutableStateOf(false ) }
50
- // val allArrows = remember { mutableListOf<Pair<NodePosition, NodePosition>>() }
51
51
52
52
drawTree(root, nodePositions, nodeCount, nodeMapSize)
53
53
54
54
LaunchedEffect (nodeMapSize.value) {
55
55
if (nodePositions.size == nodeCount.value) {
56
- // aggregateArrows(root, nodePositions, allArrows)
57
56
readyToDraw.value = true
58
57
}
59
58
}
@@ -75,7 +74,7 @@ private fun drawTree(
75
74
nodeMapSize : MutableState <Int >
76
75
) {
77
76
Column (
78
- modifier = Modifier .padding(20 .dp).border( 1 .dp, Color . Black ),
77
+ modifier = Modifier .padding(10 .dp),
79
78
horizontalAlignment = Alignment .CenterHorizontally ,
80
79
) {
81
80
drawNode(node, nodePositions, nodeMapSize)
@@ -105,12 +104,10 @@ private fun drawNode(
105
104
nodeMapSize : MutableState <Int >
106
105
) {
107
106
val open = remember { mutableStateOf(false ) }
108
-
109
107
Box (
110
108
modifier = Modifier
111
109
.border(1 .dp, Color .Black )
112
110
.clickable { open.value = ! open.value }
113
- .padding(10 .dp)
114
111
.onGloballyPositioned {
115
112
val coords = it.positionInRoot()
116
113
nodePositions[node.id] = coords
@@ -146,45 +143,3 @@ private fun drawArrows(
146
143
drawArrows(childNode, nodePositions)
147
144
}
148
145
}
149
-
150
- // iterative
151
- // @Composable
152
- // private fun drawArrows(
153
- // arrowLocations: List<Pair<NodePosition, NodePosition>>,
154
- // ) {
155
- // drawAllArrows(arrowLocations)
156
- // }
157
-
158
- //
159
- // /**
160
- // * Recurively adds all the arrows from each parent node to its children
161
- // *
162
- // */
163
- // private fun aggregateArrows(
164
- // node: WorkflowNode,
165
- // nodePositions: MutableMap<String, Offset>,
166
- // allArrows: MutableList<Pair<NodePosition, NodePosition>>
167
- // ){
168
- // for (childNode in node.children) {
169
- // val parent = NodePosition(
170
- // id = node.id,
171
- // position = nodePositions[node.id] ?: Offset.Zero
172
- // )
173
- // val child = NodePosition(
174
- // id = childNode.id,
175
- // position = nodePositions[childNode.id] ?: Offset.Zero
176
- // )
177
- // allArrows.add(Pair(parent, child))
178
- //
179
- // aggregateArrows(childNode, nodePositions, allArrows)
180
- // }
181
- // }
182
- //
183
- // /**
184
- // * provides structure for each arrow to be drawn. Also allows more data to be stored if we planned
185
- // * each arrow to be clickable and show more information about the data being passed
186
- // */
187
- // public data class NodePosition(
188
- // val id: String,
189
- // val position: Offset
190
- // )
0 commit comments