Skip to content

Commit 82eae8b

Browse files
committed
Fix compose violations
1 parent 5ec8a18 commit 82eae8b

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal fun App(
3434
) {
3535
var selectedNode by remember { mutableStateOf<NodeUpdate?>(null) }
3636
var frameSize by remember { mutableIntStateOf(0) }
37-
var rawRenderPass by remember { mutableStateOf("")}
37+
var rawRenderPass by remember { mutableStateOf("") }
3838
var frameIndex by remember { mutableIntStateOf(0) }
3939
val sandboxState = remember { SandboxState() }
4040

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/ui/WorkflowTree.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ private fun DrawChildrenInGroups(
324324
}
325325

326326
Column(
327-
verticalArrangement = Arrangement.spacedBy(16.dp), // Increased spacing between sections
327+
verticalArrangement = Arrangement.spacedBy(16.dp)
328328
) {
329329
// Draw simple children in a grid at the top
330330
if (simpleChildren.isNotEmpty()) {
@@ -349,7 +349,6 @@ private fun DrawChildrenInGroups(
349349
)
350350
}
351351
}
352-
353352
}
354353
}
355354

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/util/DiffUtils.kt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.compose.ui.text.SpanStyle
66
import androidx.compose.ui.text.buildAnnotatedString
77
import com.github.difflib.text.DiffRow.Tag
88
import com.github.difflib.text.DiffRowGenerator
9+
import com.squareup.workflow1.traceviewer.util.DiffStyles.buildStringWithStyle
910

1011
/**
1112
* Generates a field-level word-diff for each node's states.
@@ -32,9 +33,9 @@ fun computeAnnotatedDiff(
3233
var existsDiff = false
3334
return buildAnnotatedString {
3435
// A full change in the type means all internal data will be changed, so it's easier to just
35-
//generalize and show the diff in the type's name
36+
// generalize and show the diff in the type's name
3637
if (pastName != currentName) {
37-
buildString(
38+
buildStringWithStyle(
3839
style = DiffStyles.DELETE,
3940
text = "$pastName(...)",
4041
builder = this
@@ -43,7 +44,7 @@ fun computeAnnotatedDiff(
4344
// append("$pastName(...)")
4445
// pop()
4546
append("")
46-
buildString(
47+
buildStringWithStyle(
4748
style = DiffStyles.INSERT,
4849
text = "$currentName(...)",
4950
builder = this
@@ -69,7 +70,7 @@ fun computeAnnotatedDiff(
6970
Tag.CHANGE -> {
7071
existsDiff = true
7172
parseChangedDiff(fullDiff).forEach { (style, text) ->
72-
buildString(
73+
buildStringWithStyle(
7374
style = style,
7475
text = text,
7576
builder = this
@@ -80,7 +81,7 @@ fun computeAnnotatedDiff(
8081

8182
Tag.INSERT -> {
8283
existsDiff = true
83-
buildString(
84+
buildStringWithStyle(
8485
text = fullDiff.replace("++", ""),
8586
style = DiffStyles.INSERT,
8687
builder = this
@@ -90,7 +91,7 @@ fun computeAnnotatedDiff(
9091

9192
Tag.DELETE -> {
9293
existsDiff = true
93-
buildString(
94+
buildStringWithStyle(
9495
text = fullDiff.replace("--", ""),
9596
style = DiffStyles.DELETE,
9697
builder = this
@@ -105,7 +106,7 @@ fun computeAnnotatedDiff(
105106
}
106107

107108
if (!existsDiff) {
108-
buildString(
109+
buildStringWithStyle(
109110
style = DiffStyles.NO_CHANGE,
110111
text = "No Diff",
111112
builder = this
@@ -159,16 +160,16 @@ object DiffStyles {
159160
val INSERT = SpanStyle(background = Color.Green.copy(alpha = 0.3f))
160161
val NO_CHANGE = SpanStyle(background = Color.LightGray)
161162
val UNCHANGED = SpanStyle()
162-
}
163163

164-
internal fun buildString(
165-
style: SpanStyle,
166-
text: String,
167-
builder: AnnotatedString.Builder
168-
) {
169-
builder.pushStyle(style)
170-
builder.append(text)
171-
builder.pop()
164+
fun buildStringWithStyle(
165+
style: SpanStyle,
166+
text: String,
167+
builder: AnnotatedString.Builder
168+
) {
169+
builder.pushStyle(style)
170+
builder.append(text)
171+
builder.pop()
172+
}
172173
}
173174

174175
/**

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/util/FileDump.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ import java.time.format.DateTimeFormatter
2222
@Composable
2323
internal fun FileDump(
2424
trace: String,
25-
modifier: Modifier
25+
modifier: Modifier = Modifier
2626
) {
2727
var clicked by remember { mutableStateOf(false) }
28-
Button (
28+
Button(
2929
modifier = modifier.padding(16.dp),
3030
shape = CircleShape,
3131
colors = buttonColors(Color.Black),
@@ -59,4 +59,3 @@ private fun writeToFile(trace: String) {
5959
}
6060
}
6161
}
62-

0 commit comments

Comments
 (0)